Initial step for connectivity refactor.
Instead of wiring up pointers with prepareNodeEval() and finishNodeEval() use for each connection a single memory block where outputs and inputs point to.
This commit is contained in:
@@ -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->SetPropertyValue("Filename", "trans_x");
|
||||
trans_x_node.m_socket_accessor->SetProperty("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->SetPropertyValue("Filename", "trans_y");
|
||||
trans_y_node.m_socket_accessor->SetProperty("Filename", std::string("trans_y"));
|
||||
trans_y_node.m_name = "trans_y";
|
||||
|
||||
AnimNodeResource& blend_node = graph_resource.m_nodes[blend_node_index];
|
||||
|
||||
+14
-358
@@ -48,9 +48,9 @@ TEST_CASE("BasicGraph", "[AnimGraphResource]") {
|
||||
|
||||
AnimNodeResource& walk_node = graph_resource.m_nodes[walk_node_index];
|
||||
walk_node.m_name = "WalkAnim";
|
||||
walk_node.m_socket_accessor->SetPropertyValue("Filename", "data/walk.anim.ozz");
|
||||
walk_node.m_socket_accessor->SetProperty("Filename", std::string("data/walk.anim.ozz"));
|
||||
AnimNodeResource& run_node = graph_resource.m_nodes[run_node_index];
|
||||
run_node.m_socket_accessor->SetPropertyValue("Filename", "data/run.anim.ozz");
|
||||
run_node.m_socket_accessor->SetProperty("Filename", std::string("data/run.anim.ozz"));
|
||||
run_node.m_name = "RunAnim";
|
||||
AnimNodeResource& blend_node = graph_resource.m_nodes[blend_node_index];
|
||||
blend_node.m_name = "BlendWalkRun";
|
||||
@@ -132,46 +132,33 @@ TEST_CASE("BasicGraph", "[AnimGraphResource]") {
|
||||
CHECK(graph.m_anim_data_allocator.size() == 0);
|
||||
graph.prepareNodeEval(graph_context, walk_node_index);
|
||||
graph.finishNodeEval(walk_node_index);
|
||||
CHECK(graph.m_anim_data_allocator.m_num_allocations == 1);
|
||||
CHECK(graph.m_anim_data_allocator.size() == 0);
|
||||
|
||||
graph.prepareNodeEval(graph_context, run_node_index);
|
||||
graph.finishNodeEval(run_node_index);
|
||||
CHECK(graph.m_anim_data_allocator.m_num_allocations == 2);
|
||||
CHECK(graph.m_anim_data_allocator.size() == 0);
|
||||
|
||||
graph.prepareNodeEval(graph_context, blend_node_index);
|
||||
CHECK(blend2_instance->i_input0 == anim_sampler_walk->o_output);
|
||||
CHECK(blend2_instance->i_input1 == anim_sampler_run->o_output);
|
||||
CHECK(graph.m_anim_data_allocator.m_num_allocations == 3);
|
||||
CHECK(graph.m_anim_data_allocator.size() == 0);
|
||||
|
||||
graph.finishNodeEval(blend_node_index);
|
||||
CHECK(anim_sampler_walk->o_output == nullptr);
|
||||
CHECK(anim_sampler_run->o_output == nullptr);
|
||||
CHECK(graph.m_anim_data_allocator.m_num_allocations == 3);
|
||||
CHECK(graph.m_anim_data_allocator.size() == 2);
|
||||
|
||||
// Evaluate output node.
|
||||
graph.evalOutputNode();
|
||||
graph.finishNodeEval(0);
|
||||
|
||||
|
||||
const Socket* graph_output_socket = graph.getOutputSocket("GraphOutput");
|
||||
AnimData* graph_output =
|
||||
static_cast<AnimData*>(graph_output_socket->m_reference.ptr);
|
||||
static_cast<AnimData*>(*graph_output_socket->m_reference.ptr_ptr);
|
||||
|
||||
CHECK(graph_output->m_local_matrices.size() == graph_context.m_skeleton->num_soa_joints());
|
||||
|
||||
CHECK(graph.m_anim_data_allocator.m_num_allocations == 3);
|
||||
CHECK(graph.m_anim_data_allocator.size() == 3);
|
||||
|
||||
CHECK(blend2_instance->o_output == nullptr);
|
||||
CHECK(blend2_instance->o_output == *graph_output_socket->m_reference.ptr_ptr);
|
||||
}
|
||||
|
||||
graph_context.freeAnimations();
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("InputAttributeConversion", "[AnimGraphResource]") {
|
||||
int node_id = 3321;
|
||||
int input_index = 221;
|
||||
@@ -191,6 +178,7 @@ TEST_CASE("InputAttributeConversion", "[AnimGraphResource]") {
|
||||
CHECK(output_index == parsed_output_index);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("ResourceSaveLoadMathGraphInputs", "[AnimGraphResource]") {
|
||||
AnimGraphResource graph_resource_origin;
|
||||
|
||||
@@ -269,16 +257,16 @@ TEST_CASE("ResourceSaveLoadMathGraphInputs", "[AnimGraphResource]") {
|
||||
== graph_loaded_input_node.m_socket_accessor->m_outputs.size());
|
||||
|
||||
REQUIRE(
|
||||
graph_loaded_input_node.m_socket_accessor->FindOutputSocket(
|
||||
graph_loaded_input_node.m_socket_accessor->GetOutputSocket(
|
||||
"GraphFloatInput")
|
||||
!= nullptr);
|
||||
|
||||
REQUIRE(
|
||||
graph_loaded_output_node.m_socket_accessor->FindInputSocket(
|
||||
graph_loaded_output_node.m_socket_accessor->GetInputSocket(
|
||||
"GraphFloatOutput")
|
||||
!= nullptr);
|
||||
REQUIRE(
|
||||
graph_loaded_output_node.m_socket_accessor->FindInputSocket(
|
||||
graph_loaded_output_node.m_socket_accessor->GetInputSocket(
|
||||
"GraphVec3Output")
|
||||
!= nullptr);
|
||||
|
||||
@@ -312,9 +300,9 @@ TEST_CASE("ResourceSaveLoadMathGraphInputs", "[AnimGraphResource]") {
|
||||
*static_cast<Vec3*>(vec3_output_socket->m_reference.ptr);
|
||||
|
||||
THEN("output vector components equal the graph input vaulues") {
|
||||
CHECK(vec3_output[0] == *graph_float_input);
|
||||
CHECK(vec3_output[1] == *graph_float_input);
|
||||
CHECK(vec3_output[2] == *graph_float_input);
|
||||
CHECK(vec3_output.v[0] == *graph_float_input);
|
||||
CHECK(vec3_output.v[1] == *graph_float_input);
|
||||
CHECK(vec3_output.v[2] == *graph_float_input);
|
||||
}
|
||||
|
||||
context.freeAnimations();
|
||||
@@ -324,6 +312,7 @@ TEST_CASE("ResourceSaveLoadMathGraphInputs", "[AnimGraphResource]") {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
TEST_CASE("SimpleMathEvaluations", "[AnimGraphResource]") {
|
||||
AnimGraphResource graph_resource_origin;
|
||||
|
||||
@@ -470,337 +459,4 @@ TEST_CASE("SimpleMathEvaluations", "[AnimGraphResource]") {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
WHEN("Connecting input to output and instantiating the graph") {
|
||||
AnimNodeResource& graph_output_node = graph_resource_origin.m_nodes[0];
|
||||
AnimNodeResource& graph_input_node = graph_resource_origin.m_nodes[1];
|
||||
|
||||
REQUIRE(graph_resource_origin.connectSockets(
|
||||
graph_input_node,
|
||||
"GraphAnimInput",
|
||||
graph_output_node,
|
||||
"GraphOutput"));
|
||||
|
||||
AnimGraph anim_graph = graph_resource_origin.createInstance();
|
||||
|
||||
void* graph_anim_input_ptr = anim_graph.getInput("GraphAnimInput");
|
||||
void* graph_output_ptr = anim_graph.getOutput("GraphOutput");
|
||||
|
||||
REQUIRE(graph_anim_input_ptr == graph_output_ptr);
|
||||
REQUIRE(graph_output_ptr == anim_graph.m_output_buffer);
|
||||
|
||||
REQUIRE(
|
||||
anim_graph.getInput("GraphAnimInput")
|
||||
== anim_graph.getOutput("GraphOutput"));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
|
||||
AnimGraphResource sGraphGresource;
|
||||
|
||||
sGraphGresource.clear();
|
||||
sGraphGresource.m_name = "TestGraphInputOutputConnectivity";
|
||||
|
||||
AnimNodeResource& graph_output_node = sGraphGresource.m_nodes[0];
|
||||
graph_output_node.m_socket_accessor->RegisterInput<float>(
|
||||
"GraphFloatOutput",
|
||||
nullptr);
|
||||
graph_output_node.m_socket_accessor->RegisterInput<AnimData>(
|
||||
"GraphAnimOutput",
|
||||
nullptr);
|
||||
|
||||
AnimNodeResource& graph_input_node = sGraphGresource.m_nodes[1];
|
||||
graph_input_node.m_socket_accessor->RegisterOutput<float>(
|
||||
"GraphFloatInput",
|
||||
nullptr);
|
||||
graph_input_node.m_socket_accessor->RegisterOutput<float>(
|
||||
"SpeedScaleInput",
|
||||
nullptr);
|
||||
graph_input_node.m_socket_accessor->RegisterOutput<AnimData>(
|
||||
"GraphAnimInput0",
|
||||
nullptr);
|
||||
graph_input_node.m_socket_accessor->RegisterOutput<AnimData>(
|
||||
"GraphAnimInput1",
|
||||
nullptr);
|
||||
|
||||
WHEN("Connecting float input with float output") {
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
sGraphGresource.getGraphInputNode(),
|
||||
"GraphFloatInput",
|
||||
sGraphGresource.getGraphOutputNode(),
|
||||
"GraphFloatOutput"));
|
||||
|
||||
AnimGraph anim_graph = sGraphGresource.createInstance();
|
||||
|
||||
THEN("Writing to the input pointer changes the value of the output.") {
|
||||
float* float_input_ptr = (float*)anim_graph.getInput("GraphFloatInput");
|
||||
REQUIRE(float_input_ptr != nullptr);
|
||||
*float_input_ptr = 23.123f;
|
||||
|
||||
float* float_output_ptr =
|
||||
(float*)anim_graph.getOutput("GraphFloatOutput");
|
||||
REQUIRE(float_output_ptr != nullptr);
|
||||
CHECK(*float_output_ptr == Approx(23.123f));
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("Connecting adding a Blend2 node") {
|
||||
size_t blend2_node_index =
|
||||
sGraphGresource.addNode(AnimNodeResourceFactory("Blend2"));
|
||||
AnimNodeResource& blend2_node_resource =
|
||||
sGraphGresource.m_nodes[blend2_node_index];
|
||||
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
sGraphGresource.getGraphInputNode(),
|
||||
"GraphFloatInput",
|
||||
blend2_node_resource,
|
||||
"Weight"));
|
||||
|
||||
THEN("Connected float input points to the blend weight.") {
|
||||
AnimGraph anim_graph = sGraphGresource.createInstance();
|
||||
|
||||
Blend2Node* blend2_node =
|
||||
dynamic_cast<Blend2Node*>(anim_graph.m_nodes[blend2_node_index]);
|
||||
|
||||
REQUIRE(
|
||||
*anim_graph.m_socket_accessor->m_outputs[0].m_reference.ptr_ptr
|
||||
== blend2_node->i_blend_weight);
|
||||
float* float_input_ptr = (float*)anim_graph.getInput("GraphFloatInput");
|
||||
REQUIRE(float_input_ptr == blend2_node->i_blend_weight);
|
||||
}
|
||||
|
||||
WHEN(
|
||||
"Connecting AnimData inputs to blend2 node and blend2 output to graph "
|
||||
"output.") {
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
sGraphGresource.getGraphInputNode(),
|
||||
"GraphAnimInput0",
|
||||
blend2_node_resource,
|
||||
"Input0"));
|
||||
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
sGraphGresource.getGraphInputNode(),
|
||||
"GraphAnimInput1",
|
||||
blend2_node_resource,
|
||||
"Input1"));
|
||||
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
blend2_node_resource,
|
||||
"Output",
|
||||
sGraphGresource.getGraphOutputNode(),
|
||||
"GraphAnimOutput"));
|
||||
|
||||
THEN(
|
||||
"AnimData from output gets blended and result is written to "
|
||||
"Output.") {
|
||||
AnimGraph anim_graph = sGraphGresource.createInstance();
|
||||
|
||||
Blend2Node* blend2_node =
|
||||
dynamic_cast<Blend2Node*>(anim_graph.m_nodes[blend2_node_index]);
|
||||
|
||||
AnimData* graph_input0 =
|
||||
(AnimData*)anim_graph.getInput("GraphAnimInput0");
|
||||
REQUIRE(graph_input0 == blend2_node->i_input0);
|
||||
REQUIRE(
|
||||
anim_graph.m_nodes[1]
|
||||
== anim_graph.getAnimNodeForInput(blend2_node_index, "Input0"));
|
||||
|
||||
AnimData* graph_input1 =
|
||||
(AnimData*)anim_graph.getInput("GraphAnimInput1");
|
||||
REQUIRE(graph_input1 == blend2_node->i_input1);
|
||||
REQUIRE(
|
||||
anim_graph.m_nodes[1]
|
||||
== anim_graph.getAnimNodeForInput(blend2_node_index, "Input1"));
|
||||
|
||||
AnimData* graph_output =
|
||||
(AnimData*)anim_graph.getOutput("GraphAnimOutput");
|
||||
REQUIRE(graph_output == blend2_node->o_output);
|
||||
REQUIRE(
|
||||
anim_graph.m_nodes[blend2_node_index]
|
||||
== anim_graph.getAnimNodeForInput(0, "GraphAnimOutput"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("Adding AnimSampler Nodes") {
|
||||
size_t blend2_node_index =
|
||||
sGraphGresource.addNode(AnimNodeResourceFactory("Blend2"));
|
||||
size_t sampler_node_index =
|
||||
sGraphGresource.addNode(AnimNodeResourceFactory("AnimSampler"));
|
||||
size_t speed_scale_node_index =
|
||||
sGraphGresource.addNode(AnimNodeResourceFactory("SpeedScale"));
|
||||
|
||||
AnimNodeResource& blend2_node_resource =
|
||||
sGraphGresource.m_nodes[blend2_node_index];
|
||||
AnimNodeResource& sampler_node_resource =
|
||||
sGraphGresource.m_nodes[sampler_node_index];
|
||||
AnimNodeResource& speed_scale_node_resource =
|
||||
sGraphGresource.m_nodes[speed_scale_node_index];
|
||||
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
sGraphGresource.getGraphInputNode(),
|
||||
"GraphFloatInput",
|
||||
blend2_node_resource,
|
||||
"Weight"));
|
||||
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
sGraphGresource.getGraphInputNode(),
|
||||
"SpeedScaleInput",
|
||||
speed_scale_node_resource,
|
||||
"SpeedScale"));
|
||||
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
sGraphGresource.getGraphInputNode(),
|
||||
"GraphAnimInput0",
|
||||
blend2_node_resource,
|
||||
"Input0"));
|
||||
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
sampler_node_resource,
|
||||
"Output",
|
||||
speed_scale_node_resource,
|
||||
"Input"));
|
||||
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
speed_scale_node_resource,
|
||||
"Output",
|
||||
blend2_node_resource,
|
||||
"Input1"));
|
||||
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
blend2_node_resource,
|
||||
"Output",
|
||||
sGraphGresource.getGraphOutputNode(),
|
||||
"GraphAnimOutput"));
|
||||
|
||||
THEN("Data flow and node ordering must be correct.") {
|
||||
AnimGraph anim_graph = sGraphGresource.createInstance();
|
||||
Blend2Node* blend2_node =
|
||||
dynamic_cast<Blend2Node*>(anim_graph.m_nodes[blend2_node_index]);
|
||||
SpeedScaleNode* speed_scale_node = dynamic_cast<SpeedScaleNode*>(
|
||||
anim_graph.m_nodes[speed_scale_node_index]);
|
||||
AnimSamplerNode* sampler_node = dynamic_cast<AnimSamplerNode*>(
|
||||
anim_graph.m_nodes[sampler_node_index]);
|
||||
|
||||
//
|
||||
// check connectivity
|
||||
//
|
||||
AnimData* graph_input0 =
|
||||
(AnimData*)anim_graph.getInput("GraphAnimInput0");
|
||||
REQUIRE(graph_input0 == blend2_node->i_input0);
|
||||
REQUIRE(
|
||||
anim_graph.m_nodes[1]
|
||||
== anim_graph.getAnimNodeForInput(blend2_node_index, "Input0"));
|
||||
|
||||
AnimData* graph_input1 =
|
||||
(AnimData*)anim_graph.getInput("GraphAnimInput1");
|
||||
REQUIRE(graph_input1 == nullptr);
|
||||
|
||||
REQUIRE(sampler_node->o_output == speed_scale_node->i_input);
|
||||
REQUIRE(
|
||||
sampler_node
|
||||
== anim_graph.getAnimNodeForInput(speed_scale_node_index, "Input"));
|
||||
|
||||
REQUIRE(speed_scale_node->o_output == blend2_node->i_input1);
|
||||
REQUIRE(
|
||||
speed_scale_node
|
||||
== anim_graph.getAnimNodeForInput(blend2_node_index, "Input1"));
|
||||
|
||||
AnimData* graph_output =
|
||||
(AnimData*)anim_graph.getOutput("GraphAnimOutput");
|
||||
REQUIRE(graph_output == blend2_node->o_output);
|
||||
REQUIRE(
|
||||
anim_graph.m_nodes[blend2_node_index]
|
||||
== anim_graph.getAnimNodeForInput(0, "GraphAnimOutput"));
|
||||
|
||||
//
|
||||
// check ordering
|
||||
//
|
||||
REQUIRE(
|
||||
anim_graph.getNodeEvalOrderIndex(blend2_node)
|
||||
< anim_graph.getNodeEvalOrderIndex(sampler_node));
|
||||
REQUIRE(
|
||||
anim_graph.getNodeEvalOrderIndex(blend2_node)
|
||||
< anim_graph.getNodeEvalOrderIndex(speed_scale_node));
|
||||
REQUIRE(
|
||||
anim_graph.getNodeEvalOrderIndex(speed_scale_node)
|
||||
< anim_graph.getNodeEvalOrderIndex(sampler_node));
|
||||
}
|
||||
|
||||
WHEN("Instantiating graph") {
|
||||
AnimGraph anim_graph = sGraphGresource.createInstance();
|
||||
float* blend_weight_input =
|
||||
reinterpret_cast<float*>(anim_graph.getInput("GraphFloatInput"));
|
||||
|
||||
Blend2Node* blend2_node =
|
||||
dynamic_cast<Blend2Node*>(anim_graph.m_nodes[blend2_node_index]);
|
||||
SpeedScaleNode* speed_scale_node = dynamic_cast<SpeedScaleNode*>(
|
||||
anim_graph.m_nodes[speed_scale_node_index]);
|
||||
AnimSamplerNode* sampler_node = dynamic_cast<AnimSamplerNode*>(
|
||||
anim_graph.m_nodes[sampler_node_index]);
|
||||
|
||||
WHEN("Setting weight to 0. and marking nodes active.") {
|
||||
*blend_weight_input = 0.;
|
||||
anim_graph.markActiveNodes();
|
||||
|
||||
THEN("Speed scale and sampler node are inactive") {
|
||||
REQUIRE(anim_graph.checkIsNodeActive(speed_scale_node) == false);
|
||||
REQUIRE(anim_graph.checkIsNodeActive(sampler_node) == false);
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("Setting weight to 0. and marking nodes active") {
|
||||
*blend_weight_input = 0.1;
|
||||
anim_graph.markActiveNodes();
|
||||
|
||||
THEN("Speed scale and sampler nodes are active") {
|
||||
REQUIRE(anim_graph.checkIsNodeActive(speed_scale_node) == true);
|
||||
REQUIRE(anim_graph.checkIsNodeActive(sampler_node) == true);
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("Setting weight to 1. and marking nodes active") {
|
||||
*blend_weight_input = 1.0;
|
||||
anim_graph.markActiveNodes();
|
||||
|
||||
THEN("Speed scale and sampler nodes are active") {
|
||||
REQUIRE(anim_graph.checkIsNodeActive(speed_scale_node) == true);
|
||||
REQUIRE(anim_graph.checkIsNodeActive(sampler_node) == true);
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("Updating time with dt = 0.3f and speed scale = 1.0f") {
|
||||
float* speed_scale_input =
|
||||
reinterpret_cast<float*>(anim_graph.getInput("SpeedScaleInput"));
|
||||
|
||||
*blend_weight_input = 0.1;
|
||||
*speed_scale_input = 1.0f;
|
||||
|
||||
anim_graph.markActiveNodes();
|
||||
anim_graph.updateTime(0.3f);
|
||||
|
||||
THEN ("Anim sampler node time now must be 0.3f") {
|
||||
REQUIRE(sampler_node->m_time_now == Approx(0.3f));
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("Updating time with dt = 0.3f and speed scale = 1.3f") {
|
||||
float* speed_scale_input =
|
||||
reinterpret_cast<float*>(anim_graph.getInput("SpeedScaleInput"));
|
||||
|
||||
*blend_weight_input = 0.1;
|
||||
*speed_scale_input = 1.3f;
|
||||
|
||||
anim_graph.markActiveNodes();
|
||||
anim_graph.updateTime(0.3f);
|
||||
|
||||
THEN ("Anim sampler node time now must be 0.39f") {
|
||||
REQUIRE(sampler_node->m_time_now == Approx(0.39f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
*/
|
||||
Reference in New Issue
Block a user