mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 06:53:52 +00:00
Combine animation handling into the base class
This commit is contained in:
parent
fcaa8aae06
commit
81ce8dbe12
4 changed files with 33 additions and 48 deletions
|
@ -42,4 +42,33 @@ void Animation::skipAnim()
|
|||
mAnimate = 0;
|
||||
}
|
||||
|
||||
void Animation::runAnimation(float timepassed)
|
||||
{
|
||||
if(mAnimate != 0)
|
||||
{
|
||||
mTime += timepassed;
|
||||
|
||||
if(mEntityList.mSkelBase)
|
||||
{
|
||||
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
|
||||
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
|
||||
while(as.hasMoreElements())
|
||||
{
|
||||
Ogre::AnimationState *state = as.getNext();
|
||||
state->setTimePosition(mTime);
|
||||
if(mTime >= state->getLength())
|
||||
{
|
||||
if(mAnimate != -1)
|
||||
mAnimate--;
|
||||
//std::cout << "Stopping the animation\n";
|
||||
if(mAnimate == 0)
|
||||
mTime = state->getLength();
|
||||
else
|
||||
mTime = mTime - state->getLength();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
|
||||
void playGroup(std::string groupname, int mode, int loops);
|
||||
void skipAnim();
|
||||
virtual void runAnimation(float timepassed) = 0;
|
||||
virtual void runAnimation(float timepassed);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -69,30 +69,9 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::O
|
|||
|
||||
void CreatureAnimation::runAnimation(float timepassed)
|
||||
{
|
||||
if(mAnimate > 0)
|
||||
{
|
||||
mTime += timepassed;
|
||||
// Placeholder
|
||||
|
||||
if(mEntityList.mSkelBase)
|
||||
{
|
||||
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
|
||||
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
|
||||
while(as.hasMoreElements())
|
||||
{
|
||||
Ogre::AnimationState *state = as.getNext();
|
||||
state->setTimePosition(mTime);
|
||||
if(state->getTimePosition() >= state->getLength())
|
||||
{
|
||||
mAnimate--;
|
||||
//std::cout << "Stopping the animation\n";
|
||||
if(mAnimate == 0)
|
||||
mTime = state->getLength();
|
||||
else
|
||||
mTime = mTime - state->getLength();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Animation::runAnimation(timepassed);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -373,30 +373,7 @@ void NpcAnimation::runAnimation(float timepassed)
|
|||
}
|
||||
timeToChange += timepassed;
|
||||
|
||||
if(mAnimate > 0)
|
||||
{
|
||||
mTime += timepassed;
|
||||
|
||||
if(mEntityList.mSkelBase)
|
||||
{
|
||||
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
|
||||
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
|
||||
while(as.hasMoreElements())
|
||||
{
|
||||
Ogre::AnimationState *state = as.getNext();
|
||||
state->setTimePosition(mTime);
|
||||
if(state->getTimePosition() >= state->getLength())
|
||||
{
|
||||
mAnimate--;
|
||||
//std::cout << "Stopping the animation\n";
|
||||
if(mAnimate == 0)
|
||||
mTime = state->getLength();
|
||||
else
|
||||
mTime = mTime - state->getLength();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Animation::runAnimation(timepassed);
|
||||
}
|
||||
|
||||
void NpcAnimation::removeEntities(NifOgre::EntityList &entities)
|
||||
|
|
Loading…
Reference in a new issue