11 #ifndef hifi_AnimContext_h
12 #define hifi_AnimContext_h
14 #include <glm/glm.hpp>
15 #include <glm/gtc/quaternion.hpp>
18 #include <QStringList>
21 enum class AnimNodeType {
27 RandomSwitchStateMachine,
40 AnimBlendType_AddRelative,
41 AnimBlendType_AddAbsolute,
42 AnimBlendType_NumTypes
48 AnimContext(
bool enableDebugDrawIKTargets,
bool enableDebugDrawIKConstraints,
bool enableDebugDrawIKChains,
49 const glm::mat4& geometryToRigMatrix,
const glm::mat4& rigToWorldMatrix,
int evaluationCount);
51 bool getEnableDebugDrawIKTargets()
const {
return _enableDebugDrawIKTargets; }
52 bool getEnableDebugDrawIKConstraints()
const {
return _enableDebugDrawIKConstraints; }
53 bool getEnableDebugDrawIKChains()
const {
return _enableDebugDrawIKChains; }
54 const glm::mat4& getGeometryToRigMatrix()
const {
return _geometryToRigMatrix; }
55 const glm::mat4& getRigToWorldMatrix()
const {
return _rigToWorldMatrix; }
56 int getEvaluationCount()
const {
return _evaluationCount; }
58 float getDebugAlpha(
const QString& key)
const {
59 auto it = _debugAlphaMap.find(key);
60 if (it != _debugAlphaMap.end()) {
61 return std::get<0>(it->second);
67 using DebugAlphaMapValue = std::tuple<float, AnimNodeType>;
68 using DebugAlphaMap = std::map<QString, DebugAlphaMapValue>;
70 void setDebugAlpha(
const QString& key,
float alpha, AnimNodeType type)
const {
71 _debugAlphaMap[key] = DebugAlphaMapValue(alpha, type);
74 const DebugAlphaMap& getDebugAlphaMap()
const {
75 return _debugAlphaMap;
78 using DebugStateMachineMapValue = QString;
79 using DebugStateMachineMap = std::map<QString, DebugStateMachineMapValue>;
81 void addStateMachineInfo(
const QString& stateMachineName,
const QString& currentState,
const QString& previousState,
bool duringInterp,
float alpha)
const {
83 _stateMachineMap[stateMachineName] = QString(
"%1: %2 -> %3 (%4)").arg(stateMachineName).arg(previousState).arg(currentState).arg(QString::number(alpha,
'f', 2));
85 _stateMachineMap[stateMachineName] = QString(
"%1: %2").arg(stateMachineName).arg(currentState);
89 const DebugStateMachineMap& getStateMachineMap()
const {
return _stateMachineMap; }
93 bool _enableDebugDrawIKTargets {
false };
94 bool _enableDebugDrawIKConstraints {
false };
95 bool _enableDebugDrawIKChains {
false };
96 glm::mat4 _geometryToRigMatrix;
97 glm::mat4 _rigToWorldMatrix;
98 int _evaluationCount{ 0 };
101 mutable DebugAlphaMap _debugAlphaMap;
102 mutable DebugStateMachineMap _stateMachineMap;