mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-31 22:45:35 +00:00
Allow specifying which bone groups to play an animation on
This commit is contained in:
parent
56eede2610
commit
abc676eedd
4 changed files with 24 additions and 10 deletions
|
@ -171,7 +171,9 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
|
|||
|
||||
std::string group;
|
||||
getCurrentGroup(group);
|
||||
mMovingAnim = mAnimation->play(group, MWRender::Animation::Priority_Default, "start", "stop", 1.0f, loop ? (~(size_t)0) : 0);
|
||||
mMovingAnim = mAnimation->play(group, MWRender::Animation::Priority_Default,
|
||||
MWRender::Animation::Group_All,
|
||||
"start", "stop", 1.0f, loop ? (~(size_t)0) : 0);
|
||||
}
|
||||
|
||||
CharacterController::~CharacterController()
|
||||
|
@ -347,6 +349,7 @@ void CharacterController::update(float duration, Movement &movement)
|
|||
{
|
||||
mMovingAnim = mAnimation->play(mAnimQueue.front().first,
|
||||
MWRender::Animation::Priority_Default,
|
||||
MWRender::Animation::Group_All,
|
||||
"start", "stop", 0.0f,
|
||||
mAnimQueue.front().second);
|
||||
mAnimQueue.pop_front();
|
||||
|
@ -383,6 +386,7 @@ void CharacterController::playGroup(const std::string &groupname, int mode, int
|
|||
mCharState = CharState_SpecialIdle;
|
||||
mLooping = false;
|
||||
mMovingAnim = mAnimation->play(groupname, MWRender::Animation::Priority_Default,
|
||||
MWRender::Animation::Group_All,
|
||||
((mode==2) ? "loop start" : "start"), "stop", 0.0f, count-1);
|
||||
}
|
||||
else if(mode == 0)
|
||||
|
@ -427,6 +431,7 @@ void CharacterController::forceStateUpdate()
|
|||
std::string group;
|
||||
getCurrentGroup(group);
|
||||
mMovingAnim = mAnimation->play(group, MWRender::Animation::Priority_Default,
|
||||
MWRender::Animation::Group_All,
|
||||
"start", "stop", 0.0f, mLooping ? (~(size_t)0) : 0);
|
||||
|
||||
mAnimation->showWeapons(mWeapState != WeapState_None && mWeapState != WeapState_HandToHand &&
|
||||
|
|
|
@ -474,7 +474,7 @@ bool Animation::handleTextKey(AnimState &state, const std::string &groupname, co
|
|||
}
|
||||
|
||||
|
||||
bool Animation::play(const std::string &groupname, Priority priority, const std::string &start, const std::string &stop, float startpoint, size_t loops)
|
||||
bool Animation::play(const std::string &groupname, Priority priority, int groups, const std::string &start, const std::string &stop, float startpoint, size_t loops)
|
||||
{
|
||||
if(!mSkelBase)
|
||||
return false;
|
||||
|
@ -502,6 +502,7 @@ bool Animation::play(const std::string &groupname, Priority priority, const std:
|
|||
state.mLoopCount = loops;
|
||||
state.mPlaying = true;
|
||||
state.mPriority = priority;
|
||||
state.mGroups = groups;
|
||||
mStates[groupname] = state;
|
||||
|
||||
break;
|
||||
|
@ -522,10 +523,9 @@ bool Animation::resetActiveGroups()
|
|||
AnimStateMap::const_iterator state = mStates.begin();
|
||||
for(;state != mStates.end();state++)
|
||||
{
|
||||
#if 0
|
||||
if(!(state->second.mGroups&(1<<grp)))
|
||||
continue;
|
||||
#endif
|
||||
|
||||
if(active == mStates.end() || active->second.mPriority < state->second.mPriority)
|
||||
active = state;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,11 @@ public:
|
|||
Num_Priorities
|
||||
};
|
||||
|
||||
enum Group {
|
||||
Group_Default = 1<<0,
|
||||
Group_All = Group_Default
|
||||
};
|
||||
|
||||
protected:
|
||||
static const size_t sNumGroups = 1;
|
||||
|
||||
|
@ -64,6 +69,7 @@ protected:
|
|||
size_t mLoopCount;
|
||||
|
||||
int mPriority;
|
||||
int mGroups;
|
||||
|
||||
AnimState() : mSource(NULL), mTime(0.0f), mPlaying(false), mLoopCount(0)
|
||||
{ }
|
||||
|
@ -152,6 +158,7 @@ public:
|
|||
* \param priority Priority of the animation. The animation will play on
|
||||
* bone groups that don't have another animation set of a
|
||||
* higher priority.
|
||||
* \param groups Bone groups to play the animation on.
|
||||
* \param start Key marker from which to start.
|
||||
* \param stop Key marker to stop at.
|
||||
* \param startpoint How far in between the two markers to start. 0 starts
|
||||
|
@ -162,9 +169,9 @@ public:
|
|||
* \return Boolean specifying whether the animation will return movement
|
||||
* for the character at all.
|
||||
*/
|
||||
bool play(const std::string &groupname, Priority priority, const std::string &start, const std::string &stop, float startpoint, size_t loops);
|
||||
|
||||
void disable(const std::string &groupname);
|
||||
bool play(const std::string &groupname, Priority priority, int groups,
|
||||
const std::string &start, const std::string &stop,
|
||||
float startpoint, size_t loops);
|
||||
|
||||
/** Gets info about the given animation group.
|
||||
* \param groupname Animation group to check.
|
||||
|
|
|
@ -172,7 +172,8 @@ namespace MWRender
|
|||
if(groupname != mCurrentAnimGroup)
|
||||
{
|
||||
mCurrentAnimGroup = groupname;
|
||||
mAnimation->play(mCurrentAnimGroup, Animation::Priority_Default, "start", "stop", 0.0f, 0);
|
||||
mAnimation->play(mCurrentAnimGroup, Animation::Priority_Default,
|
||||
Animation::Group_All, "start", "stop", 0.0f, 0);
|
||||
}
|
||||
|
||||
mAnimation->forceUpdate();
|
||||
|
@ -199,7 +200,8 @@ namespace MWRender
|
|||
mAnimation->showWeapons(true);
|
||||
|
||||
mCurrentAnimGroup = "inventoryhandtohand";
|
||||
mAnimation->play(mCurrentAnimGroup, Animation::Priority_Default, "start", "stop", 0.0f, 0);
|
||||
mAnimation->play(mCurrentAnimGroup, Animation::Priority_Default,
|
||||
Animation::Group_All, "start", "stop", 0.0f, 0);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------
|
||||
|
@ -233,7 +235,7 @@ namespace MWRender
|
|||
|
||||
void RaceSelectionPreview::onSetup ()
|
||||
{
|
||||
mAnimation->play("idle", Animation::Priority_Default, "start", "stop", 0.0f, 0);
|
||||
mAnimation->play("idle", Animation::Priority_Default, Animation::Group_All, "start", "stop", 0.0f, 0);
|
||||
|
||||
updateCamera();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue