Refactoring.

This commit is contained in:
Martin Felis
2022-03-25 12:05:56 +01:00
parent 6c0c0599f8
commit abddbea62b
4 changed files with 260 additions and 255 deletions
+11 -9
View File
@@ -65,7 +65,7 @@ TEST_CASE("BasicGraph", "[AnimGraphResource]") {
graph_resource.saveToFile("WalkGraph.animgraph.json");
AnimGraph graph = AnimGraph::createFromResource(graph_resource);
AnimGraph graph = graph_resource.createInstance();
REQUIRE(graph.m_nodes.size() == 5);
REQUIRE(graph.m_nodes[0]->m_node_type_name == "BlendTree");
@@ -192,8 +192,8 @@ TEST_CASE("ResourceSaveLoadGraphInputs", "[AnimGraphResource]") {
}
WHEN("Instantiating an AnimGraph") {
AnimGraph anim_graph =
AnimGraph::createFromResource(graph_resource_loaded);
AnimGraph anim_graph = graph_resource_loaded.createInstance();
REQUIRE(
anim_graph.getOutput("GraphOutput") == anim_graph.m_output_buffer);
REQUIRE(
@@ -216,7 +216,7 @@ TEST_CASE("ResourceSaveLoadGraphInputs", "[AnimGraphResource]") {
graph_output_node,
"GraphOutput"));
AnimGraph anim_graph = AnimGraph::createFromResource(graph_resource_origin);
AnimGraph anim_graph = graph_resource_origin.createInstance();
void* graph_anim_input_ptr = anim_graph.getInput("GraphAnimInput");
void* graph_output_ptr = anim_graph.getOutput("GraphOutput");
@@ -265,7 +265,7 @@ TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
graph_resource.getGraphOutputNode(),
"GraphFloatOutput"));
AnimGraph anim_graph = AnimGraph::createFromResource(graph_resource);
AnimGraph anim_graph = graph_resource.createInstance();
THEN("Writing to the input pointer changes the value of the output.") {
float* float_input_ptr = (float*)anim_graph.getInput("GraphFloatInput");
@@ -292,7 +292,8 @@ TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
"Weight"));
THEN("Connected float input points to the blend weight.") {
AnimGraph anim_graph = AnimGraph::createFromResource(graph_resource);
AnimGraph anim_graph = graph_resource.createInstance();
Blend2Node* blend2_node =
dynamic_cast<Blend2Node*>(anim_graph.m_nodes[blend2_node_index]);
@@ -327,7 +328,8 @@ TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
THEN(
"AnimData from output gets blended and result is written to "
"Output.") {
AnimGraph anim_graph = AnimGraph::createFromResource(graph_resource);
AnimGraph anim_graph = graph_resource.createInstance();
Blend2Node* blend2_node =
dynamic_cast<Blend2Node*>(anim_graph.m_nodes[blend2_node_index]);
@@ -407,7 +409,7 @@ TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
"GraphAnimOutput"));
THEN("Data flow and node ordering must be correct.") {
AnimGraph anim_graph = AnimGraph::createFromResource(graph_resource);
AnimGraph anim_graph = graph_resource.createInstance();
Blend2Node* blend2_node =
dynamic_cast<Blend2Node*>(anim_graph.m_nodes[blend2_node_index]);
SpeedScaleNode* speed_scale_node = dynamic_cast<SpeedScaleNode*>(
@@ -461,7 +463,7 @@ TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
}
WHEN("Instantiating graph") {
AnimGraph anim_graph = AnimGraph::createFromResource(graph_resource);
AnimGraph anim_graph = graph_resource.createInstance();
float* blend_weight_input =
reinterpret_cast<float*>(anim_graph.getInput("GraphFloatInput"));