mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-02 04:15:34 +00:00
Keep track of the current text key in the animation
This commit is contained in:
parent
f46587c383
commit
0a2f92f679
2 changed files with 30 additions and 4 deletions
|
@ -130,6 +130,11 @@ void Animation::updatePosition(float time)
|
||||||
void Animation::resetPosition(float time)
|
void Animation::resetPosition(float time)
|
||||||
{
|
{
|
||||||
mCurGroup.mAnimState->setTimePosition(time);
|
mCurGroup.mAnimState->setTimePosition(time);
|
||||||
|
|
||||||
|
mCurGroup.mNext = mCurGroup.mStart;
|
||||||
|
while(mCurGroup.mNext->first < time)
|
||||||
|
mCurGroup.mNext++;
|
||||||
|
|
||||||
if(mNonAccumRoot)
|
if(mNonAccumRoot)
|
||||||
{
|
{
|
||||||
mEntityList.mSkelBase->getSkeleton()->setAnimationState(*mCurGroup.mAnimState->getParent());
|
mEntityList.mSkelBase->getSkeleton()->setAnimationState(*mCurGroup.mAnimState->getParent());
|
||||||
|
@ -141,7 +146,8 @@ void Animation::resetPosition(float time)
|
||||||
|
|
||||||
bool Animation::findGroupTimes(const std::string &groupname, Animation::GroupTimes *times)
|
bool Animation::findGroupTimes(const std::string &groupname, Animation::GroupTimes *times)
|
||||||
{
|
{
|
||||||
const NifOgre::TextKeyMap &textkeys = mTextKeys[groupname];
|
times->mTextKeys = &mTextKeys[groupname];
|
||||||
|
const NifOgre::TextKeyMap &textkeys = *times->mTextKeys;
|
||||||
if(textkeys.size() == 0)
|
if(textkeys.size() == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -202,6 +208,7 @@ void Animation::playGroup(std::string groupname, int mode, int loops)
|
||||||
std::cerr<< e.what() <<std::endl;
|
std::cerr<< e.what() <<std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
times.mNext = ((mode==2) ? times.mLoopStart : times.mStart);
|
||||||
|
|
||||||
if(mode == 0 && mCurGroup.mLoops > 0)
|
if(mode == 0 && mCurGroup.mLoops > 0)
|
||||||
mNextGroup = times;
|
mNextGroup = times;
|
||||||
|
@ -211,7 +218,7 @@ void Animation::playGroup(std::string groupname, int mode, int loops)
|
||||||
mCurGroup.mAnimState->setEnabled(false);
|
mCurGroup.mAnimState->setEnabled(false);
|
||||||
mCurGroup = times;
|
mCurGroup = times;
|
||||||
mNextGroup = GroupTimes();
|
mNextGroup = GroupTimes();
|
||||||
mTime = ((mode==2) ? mCurGroup.mLoopStart : mCurGroup.mStart)->first;
|
mTime = mCurGroup.mNext->first;
|
||||||
mCurGroup.mAnimState->setEnabled(true);
|
mCurGroup.mAnimState->setEnabled(true);
|
||||||
resetPosition(mTime);
|
resetPosition(mTime);
|
||||||
}
|
}
|
||||||
|
@ -230,6 +237,12 @@ void Animation::runAnimation(float timepassed)
|
||||||
recheck:
|
recheck:
|
||||||
if(mTime >= mCurGroup.mLoopStop->first)
|
if(mTime >= mCurGroup.mLoopStop->first)
|
||||||
{
|
{
|
||||||
|
while(mCurGroup.mNext != mCurGroup.mTextKeys->end() &&
|
||||||
|
mCurGroup.mNext->first <= mCurGroup.mLoopStop->first)
|
||||||
|
{
|
||||||
|
mCurGroup.mNext++;
|
||||||
|
}
|
||||||
|
|
||||||
if(mCurGroup.mLoops > 1)
|
if(mCurGroup.mLoops > 1)
|
||||||
{
|
{
|
||||||
mCurGroup.mLoops--;
|
mCurGroup.mLoops--;
|
||||||
|
@ -240,6 +253,11 @@ void Animation::runAnimation(float timepassed)
|
||||||
}
|
}
|
||||||
else if(mTime >= mCurGroup.mStop->first)
|
else if(mTime >= mCurGroup.mStop->first)
|
||||||
{
|
{
|
||||||
|
while(mCurGroup.mNext != mCurGroup.mTextKeys->end() &&
|
||||||
|
mCurGroup.mNext->first <= mCurGroup.mStop->first)
|
||||||
|
{
|
||||||
|
mCurGroup.mNext++;
|
||||||
|
}
|
||||||
if(mNextGroup.mLoops > 0)
|
if(mNextGroup.mLoops > 0)
|
||||||
{
|
{
|
||||||
updatePosition(mCurGroup.mStop->first);
|
updatePosition(mCurGroup.mStop->first);
|
||||||
|
@ -254,6 +272,11 @@ void Animation::runAnimation(float timepassed)
|
||||||
mTime = mCurGroup.mStop->first;
|
mTime = mCurGroup.mStop->first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
while(mCurGroup.mNext != mCurGroup.mTextKeys->end() &&
|
||||||
|
mCurGroup.mNext->first <= mTime)
|
||||||
|
{
|
||||||
|
mCurGroup.mNext++;
|
||||||
|
}
|
||||||
|
|
||||||
updatePosition(mTime);
|
updatePosition(mTime);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,16 +16,19 @@ namespace MWRender
|
||||||
class Animation
|
class Animation
|
||||||
{
|
{
|
||||||
struct GroupTimes {
|
struct GroupTimes {
|
||||||
|
NifOgre::TextKeyMap *mTextKeys;
|
||||||
|
|
||||||
NifOgre::TextKeyMap::const_iterator mStart;
|
NifOgre::TextKeyMap::const_iterator mStart;
|
||||||
NifOgre::TextKeyMap::const_iterator mStop;
|
NifOgre::TextKeyMap::const_iterator mStop;
|
||||||
NifOgre::TextKeyMap::const_iterator mLoopStart;
|
NifOgre::TextKeyMap::const_iterator mLoopStart;
|
||||||
NifOgre::TextKeyMap::const_iterator mLoopStop;
|
NifOgre::TextKeyMap::const_iterator mLoopStop;
|
||||||
|
|
||||||
|
NifOgre::TextKeyMap::const_iterator mNext;
|
||||||
|
|
||||||
Ogre::AnimationState *mAnimState;
|
Ogre::AnimationState *mAnimState;
|
||||||
size_t mLoops;
|
size_t mLoops;
|
||||||
|
|
||||||
GroupTimes()
|
GroupTimes() : mTextKeys(NULL), mAnimState(NULL), mLoops(0)
|
||||||
: mAnimState(NULL), mLoops(0)
|
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue