From 136b1fc421e997f460a9b3c576fce8eb1d55d8b7 Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Tue, 23 Nov 2021 17:25:40 +0100 Subject: [PATCH] Fix anim graph crash regression --- Source/Engine/Animations/Graph/AnimGraph.cpp | 17 +++++++++++------ .../Animations/Graph/AnimGroup.Animation.cpp | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/Engine/Animations/Graph/AnimGraph.cpp b/Source/Engine/Animations/Graph/AnimGraph.cpp index 41d9a3589..ec126b88f 100644 --- a/Source/Engine/Animations/Graph/AnimGraph.cpp +++ b/Source/Engine/Animations/Graph/AnimGraph.cpp @@ -258,17 +258,22 @@ void AnimGraphExecutor::Update(AnimGraphInstanceData& data, float dt) } // Update the animation graph and gather skeleton nodes transformations in nodes local space - AnimGraphImpulse* animResult; + AnimGraphImpulse* animResult = nullptr; { ANIM_GRAPH_PROFILE_EVENT("Evaluate"); - auto result = eatBox((Node*)_graph._rootNode, &_graph._rootNode->Boxes[0]); - if (result.Type.Type != VariantType::Pointer) + const Variant result = eatBox((Node*)_graph._rootNode, &_graph._rootNode->Boxes[0]); + switch (result.Type.Type) { - result = VariantType::Null; - LOG(Warning, "Invalid animation update result"); + case VariantType::Pointer: + animResult = (AnimGraphImpulse*)result.AsPointer; + break; + case ValueType::Null: + break; + default: + LOG(Warning, "Invalid animation update result type {0}", result.Type.ToString()); + break; } - animResult = (AnimGraphImpulse*)result.AsPointer; if (animResult == nullptr) animResult = GetEmptyNodes(); } diff --git a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp index f12f5570e..4daab5776 100644 --- a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp +++ b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp @@ -588,6 +588,7 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu // Animation Output case 1: value = tryGetValue(box, Value::Null); + break; // Animation case 2: {