mirror of
https://github.com/vrld/HC.git
synced 2024-11-18 12:54:23 +00:00
Remove Spatialhash:getNeighbors() in favor of :inRange()
This commit is contained in:
parent
1280b0a2d4
commit
f1ad856da9
8
init.lua
8
init.lua
@ -108,13 +108,13 @@ local function new_shape(self, shape)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function shape:neighbors()
|
function shape:neighbors()
|
||||||
local x1,y1, x2,y2 = self:bbox()
|
local neighbors = hash:inRange(self:bbox())
|
||||||
return pairs(hash:getNeighbors(self, x1,y1, x2,y2))
|
rawset(neighbors, self, nil)
|
||||||
|
return neighbors
|
||||||
end
|
end
|
||||||
|
|
||||||
function shape:_removeFromHash()
|
function shape:_removeFromHash()
|
||||||
local x1,y1, x2,y2 = self:bbox()
|
return hash:remove(shape, self:bbox())
|
||||||
hash:remove(shape, x1,y1, x2,y2)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return shape
|
return shape
|
||||||
|
@ -137,12 +137,6 @@ function Spatialhash:update(obj, old_x1,old_y1, old_x2,old_y2, new_x1,new_y1, ne
|
|||||||
end
|
end
|
||||||
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)
|
function Spatialhash:draw(how, show_empty, print_key)
|
||||||
if show_empty == nil then show_empty = true end
|
if show_empty == nil then show_empty = true end
|
||||||
for k1,v in pairs(self.cells) do
|
for k1,v in pairs(self.cells) do
|
||||||
|
Loading…
Reference in New Issue
Block a user