diff --git a/Source/Editor/Surface/Archetypes/Animation.MultiBlend.cs b/Source/Editor/Surface/Archetypes/Animation.MultiBlend.cs index 74e0a2b4b..174f867fc 100644 --- a/Source/Editor/Surface/Archetypes/Animation.MultiBlend.cs +++ b/Source/Editor/Surface/Archetypes/Animation.MultiBlend.cs @@ -21,8 +21,8 @@ namespace FlaxEditor.Surface.Archetypes { private readonly Animation.MultiBlend _node; private readonly bool _is2D; - private Float2 _rangeX; - private Float2 _rangeY; + private Float2 _rangeX, _rangeY; + private Float2 _debugPos = Float2.Minimum; private readonly BlendPoint[] _blendPoints = new BlendPoint[Animation.MultiBlend.MaxAnimationsCount]; private readonly Guid[] _pointsAnims = new Guid[Animation.MultiBlend.MaxAnimationsCount]; private readonly Float2[] _pointsLocations = new Float2[Animation.MultiBlend.MaxAnimationsCount]; @@ -419,6 +419,26 @@ namespace FlaxEditor.Surface.Archetypes } } + // Debug current playback position + if (((AnimGraphSurface)_node.Surface).TryGetTraceEvent(_node, out var traceEvent)) + { + if (_is2D) + { + unsafe + { + // Unpack xy from 32-bits + Half2 packed = *(Half2*)&traceEvent.Value; + _debugPos = (Float2)packed; + } + } + else + _debugPos = new Float2(traceEvent.Value, 0.0f); + } + else + { + _debugPos = Float2.Minimum; + } + base.Update(deltaTime); } @@ -558,6 +578,19 @@ namespace FlaxEditor.Surface.Archetypes base.Draw(); + // Draw debug position + if (_debugPos.X > float.MinValue) + { + // Draw dot with outline + var icon = Editor.Instance.Icons.VisjectBoxOpen32; + var size = BlendPoint.DefaultSize; + var debugPos = BlendSpacePosToBlendPointPos(_debugPos); + var debugRect = new Rectangle(debugPos + new Float2(size * -0.5f) + size * 0.5f, new Float2(size)); + var outline = Color.Black; // Shadow + Render2D.DrawSprite(icon, debugRect.MakeExpanded(2.0f), outline); + Render2D.DrawSprite(icon, debugRect, style.ProgressNormal); + } + // Frame var frameColor = containsFocus ? style.BackgroundSelected : (IsMouseOver ? style.ForegroundGrey : style.ForegroundDisabled); Render2D.DrawRectangle(new Rectangle(1, 1, rect.Width - 2, rect.Height - 2), frameColor); diff --git a/Source/Engine/Animations/Graph/AnimGraph.Base.cpp b/Source/Engine/Animations/Graph/AnimGraph.Base.cpp index 7cbc3367d..dcc46f1ce 100644 --- a/Source/Engine/Animations/Graph/AnimGraph.Base.cpp +++ b/Source/Engine/Animations/Graph/AnimGraph.Base.cpp @@ -174,7 +174,6 @@ bool AnimGraphBase::onNodeLoaded(Node* n) { ADD_BUCKET(MultiBlendBucketInit); n->Data.MultiBlend1D.Length = -1; - const Float4 range = n->Values[0].AsFloat4(); for (int32 i = 0; i < ANIM_GRAPH_MULTI_BLEND_MAX_ANIMS; i++) { n->Assets[i] = Content::LoadAsync((Guid)n->Values[i * 2 + 5]); @@ -192,7 +191,6 @@ bool AnimGraphBase::onNodeLoaded(Node* n) // Get blend points locations Array> vertices; byte vertexIndexToAnimIndex[ANIM_GRAPH_MULTI_BLEND_MAX_ANIMS]; - const Float4 range = n->Values[0].AsFloat4(); for (int32 i = 0; i < ANIM_GRAPH_MULTI_BLEND_MAX_ANIMS; i++) { n->Assets[i] = (Asset*)Content::LoadAsync((Guid)n->Values[i * 2 + 5]); diff --git a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp index 21eb44265..ae1b7369f 100644 --- a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp +++ b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp @@ -1275,6 +1275,13 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu float x = (float)tryGetValue(node->GetBox(4), Value::Zero); x = Math::Clamp(x, range.X, range.Y); + // Add to trace + if (context.Data->EnableTracing) + { + auto& trace = context.AddTraceEvent(node); + trace.Value = x; + } + // Check if need to evaluate multi blend length if (data.Length < 0) ComputeMultiBlendLength(data.Length, node); @@ -1368,6 +1375,14 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu float y = (float)tryGetValue(node->GetBox(5), Value::Zero); y = Math::Clamp(y, range.Z, range.W); + // Add to trace + if (context.Data->EnableTracing) + { + auto& trace = context.AddTraceEvent(node); + const Half2 packed(x, y); // Pack xy into 32-bits + *(uint32*)&trace.Value = *(uint32*)&packed; + } + // Check if need to evaluate multi blend length if (data.Length < 0) ComputeMultiBlendLength(data.Length, node);