Skip to content

Commit

Permalink
LightGrid: Ignore notifications about sector lighting changes if not …
Browse files Browse the repository at this point in the history
…enabled

If a light grid is initialized but disabled we should ignore any
notifications about sector lighting changes. It would be possible
to dynamically join/leave the relevant audiences when the enabled
state changes however this is probably unnecessary.
  • Loading branch information
danij-deng committed May 21, 2013
1 parent 318b24d commit 5a0b4bf
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions doomsday/client/src/render/lightgrid.cpp
Expand Up @@ -799,14 +799,18 @@ DENG2_OBSERVES(Sector, LightLevelChange)
self.markAllForUpdate();

// How much time did we spend?
LOG_INFO(String("LightGrid::initialize: Done in %1 seconds.").arg(begunAt.since(), 0, 'g', 2));
LOG_INFO(String("Done in %1 seconds.").arg(begunAt.since(), 0, 'g', 2));
}

/**
* To be called when the ambient lighting properties in the sector change.
*/
void sectorChanged(Sector &sector)
{
// Do not update if not enabled.
/// @todo We could dynamically join/leave the relevant audiences.
if(!lgEnabled) return;

Sector::LightGridData &lgData = sector._lightGridData;
if(!lgData.changedBlockCount && !lgData.blockCount)
return;
Expand Down Expand Up @@ -857,6 +861,9 @@ coord_t LightGrid::blockSize() const

Vector3f LightGrid::evaluate(Vector3d const &point)
{
// If not enabled the color is black.
if(!lgEnabled) return Vector3f(0, 0, 0);

LightBlock &block = d->lightBlock(point);
Vector3f color = block.evaluate();

Expand All @@ -878,6 +885,9 @@ float LightGrid::evaluateLightLevel(Vector3d const &point)

void LightGrid::markAllForUpdate()
{
// Updates are unnecessary if not enabled.
if(!lgEnabled) return;

// Mark all blocks and contributors.
foreach(Sector *sector, d->map.sectors())
{
Expand All @@ -896,8 +906,11 @@ void LightGrid::update()
.1f, .2f, .25f, .2f, .1f
};

if(!d->needUpdate)
return;
// Updates are unnecessary if not enabled.
if(!lgEnabled) return;

// Any work to do?
if(!d->needUpdate) return;

for(int y = 0; y < d->dimensions.y; ++y)
for(int x = 0; x < d->dimensions.x; ++x)
Expand Down

0 comments on commit 5a0b4bf

Please sign in to comment.