Remove Spatialhash:getNeighbors() in favor of :inRange()

This commit is contained in:
Matthias Richter 2012-07-10 16:21:33 +02:00
parent 1280b0a2d4
commit f1ad856da9
2 changed files with 4 additions and 10 deletions

View File

@ -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

View File

@ -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