mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-30 11:06:43 +00:00
Analyze only used LOD levels in ObjectPaging
This commit is contained in:
parent
a939cb6692
commit
132fedf290
1 changed files with 19 additions and 0 deletions
|
@ -271,6 +271,7 @@ namespace MWRender
|
||||||
AnalyzeVisitor(osg::Node::NodeMask analyzeMask)
|
AnalyzeVisitor(osg::Node::NodeMask analyzeMask)
|
||||||
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
||||||
, mCurrentStateSet(nullptr)
|
, mCurrentStateSet(nullptr)
|
||||||
|
, mCurrentDistance(0.f)
|
||||||
, mAnalyzeMask(analyzeMask) {}
|
, mAnalyzeMask(analyzeMask) {}
|
||||||
|
|
||||||
typedef std::unordered_map<osg::StateSet*, unsigned int> StateSetCounter;
|
typedef std::unordered_map<osg::StateSet*, unsigned int> StateSetCounter;
|
||||||
|
@ -287,6 +288,22 @@ namespace MWRender
|
||||||
|
|
||||||
if (node.getStateSet())
|
if (node.getStateSet())
|
||||||
mCurrentStateSet = node.getStateSet();
|
mCurrentStateSet = node.getStateSet();
|
||||||
|
|
||||||
|
if (osg::Switch* sw = node.asSwitch())
|
||||||
|
{
|
||||||
|
for (unsigned int i=0; i<sw->getNumChildren(); ++i)
|
||||||
|
if (sw->getValue(i))
|
||||||
|
traverse(*sw->getChild(i));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (osg::LOD* lod = dynamic_cast<osg::LOD*>(&node))
|
||||||
|
{
|
||||||
|
for (unsigned int i=0; i<lod->getNumChildren(); ++i)
|
||||||
|
if (lod->getMinRange(i) * lod->getMinRange(i) <= mCurrentDistance && mCurrentDistance < lod->getMaxRange(i) * lod->getMaxRange(i))
|
||||||
|
traverse(*lod->getChild(i));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
traverse(node);
|
traverse(node);
|
||||||
}
|
}
|
||||||
void apply(osg::Geometry& geom) override
|
void apply(osg::Geometry& geom) override
|
||||||
|
@ -327,6 +344,7 @@ namespace MWRender
|
||||||
Result mResult;
|
Result mResult;
|
||||||
osg::StateSet* mCurrentStateSet;
|
osg::StateSet* mCurrentStateSet;
|
||||||
StateSetCounter mGlobalStateSetCounter;
|
StateSetCounter mGlobalStateSetCounter;
|
||||||
|
float mCurrentDistance;
|
||||||
osg::Node::NodeMask mAnalyzeMask;
|
osg::Node::NodeMask mAnalyzeMask;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -530,6 +548,7 @@ namespace MWRender
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
analyzeVisitor.mCurrentDistance = dSqr;
|
||||||
auto emplaced = nodes.emplace(cnode, InstanceList());
|
auto emplaced = nodes.emplace(cnode, InstanceList());
|
||||||
if (emplaced.second)
|
if (emplaced.second)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue