forked from teamnwah/openmw-tes3coop
Avoid trying to animate things that don't have animations
This commit is contained in:
parent
94b93227d3
commit
3c32385e17
3 changed files with 24 additions and 2 deletions
|
@ -29,7 +29,7 @@ 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)
|
if(!mAnimation || mAnimation->getAnimationCount() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mAnimation->setController(this);
|
mAnimation->setController(this);
|
||||||
|
@ -47,7 +47,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)
|
if(!mAnimation || mAnimation->getAnimationCount() == 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);
|
||||||
|
@ -68,6 +68,9 @@ void CharacterController::markerEvent(const std::string &evt)
|
||||||
void CharacterController::setState(CharacterState state)
|
void CharacterController::setState(CharacterState state)
|
||||||
{
|
{
|
||||||
mState = state;
|
mState = state;
|
||||||
|
|
||||||
|
if(!mAnimation || mAnimation->getAnimationCount() == 0)
|
||||||
|
return;
|
||||||
switch(mState)
|
switch(mState)
|
||||||
{
|
{
|
||||||
case CharState_Idle:
|
case CharState_Idle:
|
||||||
|
|
|
@ -98,6 +98,23 @@ void Animation::createEntityList(Ogre::SceneNode *node, const std::string &model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Animation::getAnimationCount()
|
||||||
|
{
|
||||||
|
int num = 0;
|
||||||
|
if(mEntityList.mSkelBase)
|
||||||
|
{
|
||||||
|
Ogre::AnimationStateSet *as = mEntityList.mSkelBase->getAllAnimationStates();
|
||||||
|
Ogre::AnimationStateIterator ai = as->getAnimationStateIterator();
|
||||||
|
while(ai.hasMoreElements())
|
||||||
|
{
|
||||||
|
num++;
|
||||||
|
ai.moveNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Animation::setController(MWMechanics::CharacterController *controller)
|
void Animation::setController(MWMechanics::CharacterController *controller)
|
||||||
{
|
{
|
||||||
mController = controller;
|
mController = controller;
|
||||||
|
|
|
@ -66,6 +66,8 @@ public:
|
||||||
virtual ~Animation();
|
virtual ~Animation();
|
||||||
|
|
||||||
void setController(MWMechanics::CharacterController *controller);
|
void setController(MWMechanics::CharacterController *controller);
|
||||||
|
int getAnimationCount();
|
||||||
|
|
||||||
void playGroup(std::string groupname, int mode, int loops);
|
void playGroup(std::string groupname, int mode, int loops);
|
||||||
void skipAnim();
|
void skipAnim();
|
||||||
virtual void runAnimation(float timepassed);
|
virtual void runAnimation(float timepassed);
|
||||||
|
|
Loading…
Reference in a new issue