mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-20 21:11:33 +00:00
Ignore empty children of osg::LOD and osg::Switch like in OSG
This commit is contained in:
parent
63fe02b1ba
commit
957d2a890f
2 changed files with 5 additions and 18 deletions
|
@ -735,20 +735,6 @@ bool Optimizer::CombineStaticTransformsVisitor::removeTransforms(osg::Node* node
|
||||||
// RemoveEmptyNodes.
|
// RemoveEmptyNodes.
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void Optimizer::RemoveEmptyNodesVisitor::apply(osg::Switch& switchNode)
|
|
||||||
{
|
|
||||||
// We should keep all switch child nodes since they reflect different switch states.
|
|
||||||
for (unsigned int i=0; i<switchNode.getNumChildren(); ++i)
|
|
||||||
traverse(*switchNode.getChild(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Optimizer::RemoveEmptyNodesVisitor::apply(osg::LOD& lod)
|
|
||||||
{
|
|
||||||
// don't remove any direct children of the LOD because they are used to define each LOD level.
|
|
||||||
for (unsigned int i=0; i<lod.getNumChildren(); ++i)
|
|
||||||
traverse(*lod.getChild(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Optimizer::RemoveEmptyNodesVisitor::apply(osg::Group& group)
|
void Optimizer::RemoveEmptyNodesVisitor::apply(osg::Group& group)
|
||||||
{
|
{
|
||||||
if (group.getNumParents()>0)
|
if (group.getNumParents()>0)
|
||||||
|
@ -787,10 +773,13 @@ void Optimizer::RemoveEmptyNodesVisitor::removeEmptyNodes()
|
||||||
++pitr)
|
++pitr)
|
||||||
{
|
{
|
||||||
osg::Group* parent = *pitr;
|
osg::Group* parent = *pitr;
|
||||||
|
if (!parent->asSwitch() && !dynamic_cast<osg::LOD*>(parent))
|
||||||
|
{
|
||||||
parent->removeChild(nodeToRemove.get());
|
parent->removeChild(nodeToRemove.get());
|
||||||
if (parent->getNumChildren()==0 && isOperationPermissibleForObject(parent)) newEmptyGroups.insert(parent);
|
if (parent->getNumChildren()==0 && isOperationPermissibleForObject(parent)) newEmptyGroups.insert(parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_redundantNodeList.clear();
|
_redundantNodeList.clear();
|
||||||
_redundantNodeList.swap(newEmptyGroups);
|
_redundantNodeList.swap(newEmptyGroups);
|
||||||
|
|
|
@ -321,8 +321,6 @@ class Optimizer
|
||||||
BaseOptimizerVisitor(optimizer, REMOVE_REDUNDANT_NODES) {}
|
BaseOptimizerVisitor(optimizer, REMOVE_REDUNDANT_NODES) {}
|
||||||
|
|
||||||
virtual void apply(osg::Group& group);
|
virtual void apply(osg::Group& group);
|
||||||
virtual void apply(osg::LOD& lod);
|
|
||||||
virtual void apply(osg::Switch& switchNode);
|
|
||||||
|
|
||||||
void removeEmptyNodes();
|
void removeEmptyNodes();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue