Added test for embedded blend tree evaluation.
This commit is contained in:
parent
be6e021198
commit
06198d595f
@ -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<BLTAnimationNodeBlendTree> embedded_blend_tree;
|
||||
embedded_blend_tree.instantiate();
|
||||
|
||||
// TestAnimationB
|
||||
Ref<BLTAnimationNodeSampler> 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<BLTAnimationNodeBlendTree> blend_tree;
|
||||
blend_tree.instantiate();
|
||||
|
||||
// Blend2
|
||||
Ref<BLTAnimationNodeBlend2> blend2;
|
||||
blend2.instantiate();
|
||||
blend2->set_name("Blend2");
|
||||
blend2->blend_weight = 0.5;
|
||||
blend2->sync = true;
|
||||
|
||||
blend_tree->add_node(blend2);
|
||||
|
||||
// TestAnimationA
|
||||
Ref<BLTAnimationNodeSampler> 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<Ref<BLTAnimationNode>>());
|
||||
blend_tree->calculate_sync_track(Vector<Ref<BLTAnimationNode>>());
|
||||
blend_tree->update_time(0.1);
|
||||
blend_tree->evaluate(graph_context, LocalVector<AnimationData *>(), *graph_output);
|
||||
|
||||
// Check values
|
||||
AnimationData::TransformTrackValue *hip_transform_value = graph_output->get_value<AnimationData::TransformTrackValue>(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
|
||||
Loading…
x
Reference in New Issue
Block a user