mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 18:03:27 +02:00
made changes requested
This commit is contained in:
parent
76164ecee8
commit
27ed468946
8 changed files with 96 additions and 99 deletions
|
@ -989,7 +989,6 @@
|
||||||
"type": "randomSwitchStateMachine",
|
"type": "randomSwitchStateMachine",
|
||||||
"data": {
|
"data": {
|
||||||
"currentState": "masterIdle",
|
"currentState": "masterIdle",
|
||||||
"triggerRandomSwitch": "idleSwitch",
|
|
||||||
"triggerTimeMin": 10.0,
|
"triggerTimeMin": 10.0,
|
||||||
"triggerTimeMax": 40.0,
|
"triggerTimeMax": 40.0,
|
||||||
"transitionVar": "timeToFidget",
|
"transitionVar": "timeToFidget",
|
||||||
|
@ -1105,7 +1104,6 @@
|
||||||
"type": "randomSwitchStateMachine",
|
"type": "randomSwitchStateMachine",
|
||||||
"data": {
|
"data": {
|
||||||
"currentState": "movement",
|
"currentState": "movement",
|
||||||
"triggerRandomSwitch": "fidgetSwitch",
|
|
||||||
"states": [
|
"states": [
|
||||||
{
|
{
|
||||||
"id": "movement",
|
"id": "movement",
|
||||||
|
@ -1131,7 +1129,6 @@
|
||||||
"type": "randomSwitchStateMachine",
|
"type": "randomSwitchStateMachine",
|
||||||
"data": {
|
"data": {
|
||||||
"currentState": "movement1",
|
"currentState": "movement1",
|
||||||
"triggerRandomSwitch": "movementSwitch",
|
|
||||||
"states": [
|
"states": [
|
||||||
{
|
{
|
||||||
"id": "movement1",
|
"id": "movement1",
|
||||||
|
@ -1303,7 +1300,6 @@
|
||||||
"type": "randomSwitchStateMachine",
|
"type": "randomSwitchStateMachine",
|
||||||
"data": {
|
"data": {
|
||||||
"currentState": "transitionToAltIdle1",
|
"currentState": "transitionToAltIdle1",
|
||||||
"triggerRandomSwitch": "altIdleSwitch",
|
|
||||||
"triggerTimeMin": 10.0,
|
"triggerTimeMin": 10.0,
|
||||||
"triggerTimeMax": 40.0,
|
"triggerTimeMax": 40.0,
|
||||||
"transitionVar": "finishAltIdle2",
|
"transitionVar": "finishAltIdle2",
|
||||||
|
|
|
@ -11,12 +11,12 @@
|
||||||
#include "AnimContext.h"
|
#include "AnimContext.h"
|
||||||
|
|
||||||
AnimContext::AnimContext(bool enableDebugDrawIKTargets, bool enableDebugDrawIKConstraints, bool enableDebugDrawIKChains,
|
AnimContext::AnimContext(bool enableDebugDrawIKTargets, bool enableDebugDrawIKConstraints, bool enableDebugDrawIKChains,
|
||||||
const glm::mat4& geometryToRigMatrix, const glm::mat4& rigToWorldMatrix, int framesAnimatedThisSession) :
|
const glm::mat4& geometryToRigMatrix, const glm::mat4& rigToWorldMatrix, int evaluationCount) :
|
||||||
_enableDebugDrawIKTargets(enableDebugDrawIKTargets),
|
_enableDebugDrawIKTargets(enableDebugDrawIKTargets),
|
||||||
_enableDebugDrawIKConstraints(enableDebugDrawIKConstraints),
|
_enableDebugDrawIKConstraints(enableDebugDrawIKConstraints),
|
||||||
_enableDebugDrawIKChains(enableDebugDrawIKChains),
|
_enableDebugDrawIKChains(enableDebugDrawIKChains),
|
||||||
_geometryToRigMatrix(geometryToRigMatrix),
|
_geometryToRigMatrix(geometryToRigMatrix),
|
||||||
_rigToWorldMatrix(rigToWorldMatrix),
|
_rigToWorldMatrix(rigToWorldMatrix),
|
||||||
_framesAnimatedThisSession(framesAnimatedThisSession)
|
_evaluationCount(evaluationCount)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,14 +38,14 @@ class AnimContext {
|
||||||
public:
|
public:
|
||||||
AnimContext() {}
|
AnimContext() {}
|
||||||
AnimContext(bool enableDebugDrawIKTargets, bool enableDebugDrawIKConstraints, bool enableDebugDrawIKChains,
|
AnimContext(bool enableDebugDrawIKTargets, bool enableDebugDrawIKConstraints, bool enableDebugDrawIKChains,
|
||||||
const glm::mat4& geometryToRigMatrix, const glm::mat4& rigToWorldMatrix, int framesAnimatedThisSession);
|
const glm::mat4& geometryToRigMatrix, const glm::mat4& rigToWorldMatrix, int evaluationCount);
|
||||||
|
|
||||||
bool getEnableDebugDrawIKTargets() const { return _enableDebugDrawIKTargets; }
|
bool getEnableDebugDrawIKTargets() const { return _enableDebugDrawIKTargets; }
|
||||||
bool getEnableDebugDrawIKConstraints() const { return _enableDebugDrawIKConstraints; }
|
bool getEnableDebugDrawIKConstraints() const { return _enableDebugDrawIKConstraints; }
|
||||||
bool getEnableDebugDrawIKChains() const { return _enableDebugDrawIKChains; }
|
bool getEnableDebugDrawIKChains() const { return _enableDebugDrawIKChains; }
|
||||||
const glm::mat4& getGeometryToRigMatrix() const { return _geometryToRigMatrix; }
|
const glm::mat4& getGeometryToRigMatrix() const { return _geometryToRigMatrix; }
|
||||||
const glm::mat4& getRigToWorldMatrix() const { return _rigToWorldMatrix; }
|
const glm::mat4& getRigToWorldMatrix() const { return _rigToWorldMatrix; }
|
||||||
int getFramesAnimatedThisSession() const { return _framesAnimatedThisSession; }
|
int getEvaluationCount() const { return _evaluationCount; }
|
||||||
|
|
||||||
float getDebugAlpha(const QString& key) const {
|
float getDebugAlpha(const QString& key) const {
|
||||||
auto it = _debugAlphaMap.find(key);
|
auto it = _debugAlphaMap.find(key);
|
||||||
|
@ -87,7 +87,7 @@ protected:
|
||||||
bool _enableDebugDrawIKChains { false };
|
bool _enableDebugDrawIKChains { false };
|
||||||
glm::mat4 _geometryToRigMatrix;
|
glm::mat4 _geometryToRigMatrix;
|
||||||
glm::mat4 _rigToWorldMatrix;
|
glm::mat4 _rigToWorldMatrix;
|
||||||
int _framesAnimatedThisSession { 0 };
|
int _evaluationCount{ 0 };
|
||||||
|
|
||||||
// used for debugging internal state of animation system.
|
// used for debugging internal state of animation system.
|
||||||
mutable DebugAlphaMap _debugAlphaMap;
|
mutable DebugAlphaMap _debugAlphaMap;
|
||||||
|
|
|
@ -25,7 +25,7 @@ const AnimPoseVec& AnimRandomSwitch::evaluate(const AnimVariantMap& animVars, co
|
||||||
float parentDebugAlpha = context.getDebugAlpha(_id);
|
float parentDebugAlpha = context.getDebugAlpha(_id);
|
||||||
|
|
||||||
AnimRandomSwitch::RandomSwitchState::Pointer desiredState = _currentState;
|
AnimRandomSwitch::RandomSwitchState::Pointer desiredState = _currentState;
|
||||||
if (abs(_framesActive - context.getFramesAnimatedThisSession()) > 1 || animVars.lookup(_triggerRandomSwitchVar, false)) {
|
if (abs(_randomSwitchEvaluationCount - context.getEvaluationCount()) > 1 || animVars.lookup(_triggerRandomSwitchVar, false)) {
|
||||||
// get a random number and decide which motion to choose.
|
// get a random number and decide which motion to choose.
|
||||||
bool currentStateHasPriority = false;
|
bool currentStateHasPriority = false;
|
||||||
float dice = randFloatInRange(0.0f, 1.0f);
|
float dice = randFloatInRange(0.0f, 1.0f);
|
||||||
|
@ -43,7 +43,7 @@ const AnimPoseVec& AnimRandomSwitch::evaluate(const AnimVariantMap& animVars, co
|
||||||
currentStateHasPriority = currentStateHasPriority || (_currentState == randState);
|
currentStateHasPriority = currentStateHasPriority || (_currentState == randState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (abs(_framesActive - context.getFramesAnimatedThisSession()) > 1) {
|
if (abs(_randomSwitchEvaluationCount - context.getEvaluationCount()) > 1) {
|
||||||
_duringInterp = false;
|
_duringInterp = false;
|
||||||
switchRandomState(animVars, context, desiredState, _duringInterp);
|
switchRandomState(animVars, context, desiredState, _duringInterp);
|
||||||
} else {
|
} else {
|
||||||
|
@ -126,7 +126,7 @@ const AnimPoseVec& AnimRandomSwitch::evaluate(const AnimVariantMap& animVars, co
|
||||||
_poses = currentStateNode->evaluate(animVars, context, dt, triggersOut);
|
_poses = currentStateNode->evaluate(animVars, context, dt, triggersOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
_framesActive = context.getFramesAnimatedThisSession();
|
_randomSwitchEvaluationCount = context.getEvaluationCount();
|
||||||
processOutputJoints(triggersOut);
|
processOutputJoints(triggersOut);
|
||||||
|
|
||||||
context.addStateMachineInfo(_id, _currentState->getID(), _previousState->getID(), _duringInterp, _alpha);
|
context.addStateMachineInfo(_id, _currentState->getID(), _previousState->getID(), _duringInterp, _alpha);
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
// evaluated dynamically. During the interpolation period the previous snapshot is interpolated with the target pose
|
// evaluated dynamically. During the interpolation period the previous snapshot is interpolated with the target pose
|
||||||
// to produce smooth motion between them. This mode is useful for interping into a blended animation where the actual
|
// to produce smooth motion between them. This mode is useful for interping into a blended animation where the actual
|
||||||
// blend factor is not known at the start of the interp or is might change dramatically during the interp.
|
// blend factor is not known at the start of the interp or is might change dramatically during the interp.
|
||||||
|
//
|
||||||
|
|
||||||
class AnimRandomSwitch : public AnimNode {
|
class AnimRandomSwitch : public AnimNode {
|
||||||
public:
|
public:
|
||||||
|
@ -150,7 +151,7 @@ protected:
|
||||||
|
|
||||||
AnimPoseVec _poses;
|
AnimPoseVec _poses;
|
||||||
|
|
||||||
int _framesActive { 0 };
|
int _randomSwitchEvaluationCount { 0 };
|
||||||
// interpolation state
|
// interpolation state
|
||||||
bool _duringInterp = false;
|
bool _duringInterp = false;
|
||||||
InterpType _interpType{ InterpType::SnapshotPrev };
|
InterpType _interpType{ InterpType::SnapshotPrev };
|
||||||
|
|
|
@ -1480,7 +1480,7 @@ void Rig::updateAnimations(float deltaTime, const glm::mat4& rootTransform, cons
|
||||||
if (_animNode && _enabledAnimations) {
|
if (_animNode && _enabledAnimations) {
|
||||||
DETAILED_PERFORMANCE_TIMER("handleTriggers");
|
DETAILED_PERFORMANCE_TIMER("handleTriggers");
|
||||||
|
|
||||||
++_framesAnimatedThisSession;
|
++_evaluationCount;
|
||||||
|
|
||||||
updateAnimationStateHandlers();
|
updateAnimationStateHandlers();
|
||||||
_animVars.setRigToGeometryTransform(_rigToGeometryTransform);
|
_animVars.setRigToGeometryTransform(_rigToGeometryTransform);
|
||||||
|
@ -1488,7 +1488,7 @@ void Rig::updateAnimations(float deltaTime, const glm::mat4& rootTransform, cons
|
||||||
_networkVars.setRigToGeometryTransform(_rigToGeometryTransform);
|
_networkVars.setRigToGeometryTransform(_rigToGeometryTransform);
|
||||||
}
|
}
|
||||||
AnimContext context(_enableDebugDrawIKTargets, _enableDebugDrawIKConstraints, _enableDebugDrawIKChains,
|
AnimContext context(_enableDebugDrawIKTargets, _enableDebugDrawIKConstraints, _enableDebugDrawIKChains,
|
||||||
getGeometryToRigTransform(), rigToWorldTransform, _framesAnimatedThisSession);
|
getGeometryToRigTransform(), rigToWorldTransform, _evaluationCount);
|
||||||
|
|
||||||
// evaluate the animation
|
// evaluate the animation
|
||||||
AnimVariantMap triggersOut;
|
AnimVariantMap triggersOut;
|
||||||
|
|
|
@ -418,7 +418,7 @@ protected:
|
||||||
HandAnimState _rightHandAnimState;
|
HandAnimState _rightHandAnimState;
|
||||||
HandAnimState _leftHandAnimState;
|
HandAnimState _leftHandAnimState;
|
||||||
std::map<QString, RoleAnimState> _roleAnimStates;
|
std::map<QString, RoleAnimState> _roleAnimStates;
|
||||||
int _framesAnimatedThisSession { 0 };
|
int _evaluationCount{ 0 };
|
||||||
|
|
||||||
float _leftHandOverlayAlpha { 0.0f };
|
float _leftHandOverlayAlpha { 0.0f };
|
||||||
float _rightHandOverlayAlpha { 0.0f };
|
float _rightHandOverlayAlpha { 0.0f };
|
||||||
|
|
Loading…
Reference in a new issue