Add sanity check to prevent crashes when Animated Model has NaN in skeleton pose

#2118
This commit is contained in:
Wojtek Figat
2024-01-05 11:29:53 +01:00
parent 37da55896c
commit d9ca3e5b57

View File

@@ -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