From 06198d595ff9f0f1a6de0b374767df467eced749 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Wed, 18 Feb 2026 22:13:51 +0100 Subject: [PATCH] Added test for embedded blend tree evaluation. --- tests/test_blendalot_animgraph.h | 57 ++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/tests/test_blendalot_animgraph.h b/tests/test_blendalot_animgraph.h index bc6c5e6..511b713 100644 --- a/tests/test_blendalot_animgraph.h +++ b/tests/test_blendalot_animgraph.h @@ -599,4 +599,61 @@ TEST_CASE_FIXTURE(BlendTreeFixture, "[SceneTree][Blendalot][BlendTreeGraph][Chan } } +TEST_CASE_FIXTURE(BlendTreeFixture, "[SceneTree][Blendalot][BlendTreeGraph][EmbeddedBlendTree] BlendTree with an embedded BlendTree subgraph") { + // Embedded BlendTree + Ref embedded_blend_tree; + embedded_blend_tree.instantiate(); + + // TestAnimationB + Ref animation_sampler_node_b; + animation_sampler_node_b.instantiate(); + animation_sampler_node_b->animation_name = "animation_library/TestAnimationB"; + + embedded_blend_tree->add_node(animation_sampler_node_b); + embedded_blend_tree->add_connection(animation_sampler_node_b, embedded_blend_tree->get_output_node(), "Output"); + + Ref blend_tree; + blend_tree.instantiate(); + + // Blend2 + Ref blend2; + blend2.instantiate(); + blend2->set_name("Blend2"); + blend2->blend_weight = 0.5; + blend2->sync = true; + + blend_tree->add_node(blend2); + + // TestAnimationA + Ref animation_sampler_node_a; + animation_sampler_node_a.instantiate(); + animation_sampler_node_a->animation_name = "animation_library/TestAnimationA"; + + blend_tree->add_node(animation_sampler_node_a); + + blend_tree->add_node(embedded_blend_tree); + + blend_tree->add_connection(animation_sampler_node_a, blend2, "Input0"); + blend_tree->add_connection(embedded_blend_tree, blend2, "Input1"); + blend_tree->add_connection(blend2, blend_tree->get_output_node(), "Output"); + + // Trigger initialization + animation_graph->set_root_animation_node(blend_tree); + GraphEvaluationContext &graph_context = animation_graph->get_context(); + REQUIRE(blend_tree->initialize(graph_context)); + + // Perform evaluation + AnimationData *graph_output = graph_context.animation_data_allocator.allocate(); + blend_tree->activate_inputs(Vector>()); + blend_tree->calculate_sync_track(Vector>()); + blend_tree->update_time(0.1); + blend_tree->evaluate(graph_context, LocalVector(), *graph_output); + + // Check values + AnimationData::TransformTrackValue *hip_transform_value = graph_output->get_value(test_animation_a->get_tracks()[0]->thash); + CHECK(hip_transform_value->loc[0] == doctest::Approx(0.15)); + CHECK(hip_transform_value->loc[1] == doctest::Approx(0.3)); + CHECK(hip_transform_value->loc[2] == doctest::Approx(0.45)); +} + } //namespace TestBlendalotAnimationGraph \ No newline at end of file