From e9285410e2c15bf8ae88d88f83bdcaa11e810d69 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 7 Dec 2023 20:27:24 -0600 Subject: [PATCH] Fix blending additive animations. --- .../Engine/Animations/Graph/AnimGroup.Animation.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp index 6f0d7661b..37e605916 100644 --- a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp +++ b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp @@ -1075,11 +1075,16 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu { tA = nodesA->Nodes[i]; tB = nodesB->Nodes[i]; - t.Translation = tA.Translation + tB.Translation; - t.Orientation = tA.Orientation * tB.Orientation; - t.Scale = tA.Scale * tB.Scale; + t.Translation = tA.Translation * (1 - alpha) + tB.Translation * alpha; + auto originalOrientation = (1 - alpha) * tA.Orientation; + auto additiveOrientation = alpha * tB.Orientation; + if (Quaternion::Dot(originalOrientation, additiveOrientation) < 0) + additiveOrientation *= -1; + t.Orientation = originalOrientation + additiveOrientation; + t.Scale = tA.Scale * (1 - alpha) + tB.Scale * alpha; t.Orientation.Normalize(); - Transform::Lerp(tA, t, alpha, nodes->Nodes[i]); + nodes->Nodes[i] = t; + //Transform::Lerp(tA, t, alpha, nodes->Nodes[i]); } Transform::Lerp(nodesA->RootMotion, nodesA->RootMotion + nodesB->RootMotion, alpha, nodes->RootMotion); value = nodes;