Refactored anim graph data usage and evaluation.
- Refactored NodeSocketAccessor to NodeDescriptor. - Connections are wired up during AnimGraph instantiation. - Output and input sockets point to the same memory location. - No re-wiring needed during evaluation. - AnimGraph are pre-allocated (refactoring for less memory usage postponed). - Evaluation of AnimGraph now possible from the editor.
This commit is contained in:
+10
-12
@@ -153,11 +153,11 @@ TEST_CASE_METHOD(
|
||||
|
||||
// Setup nodes
|
||||
AnimNodeResource& trans_x_node = graph_resource.m_nodes[trans_x_node_index];
|
||||
trans_x_node.m_socket_accessor->SetProperty("Filename", std::string("trans_x"));
|
||||
trans_x_node.m_socket_accessor->SetPropertyValue("Filename", std::string("trans_x"));
|
||||
trans_x_node.m_name = "trans_x";
|
||||
|
||||
AnimNodeResource& trans_y_node = graph_resource.m_nodes[trans_y_node_index];
|
||||
trans_y_node.m_socket_accessor->SetProperty("Filename", std::string("trans_y"));
|
||||
trans_y_node.m_socket_accessor->SetPropertyValue("Filename", std::string("trans_y"));
|
||||
trans_y_node.m_name = "trans_y";
|
||||
|
||||
AnimNodeResource& blend_node = graph_resource.m_nodes[blend_node_index];
|
||||
@@ -195,17 +195,15 @@ TEST_CASE_METHOD(
|
||||
graph.init(graph_context);
|
||||
|
||||
// Get runtime graph inputs and outputs
|
||||
float* graph_float_input = nullptr;
|
||||
graph_float_input =
|
||||
static_cast<float*>(graph.getInputPtr("GraphFloatInput"));
|
||||
float graph_float_input = 0.f;
|
||||
graph.SetInput("GraphFloatInput", &graph_float_input);
|
||||
|
||||
Socket* anim_output_socket =
|
||||
graph.getOutputSocket("GraphOutput");
|
||||
|
||||
AnimData* graph_anim_output = static_cast<AnimData*>(graph.getOutputPtr("GraphOutput"));
|
||||
AnimData graph_anim_output;
|
||||
graph_anim_output.m_local_matrices.resize(skeleton->num_joints());
|
||||
graph.SetOutput("GraphOutput", &graph_anim_output);
|
||||
|
||||
// Evaluate graph
|
||||
*graph_float_input = 0.1f;
|
||||
graph_float_input = 0.1f;
|
||||
|
||||
graph.markActiveNodes();
|
||||
CHECK(graph.m_nodes[trans_x_node_index]->m_state == AnimNodeEvalState::Activated);
|
||||
@@ -215,6 +213,6 @@ TEST_CASE_METHOD(
|
||||
graph.updateTime(0.5f);
|
||||
graph.evaluate(graph_context);
|
||||
|
||||
CHECK(graph_anim_output->m_local_matrices[0].translation.x[0] == Approx(0.5).margin(0.1));
|
||||
CHECK(graph_anim_output->m_local_matrices[0].translation.y[0] == Approx(0.05).margin(0.01));
|
||||
CHECK(graph_anim_output.m_local_matrices[0].translation.x[0] == Approx(0.5).margin(0.1));
|
||||
CHECK(graph_anim_output.m_local_matrices[0].translation.y[0] == Approx(0.05).margin(0.01));
|
||||
}
|
||||
Reference in New Issue
Block a user