From a6a94d5f77d8cf5edc25984dc4832c9410589632 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 8 Dec 2023 00:59:41 -0600 Subject: [PATCH] 2nd pass on additive blend math. --- .../Animations/Graph/AnimGroup.Animation.cpp | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp index 4d4c7835c..e8a203a83 100644 --- a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp +++ b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp @@ -1076,11 +1076,28 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu tA = nodesA->Nodes[i]; tB = nodesB->Nodes[i]; - auto t = tB; - auto originalOrientation = (1 - alpha) * tA.Orientation; - auto additiveOrientation = alpha * t.Orientation; - if (Quaternion::Dot(originalOrientation, additiveOrientation) < 0) - t.Orientation *= -1; + // Get Base pose nodes + auto baseNode = _graph.BaseModel.Get()->GetNodes()[i]; + + t.Translation = tA.Translation + (tB.Translation - baseNode.LocalTransform.Translation) * alpha; + + //auto baseOrientation = tA.Orientation; + //Quaternion additiveOrientation = alpha * (tB.Orientation - baseNode.LocalTransform.Orientation); + //t.Orientation = baseOrientation + additiveOrientation; + auto m1 = Matrix::RotationQuaternion(tA.Orientation); + auto m2 = Matrix::RotationQuaternion(alpha * tB.Orientation); + auto m3 = Matrix::RotationQuaternion(alpha * baseNode.LocalTransform.Orientation); + Matrix m4; + Matrix::Subtract(m2, m3, m4); + Matrix m5; + Matrix::Add(m1, m4, m5); + + t.SetRotation(m5); + t.Orientation.Normalize(); + + t.Scale = tA.Scale * tB.Scale; + + //nodes->Nodes[i] = t; Transform::Lerp(tA, t, alpha, nodes->Nodes[i]); } Transform::Lerp(nodesA->RootMotion, nodesA->RootMotion + nodesB->RootMotion, alpha, nodes->RootMotion);