Skip to content

Commit

Permalink
World|ContactBlockmap|Client: Avoid unnecessary allocations when spre…
Browse files Browse the repository at this point in the history
…ading contacts

Spreading doesn't actually alter the blockmap, so we don't need to
allocate cell data simply because a given cell is "touched".
  • Loading branch information
danij-deng committed Oct 6, 2013
1 parent 5e2d252 commit 806da2b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions doomsday/client/src/world/contactblockmap.cpp
Expand Up @@ -543,14 +543,17 @@ void ContactBlockmap::spreadAllContacts(AABoxd const &box)
for(cell.y = cellBlock.min.y; cell.y <= cellBlock.max.y; ++cell.y)
for(cell.x = cellBlock.min.x; cell.x <= cellBlock.max.x; ++cell.x)
{
Instance::CellData *data = d->cellData(cell, true/*can allocate a block*/);
if(!data->doneSpread)
if(Instance::CellData *data = d->cellData(cell))
{
for(Contact *iter = data->head; iter; iter = iter->nextInBlock)
if(!data->doneSpread)
{
d->spreadContact(*iter);
data->doneSpread = true;

for(Contact *iter = data->head; iter; iter = iter->nextInBlock)
{
d->spreadContact(*iter);
}
}
data->doneSpread = true;
}
}
}
Expand Down

0 comments on commit 806da2b

Please sign in to comment.