diff --git a/include/osgSim/DOFTransform b/include/osgSim/DOFTransform index b4ba8592c..fd7e6eaf0 100644 --- a/include/osgSim/DOFTransform +++ b/include/osgSim/DOFTransform @@ -100,11 +100,11 @@ class OSGSIM_EXPORT DOFTransform : public osg::Transform RHP }; - void setHPRMultOrder(const MultOrder order) {_multOrder = order;} + void setHPRMultOrder(const MultOrder order) { _multOrder = order; } inline const MultOrder getHPRMultOrder() const { return _multOrder;} - inline void setAnimationOn(bool do_animate) {_animationOn = do_animate;} - inline bool getAnimationOn() const {return _animationOn;} + void setAnimationOn(bool do_animate); + inline bool getAnimationOn() const { return _animationOn; } void animate(float deltaTime); diff --git a/src/osgSim/DOFTransform.cpp b/src/osgSim/DOFTransform.cpp index 3625fb5e8..b6c55bd7e 100644 --- a/src/osgSim/DOFTransform.cpp +++ b/src/osgSim/DOFTransform.cpp @@ -34,7 +34,6 @@ DOFTransform::DOFTransform(): _increasingFlags(0xffff), _multOrder(PRH) { - setNumChildrenRequiringUpdateTraversal(1); } DOFTransform::DOFTransform(const DOFTransform& dof, const osg::CopyOp& copyop): @@ -60,7 +59,7 @@ DOFTransform::DOFTransform(const DOFTransform& dof, const osg::CopyOp& copyop): _increasingFlags(dof._increasingFlags), _multOrder(dof._multOrder) { - setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1); + if (_animationOn) setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1); } void DOFTransform::traverse(osg::NodeVisitor& nv) @@ -460,6 +459,20 @@ void DOFTransform::updateCurrentScale(const osg::Vec3& scale) dirtyBound(); } +void DOFTransform::setAnimationOn(bool do_animate) +{ + if (_animationOn == do_animate) return; + + int delta = 0; + + if (_animationOn) --delta; + if (do_animate) ++delta; + + _animationOn = do_animate; + + if (_animationOn) setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+delta); +} + void DOFTransform::animate(float deltaTime) { if(!_animationOn) return;