mirror of
https://github.com/vrld/HC.git
synced 2024-11-18 12:54:23 +00:00
Better check if cell is empty in Hash:draw()
This commit is contained in:
parent
8283c13cfb
commit
ec2cc20a6b
@ -141,9 +141,8 @@ 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
|
||||||
for k2,cell in pairs(v) do
|
for k2,cell in pairs(v) do
|
||||||
local empty = true
|
local is_empty = (next(cell) == nil)
|
||||||
(function() for _ in pairs(cell) do empty = false; return end end)()
|
if show_empty or not is_empty then
|
||||||
if show_empty or not empty then
|
|
||||||
local x = k1 * self.cell_size
|
local x = k1 * self.cell_size
|
||||||
local y = k2 * self.cell_size
|
local y = k2 * self.cell_size
|
||||||
love.graphics.rectangle(how or 'line', x,y, self.cell_size, self.cell_size)
|
love.graphics.rectangle(how or 'line', x,y, self.cell_size, self.cell_size)
|
||||||
|
Loading…
Reference in New Issue
Block a user