From 2b1e5e4958e725c36a7c5df3d399a417913f5e8e Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Thu, 9 Dec 2021 17:09:31 +0100 Subject: [PATCH] Fix various issues with Multi Blend 2D node --- Source/Engine/Animations/Graph/AnimGraph.Base.cpp | 12 ++++++++++++ .../Engine/Animations/Graph/AnimGroup.Animation.cpp | 6 ++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Animations/Graph/AnimGraph.Base.cpp b/Source/Engine/Animations/Graph/AnimGraph.Base.cpp index 8748e99bb..facf78b43 100644 --- a/Source/Engine/Animations/Graph/AnimGraph.Base.cpp +++ b/Source/Engine/Animations/Graph/AnimGraph.Base.cpp @@ -204,6 +204,18 @@ bool AnimGraphBase::onNodeLoaded(Node* n) // Triangulate Array> triangles; Delaunay2D::Triangulate(vertices, triangles); + if (triangles.Count() == 0) + { + switch (vertices.Count()) + { + case 1: + triangles.Add(Delaunay2D::Triangle(0, 0, 0)); + break; + case 2: + triangles.Add(Delaunay2D::Triangle(0, 1, 0)); + break; + } + } // Store triangles vertices indices (map the back to the anim node slots) for (int32 i = 0; i < triangles.Count(); i++) diff --git a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp index 2895f7931..4b99e2026 100644 --- a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp +++ b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp @@ -1065,6 +1065,7 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu case 13: { ASSERT(box->ID == 0); + value = Value::Null; // Note data layout: // [0]: Vector4 Range (minX, maxX, minY, maxY) @@ -1087,7 +1088,6 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu if (data.TrianglesP0[0] == ANIM_GRAPH_MULTI_BLEND_MAX_ANIMS) { // Nothing to sample - value = Value::Null; break; } @@ -1107,7 +1107,6 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu if (data.Length <= ZeroTolerance) { // Nothing to sample - value = Value::Null; break; } @@ -1122,7 +1121,6 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu ANIM_GRAPH_PROFILE_EVENT("Multi Blend 2D"); // Find 3 animations to blend (triangle) - value = Value::Null; Vector2 p(x, y); bool hasBest = false; Vector2 bestPoint; @@ -1230,7 +1228,7 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu } // Check if use the closes sample - if (value.AsPointer == nullptr && hasBest) + if ((void*)value == nullptr && hasBest) { const auto aAnim = node->Assets[bestAnims[0]].As(); const auto aData = node->Values[4 + bestAnims[0] * 2].AsVector4();