Started working on evaluating embedded blend trees.

This commit is contained in:
Martin Felis
2024-03-25 22:26:29 +01:00
parent 99f11e61d8
commit 0aebe44bd5
7 changed files with 96 additions and 37 deletions
+36
View File
@@ -181,6 +181,7 @@ class EmbeddedBlendTreeGraphResource {
parent_blend_tree_resource->m_nodes.back());
embedded_graph->m_name = "EmbeddedBlendTree";
embedded_graph->m_node_type_name = "BlendTree";
embedded_graph->m_graph_type_name = "BlendTree";
embedded_blend_tree_resource = &embedded_graph->m_blend_tree_resource;
// Embedded: outputs
@@ -202,6 +203,7 @@ class EmbeddedBlendTreeGraphResource {
AnimNodeResourceFactory("SpeedScale"));
AnimNodeResource* embedded_speed_scale_resource =
embedded_blend_tree_resource->m_nodes.back();
embedded_speed_scale_resource->m_socket_accessor->SetInputValue("SpeedScale", 0.1f);
// Embedded: setup connections
embedded_blend_tree_resource->ConnectSockets(
@@ -1021,4 +1023,38 @@ TEST_CASE_METHOD(
embedded_connection.target_socket_name
== embedded_connection_loaded.target_socket_name);
}
}
TEST_CASE_METHOD(
EmbeddedBlendTreeGraphResource,
"EmbeddedBlendTreeGraphResource instantiation",
"[EmbeddedBlendTreeGraphResource]") {
AnimGraphBlendTree blend_tree;
parent_graph_resource.CreateBlendTreeInstance(blend_tree);
AnimGraphContext graph_context;
ozz::animation::Skeleton skeleton;
REQUIRE(load_skeleton(skeleton, "media/skeleton.ozz"));
graph_context.m_skeleton = &skeleton;
blend_tree.Init(graph_context);
// Marking of active inputs is not properly working as we do not properly
// populate AnimNode::m_inputs.
//
// Here comes an iffy problem: How to mark nodes in a parent blend tree
// as active?
//
// - Simplest would be if the AnimNodes don't distinguish between nodes within
// the tree they are contained or in a possible parent (or nested) tree.
// - But then how to propagate active connections across multiple layers?
// - Therefore probably better to have a blend tree store which sockets are
// active and use that within the graph.
// - But then: AnimGraphConnection already stores raw AnimNode pointers of the
// connected nodes. Still... populating them accross layers could be messy.
blend_tree.MarkActiveInputs();
blend_tree.UpdateTime(0.f, 0.1f);
blend_tree.Evaluate(graph_context);
graph_context.freeAnimations();
}