From a1399c51575cd98a2a90b5f4eab7320b22bf7d35 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 9 Feb 2026 18:02:58 +0100 Subject: [PATCH] Optimize Anim Graph retarget to use cached pose to avoid dynamic memory allocation #3827 --- Source/Engine/Animations/Graph/AnimGraph.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Engine/Animations/Graph/AnimGraph.cpp b/Source/Engine/Animations/Graph/AnimGraph.cpp index e99f53b8f..3c2630b51 100644 --- a/Source/Engine/Animations/Graph/AnimGraph.cpp +++ b/Source/Engine/Animations/Graph/AnimGraph.cpp @@ -336,11 +336,13 @@ void AnimGraphExecutor::Update(AnimGraphInstanceData& data, float dt) SkeletonData* animResultSkeleton = &skeleton; // Retarget animation when using output pose from other skeleton - AnimGraphImpulse retargetNodes; if (_graph.BaseModel != data.NodesSkeleton) { ANIM_GRAPH_PROFILE_EVENT("Retarget"); auto& targetSkeleton = data.NodesSkeleton->Skeleton; + if (context.PoseCacheSize == context.PoseCache.Count()) + context.PoseCache.AddOne(); + auto& retargetNodes = context.PoseCache[context.PoseCacheSize++]; retargetNodes = *animResult; retargetNodes.Nodes.Resize(targetSkeleton.Nodes.Count()); Transform* targetNodes = retargetNodes.Nodes.Get();