mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-13 21:09:39 +00:00
Store the available animation names in the character controller
This commit is contained in:
parent
afbc9f3e41
commit
852aa214cc
4 changed files with 17 additions and 14 deletions
|
@ -32,10 +32,13 @@ 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)
|
||||||
|
mAnimNames = mAnimation->getAnimationNames();
|
||||||
|
if(mAnimNames.size() == 0)
|
||||||
|
{
|
||||||
mAnimation = NULL;
|
mAnimation = NULL;
|
||||||
if(!mAnimation)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mAnimation->setController(this);
|
mAnimation->setController(this);
|
||||||
switch(mState)
|
switch(mState)
|
||||||
|
@ -52,9 +55,10 @@ 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), mAnimNames(rhs.mAnimNames)
|
||||||
|
, mState(rhs.mState)
|
||||||
{
|
{
|
||||||
if(!mAnimation)
|
if(mAnimNames.size() == 0)
|
||||||
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);
|
||||||
|
@ -82,7 +86,7 @@ Ogre::Vector3 CharacterController::update(float duration)
|
||||||
void CharacterController::playGroup(const std::string &groupname, int mode, int count)
|
void CharacterController::playGroup(const std::string &groupname, int mode, int count)
|
||||||
{
|
{
|
||||||
// set mState = CharState_Idle?
|
// set mState = CharState_Idle?
|
||||||
if(mAnimation)
|
if(std::find(mAnimNames.begin(), mAnimNames.end(), groupname) != mAnimNames.end())
|
||||||
mAnimation->playGroup(groupname, mode, count);
|
mAnimation->playGroup(groupname, mode, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +101,7 @@ void CharacterController::setState(CharacterState state)
|
||||||
{
|
{
|
||||||
mState = state;
|
mState = state;
|
||||||
|
|
||||||
if(!mAnimation)
|
if(mAnimNames.size() == 0)
|
||||||
return;
|
return;
|
||||||
switch(mState)
|
switch(mState)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,8 @@ class CharacterController
|
||||||
MWWorld::Ptr mPtr;
|
MWWorld::Ptr mPtr;
|
||||||
MWRender::Animation *mAnimation;
|
MWRender::Animation *mAnimation;
|
||||||
|
|
||||||
|
std::vector<std::string> mAnimNames;
|
||||||
|
|
||||||
std::string mCurrentGroup;
|
std::string mCurrentGroup;
|
||||||
CharacterState mState;
|
CharacterState mState;
|
||||||
|
|
||||||
|
|
|
@ -98,20 +98,17 @@ void Animation::createEntityList(Ogre::SceneNode *node, const std::string &model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Animation::getAnimationCount()
|
std::vector<std::string> Animation::getAnimationNames()
|
||||||
{
|
{
|
||||||
int num = 0;
|
std::vector<std::string> anims;
|
||||||
if(mEntityList.mSkelBase)
|
if(mEntityList.mSkelBase)
|
||||||
{
|
{
|
||||||
Ogre::AnimationStateSet *as = mEntityList.mSkelBase->getAllAnimationStates();
|
Ogre::AnimationStateSet *as = mEntityList.mSkelBase->getAllAnimationStates();
|
||||||
Ogre::AnimationStateIterator ai = as->getAnimationStateIterator();
|
Ogre::AnimationStateIterator ai = as->getAnimationStateIterator();
|
||||||
while(ai.hasMoreElements())
|
while(ai.hasMoreElements())
|
||||||
{
|
anims.push_back(ai.getNext()->getAnimationName());
|
||||||
num++;
|
|
||||||
ai.moveNext();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return num;
|
return anims;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
virtual ~Animation();
|
virtual ~Animation();
|
||||||
|
|
||||||
void setController(MWMechanics::CharacterController *controller);
|
void setController(MWMechanics::CharacterController *controller);
|
||||||
int getAnimationCount();
|
std::vector<std::string> getAnimationNames();
|
||||||
|
|
||||||
void playGroup(std::string groupname, int mode, int loops);
|
void playGroup(std::string groupname, int mode, int loops);
|
||||||
void skipAnim();
|
void skipAnim();
|
||||||
|
|
Loading…
Reference in a new issue