WIP AnimGraph instantiation.
This commit is contained in:
@@ -8,41 +8,56 @@
|
||||
TEST_CASE("BasicGraph", "[AnimGraphResource]") {
|
||||
AnimGraphResource graph_resource;
|
||||
|
||||
graph_resource.clear();
|
||||
graph_resource.m_name = "WalkRunBlendGraph";
|
||||
|
||||
AnimNodeResource walk_node;
|
||||
// Prepare graph inputs and outputs
|
||||
size_t walk_node_index =
|
||||
graph_resource.addNode(AnimNodeResourceFactory("AnimSampler"));
|
||||
size_t run_node_index =
|
||||
graph_resource.addNode(AnimNodeResourceFactory("AnimSampler"));
|
||||
size_t blend_node_index =
|
||||
graph_resource.addNode(AnimNodeResourceFactory("Blend2"));
|
||||
|
||||
AnimNodeResource& walk_node = graph_resource.m_nodes[walk_node_index];
|
||||
walk_node.m_name = "WalkAnim";
|
||||
walk_node.m_type_name = "AnimSampler";
|
||||
graph_resource.m_nodes.push_back(walk_node);
|
||||
AnimNodeResource& run_node = graph_resource.m_nodes[run_node_index];
|
||||
walk_node.m_name = "RunAnim";
|
||||
AnimNodeResource& blend_node = graph_resource.m_nodes[blend_node_index];
|
||||
walk_node.m_name = "BlendWalkRun";
|
||||
|
||||
AnimNodeResource run_node;
|
||||
run_node.m_name = "RunAnim";
|
||||
run_node.m_type_name = "AnimSampler";
|
||||
graph_resource.m_nodes.push_back(run_node);
|
||||
AnimNodeResource& graph_node = graph_resource.m_nodes[0];
|
||||
graph_node.m_socket_accessor->RegisterInput<AnimData>("Output", nullptr);
|
||||
|
||||
AnimNodeResource blend_node;
|
||||
blend_node.m_name = "BlendWalkRun";
|
||||
blend_node.m_type_name = "Blend2";
|
||||
graph_resource.m_nodes.push_back(blend_node);
|
||||
REQUIRE(graph_node.m_socket_accessor->m_inputs.size() == 1);
|
||||
REQUIRE(blend_node.m_socket_accessor->GetInputIndex("Input0") == 0);
|
||||
REQUIRE(blend_node.m_socket_accessor->GetInputIndex("Input1") == 1);
|
||||
|
||||
AnimGraphConnection walk_to_blend;
|
||||
walk_to_blend.m_source_node = &walk_node;
|
||||
walk_to_blend.m_source_socket_name = "Output";
|
||||
walk_to_blend.m_target_node = &blend_node;
|
||||
walk_to_blend.m_target_socket_name = "Input0";
|
||||
walk_to_blend.m_source_node_index = walk_node_index;
|
||||
walk_to_blend.m_source_socket_index =
|
||||
walk_node.m_socket_accessor->GetOutputIndex("Output");
|
||||
walk_to_blend.m_target_node_index = blend_node_index;
|
||||
walk_to_blend.m_target_socket_index =
|
||||
blend_node.m_socket_accessor->GetInputIndex("Input0");
|
||||
graph_resource.m_connections.push_back(walk_to_blend);
|
||||
|
||||
AnimGraphConnection run_to_blend;
|
||||
run_to_blend.m_source_node = &run_node;
|
||||
run_to_blend.m_source_socket_name = "Output";
|
||||
run_to_blend.m_target_node = &blend_node;
|
||||
run_to_blend.m_target_socket_name = "Input1";
|
||||
run_to_blend.m_source_node_index = run_node_index;
|
||||
run_to_blend.m_source_socket_index =
|
||||
run_node.m_socket_accessor->GetOutputIndex("Output");
|
||||
run_to_blend.m_target_node_index = blend_node_index;
|
||||
run_to_blend.m_target_socket_index =
|
||||
blend_node.m_socket_accessor->GetInputIndex("Input1");
|
||||
graph_resource.m_connections.push_back(run_to_blend);
|
||||
|
||||
AnimGraphConnection blend_to_output;
|
||||
blend_to_output.m_source_node = &blend_node;
|
||||
blend_to_output.m_source_socket_name = "Output";
|
||||
blend_to_output.m_target_socket_name = "GraphOutput";
|
||||
blend_to_output.m_source_node_index = blend_node_index;
|
||||
blend_to_output.m_source_socket_index =
|
||||
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_resource.m_connections.push_back(blend_to_output);
|
||||
|
||||
graph_resource.saveToFile("WalkGraph.animgraph.json");
|
||||
@@ -55,16 +70,17 @@ TEST_CASE("BasicGraph", "[AnimGraphResource]") {
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
CHECK(graph.m_nodes.size() == 3);
|
||||
CHECK(graph.m_nodes[0]->m_node_type_name == "AnimSampler");
|
||||
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 == "Blend2");
|
||||
CHECK(graph.m_nodes[2]->m_node_type_name == "AnimSampler");
|
||||
CHECK(graph.m_nodes[3]->m_node_type_name == "Blend2");
|
||||
|
||||
AnimSamplerNode* anim_sampler_instance0 =
|
||||
dynamic_cast<AnimSamplerNode*>(graph.m_nodes[0]);
|
||||
AnimSamplerNode* anim_sampler_instance1 =
|
||||
dynamic_cast<AnimSamplerNode*>(graph.m_nodes[1]);
|
||||
Blend2Node* blend2_instance = dynamic_cast<Blend2Node*>(graph.m_nodes[2]);
|
||||
AnimSamplerNode* anim_sampler_instance1 =
|
||||
dynamic_cast<AnimSamplerNode*>(graph.m_nodes[2]);
|
||||
Blend2Node* blend2_instance = dynamic_cast<Blend2Node*>(graph.m_nodes[3]);
|
||||
CHECK(anim_sampler_instance0->m_output == &blend2_instance->m_input0);
|
||||
CHECK(anim_sampler_instance1->m_output == &blend2_instance->m_input1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user