Keylight inherit/off/on working

This commit is contained in:
Nissim Hadar 2017-12-22 08:05:12 -08:00
parent e974cac177
commit 502cac2ac7
2 changed files with 14 additions and 1 deletions

View file

@ -165,7 +165,17 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) {
if (_visible) {
// Finally, push the light visible in the frame
if (_keyLightMode != BACKGROUND_MODE_INHERIT) {
if (_keyLightMode == COMPONENT_MODE_DISABLED && sunOnIndex == NO_STORED_VALUE) {
// Just turned off, store previous value before changing
sunOnIndex = _sunIndex;
_sunIndex = _stage->getSunOffLight();
} else if (_keyLightMode == COMPONENT_MODE_ENABLED && sunOnIndex != NO_STORED_VALUE) {
// Just turned on, restore previous value before clearing stored value
_sunIndex = sunOnIndex;
sunOnIndex = NO_STORED_VALUE;
}
if (_keyLightMode != COMPONENT_MODE_INHERIT) {
_stage->_currentFrame.pushSunLight(_sunIndex);
}

View file

@ -95,6 +95,9 @@ private:
indexed_container::Index _shadowIndex{ LightStage::INVALID_INDEX };
indexed_container::Index _ambientIndex{ LightStage::INVALID_INDEX };
const int NO_STORED_VALUE { -1 };
indexed_container::Index sunOnIndex { NO_STORED_VALUE };
BackgroundStagePointer _backgroundStage;
BackgroundStage::Index _backgroundIndex{ BackgroundStage::INVALID_INDEX };