mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 10:39:39 +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;
|
std::string group;
|
||||||
getCurrentGroup(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()
|
CharacterController::~CharacterController()
|
||||||
|
@ -347,6 +349,7 @@ void CharacterController::update(float duration, Movement &movement)
|
||||||
{
|
{
|
||||||
mMovingAnim = mAnimation->play(mAnimQueue.front().first,
|
mMovingAnim = mAnimation->play(mAnimQueue.front().first,
|
||||||
MWRender::Animation::Priority_Default,
|
MWRender::Animation::Priority_Default,
|
||||||
|
MWRender::Animation::Group_All,
|
||||||
"start", "stop", 0.0f,
|
"start", "stop", 0.0f,
|
||||||
mAnimQueue.front().second);
|
mAnimQueue.front().second);
|
||||||
mAnimQueue.pop_front();
|
mAnimQueue.pop_front();
|
||||||
|
@ -383,6 +386,7 @@ void CharacterController::playGroup(const std::string &groupname, int mode, int
|
||||||
mCharState = CharState_SpecialIdle;
|
mCharState = CharState_SpecialIdle;
|
||||||
mLooping = false;
|
mLooping = false;
|
||||||
mMovingAnim = mAnimation->play(groupname, MWRender::Animation::Priority_Default,
|
mMovingAnim = mAnimation->play(groupname, MWRender::Animation::Priority_Default,
|
||||||
|
MWRender::Animation::Group_All,
|
||||||
((mode==2) ? "loop start" : "start"), "stop", 0.0f, count-1);
|
((mode==2) ? "loop start" : "start"), "stop", 0.0f, count-1);
|
||||||
}
|
}
|
||||||
else if(mode == 0)
|
else if(mode == 0)
|
||||||
|
@ -427,6 +431,7 @@ void CharacterController::forceStateUpdate()
|
||||||
std::string group;
|
std::string group;
|
||||||
getCurrentGroup(group);
|
getCurrentGroup(group);
|
||||||
mMovingAnim = mAnimation->play(group, MWRender::Animation::Priority_Default,
|
mMovingAnim = mAnimation->play(group, MWRender::Animation::Priority_Default,
|
||||||
|
MWRender::Animation::Group_All,
|
||||||
"start", "stop", 0.0f, mLooping ? (~(size_t)0) : 0);
|
"start", "stop", 0.0f, mLooping ? (~(size_t)0) : 0);
|
||||||
|
|
||||||
mAnimation->showWeapons(mWeapState != WeapState_None && mWeapState != WeapState_HandToHand &&
|
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)
|
if(!mSkelBase)
|
||||||
return false;
|
return false;
|
||||||
|
@ -502,6 +502,7 @@ bool Animation::play(const std::string &groupname, Priority priority, const std:
|
||||||
state.mLoopCount = loops;
|
state.mLoopCount = loops;
|
||||||
state.mPlaying = true;
|
state.mPlaying = true;
|
||||||
state.mPriority = priority;
|
state.mPriority = priority;
|
||||||
|
state.mGroups = groups;
|
||||||
mStates[groupname] = state;
|
mStates[groupname] = state;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -522,10 +523,9 @@ bool Animation::resetActiveGroups()
|
||||||
AnimStateMap::const_iterator state = mStates.begin();
|
AnimStateMap::const_iterator state = mStates.begin();
|
||||||
for(;state != mStates.end();state++)
|
for(;state != mStates.end();state++)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
if(!(state->second.mGroups&(1<<grp)))
|
if(!(state->second.mGroups&(1<<grp)))
|
||||||
continue;
|
continue;
|
||||||
#endif
|
|
||||||
if(active == mStates.end() || active->second.mPriority < state->second.mPriority)
|
if(active == mStates.end() || active->second.mPriority < state->second.mPriority)
|
||||||
active = state;
|
active = state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,11 @@ public:
|
||||||
Num_Priorities
|
Num_Priorities
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum Group {
|
||||||
|
Group_Default = 1<<0,
|
||||||
|
Group_All = Group_Default
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static const size_t sNumGroups = 1;
|
static const size_t sNumGroups = 1;
|
||||||
|
|
||||||
|
@ -64,6 +69,7 @@ protected:
|
||||||
size_t mLoopCount;
|
size_t mLoopCount;
|
||||||
|
|
||||||
int mPriority;
|
int mPriority;
|
||||||
|
int mGroups;
|
||||||
|
|
||||||
AnimState() : mSource(NULL), mTime(0.0f), mPlaying(false), mLoopCount(0)
|
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
|
* \param priority Priority of the animation. The animation will play on
|
||||||
* bone groups that don't have another animation set of a
|
* bone groups that don't have another animation set of a
|
||||||
* higher priority.
|
* higher priority.
|
||||||
|
* \param groups Bone groups to play the animation on.
|
||||||
* \param start Key marker from which to start.
|
* \param start Key marker from which to start.
|
||||||
* \param stop Key marker to stop at.
|
* \param stop Key marker to stop at.
|
||||||
* \param startpoint How far in between the two markers to start. 0 starts
|
* \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
|
* \return Boolean specifying whether the animation will return movement
|
||||||
* for the character at all.
|
* 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);
|
bool play(const std::string &groupname, Priority priority, int groups,
|
||||||
|
const std::string &start, const std::string &stop,
|
||||||
void disable(const std::string &groupname);
|
float startpoint, size_t loops);
|
||||||
|
|
||||||
/** Gets info about the given animation group.
|
/** Gets info about the given animation group.
|
||||||
* \param groupname Animation group to check.
|
* \param groupname Animation group to check.
|
||||||
|
|
|
@ -172,7 +172,8 @@ namespace MWRender
|
||||||
if(groupname != mCurrentAnimGroup)
|
if(groupname != mCurrentAnimGroup)
|
||||||
{
|
{
|
||||||
mCurrentAnimGroup = groupname;
|
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();
|
mAnimation->forceUpdate();
|
||||||
|
@ -199,7 +200,8 @@ namespace MWRender
|
||||||
mAnimation->showWeapons(true);
|
mAnimation->showWeapons(true);
|
||||||
|
|
||||||
mCurrentAnimGroup = "inventoryhandtohand";
|
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 ()
|
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();
|
updateCamera();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue