Stay closer to the old code (Use early exit)

This commit is contained in:
Atlante45 2016-01-12 15:15:19 -08:00
parent 911375b7a1
commit 47586e97a6

View file

@ -260,10 +260,29 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
auto sceneKeyLight = sceneStage->getKeyLight();
auto sceneLocation = sceneStage->getLocation();
auto sceneTime = sceneStage->getTime();
auto backgroundMode = BACKGROUND_MODE_INHERIT; // Default
if (zone) {
backgroundMode = zone->getBackgroundMode();
if (!zone) {
_pendingSkyboxTexture = false;
_skyboxTexture.clear();
if (_hasPreviousZone) {
sceneKeyLight->setColor(_previousKeyLightColor);
sceneKeyLight->setIntensity(_previousKeyLightIntensity);
sceneKeyLight->setAmbientIntensity(_previousKeyLightAmbientIntensity);
sceneKeyLight->setDirection(_previousKeyLightDirection);
sceneStage->setSunModelEnable(_previousStageSunModelEnabled);
sceneStage->setLocation(_previousStageLongitude, _previousStageLatitude,
_previousStageAltitude);
sceneTime->setHour(_previousStageHour);
sceneTime->setDay(_previousStageDay);
_hasPreviousZone = false;
}
_viewState->endOverrideEnvironmentData();
skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME); // let the application atmosphere through
return; // Early exit
}
if (!_hasPreviousZone) {
_previousKeyLightColor = sceneKeyLight->getColor();
@ -288,9 +307,8 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
zone->getStageProperties().getAltitude());
sceneTime->setHour(zone->getStageProperties().calculateHour());
sceneTime->setDay(zone->getStageProperties().calculateDay());
}
switch (backgroundMode) {
switch (zone->getBackgroundMode()) {
case BACKGROUND_MODE_ATMOSPHERE: {
EnvironmentData data = zone->getEnvironmentData();
glm::vec3 keyLightDirection = sceneKeyLight->getDirection();
@ -348,18 +366,6 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
break;
}
case BACKGROUND_MODE_INHERIT:
if (_hasPreviousZone) {
sceneKeyLight->setColor(_previousKeyLightColor);
sceneKeyLight->setIntensity(_previousKeyLightIntensity);
sceneKeyLight->setAmbientIntensity(_previousKeyLightAmbientIntensity);
sceneKeyLight->setDirection(_previousKeyLightDirection);
sceneStage->setSunModelEnable(_previousStageSunModelEnabled);
sceneStage->setLocation(_previousStageLongitude, _previousStageLatitude,
_previousStageAltitude);
sceneTime->setHour(_previousStageHour);
sceneTime->setDay(_previousStageDay);
_hasPreviousZone = false;
}
_viewState->endOverrideEnvironmentData();
skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME); // let the application atmosphere through
_pendingSkyboxTexture = false;