PlayGroup: Don't loop animations with no loop keys (Fixes #2223)

moveref
scrawl 10 years ago
parent 9e5dfb6e98
commit 8bc7eb5530

@ -325,7 +325,7 @@ void CharacterController::refreshCurrentAnims(CharacterState idle, CharacterStat
mCurrentIdle = idle;
if(!mCurrentIdle.empty())
mAnimation->play(mCurrentIdle, Priority_Default, MWRender::Animation::Group_All, false,
1.0f, "start", "stop", 0.0f, ~0ul);
1.0f, "start", "stop", 0.0f, ~0ul, true);
}
updateIdleStormState();
@ -1289,7 +1289,7 @@ bool CharacterController::updateWeaponState()
{
mAnimation->play("torch", Priority_Torch, MWRender::Animation::Group_LeftArm,
false, 1.0f, "start", "stop", 0.0f, (~(size_t)0));
false, 1.0f, "start", "stop", 0.0f, (~(size_t)0), true);
}
else if (mAnimation->isPlaying("torch"))
{

@ -613,7 +613,7 @@ void Animation::updatePosition(float oldtime, float newtime, Ogre::Vector3 &posi
mAccumRoot->setPosition(-off);
}
bool Animation::reset(AnimState &state, const NifOgre::TextKeyMap &keys, const std::string &groupname, const std::string &start, const std::string &stop, float startpoint)
bool Animation::reset(AnimState &state, const NifOgre::TextKeyMap &keys, const std::string &groupname, const std::string &start, const std::string &stop, float startpoint, bool loopfallback)
{
// Look for text keys in reverse. This normally wouldn't matter, but for some reason undeadwolf_2.nif has two
// separate walkforward keys, and the last one is supposed to be used.
@ -654,8 +654,16 @@ bool Animation::reset(AnimState &state, const NifOgre::TextKeyMap &keys, const s
return false;
state.mStartTime = startkey->first;
state.mLoopStartTime = startkey->first;
state.mLoopStopTime = stopkey->first;
if (loopfallback)
{
state.mLoopStartTime = startkey->first;
state.mLoopStopTime = stopkey->first;
}
else
{
state.mLoopStartTime = startkey->first;
state.mLoopStopTime = std::numeric_limits<float>::max();
}
state.mStopTime = stopkey->first;
state.mTime = state.mStartTime + ((state.mStopTime - state.mStartTime) * startpoint);
@ -850,7 +858,7 @@ void Animation::stopLooping(const std::string& groupname)
}
}
void Animation::play(const std::string &groupname, int priority, int groups, bool autodisable, float speedmult, const std::string &start, const std::string &stop, float startpoint, size_t loops)
void Animation::play(const std::string &groupname, int priority, int groups, bool autodisable, float speedmult, const std::string &start, const std::string &stop, float startpoint, size_t loops, bool loopfallback)
{
if(!mSkelBase || mAnimSources.empty())
return;
@ -886,7 +894,7 @@ void Animation::play(const std::string &groupname, int priority, int groups, boo
for(;iter != mAnimSources.rend();++iter)
{
const NifOgre::TextKeyMap &textkeys = (*iter)->mTextKeys;
if(reset(state, textkeys, groupname, start, stop, startpoint))
if(reset(state, textkeys, groupname, start, stop, startpoint, loopfallback))
{
state.mSource = *iter;
state.mSpeedMult = speedmult;

@ -173,7 +173,7 @@ protected:
*/
bool reset(AnimState &state, const NifOgre::TextKeyMap &keys,
const std::string &groupname, const std::string &start, const std::string &stop,
float startpoint);
float startpoint, bool loopfallback);
void handleTextKey(AnimState &state, const std::string &groupname, const NifOgre::TextKeyMap::const_iterator &key,
const NifOgre::TextKeyMap& map);
@ -255,11 +255,14 @@ public:
* at the start marker, 1 starts at the stop marker.
* \param loops How many times to loop the animation. This will use the
* "loop start" and "loop stop" markers if they exist,
* otherwise it will use "start" and "stop".
* otherwise it may fall back to "start" and "stop", but only if
* the \a loopFallback parameter is true.
* \param loopFallback Allow looping an animation that has no loop keys, i.e. fall back to use
* the "start" and "stop" keys for looping?
*/
void play(const std::string &groupname, int priority, int groups, bool autodisable,
float speedmult, const std::string &start, const std::string &stop,
float startpoint, size_t loops);
float startpoint, size_t loops, bool loopfallback=false);
/** If the given animation group is currently playing, set its remaining loop count to '0'.
*/

@ -242,7 +242,7 @@ namespace MWRender
{
if(!mAnimation->getInfo("torch"))
mAnimation->play("torch", 2, MWRender::Animation::Group_LeftArm, false,
1.0f, "start", "stop", 0.0f, ~0ul);
1.0f, "start", "stop", 0.0f, ~0ul, true);
}
else if(mAnimation->getInfo("torch"))
mAnimation->disable("torch");

Loading…
Cancel
Save