From 958b8d74dd48a53f0be457b1d5c16a9c4ee9166a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 7 Feb 2007 21:48:53 +0000 Subject: [PATCH] Changed the setting of need to traverse during the update traverse so it is only enabled when animation is switched on. --- include/osgSim/DOFTransform | 6 +++--- src/osgSim/DOFTransform.cpp | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) 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;