1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

add a priority for death animations, and store it in the state list

This commit is contained in:
Chris Robinson 2013-05-12 19:19:21 -07:00
parent 4e389b5a8f
commit 7ba2508556
3 changed files with 52 additions and 47 deletions

View File

@ -40,55 +40,56 @@ namespace MWMechanics
static const struct { static const struct {
CharacterState state; CharacterState state;
const char groupname[32]; const char groupname[32];
MWRender::Animation::Priority priority;
bool loops; bool loops;
} sStateList[] = { } sStateList[] = {
{ CharState_Idle, "idle", true }, { CharState_Idle, "idle", MWRender::Animation::Priority_Default, true },
{ CharState_Idle2, "idle2", true }, { CharState_Idle2, "idle2", MWRender::Animation::Priority_Default, true },
{ CharState_Idle3, "idle3", true }, { CharState_Idle3, "idle3", MWRender::Animation::Priority_Default, true },
{ CharState_Idle4, "idle4", true }, { CharState_Idle4, "idle4", MWRender::Animation::Priority_Default, true },
{ CharState_Idle5, "idle5", true }, { CharState_Idle5, "idle5", MWRender::Animation::Priority_Default, true },
{ CharState_Idle6, "idle6", true }, { CharState_Idle6, "idle6", MWRender::Animation::Priority_Default, true },
{ CharState_Idle7, "idle7", true }, { CharState_Idle7, "idle7", MWRender::Animation::Priority_Default, true },
{ CharState_Idle8, "idle8", true }, { CharState_Idle8, "idle8", MWRender::Animation::Priority_Default, true },
{ CharState_Idle9, "idle9", true }, { CharState_Idle9, "idle9", MWRender::Animation::Priority_Default, true },
{ CharState_IdleSwim, "idleswim", true }, { CharState_IdleSwim, "idleswim", MWRender::Animation::Priority_Default, true },
{ CharState_IdleSneak, "idlesneak", true }, { CharState_IdleSneak, "idlesneak", MWRender::Animation::Priority_Default, true },
{ CharState_WalkForward, "walkforward", true }, { CharState_WalkForward, "walkforward", MWRender::Animation::Priority_Default, true },
{ CharState_WalkBack, "walkback", true }, { CharState_WalkBack, "walkback", MWRender::Animation::Priority_Default, true },
{ CharState_WalkLeft, "walkleft", true }, { CharState_WalkLeft, "walkleft", MWRender::Animation::Priority_Default, true },
{ CharState_WalkRight, "walkright", true }, { CharState_WalkRight, "walkright", MWRender::Animation::Priority_Default, true },
{ CharState_SwimWalkForward, "swimwalkforward", true }, { CharState_SwimWalkForward, "swimwalkforward", MWRender::Animation::Priority_Default, true },
{ CharState_SwimWalkBack, "swimwalkback", true }, { CharState_SwimWalkBack, "swimwalkback", MWRender::Animation::Priority_Default, true },
{ CharState_SwimWalkLeft, "swimwalkleft", true }, { CharState_SwimWalkLeft, "swimwalkleft", MWRender::Animation::Priority_Default, true },
{ CharState_SwimWalkRight, "swimwalkright", true }, { CharState_SwimWalkRight, "swimwalkright", MWRender::Animation::Priority_Default, true },
{ CharState_RunForward, "runforward", true }, { CharState_RunForward, "runforward", MWRender::Animation::Priority_Default, true },
{ CharState_RunBack, "runback", true }, { CharState_RunBack, "runback", MWRender::Animation::Priority_Default, true },
{ CharState_RunLeft, "runleft", true }, { CharState_RunLeft, "runleft", MWRender::Animation::Priority_Default, true },
{ CharState_RunRight, "runright", true }, { CharState_RunRight, "runright", MWRender::Animation::Priority_Default, true },
{ CharState_SwimRunForward, "swimrunforward", true }, { CharState_SwimRunForward, "swimrunforward", MWRender::Animation::Priority_Default, true },
{ CharState_SwimRunBack, "swimrunback", true }, { CharState_SwimRunBack, "swimrunback", MWRender::Animation::Priority_Default, true },
{ CharState_SwimRunLeft, "swimrunleft", true }, { CharState_SwimRunLeft, "swimrunleft", MWRender::Animation::Priority_Default, true },
{ CharState_SwimRunRight, "swimrunright", true }, { CharState_SwimRunRight, "swimrunright", MWRender::Animation::Priority_Default, true },
{ CharState_SneakForward, "sneakforward", true }, { CharState_SneakForward, "sneakforward", MWRender::Animation::Priority_Default, true },
{ CharState_SneakBack, "sneakback", true }, { CharState_SneakBack, "sneakback", MWRender::Animation::Priority_Default, true },
{ CharState_SneakLeft, "sneakleft", true }, { CharState_SneakLeft, "sneakleft", MWRender::Animation::Priority_Default, true },
{ CharState_SneakRight, "sneakright", true }, { CharState_SneakRight, "sneakright", MWRender::Animation::Priority_Default, true },
{ CharState_TurnLeft, "turnleft", true }, { CharState_TurnLeft, "turnleft", MWRender::Animation::Priority_Default, true },
{ CharState_TurnRight, "turnright", true }, { CharState_TurnRight, "turnright", MWRender::Animation::Priority_Default, true },
{ CharState_Jump, "jump", true }, { CharState_Jump, "jump", MWRender::Animation::Priority_Default, true },
{ CharState_Death1, "death1", false }, { CharState_Death1, "death1", MWRender::Animation::Priority_Death, false },
{ CharState_Death2, "death2", false }, { CharState_Death2, "death2", MWRender::Animation::Priority_Death, false },
{ CharState_Death3, "death3", false }, { CharState_Death3, "death3", MWRender::Animation::Priority_Death, false },
{ CharState_Death4, "death4", false }, { CharState_Death4, "death4", MWRender::Animation::Priority_Death, false },
{ CharState_Death5, "death5", false }, { CharState_Death5, "death5", MWRender::Animation::Priority_Death, false },
}; };
static const size_t sStateListSize = sizeof(sStateList)/sizeof(sStateList[0]); static const size_t sStateListSize = sizeof(sStateList)/sizeof(sStateList[0]);
@ -110,7 +111,7 @@ static const struct {
static const size_t sWeaponTypeListSize = sizeof(sWeaponTypeList)/sizeof(sWeaponTypeList[0]); static const size_t sWeaponTypeListSize = sizeof(sWeaponTypeList)/sizeof(sWeaponTypeList[0]);
void CharacterController::getCurrentGroup(std::string &group, bool &loops) const void CharacterController::getCurrentGroup(std::string &group, MWRender::Animation::Priority &priority, bool &loops) const
{ {
std::string name; std::string name;
for(size_t i = 0;i < sStateListSize;i++) for(size_t i = 0;i < sStateListSize;i++)
@ -118,6 +119,7 @@ void CharacterController::getCurrentGroup(std::string &group, bool &loops) const
if(sStateList[i].state == mCharState) if(sStateList[i].state == mCharState)
{ {
name = sStateList[i].groupname; name = sStateList[i].groupname;
priority = sStateList[i].priority;
loops = sStateList[i].loops; loops = sStateList[i].loops;
break; break;
} }
@ -170,10 +172,10 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
} }
std::string group; std::string group;
MWRender::Animation::Priority prio;
bool loops; bool loops;
getCurrentGroup(group, loops); getCurrentGroup(group, prio, loops);
mAnimation->play(group, MWRender::Animation::Priority_Default, mAnimation->play(group, prio, MWRender::Animation::Group_All, false,
MWRender::Animation::Group_All, false,
"start", "stop", 1.0f, loops ? (~(size_t)0) : 0); "start", "stop", 1.0f, loops ? (~(size_t)0) : 0);
} }
@ -431,10 +433,10 @@ void CharacterController::forceStateUpdate()
mAnimQueue.clear(); mAnimQueue.clear();
std::string group; std::string group;
MWRender::Animation::Priority prio;
bool loops; bool loops;
getCurrentGroup(group, loops); getCurrentGroup(group, prio, loops);
mAnimation->play(group, MWRender::Animation::Priority_Default, mAnimation->play(group, prio, MWRender::Animation::Group_All, false,
MWRender::Animation::Group_All, false,
"start", "stop", 0.0f, loops ? (~(size_t)0) : 0); "start", "stop", 0.0f, loops ? (~(size_t)0) : 0);
mAnimation->showWeapons(mWeaponType != WeapType_None && mWeaponType != WeapType_HandToHand && mAnimation->showWeapons(mWeaponType != WeapType_None && mWeaponType != WeapType_HandToHand &&

View File

@ -4,6 +4,7 @@
#include <OgreVector3.h> #include <OgreVector3.h>
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwrender/animation.hpp"
namespace MWRender namespace MWRender
{ {
@ -98,7 +99,7 @@ class CharacterController
float mSecondsOfRunning; float mSecondsOfRunning;
// Gets an animation group name from the current character state, and whether it should loop. // Gets an animation group name from the current character state, and whether it should loop.
void getCurrentGroup(std::string &group, bool &loops) const; void getCurrentGroup(std::string &group, MWRender::Animation::Priority &prio, bool &loops) const;
public: public:
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state); CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state);

View File

@ -19,6 +19,8 @@ public:
Priority_Nil = -1, /* Do not use */ Priority_Nil = -1, /* Do not use */
Priority_Default, Priority_Default,
Priority_Death,
Num_Priorities Num_Priorities
}; };