Changed the setting of need to traverse during the update traverse so it is only enabled when animation is switched on.

This commit is contained in:
Robert Osfield 2007-02-07 21:48:53 +00:00
parent e2d4581443
commit 958b8d74dd
2 changed files with 18 additions and 5 deletions

View File

@ -103,7 +103,7 @@ class OSGSIM_EXPORT DOFTransform : public osg::Transform
void setHPRMultOrder(const MultOrder order) { _multOrder = order; } void setHPRMultOrder(const MultOrder order) { _multOrder = order; }
inline const MultOrder getHPRMultOrder() const { return _multOrder;} inline const MultOrder getHPRMultOrder() const { return _multOrder;}
inline void setAnimationOn(bool do_animate) {_animationOn = do_animate;} void setAnimationOn(bool do_animate);
inline bool getAnimationOn() const { return _animationOn; } inline bool getAnimationOn() const { return _animationOn; }
void animate(float deltaTime); void animate(float deltaTime);

View File

@ -34,7 +34,6 @@ DOFTransform::DOFTransform():
_increasingFlags(0xffff), _increasingFlags(0xffff),
_multOrder(PRH) _multOrder(PRH)
{ {
setNumChildrenRequiringUpdateTraversal(1);
} }
DOFTransform::DOFTransform(const DOFTransform& dof, const osg::CopyOp& copyop): 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), _increasingFlags(dof._increasingFlags),
_multOrder(dof._multOrder) _multOrder(dof._multOrder)
{ {
setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1); if (_animationOn) setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1);
} }
void DOFTransform::traverse(osg::NodeVisitor& nv) void DOFTransform::traverse(osg::NodeVisitor& nv)
@ -460,6 +459,20 @@ void DOFTransform::updateCurrentScale(const osg::Vec3& scale)
dirtyBound(); 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) void DOFTransform::animate(float deltaTime)
{ {
if(!_animationOn) return; if(!_animationOn) return;