Thanks Konstantin, your analysis of the buggy code and fix all look good, fix now merged with svn/trunk and OSG-2.8 branch.
On Thu, Mar 12, 2009 at 10:54 AM, Konstantin Sinitsyn <[email protected]> wrote: > Good day! > > At this moment, I just introducing to OSG. When I reviewing optimizer code, > I find a mistake in Optimizer::RemoveLoadedProxyNodesVisitor, as it seems. > This optimizer removes proxy nodes that fully loaded and in some cases > attach their childs to parrents directly (without creating of group). I dont > understand how this works, because if proxy node doesn't have any attributes > such as name, description, node mask and any callbacks, then new group does > not created to hold proxy node childs. And code below trying to attach their > children to all parents but seems like only first child beeing attached to > all parents correctly. > > // take a copy of parents list since subsequent removes will modify the > original one. > osg::Node::ParentList parents = group->getParents(); > for(unsigned int i=0;i<group->getNumChildren();++i) > { > osg::Node* child = group->getChild(i); > for(osg::Node::ParentList::iterator pitr=parents.begin(); > pitr!=parents.end(); > ++pitr) > { > (*pitr)->replaceChild(group.get(),child); > } > } > > With best regards, > Konstantin Sinitsyn! > > Index: Optimizer.cpp > =================================================================== > --- Optimizer.cpp (revision 9914) > +++ Optimizer.cpp (working copy) > @@ -1506,14 +1506,15 @@ > // take a copy of parents list since subsequent removes will > modify the original one. > osg::Node::ParentList parents = group->getParents(); > > - for(unsigned int i=0;i<group->getNumChildren();++i) > + for(osg::Node::ParentList::iterator pitr=parents.begin(); > + pitr!=parents.end(); > + ++pitr) > { > - osg::Node* child = group->getChild(i); > - for(osg::Node::ParentList::iterator > pitr=parents.begin(); > - pitr!=parents.end(); > - ++pitr) > + (*pitr)->removeChild(group.get()); > + for(unsigned int i=0;i<group->getNumChildren();++i) > { > - (*pitr)->replaceChild(group.get(),child); > + osg::Node* child = group->getChild(i); > + (*pitr)->addChild(child); > } > > } > > _______________________________________________ > osg-submissions mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org > > _______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
