Skip to content

Commit

Permalink
Marks explicitely a grid as annotated for a given walkable
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonaba committed Apr 9, 2013
1 parent ce3de3a commit c23db31
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion jumper/grid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ if (...) then
end
local hasEnoughClearance = not clearance and true or false
if not hasEnoughClearance then
if not self._isAnnotated[walkable] then return false end
local node = self:getNodeAt(x,y)
local nodeClearance = node:getClearance(walkable) or self:evalClearance(node, walkable)
local nodeClearance = node:getClearance(walkable)
hasEnoughClearance = (nodeClearance >= clearance)
end
if self._eval then
Expand Down Expand Up @@ -368,6 +369,7 @@ if (...) then
newGrid._nodes, newGrid._min_x, newGrid._max_x, newGrid._min_y, newGrid._max_y = Utils.arrayToNodes(newGrid._map)
newGrid._width = (newGrid._max_x-newGrid._min_x)+1
newGrid._height = (newGrid._max_y-newGrid._min_y)+1
newGrid._isAnnotated = {}
return setmetatable(newGrid,PreProcessGrid)
end

Expand All @@ -379,6 +381,7 @@ if (...) then
newGrid._min_x, newGrid._max_x, newGrid._min_y, newGrid._max_y = Utils.getArrayBounds(newGrid._map)
newGrid._width = (newGrid._max_x-newGrid._min_x)+1
newGrid._height = (newGrid._max_y-newGrid._min_y)+1
newGrid._isAnnotated = {}
return setmetatable(newGrid,PostProcessGrid)
end

Expand Down
4 changes: 3 additions & 1 deletion jumper/pathfinder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ if (...) then
end
end
end
self._grid._isAnnotated[self._walkable] = true
return self
end

Expand All @@ -136,8 +137,9 @@ if (...) then
function Pathfinder:clearAnnotations()
assert(self._walkable, 'Finder must implement a walkable value')
for node in self._grid:iter() do
node:removeClearance(walkable)
node:removeClearance(self._walkable)
end
self._grid._isAnnotated[self._walkable] = false
return self
end

Expand Down

0 comments on commit c23db31

Please sign in to comment.