mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-06 16:43:23 +02:00
Merge pull request #11725 from luiscuenca/case8270
8270 Changing avatars while sitting - restore animations
This commit is contained in:
commit
7c6b5081d6
2 changed files with 20 additions and 0 deletions
|
@ -152,6 +152,7 @@ void Rig::overrideRoleAnimation(const QString& role, const QString& url, float f
|
||||||
const float REFERENCE_FRAMES_PER_SECOND = 30.0f;
|
const float REFERENCE_FRAMES_PER_SECOND = 30.0f;
|
||||||
float timeScale = fps / REFERENCE_FRAMES_PER_SECOND;
|
float timeScale = fps / REFERENCE_FRAMES_PER_SECOND;
|
||||||
auto clipNode = std::make_shared<AnimClip>(role, url, firstFrame, lastFrame, timeScale, loop, false);
|
auto clipNode = std::make_shared<AnimClip>(role, url, firstFrame, lastFrame, timeScale, loop, false);
|
||||||
|
_roleAnimStates[role] = { role, url, fps, loop, firstFrame, lastFrame };
|
||||||
AnimNode::Pointer parent = node->getParent();
|
AnimNode::Pointer parent = node->getParent();
|
||||||
parent->replaceChild(node, clipNode);
|
parent->replaceChild(node, clipNode);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1638,6 +1639,11 @@ void Rig::initAnimGraph(const QUrl& url) {
|
||||||
_userAnimState = { UserAnimState::None, "", 30.0f, false, 0.0f, 0.0f };
|
_userAnimState = { UserAnimState::None, "", 30.0f, false, 0.0f, 0.0f };
|
||||||
overrideAnimation(origState.url, origState.fps, origState.loop, origState.firstFrame, origState.lastFrame);
|
overrideAnimation(origState.url, origState.fps, origState.loop, origState.firstFrame, origState.lastFrame);
|
||||||
}
|
}
|
||||||
|
// restore the role animations we had before reset.
|
||||||
|
for (auto& roleAnimState : _roleAnimStates) {
|
||||||
|
auto roleState = roleAnimState.second;
|
||||||
|
overrideRoleAnimation(roleState.role, roleState.url, roleState.fps, roleState.loop, roleState.firstFrame, roleState.lastFrame);
|
||||||
|
}
|
||||||
_animLoading = false;
|
_animLoading = false;
|
||||||
|
|
||||||
emit onLoadComplete();
|
emit onLoadComplete();
|
||||||
|
|
|
@ -335,8 +335,22 @@ protected:
|
||||||
float firstFrame;
|
float firstFrame;
|
||||||
float lastFrame;
|
float lastFrame;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct RoleAnimState {
|
||||||
|
RoleAnimState() {}
|
||||||
|
RoleAnimState(const QString& roleId, const QString& urlIn, float fpsIn, bool loopIn, float firstFrameIn, float lastFrameIn) :
|
||||||
|
role(roleId), url(urlIn), fps(fpsIn), loop(loopIn), firstFrame(firstFrameIn), lastFrame(lastFrameIn) {}
|
||||||
|
|
||||||
|
QString role;
|
||||||
|
QString url;
|
||||||
|
float fps;
|
||||||
|
bool loop;
|
||||||
|
float firstFrame;
|
||||||
|
float lastFrame;
|
||||||
|
};
|
||||||
|
|
||||||
UserAnimState _userAnimState;
|
UserAnimState _userAnimState;
|
||||||
|
std::map<QString, RoleAnimState> _roleAnimStates;
|
||||||
|
|
||||||
float _leftHandOverlayAlpha { 0.0f };
|
float _leftHandOverlayAlpha { 0.0f };
|
||||||
float _rightHandOverlayAlpha { 0.0f };
|
float _rightHandOverlayAlpha { 0.0f };
|
||||||
|
|
Loading…
Reference in a new issue