diff --git a/components/sceneutil/lightmanager.cpp b/components/sceneutil/lightmanager.cpp index 221f419c74..0377905c9d 100644 --- a/components/sceneutil/lightmanager.cpp +++ b/components/sceneutil/lightmanager.cpp @@ -1161,8 +1161,10 @@ namespace SceneUtil } const bool fillPPLights = mPPLightBuffer && it->first->getName() == Constants::SceneCamera; + const bool sceneLimitReached = getLightingMethod() == LightingMethod::SingleUBO + && it->second.size() > static_cast(getMaxLightsInScene() - 1); - if (fillPPLights || getLightingMethod() == LightingMethod::SingleUBO) + if (fillPPLights || sceneLimitReached) { auto sorter = [](const LightSourceViewBound& left, const LightSourceViewBound& right) { return left.mViewBound.center().length2() - left.mViewBound.radius2() @@ -1183,7 +1185,7 @@ namespace SceneUtil } } - if (it->second.size() > static_cast(getMaxLightsInScene() - 1)) + if (sceneLimitReached) it->second.resize(getMaxLightsInScene() - 1); } }