|
|
|
@ -1023,50 +1023,54 @@ namespace MWRender
|
|
|
|
|
{
|
|
|
|
|
float targetTime;
|
|
|
|
|
|
|
|
|
|
if(state.getTime() >= state.mLoopStopTime && state.mLoopCount > 0)
|
|
|
|
|
goto handle_loop;
|
|
|
|
|
|
|
|
|
|
targetTime = state.getTime() + timepassed;
|
|
|
|
|
if(textkey == textkeys.end() || textkey->first > targetTime)
|
|
|
|
|
{
|
|
|
|
|
if(mAccumCtrl && state.mTime == mAnimationTimePtr[0]->getTimePtr())
|
|
|
|
|
updatePosition(state.getTime(), targetTime, movement);
|
|
|
|
|
state.setTime(std::min(targetTime, state.mStopTime));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (state.getTime() < state.mLoopStopTime || state.mLoopCount == 0)
|
|
|
|
|
{
|
|
|
|
|
if(mAccumCtrl && state.mTime == mAnimationTimePtr[0]->getTimePtr())
|
|
|
|
|
updatePosition(state.getTime(), textkey->first, movement);
|
|
|
|
|
state.setTime(textkey->first);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
state.mPlaying = (state.getTime() < state.mStopTime);
|
|
|
|
|
timepassed = targetTime - state.getTime();
|
|
|
|
|
|
|
|
|
|
while(textkey != textkeys.end() && textkey->first <= state.getTime())
|
|
|
|
|
{
|
|
|
|
|
handleTextKey(state, stateiter->first, textkey, textkeys);
|
|
|
|
|
++textkey;
|
|
|
|
|
}
|
|
|
|
|
targetTime = state.getTime() + timepassed;
|
|
|
|
|
if(textkey == textkeys.end() || textkey->first > targetTime)
|
|
|
|
|
{
|
|
|
|
|
if(mAccumCtrl && state.mTime == mAnimationTimePtr[0]->getTimePtr())
|
|
|
|
|
updatePosition(state.getTime(), targetTime, movement);
|
|
|
|
|
state.setTime(std::min(targetTime, state.mStopTime));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(mAccumCtrl && state.mTime == mAnimationTimePtr[0]->getTimePtr())
|
|
|
|
|
updatePosition(state.getTime(), textkey->first, movement);
|
|
|
|
|
state.setTime(textkey->first);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(state.getTime() >= state.mLoopStopTime && state.mLoopCount > 0)
|
|
|
|
|
{
|
|
|
|
|
handle_loop:
|
|
|
|
|
state.mLoopCount--;
|
|
|
|
|
state.setTime(state.mLoopStartTime);
|
|
|
|
|
state.mPlaying = true;
|
|
|
|
|
state.mPlaying = (state.getTime() < state.mStopTime);
|
|
|
|
|
timepassed = targetTime - state.getTime();
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(state.getTime() >= state.mLoopStopTime)
|
|
|
|
|
{
|
|
|
|
|
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())
|
|
|
|
|
{
|
|
|
|
|
handleTextKey(state, stateiter->first, textkey, textkeys);
|
|
|
|
|
++textkey;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(state.getTime() >= state.mLoopStopTime)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(timepassed <= 0.0f)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -1095,6 +1099,21 @@ namespace MWRender
|
|
|
|
|
return movement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Animation::setLoopingEnabled(const std::string &groupname, bool enabled)
|
|
|
|
|
{
|
|
|
|
|
AnimStateMap::iterator state(mStates.find(groupname));
|
|
|
|
|
if(state != mStates.end())
|
|
|
|
|
state->second.mLoopingEnabled = enabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Animation::getLoopingEnabled(const std::string &groupname) const
|
|
|
|
|
{
|
|
|
|
|
AnimStateMap::const_iterator state(mStates.find(groupname));
|
|
|
|
|
if(state != mStates.end())
|
|
|
|
|
return state->second.mLoopingEnabled;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Animation::setObjectRoot(const std::string &model, bool forceskeleton, bool baseonly, bool isCreature)
|
|
|
|
|
{
|
|
|
|
|
osg::ref_ptr<osg::StateSet> previousStateset;
|
|
|
|
|