mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 16:49:54 +00:00
Light culling fix
This commit is contained in:
parent
18f4eaa8dc
commit
aad8e7b6d0
1 changed files with 10 additions and 3 deletions
|
@ -145,6 +145,10 @@ namespace SceneUtil
|
||||||
{
|
{
|
||||||
mLightsInViewSpace = false;
|
mLightsInViewSpace = false;
|
||||||
mLights.clear();
|
mLights.clear();
|
||||||
|
|
||||||
|
// do an occasional cleanup for orphaned lights
|
||||||
|
if (mStateSetCache.size() > 5000)
|
||||||
|
mStateSetCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightManager::addLight(LightSource* lightSource, osg::Matrix worldMat)
|
void LightManager::addLight(LightSource* lightSource, osg::Matrix worldMat)
|
||||||
|
@ -304,11 +308,14 @@ namespace SceneUtil
|
||||||
if (lightList.size() > maxLights)
|
if (lightList.size() > maxLights)
|
||||||
{
|
{
|
||||||
// remove lights culled by this camera
|
// 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);
|
it = lightList.erase(it);
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue