Corrected pushing of default lights.

This commit is contained in:
Nissim Hadar 2018-01-09 15:24:46 -08:00
parent 8042b4b3fb
commit b53e411184
3 changed files with 10 additions and 11 deletions

View file

@ -360,8 +360,7 @@ LightStage::LightPointer LightStage::removeLight(Index index) {
LightStage::LightPointer LightStage::getCurrentKeyLight() const {
Index keyLightId{ _defaultLightId };
// There is always at least 1 light (the off light)
if (_currentFrame._sunLights.size() > 1) {
if (!_currentFrame._sunLights.empty()) {
keyLightId = _currentFrame._sunLights.front();
}
return _lights.get(keyLightId);
@ -369,8 +368,7 @@ LightStage::LightPointer LightStage::getCurrentKeyLight() const {
LightStage::LightPointer LightStage::getCurrentAmbientLight() const {
Index keyLightId { _defaultLightId };
// There is always at least 1 light (the off light)
if (_currentFrame._ambientLights.size() > 1) {
if (!_currentFrame._ambientLights.empty()) {
keyLightId = _currentFrame._ambientLights.front();
}
return _lights.get(keyLightId);
@ -378,8 +376,7 @@ LightStage::LightPointer LightStage::getCurrentAmbientLight() const {
LightStage::ShadowPointer LightStage::getCurrentKeyShadow() const {
Index keyLightId { _defaultLightId };
// There is always at least 1 light (the off light)
if (_currentFrame._sunLights.size() > 1) {
if (!_currentFrame._sunLights.empty()) {
keyLightId = _currentFrame._sunLights.front();
}
auto shadow = getShadow(keyLightId);
@ -389,8 +386,7 @@ LightStage::ShadowPointer LightStage::getCurrentKeyShadow() const {
LightStage::LightAndShadow LightStage::getCurrentKeyLightAndShadow() const {
Index keyLightId { _defaultLightId };
// There is always at least 1 light (the off light)
if (_currentFrame._sunLights.size() > 1) {
if (!_currentFrame._sunLights.empty()) {
keyLightId = _currentFrame._sunLights.front();
}
auto shadow = getShadow(keyLightId);

View file

@ -119,6 +119,8 @@ public:
Index findLight(const LightPointer& light) const;
Index addLight(const LightPointer& light, const bool shouldSetAsDefault = false);
const Index getDefaultLight() const { return _defaultLightId; }
Index addShadow(Index lightIndex, float maxDistance = 20.0f, unsigned int cascadeCount = 1U);

View file

@ -68,10 +68,11 @@ void SetupZones::run(const RenderContextPointer& context, const Inputs& inputs)
auto lightStage = context->_scene->getStage<LightStage>();
assert(lightStage);
lightStage->_currentFrame.pushSunLight(0);
lightStage->_currentFrame.pushAmbientLight(0);
hazeStage->_currentFrame.pushHaze(0);
lightStage->_currentFrame.pushSunLight(lightStage->getDefaultLight());
lightStage->_currentFrame.pushAmbientLight(lightStage->getDefaultLight());
backgroundStage->_currentFrame.pushBackground(0);
hazeStage->_currentFrame.pushHaze(0);
}
const gpu::PipelinePointer& DebugZoneLighting::getKeyLightPipeline() {