forked from mirror/openmw-tes3mp
Return the movement vector from runAnimation
This commit is contained in:
parent
9235fba770
commit
9123f4f2af
8 changed files with 16 additions and 31 deletions
|
@ -54,11 +54,4 @@ ActivatorAnimation::ActivatorAnimation(const MWWorld::Ptr &ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivatorAnimation::runAnimation(float timepassed)
|
|
||||||
{
|
|
||||||
// Placeholder
|
|
||||||
|
|
||||||
Animation::runAnimation(timepassed);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,6 @@ namespace MWRender
|
||||||
public:
|
public:
|
||||||
ActivatorAnimation(const MWWorld::Ptr& ptr);
|
ActivatorAnimation(const MWWorld::Ptr& ptr);
|
||||||
virtual ~ActivatorAnimation();
|
virtual ~ActivatorAnimation();
|
||||||
|
|
||||||
virtual void runAnimation(float timepassed);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,16 +125,17 @@ void Animation::setAccumulation(const Ogre::Vector3 &accum)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Animation::updatePosition(float time)
|
Ogre::Vector3 Animation::updatePosition(float time)
|
||||||
{
|
{
|
||||||
mAnimState->setTimePosition(time);
|
mAnimState->setTimePosition(time);
|
||||||
|
|
||||||
|
Ogre::Vector3 posdiff = Ogre::Vector3::ZERO;
|
||||||
if(mNonAccumRoot)
|
if(mNonAccumRoot)
|
||||||
{
|
{
|
||||||
/* Update the animation and get the non-accumulation root's difference from the
|
/* Update the animation and get the non-accumulation root's difference from the
|
||||||
* last update. */
|
* last update. */
|
||||||
mEntityList.mSkelBase->getSkeleton()->setAnimationState(*mAnimState->getParent());
|
mEntityList.mSkelBase->getSkeleton()->setAnimationState(*mAnimState->getParent());
|
||||||
Ogre::Vector3 posdiff = (mNonAccumRoot->getPosition() - mLastPosition) * mAccumulate;
|
posdiff = (mNonAccumRoot->getPosition() - mLastPosition) * mAccumulate;
|
||||||
|
|
||||||
/* Translate the accumulation root back to compensate for the move. */
|
/* Translate the accumulation root back to compensate for the move. */
|
||||||
mAccumRoot->translate(-posdiff);
|
mAccumRoot->translate(-posdiff);
|
||||||
|
@ -150,6 +151,7 @@ void Animation::updatePosition(float time)
|
||||||
world->moveObject(mPtr, newpos.x, newpos.y, newpos.z);
|
world->moveObject(mPtr, newpos.x, newpos.y, newpos.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return posdiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::resetPosition(float time)
|
void Animation::resetPosition(float time)
|
||||||
|
@ -212,14 +214,15 @@ void Animation::play(const std::string &groupname, const std::string &start)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::runAnimation(float timepassed)
|
Ogre::Vector3 Animation::runAnimation(float timepassed)
|
||||||
{
|
{
|
||||||
|
Ogre::Vector3 movement = Ogre::Vector3::ZERO;
|
||||||
while(mAnimState && timepassed > 0.0f)
|
while(mAnimState && timepassed > 0.0f)
|
||||||
{
|
{
|
||||||
float targetTime = mAnimState->getTimePosition() + timepassed;
|
float targetTime = mAnimState->getTimePosition() + timepassed;
|
||||||
if(mNextKey == mCurrentKeys->end() || mNextKey->first > targetTime)
|
if(mNextKey == mCurrentKeys->end() || mNextKey->first > targetTime)
|
||||||
{
|
{
|
||||||
updatePosition(targetTime);
|
movement += updatePosition(targetTime);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,12 +230,13 @@ void Animation::runAnimation(float timepassed)
|
||||||
const std::string &evt = mNextKey->second;
|
const std::string &evt = mNextKey->second;
|
||||||
mNextKey++;
|
mNextKey++;
|
||||||
|
|
||||||
updatePosition(time);
|
movement += updatePosition(time);
|
||||||
timepassed = targetTime - time;
|
timepassed = targetTime - time;
|
||||||
|
|
||||||
if(mController)
|
if(mController)
|
||||||
mController->markerEvent(time, evt);
|
mController->markerEvent(time, evt);
|
||||||
}
|
}
|
||||||
|
return movement;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ protected:
|
||||||
|
|
||||||
/* Updates the animation to the specified time, and moves the mPtr object
|
/* Updates the animation to the specified time, and moves the mPtr object
|
||||||
* based on the change since the last update or reset. */
|
* based on the change since the last update or reset. */
|
||||||
void updatePosition(float time);
|
Ogre::Vector3 updatePosition(float time);
|
||||||
/* Updates the animation to the specified time, without moving the mPtr
|
/* Updates the animation to the specified time, without moving the mPtr
|
||||||
* object. */
|
* object. */
|
||||||
void resetPosition(float time);
|
void resetPosition(float time);
|
||||||
|
@ -56,7 +56,7 @@ public:
|
||||||
void setAccumulation(const Ogre::Vector3 &accum);
|
void setAccumulation(const Ogre::Vector3 &accum);
|
||||||
|
|
||||||
void play(const std::string &groupname, const std::string &start);
|
void play(const std::string &groupname, const std::string &start);
|
||||||
virtual void runAnimation(float timepassed);
|
virtual Ogre::Vector3 runAnimation(float timepassed);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,8 @@
|
||||||
|
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
using namespace Ogre;
|
namespace MWRender
|
||||||
using namespace NifOgre;
|
{
|
||||||
namespace MWRender{
|
|
||||||
|
|
||||||
CreatureAnimation::~CreatureAnimation()
|
CreatureAnimation::~CreatureAnimation()
|
||||||
{
|
{
|
||||||
|
@ -55,11 +54,4 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr &ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreatureAnimation::runAnimation(float timepassed)
|
|
||||||
{
|
|
||||||
// Placeholder
|
|
||||||
|
|
||||||
Animation::runAnimation(timepassed);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,6 @@ namespace MWRender
|
||||||
public:
|
public:
|
||||||
CreatureAnimation(const MWWorld::Ptr& ptr);
|
CreatureAnimation(const MWWorld::Ptr& ptr);
|
||||||
virtual ~CreatureAnimation();
|
virtual ~CreatureAnimation();
|
||||||
|
|
||||||
virtual void runAnimation(float timepassed);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -308,7 +308,7 @@ NifOgre::EntityList NpcAnimation::insertBoundedPart(const std::string &mesh, int
|
||||||
return entities;
|
return entities;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpcAnimation::runAnimation(float timepassed)
|
Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
|
||||||
{
|
{
|
||||||
if(mTimeToChange > .2)
|
if(mTimeToChange > .2)
|
||||||
{
|
{
|
||||||
|
@ -317,7 +317,7 @@ void NpcAnimation::runAnimation(float timepassed)
|
||||||
}
|
}
|
||||||
mTimeToChange += timepassed;
|
mTimeToChange += timepassed;
|
||||||
|
|
||||||
Animation::runAnimation(timepassed);
|
return Animation::runAnimation(timepassed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpcAnimation::removeEntities(NifOgre::EntityList &entities)
|
void NpcAnimation::removeEntities(NifOgre::EntityList &entities)
|
||||||
|
|
|
@ -98,7 +98,7 @@ public:
|
||||||
MWWorld::InventoryStore& inv, int visibilityFlags);
|
MWWorld::InventoryStore& inv, int visibilityFlags);
|
||||||
virtual ~NpcAnimation();
|
virtual ~NpcAnimation();
|
||||||
|
|
||||||
virtual void runAnimation(float timepassed);
|
virtual Ogre::Vector3 runAnimation(float timepassed);
|
||||||
|
|
||||||
void forceUpdate();
|
void forceUpdate();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue