From c5c4c5da1d6e11e1ceb60e994637a212b6e03de4 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 30 Oct 2006 12:14:00 +0000 Subject: [PATCH] From Edgar Ellis, " method may not take the node into consideration when computing its bound. In this case of: switch->insertChild(0, child, false); switch->insertChild(1, child, true); child will not be used in computeBound, but will be drawn. Solution: Changed compute bound to loop over children using an index instead of an iterator. This behaviour matches that of the traverse method." ----------------------------------------------- --- src/osg/Switch.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/osg/Switch.cpp b/src/osg/Switch.cpp index 4fc91aeae..0c048e503 100644 --- a/src/osg/Switch.cpp +++ b/src/osg/Switch.cpp @@ -190,16 +190,13 @@ BoundingSphere Switch::computeBound() const BoundingBox bb; bb.init(); - NodeList::const_iterator itr; - for(itr=_children.begin(); - itr!=_children.end(); - ++itr) + for(unsigned int pos=0;pos<_children.size();++pos) { - const osg::Transform* transform = (*itr)->asTransform(); + const osg::Transform* transform = _children[pos]->asTransform(); if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF) { - if( getChildValue((*itr).get()) == true ) - bb.expandBy((*itr)->getBound()); + if( _values[pos] == true ) + bb.expandBy(_children[pos]->getBound()); } } @@ -210,15 +207,13 @@ BoundingSphere Switch::computeBound() const bsphere._center = bb.center(); bsphere._radius = 0.0f; - for(itr=_children.begin(); - itr!=_children.end(); - ++itr) + for(unsigned int pos=0;pos<_children.size();++pos) { - const osg::Transform* transform = (*itr)->asTransform(); + const osg::Transform* transform = _children[pos]->asTransform(); if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF) { - if( getChildValue((*itr).get()) == true ) - bsphere.expandRadiusBy((*itr)->getBound()); + if( _values[pos] == true ) + bsphere.expandRadiusBy(_children[pos]->getBound()); } } return bsphere;