Skip to content

Commit

Permalink
Better check if cell is empty in Hash:draw()
Browse files Browse the repository at this point in the history
  • Loading branch information
vrld committed Feb 9, 2013
1 parent 8283c13 commit ec2cc20
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions spatialhash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,8 @@ 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
for k2,cell in pairs(v) do
local empty = true
(function() for _ in pairs(cell) do empty = false; return end end)()
if show_empty or not empty then
local is_empty = (next(cell) == nil)
if show_empty or not is_empty then
local x = k1 * self.cell_size
local y = k2 * self.cell_size
love.graphics.rectangle(how or 'line', x,y, self.cell_size, self.cell_size)
Expand Down

0 comments on commit ec2cc20

Please sign in to comment.