1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-03 08:49:40 +00:00

Light culling fix

This commit is contained in:
scrawl 2015-06-15 19:37:44 +02:00
parent 18f4eaa8dc
commit aad8e7b6d0

View file

@ -145,6 +145,10 @@ namespace SceneUtil
{
mLightsInViewSpace = false;
mLights.clear();
// do an occasional cleanup for orphaned lights
if (mStateSetCache.size() > 5000)
mStateSetCache.clear();
}
void LightManager::addLight(LightSource* lightSource, osg::Matrix worldMat)
@ -304,11 +308,14 @@ namespace SceneUtil
if (lightList.size() > maxLights)
{
// remove lights culled by this camera
for (LightManager::LightList::iterator it = lightList.begin(); it != lightList.end();)
for (LightManager::LightList::iterator it = lightList.begin(); it != lightList.end() && lightList.size() > maxLights; )
{
osg::CullStack::CullingStack& stack = cv->getProjectionCullingStack();
osg::CullStack::CullingStack& stack = cv->getModelViewCullingStack();
if (stack.back().isCulled(osg::BoundingSphere((*it)->mViewBound.center(), (*it)->mViewBound.radius()*2)))
osg::BoundingSphere bs = (*it)->mViewBound;
bs._radius = bs._radius*2;
osg::CullingSet& cullingSet = stack.front();
if (cullingSet.isCulled(bs))
{
it = lightList.erase(it);
continue;