MCPcopy Create free account
hub / github.com/OpenMW/openmw / removeEmptyNodes

Method removeEmptyNodes

components/sceneutil/optimizer.cpp:814–848  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

812}
813
814void Optimizer::RemoveEmptyNodesVisitor::removeEmptyNodes()
815{
816
817 NodeList newEmptyGroups;
818
819 // keep iterator through until scene graph is cleaned of empty nodes.
820 while (!_redundantNodeList.empty())
821 {
822 for(NodeList::iterator itr=_redundantNodeList.begin();
823 itr!=_redundantNodeList.end();
824 ++itr)
825 {
826
827 osg::ref_ptr<osg::Node> nodeToRemove = (*itr);
828
829 // take a copy of parents list since subsequent removes will modify the original one.
830 osg::Node::ParentList parents = nodeToRemove->getParents();
831
832 for(osg::Node::ParentList::iterator pitr=parents.begin();
833 pitr!=parents.end();
834 ++pitr)
835 {
836 osg::Group* parent = *pitr;
837 if (!parent->asSwitch() && !dynamic_cast<osg::LOD*>(parent) && !dynamic_cast<osg::Sequence*>(parent))
838 {
839 parent->removeChild(nodeToRemove.get());
840 if (parent->getNumChildren()==0 && isOperationPermissibleForObject(parent)) newEmptyGroups.insert(parent);
841 }
842 }
843 }
844
845 _redundantNodeList.clear();
846 _redundantNodeList.swap(newEmptyGroups);
847 }
848}
849
850
851////////////////////////////////////////////////////////////////////////////

Callers 1

optimizeMethod · 0.80

Calls 9

removeChildMethod · 0.80
getNumChildrenMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getMethod · 0.45
insertMethod · 0.45
clearMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected