Simple graph output connection working.

This commit is contained in:
Martin Felis
2022-02-12 11:46:50 +01:00
parent c2ae0a11d2
commit 2b7cbe9d4c
2 changed files with 58 additions and 135 deletions
+14 -7
View File
@@ -27,7 +27,7 @@ TEST_CASE("BasicGraph", "[AnimGraphResource]") {
walk_node.m_name = "BlendWalkRun";
AnimNodeResource& graph_node = graph_resource.m_nodes[0];
graph_node.m_socket_accessor->RegisterInput<AnimData>("Output", nullptr);
graph_node.m_socket_accessor->RegisterInput<AnimData>("GraphOutput", nullptr);
REQUIRE(graph_node.m_socket_accessor->m_inputs.size() == 1);
REQUIRE(blend_node.m_socket_accessor->GetInputIndex("Input0") == 0);
@@ -57,7 +57,7 @@ TEST_CASE("BasicGraph", "[AnimGraphResource]") {
blend_node.m_socket_accessor->GetOutputIndex("Output");
blend_to_output.m_target_node_index = 0;
blend_to_output.m_target_socket_index =
graph_node.m_socket_accessor->GetInputIndex("Output");
graph_node.m_socket_accessor->GetInputIndex("GraphOutput");
graph_resource.m_connections.push_back(blend_to_output);
graph_resource.saveToFile("WalkGraph.animgraph.json");
@@ -70,12 +70,13 @@ TEST_CASE("BasicGraph", "[AnimGraphResource]") {
<< std::endl;
}
CHECK(graph.m_nodes.size() == 4);
CHECK(graph.m_nodes[0]->m_node_type_name == "Graph");
CHECK(graph.m_nodes[1]->m_node_type_name == "AnimSampler");
CHECK(graph.m_nodes[2]->m_node_type_name == "AnimSampler");
CHECK(graph.m_nodes[3]->m_node_type_name == "Blend2");
REQUIRE(graph.m_nodes.size() == 4);
REQUIRE(graph.m_nodes[0]->m_node_type_name == "BlendTree");
REQUIRE(graph.m_nodes[1]->m_node_type_name == "AnimSampler");
REQUIRE(graph.m_nodes[2]->m_node_type_name == "AnimSampler");
REQUIRE(graph.m_nodes[3]->m_node_type_name == "Blend2");
// connections within the graph
AnimSamplerNode* anim_sampler_instance0 =
dynamic_cast<AnimSamplerNode*>(graph.m_nodes[1]);
AnimSamplerNode* anim_sampler_instance1 =
@@ -84,6 +85,12 @@ TEST_CASE("BasicGraph", "[AnimGraphResource]") {
CHECK(anim_sampler_instance0->m_output == &blend2_instance->m_input0);
CHECK(anim_sampler_instance1->m_output == &blend2_instance->m_input1);
// connections from graph to the graph node
CHECK(graph.m_socket_accessor->m_inputs.size() == 1);
CHECK(graph.m_socket_accessor->FindInputSocket("GraphOutput"));
CHECK(reinterpret_cast<char*>(blend2_instance->m_output) == graph.m_input_buffer);
// check node input dependencies
size_t anim_sampler_index0 = graph.getAnimNodeIndex(anim_sampler_instance0);
size_t anim_sampler_index1 = graph.getAnimNodeIndex(anim_sampler_instance1);
size_t blend_index = graph.getAnimNodeIndex(blend2_instance);