mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-05 06:42:57 +02:00
Simplified code.
This commit is contained in:
parent
e8770ec204
commit
8bd2985f1f
5 changed files with 16 additions and 81 deletions
|
@ -163,48 +163,23 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) {
|
|||
|
||||
if (_visible) {
|
||||
// Finally, push the light visible in the frame
|
||||
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) {
|
||||
if (_keyLightMode == COMPONENT_MODE_DISABLED) {
|
||||
_stage->_currentFrame.pushSunLight(_stage->getSunOffLight());
|
||||
} else if (_keyLightMode == COMPONENT_MODE_ENABLED) {
|
||||
_stage->_currentFrame.pushSunLight(_sunIndex);
|
||||
}
|
||||
|
||||
// The background only if the mode is not inherit
|
||||
if (_skyboxMode == COMPONENT_MODE_DISABLED && _skyboxOnIndex == NO_STORED_VALUE) {
|
||||
// Just turned off, store previous value before changing
|
||||
_skyboxOnIndex = _backgroundIndex;
|
||||
_backgroundIndex = INVALID_INDEX;
|
||||
} else if (_skyboxMode == COMPONENT_MODE_ENABLED && _skyboxOnIndex != NO_STORED_VALUE) {
|
||||
// Just turned on, restore previous value before clearing stored value
|
||||
_backgroundIndex = _skyboxOnIndex;
|
||||
_skyboxOnIndex = NO_STORED_VALUE;
|
||||
}
|
||||
|
||||
// _backgroundMode is kept for legacy purposes
|
||||
if (_skyboxMode != COMPONENT_MODE_INHERIT || _backgroundMode != BACKGROUND_MODE_INHERIT) {
|
||||
if (_skyboxMode == COMPONENT_MODE_DISABLED) {
|
||||
_backgroundStage->_currentFrame.pushBackground(INVALID_INDEX);
|
||||
} else if (_skyboxMode == COMPONENT_MODE_ENABLED) {
|
||||
_backgroundStage->_currentFrame.pushBackground(_backgroundIndex);
|
||||
}
|
||||
|
||||
// The ambient light only if it has a valid texture to render with
|
||||
if (_ambientLightMode == COMPONENT_MODE_DISABLED && _ambientOnIndex == NO_STORED_VALUE) {
|
||||
// Just turned off, store previous value before changing
|
||||
_ambientOnIndex = _ambientIndex;
|
||||
_ambientIndex = _stage->getAmbientOffLight();
|
||||
} else if (_ambientLightMode == COMPONENT_MODE_ENABLED && _ambientOnIndex != NO_STORED_VALUE) {
|
||||
// Just turned on, restore previous value before clearing stored value
|
||||
_ambientIndex = _ambientOnIndex;
|
||||
_ambientOnIndex = NO_STORED_VALUE;
|
||||
}
|
||||
|
||||
if (_ambientLightMode != COMPONENT_MODE_INHERIT && _validAmbientTexture) {
|
||||
if (_ambientLightMode == COMPONENT_MODE_DISABLED) {
|
||||
_stage->_currentFrame.pushAmbientLight(_stage->getAmbientOffLight());
|
||||
} else if (_ambientLightMode == COMPONENT_MODE_ENABLED) {
|
||||
_stage->_currentFrame.pushAmbientLight(_ambientIndex);
|
||||
}
|
||||
|
||||
|
@ -222,11 +197,6 @@ void ZoneEntityRenderer::removeFromScene(const ScenePointer& scene, Transaction&
|
|||
}
|
||||
#endif
|
||||
Parent::removeFromScene(scene, transaction);
|
||||
|
||||
// clear flags
|
||||
_sunOnIndex = NO_STORED_VALUE;
|
||||
_ambientOnIndex = NO_STORED_VALUE;
|
||||
_skyboxOnIndex = NO_STORED_VALUE;
|
||||
}
|
||||
|
||||
void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
|
||||
|
@ -276,7 +246,7 @@ void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen
|
|||
updateKeySunFromEntity(entity);
|
||||
}
|
||||
|
||||
if (ambientLightChanged || skyboxChanged) {
|
||||
if (ambientLightChanged) {
|
||||
updateAmbientLightFromEntity(entity);
|
||||
}
|
||||
|
||||
|
|
|
@ -100,11 +100,6 @@ 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 };
|
||||
indexed_container::Index _ambientOnIndex { NO_STORED_VALUE };
|
||||
indexed_container::Index _skyboxOnIndex { NO_STORED_VALUE };
|
||||
|
||||
BackgroundStagePointer _backgroundStage;
|
||||
BackgroundStage::Index _backgroundIndex{ BackgroundStage::INVALID_INDEX };
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ QString EntityItemProperties::getHazeModeAsString() const {
|
|||
}
|
||||
}
|
||||
|
||||
QString EntityItemProperties::getHazeModeString(uint32_t mode) {
|
||||
QString EntityItemProperties::getComponentModeString(uint32_t mode) {
|
||||
// return "inherit" if mode is not valid
|
||||
if (mode < COMPONENT_MODE_ITEM_COUNT) {
|
||||
return COMPONENT_MODES[mode].second;
|
||||
|
@ -253,15 +253,6 @@ QString EntityItemProperties::getKeyLightModeAsString() const {
|
|||
}
|
||||
}
|
||||
|
||||
QString EntityItemProperties::getKeyLightModeString(uint32_t mode) {
|
||||
// return "enabled" if mode is not valid
|
||||
if (mode < COMPONENT_MODE_ITEM_COUNT) {
|
||||
return COMPONENT_MODES[mode].second;
|
||||
} else {
|
||||
return COMPONENT_MODES[COMPONENT_MODE_ENABLED].second;
|
||||
}
|
||||
}
|
||||
|
||||
void EntityItemProperties::setKeyLightModeFromString(const QString& keyLightMode) {
|
||||
auto result = std::find_if(COMPONENT_MODES.begin(), COMPONENT_MODES.end(), [&](const ComponentPair& pair) {
|
||||
return (pair.second == keyLightMode);
|
||||
|
@ -282,15 +273,6 @@ QString EntityItemProperties::getAmbientLightModeAsString() const {
|
|||
}
|
||||
}
|
||||
|
||||
QString EntityItemProperties::getAmbientLightModeString(uint32_t mode) {
|
||||
// return "enabled" if mode is not valid
|
||||
if (mode < COMPONENT_MODE_ITEM_COUNT) {
|
||||
return COMPONENT_MODES[mode].second;
|
||||
} else {
|
||||
return COMPONENT_MODES[COMPONENT_MODE_ENABLED].second;
|
||||
}
|
||||
}
|
||||
|
||||
void EntityItemProperties::setAmbientLightModeFromString(const QString& ambientLightMode) {
|
||||
auto result = std::find_if(COMPONENT_MODES.begin(), COMPONENT_MODES.end(), [&](const ComponentPair& pair) {
|
||||
return (pair.second == ambientLightMode);
|
||||
|
@ -311,15 +293,6 @@ QString EntityItemProperties::getSkyboxModeAsString() const {
|
|||
}
|
||||
}
|
||||
|
||||
QString EntityItemProperties::getSkyboxModeString(uint32_t mode) {
|
||||
// return "enabled" if mode is not valid
|
||||
if (mode < COMPONENT_MODE_ITEM_COUNT) {
|
||||
return COMPONENT_MODES[mode].second;
|
||||
} else {
|
||||
return COMPONENT_MODES[COMPONENT_MODE_ENABLED].second;
|
||||
}
|
||||
}
|
||||
|
||||
void EntityItemProperties::setSkyboxModeFromString(const QString& skyboxMode) {
|
||||
auto result = std::find_if(COMPONENT_MODES.begin(), COMPONENT_MODES.end(), [&](const ComponentPair& pair) {
|
||||
return (pair.second == skyboxMode);
|
||||
|
|
|
@ -255,10 +255,7 @@ public:
|
|||
DEFINE_PROPERTY_REF(PROP_SERVER_SCRIPTS, ServerScripts, serverScripts, QString, ENTITY_ITEM_DEFAULT_SERVER_SCRIPTS);
|
||||
|
||||
static QString getBackgroundModeString(BackgroundMode mode);
|
||||
static QString getHazeModeString(uint32_t mode);
|
||||
static QString getKeyLightModeString(uint32_t mode);
|
||||
static QString getAmbientLightModeString(uint32_t mode);
|
||||
static QString getSkyboxModeString(uint32_t mode);
|
||||
static QString getComponentModeString(uint32_t mode);
|
||||
|
||||
public:
|
||||
float getMaxDimension() const { return glm::compMax(_dimensions); }
|
||||
|
|
|
@ -290,10 +290,10 @@ void ZoneEntityItem::debugDump() const {
|
|||
qCDebug(entities) << " dimensions:" << debugTreeVector(getScaledDimensions());
|
||||
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
|
||||
qCDebug(entities) << " _backgroundMode:" << EntityItemProperties::getBackgroundModeString(_backgroundMode);
|
||||
qCDebug(entities) << " _hazeMode:" << EntityItemProperties::getHazeModeString(_hazeMode);
|
||||
qCDebug(entities) << " _keyLightMode:" << EntityItemProperties::getKeyLightModeString(_keyLightMode);
|
||||
qCDebug(entities) << " _ambientLightMode:" << EntityItemProperties::getAmbientLightModeString(_ambientLightMode);
|
||||
qCDebug(entities) << " _skyboxMode:" << EntityItemProperties::getSkyboxModeString(_skyboxMode);
|
||||
qCDebug(entities) << " _hazeMode:" << EntityItemProperties::getComponentModeString(_hazeMode);
|
||||
qCDebug(entities) << " _keyLightMode:" << EntityItemProperties::getComponentModeString(_keyLightMode);
|
||||
qCDebug(entities) << " _ambientLightMode:" << EntityItemProperties::getComponentModeString(_ambientLightMode);
|
||||
qCDebug(entities) << " _skyboxMode:" << EntityItemProperties::getComponentModeString(_skyboxMode);
|
||||
|
||||
_keyLightProperties.debugDump();
|
||||
_ambientLightProperties.debugDump();
|
||||
|
|
Loading…
Reference in a new issue