Fix anim graph trace events debugging to include nodes path for nested graphs

This commit is contained in:
Wojtek Figat
2024-02-07 19:03:38 +01:00
parent e75902e900
commit a38d1ad7cc
6 changed files with 51 additions and 11 deletions

View File

@@ -115,16 +115,36 @@ namespace FlaxEditor.Surface
internal AnimGraphTraceEvent[] LastTraceEvents;
internal bool TryGetTraceEvent(SurfaceNode node, out AnimGraphTraceEvent traceEvent)
internal unsafe bool TryGetTraceEvent(SurfaceNode node, out AnimGraphTraceEvent traceEvent)
{
if (LastTraceEvents != null)
{
foreach (var e in LastTraceEvents)
{
// Node IDs must match
if (e.NodeId == node.ID)
{
traceEvent = e;
return true;
uint* nodePath = e.NodePath0;
// Get size of the path
int nodePathSize = 0;
while (nodePathSize < 8 && nodePath[nodePathSize] != 0)
nodePathSize++;
// Follow input node contexts path to verify if it matches with the path in the event
var c = node.Context;
for (int i = nodePathSize - 1; i >= 0 && c != null; i--)
{
if (c.OwnerNodeID != nodePath[i])
c = null;
else
c = c.Parent;
}
if (c != null)
{
traceEvent = e;
return true;
}
}
}
}

View File

@@ -62,6 +62,8 @@ namespace FlaxEditor.Surface
surfaceContext = CreateContext(_context, context);
_context?.Children.Add(surfaceContext);
_contextCache.Add(contextHandle, surfaceContext);
if (context is SurfaceNode asNode)
surfaceContext.OwnerNodeID = asNode.ID;
context.OnContextCreated(surfaceContext);

View File

@@ -156,6 +156,11 @@ namespace FlaxEditor.Surface
/// </summary>
public event Action<SurfaceControl> ControlDeleted;
/// <summary>
/// Identifier of the node that 'owns' this context (eg. State Machine which created this graph of state nodes).
/// </summary>
public uint OwnerNodeID;
/// <summary>
/// Initializes a new instance of the <see cref="VisjectSurfaceContext"/> class.
/// </summary>