mirror of
https://github.com/OpenMW/openmw.git
synced 2025-07-01 03:41:37 +00:00
Add AnimState::shouldLoop()
This commit is contained in:
parent
6450c9be27
commit
0c9882956a
2 changed files with 18 additions and 19 deletions
|
@ -1023,7 +1023,7 @@ namespace MWRender
|
|||
{
|
||||
float targetTime;
|
||||
|
||||
if (state.getTime() < state.mLoopStopTime || state.mLoopCount == 0)
|
||||
if (!state.shouldLoop())
|
||||
{
|
||||
targetTime = state.getTime() + timepassed;
|
||||
if(textkey == textkeys.end() || textkey->first > targetTime)
|
||||
|
@ -1048,27 +1048,21 @@ namespace MWRender
|
|||
++textkey;
|
||||
}
|
||||
}
|
||||
|
||||
if(state.getTime() >= state.mLoopStopTime)
|
||||
if(state.shouldLoop())
|
||||
{
|
||||
if (!state.mLoopingEnabled)
|
||||
state.mLoopCount = 0;
|
||||
else if (state.mLoopCount > 0)
|
||||
state.mLoopCount--;
|
||||
state.setTime(state.mLoopStartTime);
|
||||
state.mPlaying = true;
|
||||
|
||||
textkey = textkeys.lower_bound(state.getTime());
|
||||
while(textkey != textkeys.end() && textkey->first <= state.getTime())
|
||||
{
|
||||
state.mLoopCount--;
|
||||
state.setTime(state.mLoopStartTime);
|
||||
state.mPlaying = true;
|
||||
|
||||
textkey = textkeys.lower_bound(state.getTime());
|
||||
while(textkey != textkeys.end() && textkey->first <= state.getTime())
|
||||
{
|
||||
handleTextKey(state, stateiter->first, textkey, textkeys);
|
||||
++textkey;
|
||||
}
|
||||
|
||||
if(state.getTime() >= state.mLoopStopTime)
|
||||
break;
|
||||
handleTextKey(state, stateiter->first, textkey, textkeys);
|
||||
++textkey;
|
||||
}
|
||||
|
||||
if(state.getTime() >= state.mLoopStopTime)
|
||||
break;
|
||||
}
|
||||
|
||||
if(timepassed <= 0.0f)
|
||||
|
|
|
@ -205,6 +205,11 @@ protected:
|
|||
{
|
||||
*mTime = time;
|
||||
}
|
||||
|
||||
bool shouldLoop() const
|
||||
{
|
||||
return getTime() >= mLoopStopTime && mLoopingEnabled && mLoopCount > 0;
|
||||
}
|
||||
};
|
||||
typedef std::map<std::string,AnimState> AnimStateMap;
|
||||
AnimStateMap mStates;
|
||||
|
|
Loading…
Reference in a new issue