From e8cc8f06c58df45cf874f8ee5ed809fb5fc83c94 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 24 Jun 2005 15:34:46 +0000 Subject: [PATCH] From Martijn Kragtwijk: "I ran into the same problems as Karl Martensson (http://openscenegraph.org/archiver/osg-users/2005-June/0575.html); after switching children of a Switch node off and on again, they become unpickable. This issue occurs first in 0.9.9, with 0.9.8 everything is fine. My fix involves calling dirtyBound() every time the on/off-values of the Switch are changed" --- src/osg/Switch.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/osg/Switch.cpp b/src/osg/Switch.cpp index 4afdfcd66..e7c89cb95 100644 --- a/src/osg/Switch.cpp +++ b/src/osg/Switch.cpp @@ -50,12 +50,12 @@ bool Switch::addChild( Node *child ) if (Group::addChild(child)) { if (_children.size()>_values.size()) - { - _values.resize(_children.size(),_newChildDefaultValue); - } + { + _values.resize(_children.size(),_newChildDefaultValue); + } // note, we don't override any pre-existing _values[childPosition] setting // like in addChild(child,value) below. - return true; + return true; } return false; } @@ -66,11 +66,11 @@ bool Switch::addChild( Node *child, bool value ) if (Group::addChild(child)) { if (_children.size()>_values.size()) - { - _values.resize(_children.size(),_newChildDefaultValue); - } - _values[childPosition]=value; - return true; + { + _values.resize(_children.size(),_newChildDefaultValue); + } + _values[childPosition]=value; + return true; } return false; } @@ -85,15 +85,15 @@ bool Switch::insertChild( unsigned int index, Node *child, bool value ) if (Group::insertChild(index,child)) { if (index>=_values.size()) - { - _values.push_back(value); - } + { + _values.push_back(value); + } else { - _values.insert(_values.begin()+index, value); + _values.insert(_values.begin()+index, value); } - return true; + return true; } return false; } @@ -113,6 +113,7 @@ void Switch::setValue(unsigned int pos,bool value) { if (pos>=_values.size()) _values.resize(pos+1,_newChildDefaultValue); _values[pos]=value; + dirtyBound(); } void Switch::setChildValue(const Node* child,bool value) @@ -122,6 +123,7 @@ void Switch::setChildValue(const Node* child,bool value) if (pos==_children.size()) return; _values[pos]=value; + dirtyBound(); } bool Switch::getValue(unsigned int pos) const @@ -148,6 +150,7 @@ bool Switch::setAllChildrenOff() { *itr = false; } + dirtyBound(); return true; }