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."

-----------------------------------------------
This commit is contained in:
Robert Osfield
2006-10-30 12:14:00 +00:00
parent a48a4aa7d3
commit c5c4c5da1d

View File

@@ -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;