Skip to content

Commit

Permalink
Remove Spatialhash:getNeighbors() in favor of :inRange()
Browse files Browse the repository at this point in the history
  • Loading branch information
vrld committed Jul 10, 2012
1 parent 1280b0a commit f1ad856
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
8 changes: 4 additions & 4 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ local function new_shape(self, shape)
end

function shape:neighbors()
local x1,y1, x2,y2 = self:bbox()
return pairs(hash:getNeighbors(self, x1,y1, x2,y2))
local neighbors = hash:inRange(self:bbox())
rawset(neighbors, self, nil)
return neighbors
end

function shape:_removeFromHash()
local x1,y1, x2,y2 = self:bbox()
hash:remove(shape, x1,y1, x2,y2)
return hash:remove(shape, self:bbox())
end

return shape
Expand Down
6 changes: 0 additions & 6 deletions spatialhash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@ function Spatialhash:update(obj, old_x1,old_y1, old_x2,old_y2, new_x1,new_y1, ne
end
end

function Spatialhash:getNeighbors(obj, x1,y1, x2,y2)
local set = self:inRange(x1,y1, x2,y2)
rawset(set, obj, nil)
return set
end

function Spatialhash:draw(how, show_empty, print_key)
if show_empty == nil then show_empty = true end
for k1,v in pairs(self.cells) do
Expand Down

0 comments on commit f1ad856

Please sign in to comment.