Skip to content

Commit

Permalink
fix: revert changes for the field edge detection
Browse files Browse the repository at this point in the history
The attempt to better detect boundaries between fields
very close together resulted in zigzagged field edges
and currently we don't have a good way to straighten
them out.

Therefore, revert the field scanner change, it is better
sometimes not correctly detecting fields when they are
very close together than often generate zigzagged
headlands.
  • Loading branch information
Peter Vaiko committed Oct 18, 2024
1 parent 232de91 commit d6e5c5e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 0 additions & 2 deletions scripts/courseGenerator/Field.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ function Field:init(id, num, boundary)
self.islands = {}
if boundary then
self.boundary:calculateProperties()
self:_smoothBoundary()
end
end

Expand Down Expand Up @@ -67,7 +66,6 @@ function Field.loadSavedFields(fileName)
for _, f in pairs(fields) do
f:getBoundary():calculateProperties()
f:setupIslands()
f:_smoothBoundary()
end
return fields
end
Expand Down
14 changes: 7 additions & 7 deletions scripts/courseGenerator/test/FieldTest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ lu.EPS = 0.01
function testField()
local fields = CourseGenerator.Field.loadSavedFields('fields/Coldborough.xml')
lu.assertEquals(#fields, 9)
lu.assertEquals(#fields[8].boundary, 90)
lu.assertEquals(#fields[8].boundary, 135)
local field = fields[8]
local center = field:getCenter()
lu.assertAlmostEquals(center.x, 381.41, 0.1)
lu.assertAlmostEquals(center.y, 31.3, 0.1)
lu.assertAlmostEquals(center.x, 380.8, 0.1)
lu.assertAlmostEquals(center.y, 31.14, 0.1)
local x1, y1, x2, y2 = field:getBoundingBox()
lu.assertAlmostEquals(x1, 307.18)
lu.assertAlmostEquals(y1, -80.66)
lu.assertAlmostEquals(x2, 452.82)
lu.assertAlmostEquals(y2, 157.16)
lu.assertAlmostEquals(x1, 307.15)
lu.assertAlmostEquals(y1, -80.84)
lu.assertAlmostEquals(x2, 452.84)
lu.assertAlmostEquals(y2, 157.33)
end
os.exit(lu.LuaUnit.run())
2 changes: 1 addition & 1 deletion scripts/field/FieldScanner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function FieldScanner:init(resolution)
-- sure if it is 1 or 0.5, so 0.2 seems to be a safe bet
self.resolution = resolution or 0.2
self.highResolution = 0.1
self.normalTracerLookahead = 3.0
self.normalTracerLookahead = 5.0
self.shortTracerLookahead = self.normalTracerLookahead / 10
self.angleStep = self.highResolution / self.normalTracerLookahead
end
Expand Down

0 comments on commit d6e5c5e

Please sign in to comment.