From Cedric Pinson, Traverse StripAction instead of applying, this fix the execution of FrameCallback in BlendIn, BlendOut and AnimationAction\nFix warning of osgAnimation::StatsHandler\nFix crash when running example osganimationtimeline without nathan.osg in OSG_FILE_PATH or with bad file
This commit is contained in:
@@ -194,6 +194,8 @@ namespace osgAnimation
|
||||
void setLoop(unsigned int loop);
|
||||
void computeWeightAndUpdateAnimation(unsigned int frame);
|
||||
|
||||
void traverse(ActionVisitor& visitor);
|
||||
|
||||
protected:
|
||||
typedef std::pair<unsigned int, osg::ref_ptr<BlendOut> > FrameBlendOut;
|
||||
osg::ref_ptr<BlendIn> _blendIn;
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace osgAnimation
|
||||
META_ActionVisitor(osgAnimation, ActionVisitor);
|
||||
void traverse(Action& visitor);
|
||||
|
||||
void pushFrameActionOnStack(FrameAction& fa);
|
||||
void pushFrameActionOnStack(const FrameAction& fa);
|
||||
void popFrameAction();
|
||||
|
||||
void pushTimelineOnStack(Timeline* tm);
|
||||
@@ -71,7 +71,7 @@ namespace osgAnimation
|
||||
UpdateActionVisitor();
|
||||
void setFrame(unsigned int frame) { _frame = frame;}
|
||||
|
||||
bool isActive() const;
|
||||
bool isActive(Action& action) const;
|
||||
unsigned int getLocalFrame() const;
|
||||
|
||||
void apply(Timeline& action);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <osgAnimation/ActionVisitor>
|
||||
#include <osgAnimation/Timeline>
|
||||
|
||||
void osgAnimation::ActionVisitor::pushFrameActionOnStack(FrameAction& fa) { _stackFrameAction.push_back(fa); }
|
||||
void osgAnimation::ActionVisitor::pushFrameActionOnStack(const FrameAction& fa) { _stackFrameAction.push_back(fa); }
|
||||
void osgAnimation::ActionVisitor::popFrameAction() { _stackFrameAction.pop_back(); }
|
||||
void osgAnimation::ActionVisitor::pushTimelineOnStack(Timeline* tm) { _stackTimeline.push_back(tm); }
|
||||
void osgAnimation::ActionVisitor::popTimeline() { _stackTimeline.pop_back(); }
|
||||
@@ -52,17 +52,20 @@ void osgAnimation::UpdateActionVisitor::apply(Timeline& tm)
|
||||
tm.setLastFrameEvaluated(_frame);
|
||||
}
|
||||
|
||||
bool osgAnimation::UpdateActionVisitor::isActive() const
|
||||
bool osgAnimation::UpdateActionVisitor::isActive(Action& action) const
|
||||
{
|
||||
FrameAction fa = _stackFrameAction.back();
|
||||
if (_frame < fa.first)
|
||||
return false;
|
||||
if (!fa.second.valid())
|
||||
return false;
|
||||
if (getLocalFrame() >= fa.second->getNumFrames())
|
||||
return false;
|
||||
return true;
|
||||
|
||||
unsigned int f = getLocalFrame();
|
||||
unsigned int frameInAction;
|
||||
unsigned int loopDone;
|
||||
return action.evaluateFrame(f, frameInAction, loopDone);
|
||||
}
|
||||
|
||||
unsigned int osgAnimation::UpdateActionVisitor::getLocalFrame() const
|
||||
{
|
||||
return _frame - _stackFrameAction.back().first;
|
||||
@@ -70,7 +73,7 @@ unsigned int osgAnimation::UpdateActionVisitor::getLocalFrame() const
|
||||
|
||||
void osgAnimation::UpdateActionVisitor::apply(Action& action)
|
||||
{
|
||||
if (isActive())
|
||||
if (isActive(action))
|
||||
{
|
||||
unsigned int frame = getLocalFrame();
|
||||
|
||||
@@ -97,7 +100,7 @@ void osgAnimation::UpdateActionVisitor::apply(Action& action)
|
||||
|
||||
void osgAnimation::UpdateActionVisitor::apply(BlendIn& action)
|
||||
{
|
||||
if (isActive())
|
||||
if (isActive(action))
|
||||
{
|
||||
unsigned int frame = getLocalFrame();
|
||||
apply(static_cast<Action&>(action));
|
||||
@@ -107,7 +110,7 @@ void osgAnimation::UpdateActionVisitor::apply(BlendIn& action)
|
||||
|
||||
void osgAnimation::UpdateActionVisitor::apply(BlendOut& action)
|
||||
{
|
||||
if (isActive())
|
||||
if (isActive(action))
|
||||
{
|
||||
unsigned int frame = getLocalFrame();
|
||||
apply(static_cast<Action&>(action));
|
||||
@@ -117,7 +120,7 @@ void osgAnimation::UpdateActionVisitor::apply(BlendOut& action)
|
||||
|
||||
void osgAnimation::UpdateActionVisitor::apply(ActionAnimation& action)
|
||||
{
|
||||
if (isActive())
|
||||
if (isActive(action))
|
||||
{
|
||||
unsigned int frame = getLocalFrame();
|
||||
apply(static_cast<Action&>(action));
|
||||
@@ -127,11 +130,32 @@ void osgAnimation::UpdateActionVisitor::apply(ActionAnimation& action)
|
||||
|
||||
void osgAnimation::UpdateActionVisitor::apply(StripAnimation& action)
|
||||
{
|
||||
if (isActive())
|
||||
if (isActive(action))
|
||||
{
|
||||
unsigned int frame = getLocalFrame();
|
||||
apply(static_cast<Action&>(action));
|
||||
|
||||
#if 0
|
||||
unsigned int frame = getLocalFrame();
|
||||
// evaluate callback in blendin/blendout/animation
|
||||
{
|
||||
BlendIn* subAction = action.getBlendIn();
|
||||
if (subAction)
|
||||
apply(static_cast<Action&>(*subAction));
|
||||
}
|
||||
{
|
||||
BlendOut* subAction = action.getBlendOut();
|
||||
if (subAction)
|
||||
apply(static_cast<Action&>(*subAction));
|
||||
}
|
||||
{
|
||||
ActionAnimation* subAction = action.getActionAnimation();
|
||||
if (subAction)
|
||||
apply(static_cast<Action&>(*subAction));
|
||||
}
|
||||
action.computeWeightAndUpdateAnimation(frame);
|
||||
#else
|
||||
action.traverse(*this);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -441,7 +441,7 @@ struct ValueTextDrawCallback : public virtual osg::Drawable::DrawCallback
|
||||
_actions[name].setPosition(pos);
|
||||
//_actions[name].touch();
|
||||
}
|
||||
_actions[name]._group->setNodeMask(-1);
|
||||
_actions[name]._group->setNodeMask(~0);
|
||||
size[name] = 0;
|
||||
pos.y() -= characterSize + graphSpacing;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ void osgAnimation::StatsActionVisitor::apply(Timeline& tm)
|
||||
|
||||
void osgAnimation::StatsActionVisitor::apply(Action& action)
|
||||
{
|
||||
if (isActive())
|
||||
if (isActive(action))
|
||||
{
|
||||
_channels.push_back(action.getName());
|
||||
_stats->setAttribute(_frame,action.getName(),1);
|
||||
@@ -41,7 +41,7 @@ void osgAnimation::StatsActionVisitor::apply(Action& action)
|
||||
|
||||
void osgAnimation::StatsActionVisitor::apply(BlendIn& action)
|
||||
{
|
||||
if (isActive())
|
||||
if (isActive(action))
|
||||
{
|
||||
_channels.push_back(action.getName());
|
||||
_stats->setAttribute(_frame,action.getName(), action.getWeight());
|
||||
@@ -50,7 +50,7 @@ void osgAnimation::StatsActionVisitor::apply(BlendIn& action)
|
||||
|
||||
void osgAnimation::StatsActionVisitor::apply(BlendOut& action)
|
||||
{
|
||||
if (isActive())
|
||||
if (isActive(action))
|
||||
{
|
||||
_channels.push_back(action.getName());
|
||||
_stats->setAttribute(_frame,action.getName(), action.getWeight());
|
||||
@@ -59,7 +59,7 @@ void osgAnimation::StatsActionVisitor::apply(BlendOut& action)
|
||||
|
||||
void osgAnimation::StatsActionVisitor::apply(ActionAnimation& action)
|
||||
{
|
||||
if (isActive())
|
||||
if (isActive(action))
|
||||
{
|
||||
_channels.push_back(action.getName());
|
||||
_stats->setAttribute(_frame,action.getName(), action.getAnimation()->getWeight());
|
||||
@@ -68,7 +68,7 @@ void osgAnimation::StatsActionVisitor::apply(ActionAnimation& action)
|
||||
|
||||
void osgAnimation::StatsActionVisitor::apply(StripAnimation& action)
|
||||
{
|
||||
if (isActive())
|
||||
if (isActive(action))
|
||||
{
|
||||
_channels.push_back(action.getName());
|
||||
_stats->setAttribute(_frame,action.getName(), action.getActionAnimation()->getAnimation()->getWeight());
|
||||
|
||||
Reference in New Issue
Block a user