WIP animation based root bone transform calculation.

This commit is contained in:
Martin Felis
2021-11-21 12:33:22 +01:00
parent 89108f4e1f
commit d4f9459060
14 changed files with 156 additions and 43 deletions
+10 -4
View File
@@ -19,6 +19,8 @@ struct BlendNode : public AnimNode {
ozz::vector<ozz::math::SoaTransform> m_local_matrices_A;
ozz::vector<ozz::math::SoaTransform> m_local_matrices_B;
ozz::math::Transform m_root_transform_A;
ozz::math::Transform m_root_transform_B;
virtual void Reset() {
m_current_time = 0.f;
@@ -45,11 +47,14 @@ struct BlendNode : public AnimNode {
virtual void UpdateTime(float dt) {
if (m_is_time_synced) {
float sync_time_old = m_sync_track.CalcSyncFromAbsTime(m_current_time);
m_current_time = fmodf(m_current_time + dt, m_sync_track.m_duration);
float current_sync_time = m_sync_track.CalcSyncFromAbsTime(m_current_time);
float sync_time_dt = m_sync_track.CalcSyncFromAbsTime(m_current_time) - sync_time_old;
m_input_A->UpdateTime(current_sync_time - m_input_A->m_current_time);
m_input_B->UpdateTime(current_sync_time - m_input_B->m_current_time);
m_input_A->m_current_time = sync_time_old;
m_input_B->m_current_time = sync_time_old;
m_input_A->UpdateTime(sync_time_dt);
m_input_B->UpdateTime(sync_time_dt);
} else {
m_current_time += dt;
m_input_A->UpdateTime(dt);
@@ -58,7 +63,8 @@ struct BlendNode : public AnimNode {
}
virtual void Evaluate(
ozz::vector<ozz::math::SoaTransform>* local_matrices) override;
ozz::vector<ozz::math::SoaTransform>* local_matrices,
ozz::math::Transform* root_transform) override;
virtual void GetInputNodes(std::vector<AnimNode*>& input_nodes) const override {
input_nodes.push_back(m_input_A);