diff --git a/Source/Engine/Animations/Graph/AnimGraph.cpp b/Source/Engine/Animations/Graph/AnimGraph.cpp index 5aa720d31..7c4671a51 100644 --- a/Source/Engine/Animations/Graph/AnimGraph.cpp +++ b/Source/Engine/Animations/Graph/AnimGraph.cpp @@ -282,6 +282,20 @@ void AnimGraphExecutor::Update(AnimGraphInstanceData& data, float dt) } } } +#if !BUILD_RELEASE + { + // Perform sanity check on nodes pose to prevent crashes due to NaNs + bool anyInvalid = animResult->RootMotion.IsNanOrInfinity(); + for (int32 i = 0; i < animResult->Nodes.Count(); i++) + anyInvalid |= animResult->Nodes.Get()[i].IsNanOrInfinity(); + if (anyInvalid) + { + LOG(Error, "Animated Model pose contains NaNs due to animations sampling/blending bug."); + context.Data = nullptr; + return; + } + } +#endif SkeletonData* animResultSkeleton = &skeleton; // Retarget animation when using output pose from other skeleton