Permalink
Browse files

Added support for pausing and restart the property_animation.

  • Loading branch information...
osg-training-guest committed Nov 30, 2012
1 parent 1ac223e commit 181b81086f0d6b1d60c253f61d79f28f6de63050
@@ -158,7 +158,7 @@ public:
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
- virtual void update(osg::Node* node);
+ virtual void update(osg::Node& node);
protected:
@@ -39,10 +39,14 @@ void PropertyAnimation::reset()
{
_firstTime = DBL_MAX;
_pauseTime = DBL_MAX;
+
+ OSG_NOTICE<<"PropertyAnimation::reset()"<<std::endl;
}
void PropertyAnimation::setPause(bool pause)
{
+ OSG_NOTICE<<"PropertyAnimation::setPause("<<pause<<")"<<std::endl;
+
if (_pause==pause)
{
return;
@@ -80,7 +84,7 @@ void PropertyAnimation::operator()(osg::Node* node, osg::NodeVisitor* nv)
{
// Only update _firstTime the first time, when its value is still DBL_MAX
if (_firstTime==DBL_MAX) _firstTime = time;
- update(node);
+ update(*node);
}
}
@@ -179,7 +183,7 @@ class MySetValueVisitor : public osg::ValueObject::SetValueVisitor
osg::ValueObject* _object2;
};
-void PropertyAnimation::update(osg::Node* node)
+void PropertyAnimation::update(osg::Node& node)
{
OSG_NOTICE<<"PropertyAnimation::update()"<<this<<std::endl;
@@ -192,7 +196,7 @@ void PropertyAnimation::update(osg::Node* node)
{
// need to copy first UserDataContainer
OSG_NOTICE<<"PropertyAnimation::update() : copy first UserDataContainer"<<std::endl;
- assign(node->getOrCreateUserDataContainer(), itr->second.get());
+ assign(node.getOrCreateUserDataContainer(), itr->second.get());
}
else if (itr!=_keyFrameMap.end())
{
@@ -218,7 +222,7 @@ void PropertyAnimation::update(osg::Node* node)
// clone all the properties from p1;
- osg::ref_ptr<osg::UserDataContainer> destination = node->getOrCreateUserDataContainer();
+ osg::ref_ptr<osg::UserDataContainer> destination = node.getOrCreateUserDataContainer();
assign(destination.get(), p1);
@@ -259,7 +263,7 @@ void PropertyAnimation::update(osg::Node* node)
else // (itr==_keyFrameMap.end())
{
OSG_NOTICE<<"PropertyAnimation::update() : copy last UserDataContainer"<<std::endl;
- assign(node->getOrCreateUserDataContainer(), _keyFrameMap.rbegin()->second.get());
+ assign(node.getOrCreateUserDataContainer(), _keyFrameMap.rbegin()->second.get());
}
}
@@ -249,6 +249,7 @@ struct CallbackOperator : public ObjectOperator
osg::AnimationPathCallback* apc = dynamic_cast<osg::AnimationPathCallback*>(_callback.get());
osgUtil::TransformCallback* tc = dynamic_cast<osgUtil::TransformCallback*>(_callback.get());
AnimationMaterialCallback* amc = dynamic_cast<AnimationMaterialCallback*>(_callback.get());
+ PropertyAnimation* pa = dynamic_cast<PropertyAnimation*>(_callback.get());
if (apc)
{
OSG_INFO<<"apc->setPause("<<pause<<")"<<std::endl;
@@ -264,6 +265,10 @@ struct CallbackOperator : public ObjectOperator
OSG_INFO<<"amc->setPause("<<pause<<")"<<std::endl;
amc->setPause(pause);
}
+ else if (pa)
+ {
+ pa->setPause(pause);
+ }
else if (nc)
{
OSG_NOTICE<<"Need to pause callback : "<<nc->className()<<std::endl;
@@ -277,6 +282,7 @@ struct CallbackOperator : public ObjectOperator
osg::AnimationPathCallback* apc = dynamic_cast<osg::AnimationPathCallback*>(_callback.get());
osgUtil::TransformCallback* tc = dynamic_cast<osgUtil::TransformCallback*>(_callback.get());
AnimationMaterialCallback* amc = dynamic_cast<AnimationMaterialCallback*>(_callback.get());
+ PropertyAnimation* pa = dynamic_cast<PropertyAnimation*>(_callback.get());
if (apc)
{
apc->reset();
@@ -290,6 +296,11 @@ struct CallbackOperator : public ObjectOperator
amc->reset();
amc->update(*_node);
}
+ else if (pa)
+ {
+ pa->reset();
+ pa->update(*_node);
+ }
else
{
OSG_NOTICE<<"Need to reset callback : "<<nc->className()<<std::endl;

0 comments on commit 181b810

Please sign in to comment.