Started working on graph initialization in ATP Editor.
This commit is contained in:
@@ -190,8 +190,8 @@ TEST_CASE_METHOD(
|
||||
graph_context.m_animation_map["trans_y"] = animation_translate_y.get();
|
||||
|
||||
// Instantiate graph
|
||||
AnimGraph graph = graph_resource.createInstance();
|
||||
graph_context.m_graph = &graph;
|
||||
AnimGraph graph;
|
||||
graph_resource.createInstance(graph);
|
||||
graph.init(graph_context);
|
||||
|
||||
// Get runtime graph inputs and outputs
|
||||
|
||||
@@ -74,9 +74,9 @@ TEST_CASE("BasicGraph", "[AnimGraphResource]") {
|
||||
AnimGraphResource graph_resource_loaded;
|
||||
graph_resource_loaded.loadFromFile("WalkGraph.animgraph.json");
|
||||
|
||||
AnimGraph graph = graph_resource_loaded.createInstance();
|
||||
AnimGraph graph;
|
||||
graph_resource_loaded.createInstance(graph);
|
||||
AnimGraphContext graph_context;
|
||||
graph_context.m_graph = &graph;
|
||||
|
||||
ozz::animation::Skeleton skeleton;
|
||||
REQUIRE(load_skeleton(skeleton, "data/skeleton.ozz"));
|
||||
@@ -283,7 +283,8 @@ TEST_CASE("ResourceSaveLoadMathGraphInputs", "[AnimGraphResource]") {
|
||||
!= nullptr);
|
||||
|
||||
WHEN("Instantiating an AnimGraph") {
|
||||
AnimGraph anim_graph = graph_resource_loaded.createInstance();
|
||||
AnimGraph anim_graph;
|
||||
graph_resource_loaded.createInstance(anim_graph);
|
||||
|
||||
REQUIRE(anim_graph.getInputSocket("GraphFloatInput") != nullptr);
|
||||
REQUIRE(
|
||||
@@ -418,7 +419,8 @@ TEST_CASE("SimpleMathEvaluations", "[AnimGraphResource]") {
|
||||
graph_resource_loaded.m_nodes[1];
|
||||
|
||||
WHEN("Instantiating an AnimGraph") {
|
||||
AnimGraph anim_graph = graph_resource_loaded.createInstance();
|
||||
AnimGraph anim_graph;
|
||||
graph_resource_loaded.createInstance(anim_graph);
|
||||
|
||||
REQUIRE(anim_graph.getInputSocket("GraphFloatInput") != nullptr);
|
||||
REQUIRE(
|
||||
@@ -495,12 +497,12 @@ TEST_CASE("SimpleMathEvaluations", "[AnimGraphResource]") {
|
||||
}
|
||||
|
||||
TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
|
||||
AnimGraphResource graph_resource;
|
||||
AnimGraphResource sGraphGresource;
|
||||
|
||||
graph_resource.clear();
|
||||
graph_resource.m_name = "TestGraphInputOutputConnectivity";
|
||||
sGraphGresource.clear();
|
||||
sGraphGresource.m_name = "TestGraphInputOutputConnectivity";
|
||||
|
||||
AnimNodeResource& graph_output_node = graph_resource.m_nodes[0];
|
||||
AnimNodeResource& graph_output_node = sGraphGresource.m_nodes[0];
|
||||
graph_output_node.m_socket_accessor->RegisterInput<float>(
|
||||
"GraphFloatOutput",
|
||||
nullptr);
|
||||
@@ -508,7 +510,7 @@ TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
|
||||
"GraphAnimOutput",
|
||||
nullptr);
|
||||
|
||||
AnimNodeResource& graph_input_node = graph_resource.m_nodes[1];
|
||||
AnimNodeResource& graph_input_node = sGraphGresource.m_nodes[1];
|
||||
graph_input_node.m_socket_accessor->RegisterOutput<float>(
|
||||
"GraphFloatInput",
|
||||
nullptr);
|
||||
@@ -523,13 +525,13 @@ TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
|
||||
nullptr);
|
||||
|
||||
WHEN("Connecting float input with float output") {
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
graph_resource.getGraphInputNode(),
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
sGraphGresource.getGraphInputNode(),
|
||||
"GraphFloatInput",
|
||||
graph_resource.getGraphOutputNode(),
|
||||
sGraphGresource.getGraphOutputNode(),
|
||||
"GraphFloatOutput"));
|
||||
|
||||
AnimGraph anim_graph = graph_resource.createInstance();
|
||||
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");
|
||||
@@ -545,18 +547,18 @@ TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
|
||||
|
||||
WHEN("Connecting adding a Blend2 node") {
|
||||
size_t blend2_node_index =
|
||||
graph_resource.addNode(AnimNodeResourceFactory("Blend2"));
|
||||
sGraphGresource.addNode(AnimNodeResourceFactory("Blend2"));
|
||||
AnimNodeResource& blend2_node_resource =
|
||||
graph_resource.m_nodes[blend2_node_index];
|
||||
sGraphGresource.m_nodes[blend2_node_index];
|
||||
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
graph_resource.getGraphInputNode(),
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
sGraphGresource.getGraphInputNode(),
|
||||
"GraphFloatInput",
|
||||
blend2_node_resource,
|
||||
"Weight"));
|
||||
|
||||
THEN("Connected float input points to the blend weight.") {
|
||||
AnimGraph anim_graph = graph_resource.createInstance();
|
||||
AnimGraph anim_graph = sGraphGresource.createInstance();
|
||||
|
||||
Blend2Node* blend2_node =
|
||||
dynamic_cast<Blend2Node*>(anim_graph.m_nodes[blend2_node_index]);
|
||||
@@ -571,28 +573,28 @@ TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
|
||||
WHEN(
|
||||
"Connecting AnimData inputs to blend2 node and blend2 output to graph "
|
||||
"output.") {
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
graph_resource.getGraphInputNode(),
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
sGraphGresource.getGraphInputNode(),
|
||||
"GraphAnimInput0",
|
||||
blend2_node_resource,
|
||||
"Input0"));
|
||||
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
graph_resource.getGraphInputNode(),
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
sGraphGresource.getGraphInputNode(),
|
||||
"GraphAnimInput1",
|
||||
blend2_node_resource,
|
||||
"Input1"));
|
||||
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
blend2_node_resource,
|
||||
"Output",
|
||||
graph_resource.getGraphOutputNode(),
|
||||
sGraphGresource.getGraphOutputNode(),
|
||||
"GraphAnimOutput"));
|
||||
|
||||
THEN(
|
||||
"AnimData from output gets blended and result is written to "
|
||||
"Output.") {
|
||||
AnimGraph anim_graph = graph_resource.createInstance();
|
||||
AnimGraph anim_graph = sGraphGresource.createInstance();
|
||||
|
||||
Blend2Node* blend2_node =
|
||||
dynamic_cast<Blend2Node*>(anim_graph.m_nodes[blend2_node_index]);
|
||||
@@ -623,57 +625,57 @@ TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
|
||||
|
||||
WHEN("Adding AnimSampler Nodes") {
|
||||
size_t blend2_node_index =
|
||||
graph_resource.addNode(AnimNodeResourceFactory("Blend2"));
|
||||
sGraphGresource.addNode(AnimNodeResourceFactory("Blend2"));
|
||||
size_t sampler_node_index =
|
||||
graph_resource.addNode(AnimNodeResourceFactory("AnimSampler"));
|
||||
sGraphGresource.addNode(AnimNodeResourceFactory("AnimSampler"));
|
||||
size_t speed_scale_node_index =
|
||||
graph_resource.addNode(AnimNodeResourceFactory("SpeedScale"));
|
||||
sGraphGresource.addNode(AnimNodeResourceFactory("SpeedScale"));
|
||||
|
||||
AnimNodeResource& blend2_node_resource =
|
||||
graph_resource.m_nodes[blend2_node_index];
|
||||
sGraphGresource.m_nodes[blend2_node_index];
|
||||
AnimNodeResource& sampler_node_resource =
|
||||
graph_resource.m_nodes[sampler_node_index];
|
||||
sGraphGresource.m_nodes[sampler_node_index];
|
||||
AnimNodeResource& speed_scale_node_resource =
|
||||
graph_resource.m_nodes[speed_scale_node_index];
|
||||
sGraphGresource.m_nodes[speed_scale_node_index];
|
||||
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
graph_resource.getGraphInputNode(),
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
sGraphGresource.getGraphInputNode(),
|
||||
"GraphFloatInput",
|
||||
blend2_node_resource,
|
||||
"Weight"));
|
||||
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
graph_resource.getGraphInputNode(),
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
sGraphGresource.getGraphInputNode(),
|
||||
"SpeedScaleInput",
|
||||
speed_scale_node_resource,
|
||||
"SpeedScale"));
|
||||
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
graph_resource.getGraphInputNode(),
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
sGraphGresource.getGraphInputNode(),
|
||||
"GraphAnimInput0",
|
||||
blend2_node_resource,
|
||||
"Input0"));
|
||||
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
sampler_node_resource,
|
||||
"Output",
|
||||
speed_scale_node_resource,
|
||||
"Input"));
|
||||
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
speed_scale_node_resource,
|
||||
"Output",
|
||||
blend2_node_resource,
|
||||
"Input1"));
|
||||
|
||||
REQUIRE(graph_resource.connectSockets(
|
||||
REQUIRE(sGraphGresource.connectSockets(
|
||||
blend2_node_resource,
|
||||
"Output",
|
||||
graph_resource.getGraphOutputNode(),
|
||||
sGraphGresource.getGraphOutputNode(),
|
||||
"GraphAnimOutput"));
|
||||
|
||||
THEN("Data flow and node ordering must be correct.") {
|
||||
AnimGraph anim_graph = graph_resource.createInstance();
|
||||
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*>(
|
||||
@@ -727,7 +729,7 @@ TEST_CASE("GraphInputOutputConnectivity", "[AnimGraphResource]") {
|
||||
}
|
||||
|
||||
WHEN("Instantiating graph") {
|
||||
AnimGraph anim_graph = graph_resource.createInstance();
|
||||
AnimGraph anim_graph = sGraphGresource.createInstance();
|
||||
float* blend_weight_input =
|
||||
reinterpret_cast<float*>(anim_graph.getInput("GraphFloatInput"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user