mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 07:36:41 +00:00
The performance impact isn't so big anymore since the last commit.
This commit is contained in:
parent
1d198a5592
commit
acf9fc2d37
1 changed files with 31 additions and 46 deletions
|
@ -274,59 +274,44 @@ namespace SceneUtil
|
||||||
|
|
||||||
if (lights.size())
|
if (lights.size())
|
||||||
{
|
{
|
||||||
|
// we do the intersections in view space
|
||||||
|
osg::BoundingSphere nodeBound = node->getBound();
|
||||||
|
osg::Matrixf mat = *cv->getModelViewMatrix();
|
||||||
|
transformBoundingSphere(mat, nodeBound);
|
||||||
|
|
||||||
static std::map<osg::Node*, osg::ref_ptr<osg::StateSet> > statesets;
|
std::vector<LightSource*> lightList;
|
||||||
std::map<osg::Node*, osg::ref_ptr<osg::StateSet> >::iterator found = statesets.find(node);
|
for (unsigned int i=0; i<lights.size(); ++i)
|
||||||
osg::ref_ptr<osg::StateSet> stateset;
|
|
||||||
if (found != statesets.end())
|
|
||||||
{
|
{
|
||||||
stateset = found->second;
|
const LightManager::LightSourceTransform& l = lights[i];
|
||||||
}
|
if (l.mViewBound.intersects(nodeBound))
|
||||||
else{
|
lightList.push_back(l.mLightSource);
|
||||||
|
|
||||||
// we do the intersections in view space
|
|
||||||
osg::BoundingSphere nodeBound = node->getBound();
|
|
||||||
osg::Matrixf mat = *cv->getModelViewMatrix();
|
|
||||||
transformBoundingSphere(mat, nodeBound);
|
|
||||||
|
|
||||||
std::vector<LightSource*> lightList;
|
|
||||||
for (unsigned int i=0; i<lights.size(); ++i)
|
|
||||||
{
|
|
||||||
const LightManager::LightSourceTransform& l = lights[i];
|
|
||||||
if (l.mViewBound.intersects(nodeBound))
|
|
||||||
lightList.push_back(l.mLightSource);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lightList.empty())
|
|
||||||
{
|
|
||||||
statesets[node] = NULL;
|
|
||||||
traverse(node, nv);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int maxLights = static_cast<unsigned int> (8 - mLightManager->getStartLight());
|
|
||||||
|
|
||||||
if (lightList.size() > maxLights)
|
|
||||||
{
|
|
||||||
//std::cerr << "More than 8 lights!" << std::endl;
|
|
||||||
|
|
||||||
// TODO: sort lights by certain criteria
|
|
||||||
|
|
||||||
while (lightList.size() > maxLights)
|
|
||||||
lightList.pop_back();
|
|
||||||
}
|
|
||||||
|
|
||||||
stateset = mLightManager->getLightListStateSet(lightList);
|
|
||||||
statesets[node] = stateset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stateset)
|
if (lightList.empty())
|
||||||
cv->pushStateSet(stateset);
|
{
|
||||||
|
traverse(node, nv);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int maxLights = static_cast<unsigned int> (8 - mLightManager->getStartLight());
|
||||||
|
|
||||||
|
if (lightList.size() > maxLights)
|
||||||
|
{
|
||||||
|
//std::cerr << "More than 8 lights!" << std::endl;
|
||||||
|
|
||||||
|
// TODO: sort lights by certain criteria
|
||||||
|
|
||||||
|
while (lightList.size() > maxLights)
|
||||||
|
lightList.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
osg::StateSet* stateset = mLightManager->getLightListStateSet(lightList);
|
||||||
|
|
||||||
|
cv->pushStateSet(stateset);
|
||||||
|
|
||||||
traverse(node, nv);
|
traverse(node, nv);
|
||||||
|
|
||||||
if (stateset)
|
cv->popStateSet();
|
||||||
cv->popStateSet();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
traverse(node, nv);
|
traverse(node, nv);
|
||||||
|
|
Loading…
Reference in a new issue