From 330e5fefd1274b21e42af59f5ed2b01ebefb0f01 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 24 Feb 2017 02:43:31 +0100 Subject: [PATCH] optimizer: consider a Group with more than one child redundant as well While there could be some value in this hierarchy (i.e. improved culling), we don't know if this is being used sensibly; and using a 'flat' hierarchy helps other optimizations. --- components/sceneutil/optimizer.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/components/sceneutil/optimizer.cpp b/components/sceneutil/optimizer.cpp index b975e5463..b0686d524 100644 --- a/components/sceneutil/optimizer.cpp +++ b/components/sceneutil/optimizer.cpp @@ -840,18 +840,20 @@ void Optimizer::RemoveRedundantNodesVisitor::removeRedundantNodes() // take a copy of parents list since subsequent removes will modify the original one. osg::Node::ParentList parents = group->getParents(); - if (group->getNumChildren()==1) + for(osg::Node::ParentList::iterator pitr=parents.begin(); + pitr!=parents.end(); + ++pitr) { - osg::Node* child = group->getChild(0); - for(osg::Node::ParentList::iterator pitr=parents.begin(); - pitr!=parents.end(); - ++pitr) + for (unsigned int i=0; igetNumChildren(); ++i) { - (*pitr)->replaceChild(group.get(),child); + osg::Node* child = group->getChild(i); + (*pitr)->addChild(child); } + (*pitr)->removeChild(group); } + group->removeChildren(0, group->getNumChildren()); } else {