Added node ordering code and tests.
This commit is contained in:
+125
-19
@@ -269,7 +269,7 @@ TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
|
||||
|
||||
AnimGraph anim_graph = AnimGraph::createFromResource(graph_resource);
|
||||
|
||||
THEN ("Writing to the input pointer changes the value of the output.") {
|
||||
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;
|
||||
@@ -282,8 +282,10 @@ TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
|
||||
}
|
||||
|
||||
WHEN("Connecting adding a Blend2 node") {
|
||||
size_t blend2_node_index = graph_resource.addNode(AnimNodeResourceFactory("Blend2"));
|
||||
AnimNodeResource& blend2_node_resource = graph_resource.m_nodes[blend2_node_index];
|
||||
size_t blend2_node_index =
|
||||
graph_resource.addNode(AnimNodeResourceFactory("Blend2"));
|
||||
AnimNodeResource& blend2_node_resource =
|
||||
graph_resource.m_nodes[blend2_node_index];
|
||||
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
graph_resource.getGraphInputNode(),
|
||||
@@ -291,17 +293,21 @@ TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
|
||||
blend2_node_resource,
|
||||
"Weight"));
|
||||
|
||||
THEN ("Connected float input points to the blend weight.") {
|
||||
THEN("Connected float input points to the blend weight.") {
|
||||
AnimGraph anim_graph = AnimGraph::createFromResource(graph_resource);
|
||||
Blend2Node* blend2_node = dynamic_cast<Blend2Node*>(anim_graph.m_nodes[blend2_node_index]);
|
||||
Blend2Node* blend2_node =
|
||||
dynamic_cast<Blend2Node*>(anim_graph.m_nodes[blend2_node_index]);
|
||||
|
||||
REQUIRE (*anim_graph.m_socket_accessor->m_outputs[0].m_value.ptr_ptr == &blend2_node->m_blend_weight);
|
||||
REQUIRE(
|
||||
*anim_graph.m_socket_accessor->m_outputs[0].m_value.ptr_ptr
|
||||
== &blend2_node->m_blend_weight);
|
||||
float* float_input_ptr = (float*)anim_graph.GetInput("GraphFloatInput");
|
||||
REQUIRE (float_input_ptr == &blend2_node->m_blend_weight);
|
||||
REQUIRE(float_input_ptr == &blend2_node->m_blend_weight);
|
||||
}
|
||||
|
||||
|
||||
WHEN ("Connecting AnimData inputs to blend2 node and blend2 output to graph output.") {
|
||||
WHEN(
|
||||
"Connecting AnimData inputs to blend2 node and blend2 output to graph "
|
||||
"output.") {
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
graph_resource.getGraphInputNode(),
|
||||
"GraphAnimInput0",
|
||||
@@ -318,25 +324,125 @@ TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
|
||||
blend2_node_resource,
|
||||
"Output",
|
||||
graph_resource.getGraphOutputNode(),
|
||||
"GraphAnimOutput"
|
||||
));
|
||||
"GraphAnimOutput"));
|
||||
|
||||
THEN("AnimData from output gets blended and result is written to Output.") {
|
||||
THEN(
|
||||
"AnimData from output gets blended and result is written to "
|
||||
"Output.") {
|
||||
AnimGraph anim_graph = AnimGraph::createFromResource(graph_resource);
|
||||
Blend2Node* blend2_node = dynamic_cast<Blend2Node*>(anim_graph.m_nodes[blend2_node_index]);
|
||||
Blend2Node* blend2_node =
|
||||
dynamic_cast<Blend2Node*>(anim_graph.m_nodes[blend2_node_index]);
|
||||
|
||||
AnimData* graph_input0 = (AnimData*) anim_graph.GetInput("GraphAnimInput0");
|
||||
AnimData* graph_input0 =
|
||||
(AnimData*)anim_graph.GetInput("GraphAnimInput0");
|
||||
REQUIRE(graph_input0 == &blend2_node->m_input0);
|
||||
REQUIRE(anim_graph.m_nodes[1] == anim_graph.getAnimNodeForInput(blend2_node_index, "Input0"));
|
||||
REQUIRE(
|
||||
anim_graph.m_nodes[1]
|
||||
== anim_graph.getAnimNodeForInput(blend2_node_index, "Input0"));
|
||||
|
||||
AnimData* graph_input1 = (AnimData*) anim_graph.GetInput("GraphAnimInput1");
|
||||
AnimData* graph_input1 =
|
||||
(AnimData*)anim_graph.GetInput("GraphAnimInput1");
|
||||
REQUIRE(graph_input1 == &blend2_node->m_input1);
|
||||
REQUIRE(anim_graph.m_nodes[1] == anim_graph.getAnimNodeForInput(blend2_node_index, "Input1"));
|
||||
REQUIRE(
|
||||
anim_graph.m_nodes[1]
|
||||
== anim_graph.getAnimNodeForInput(blend2_node_index, "Input1"));
|
||||
|
||||
AnimData* graph_output = (AnimData*) anim_graph.GetOutput("GraphAnimOutput");
|
||||
AnimData* graph_output =
|
||||
(AnimData*)anim_graph.GetOutput("GraphAnimOutput");
|
||||
REQUIRE(graph_output == blend2_node->m_output);
|
||||
REQUIRE(anim_graph.m_nodes[blend2_node_index] == anim_graph.getAnimNodeForInput(0, "GraphAnimOutput"));
|
||||
REQUIRE(
|
||||
anim_graph.m_nodes[blend2_node_index]
|
||||
== anim_graph.getAnimNodeForInput(0, "GraphAnimOutput"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("Adding AnimSampler Nodes") {
|
||||
size_t blend2_node_index =
|
||||
graph_resource.addNode(AnimNodeResourceFactory("Blend2"));
|
||||
size_t sampler_node_index =
|
||||
graph_resource.addNode(AnimNodeResourceFactory("AnimSampler"));
|
||||
size_t speed_scale_node_index =
|
||||
graph_resource.addNode(AnimNodeResourceFactory("SpeedScale"));
|
||||
|
||||
AnimNodeResource& blend2_node_resource =
|
||||
graph_resource.m_nodes[blend2_node_index];
|
||||
AnimNodeResource& sampler_node_resource =
|
||||
graph_resource.m_nodes[sampler_node_index];
|
||||
AnimNodeResource& speed_scale_node_resource =
|
||||
graph_resource.m_nodes[speed_scale_node_index];
|
||||
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
graph_resource.getGraphInputNode(),
|
||||
"GraphFloatInput",
|
||||
blend2_node_resource,
|
||||
"Weight"));
|
||||
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
graph_resource.getGraphInputNode(),
|
||||
"GraphAnimInput0",
|
||||
blend2_node_resource,
|
||||
"Input0"));
|
||||
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
sampler_node_resource,
|
||||
"Output",
|
||||
speed_scale_node_resource,
|
||||
"Input"));
|
||||
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
speed_scale_node_resource,
|
||||
"Output",
|
||||
blend2_node_resource,
|
||||
"Input1"));
|
||||
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
blend2_node_resource,
|
||||
"Output",
|
||||
graph_resource.getGraphOutputNode(),
|
||||
"GraphAnimOutput"));
|
||||
|
||||
THEN("Data flow and node ordering must be correct.") {
|
||||
AnimGraph anim_graph = AnimGraph::createFromResource(graph_resource);
|
||||
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]);
|
||||
|
||||
AnimData* graph_input0 =
|
||||
(AnimData*)anim_graph.GetInput("GraphAnimInput0");
|
||||
REQUIRE(graph_input0 == &blend2_node->m_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->m_output == &speed_scale_node->m_input);
|
||||
REQUIRE(
|
||||
sampler_node
|
||||
== anim_graph.getAnimNodeForInput(speed_scale_node_index, "Input"));
|
||||
|
||||
REQUIRE(speed_scale_node->m_output == &blend2_node->m_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->m_output);
|
||||
REQUIRE(
|
||||
anim_graph.m_nodes[blend2_node_index]
|
||||
== anim_graph.getAnimNodeForInput(0, "GraphAnimOutput"));
|
||||
|
||||
// Check ordering
|
||||
REQUIRE (anim_graph.getAnimNodeOrderIndex(blend2_node) < anim_graph.getAnimNodeOrderIndex(sampler_node));
|
||||
REQUIRE (anim_graph.getAnimNodeOrderIndex(blend2_node) < anim_graph.getAnimNodeOrderIndex(speed_scale_node));
|
||||
REQUIRE (anim_graph.getAnimNodeOrderIndex(speed_scale_node) < anim_graph.getAnimNodeOrderIndex(sampler_node));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user