Add live debugging of blend position in Multi Blend

This commit is contained in:
Wojtek Figat
2024-04-18 18:42:31 +02:00
parent a3b5f4b789
commit 0845866c4d
3 changed files with 50 additions and 4 deletions

View File

@@ -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<Animation>((Guid)n->Values[i * 2 + 5]);
@@ -192,7 +191,6 @@ bool AnimGraphBase::onNodeLoaded(Node* n)
// Get blend points locations
Array<Float2, FixedAllocation<ANIM_GRAPH_MULTI_BLEND_MAX_ANIMS + 3>> 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<Animation>((Guid)n->Values[i * 2 + 5]);

View File

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