diff --git a/components/sceneutil/optimizer.cpp b/components/sceneutil/optimizer.cpp index 1aadc19d6a..99f7ae122c 100644 --- a/components/sceneutil/optimizer.cpp +++ b/components/sceneutil/optimizer.cpp @@ -847,10 +847,11 @@ void Optimizer::RemoveRedundantNodesVisitor::removeRedundantNodes() pitr!=parents.end(); ++pitr) { + unsigned int childIndex = (*pitr)->getChildIndex(group); for (unsigned int i=0; igetNumChildren(); ++i) { osg::Node* child = group->getChild(i); - (*pitr)->addChild(child); + (*pitr)->insertChild(childIndex++, child); } (*pitr)->removeChild(group);