Add the missing calculation for ipo constructor

This commit is contained in:
Benau 2018-07-08 15:29:15 +08:00
parent 3347cac92d
commit 35e2916981
2 changed files with 15 additions and 8 deletions

View File

@ -46,14 +46,7 @@ AnimationBase::AnimationBase(const XMLNode &node)
m_playing = false;
}
reset();
m_animation_duration = -1.0f;
for (const Ipo* currIpo : m_all_ipos)
{
m_animation_duration = std::max(m_animation_duration,
currIpo->getEndTime());
}
calculateAnimationDuration();
} // AnimationBase
// ----------------------------------------------------------------------------
/** Special constructor which takes one IPO (or curve). This is used by the
@ -64,8 +57,20 @@ AnimationBase::AnimationBase(Ipo *ipo)
m_playing = true;
m_all_ipos.push_back(ipo);
reset();
calculateAnimationDuration();
} // AnimationBase(Ipo)
// ----------------------------------------------------------------------------
void AnimationBase::calculateAnimationDuration()
{
m_animation_duration = -1.0f;
for (const Ipo* currIpo : m_all_ipos)
{
m_animation_duration = std::max(m_animation_duration,
currIpo->getEndTime());
}
} // calculateAnimationDuration
// ----------------------------------------------------------------------------
/** Stores the initial transform (in the IPOs actually). This is necessary
* for relative IPOs.

View File

@ -56,6 +56,8 @@ private:
/** The initial rotation of this object. */
Vec3 m_initial_hpr;
void calculateAnimationDuration();
protected:
/** All IPOs for this animation. */
PtrVector<Ipo> m_all_ipos;