forked from teamnwah/openmw-tes3coop
Run animations from the character controller
This commit is contained in:
parent
46728ab27f
commit
46fc61a4c1
5 changed files with 16 additions and 8 deletions
|
@ -263,6 +263,7 @@ namespace MWMechanics
|
||||||
std::vector<std::pair<std::string, Ogre::Vector3> > movement;
|
std::vector<std::pair<std::string, Ogre::Vector3> > movement;
|
||||||
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
||||||
{
|
{
|
||||||
|
iter->second.update(duration);
|
||||||
Ogre::Vector3 vector = MWWorld::Class::get(iter->first).getMovementVector(iter->first);
|
Ogre::Vector3 vector = MWWorld::Class::get(iter->first).getMovementVector(iter->first);
|
||||||
if(vector!=Ogre::Vector3::ZERO)
|
if(vector!=Ogre::Vector3::ZERO)
|
||||||
movement.push_back(std::make_pair(iter->first.getRefData().getHandle(), vector));
|
movement.push_back(std::make_pair(iter->first.getRefData().getHandle(), vector));
|
||||||
|
|
|
@ -32,7 +32,9 @@ namespace MWMechanics
|
||||||
CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state)
|
CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state)
|
||||||
: mPtr(ptr), mAnimation(anim), mState(state)
|
: mPtr(ptr), mAnimation(anim), mState(state)
|
||||||
{
|
{
|
||||||
if(!mAnimation || mAnimation->getAnimationCount() == 0)
|
if(mAnimation && mAnimation->getAnimationCount() == 0)
|
||||||
|
mAnimation = NULL;
|
||||||
|
if(!mAnimation)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mAnimation->setController(this);
|
mAnimation->setController(this);
|
||||||
|
@ -50,7 +52,7 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
|
||||||
CharacterController::CharacterController(const CharacterController &rhs)
|
CharacterController::CharacterController(const CharacterController &rhs)
|
||||||
: mPtr(rhs.mPtr), mAnimation(rhs.mAnimation), mState(rhs.mState)
|
: mPtr(rhs.mPtr), mAnimation(rhs.mAnimation), mState(rhs.mState)
|
||||||
{
|
{
|
||||||
if(!mAnimation || mAnimation->getAnimationCount() == 0)
|
if(!mAnimation)
|
||||||
return;
|
return;
|
||||||
/* We've been copied. Update the animation with the new controller. */
|
/* We've been copied. Update the animation with the new controller. */
|
||||||
mAnimation->setController(this);
|
mAnimation->setController(this);
|
||||||
|
@ -67,11 +69,18 @@ void CharacterController::markerEvent(const std::string &evt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CharacterController::update(float duration)
|
||||||
|
{
|
||||||
|
if(mAnimation)
|
||||||
|
mAnimation->runAnimation(duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CharacterController::setState(CharacterState state)
|
void CharacterController::setState(CharacterState state)
|
||||||
{
|
{
|
||||||
mState = state;
|
mState = state;
|
||||||
|
|
||||||
if(!mAnimation || mAnimation->getAnimationCount() == 0)
|
if(!mAnimation)
|
||||||
return;
|
return;
|
||||||
switch(mState)
|
switch(mState)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,8 @@ public:
|
||||||
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state);
|
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state);
|
||||||
CharacterController(const CharacterController &rhs);
|
CharacterController(const CharacterController &rhs);
|
||||||
|
|
||||||
|
void update(float duration);
|
||||||
|
|
||||||
void setState(CharacterState state);
|
void setState(CharacterState state);
|
||||||
CharacterState getState() const
|
CharacterState getState() const
|
||||||
{ return mState; }
|
{ return mState; }
|
||||||
|
|
|
@ -149,8 +149,7 @@ void Actors::skipAnimation (const MWWorld::Ptr& ptr)
|
||||||
}
|
}
|
||||||
void Actors::update (float duration)
|
void Actors::update (float duration)
|
||||||
{
|
{
|
||||||
for(PtrAnimationMap::const_iterator iter = mAllActors.begin();iter != mAllActors.end();iter++)
|
// Nothing to do
|
||||||
iter->second->runAnimation(duration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation* Actors::getAnimation(const MWWorld::Ptr &ptr)
|
Animation* Actors::getAnimation(const MWWorld::Ptr &ptr)
|
||||||
|
|
|
@ -129,9 +129,6 @@ namespace MWRender
|
||||||
MWBase::Environment::get().getWindowManager ()->showCrosshair
|
MWBase::Environment::get().getWindowManager ()->showCrosshair
|
||||||
(!MWBase::Environment::get().getWindowManager ()->isGuiMode () && (mFirstPersonView && !mVanity.enabled && !mPreviewMode));
|
(!MWBase::Environment::get().getWindowManager ()->isGuiMode () && (mFirstPersonView && !mVanity.enabled && !mPreviewMode));
|
||||||
|
|
||||||
if (mAnimation) {
|
|
||||||
mAnimation->runAnimation(duration);
|
|
||||||
}
|
|
||||||
mPlayerNode->setVisible(
|
mPlayerNode->setVisible(
|
||||||
mVanity.enabled || mPreviewMode || !mFirstPersonView,
|
mVanity.enabled || mPreviewMode || !mFirstPersonView,
|
||||||
false
|
false
|
||||||
|
|
Loading…
Reference in a new issue