From d6453911e28a8da0b3eb51f2a8391b3f5bd11c6e Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Thu, 24 Feb 2022 22:06:47 +0100 Subject: [PATCH] Removed node input splitting. --- src/AnimGraphResource.cc | 17 ++++++++++------- src/AnimGraphResource.h | 19 ++----------------- tests/AnimGraphResourceTests.cc | 11 ++++++----- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/src/AnimGraphResource.cc b/src/AnimGraphResource.cc index 3b211e9..6a46f62 100644 --- a/src/AnimGraphResource.cc +++ b/src/AnimGraphResource.cc @@ -359,7 +359,7 @@ void AnimGraph::UpdateOrderedNodes() { while (node_index_stack.size() > 0) { std::vector& node_inputs = - m_node_anim_inputs[node_index_stack.back()]; + m_node_inputs[node_index_stack.back()]; node_index_stack.pop_back(); for (size_t i = 0, n = node_inputs.size(); i < n; i++) { @@ -405,7 +405,7 @@ void AnimGraph::MarkActiveNodes() { AnimNode* node = m_eval_ordered_nodes[i]; if (CheckIsNodeActive(node)) { int node_index = getAnimNodeIndex(node); - node->MarkActiveInputs(m_node_anim_inputs[node_index]); + node->MarkActiveInputs(m_node_inputs[node_index]); // Non-animation data inputs are always active. for (size_t j = 0, nj = m_node_inputs[node_index].size(); j < nj; j++) { @@ -419,7 +419,7 @@ void AnimGraph::MarkActiveNodes() { } void AnimGraph::UpdateTime(float dt) { - const std::vector graph_output_inputs = m_node_anim_inputs[0]; + const std::vector graph_output_inputs = m_node_inputs[0]; for (size_t i = 0, n = graph_output_inputs.size(); i < n; i++) { AnimNode* node = m_eval_ordered_nodes[i]; if (node != nullptr) { @@ -434,14 +434,17 @@ void AnimGraph::UpdateTime(float dt) { } int node_index = getAnimNodeIndex(node); - const std::vector node_anim_inputs = - m_node_anim_inputs[node_index]; + const std::vector node_inputs = + m_node_inputs[node_index]; float node_time_now = node->m_time_now; float node_time_last = node->m_time_last; - for (size_t i = 0, n = node_anim_inputs.size(); i < n; i++) { - AnimNode* input_node = node_anim_inputs[i].m_node; + for (size_t i = 0, n = node_inputs.size(); i < n; i++) { + AnimNode* input_node = node_inputs[i].m_node; + + // Only propagate time updates via animation sockets. if (input_node != nullptr + && node_inputs[i].m_type == SocketType::SocketTypeAnimation && input_node->m_state == AnimNodeEvalState::Activated) { input_node->UpdateTime(node_time_last, node_time_now); } diff --git a/src/AnimGraphResource.h b/src/AnimGraphResource.h index da5d912..d6ef851 100644 --- a/src/AnimGraphResource.h +++ b/src/AnimGraphResource.h @@ -613,7 +613,6 @@ struct AnimGraph { std::vector m_nodes; std::vector m_eval_ordered_nodes; std::vector > m_node_inputs; - std::vector > m_node_anim_inputs; NodeSocketAccessorBase* m_socket_accessor; char* m_input_buffer = nullptr; char* m_output_buffer = nullptr; @@ -637,9 +636,9 @@ struct AnimGraph { size_t node_index, const std::string& input_name) { assert(node_index < m_nodes.size()); - assert(node_index < m_node_anim_inputs.size()); + assert(node_index < m_node_inputs.size()); - std::vector& node_inputs = m_node_anim_inputs[node_index]; + std::vector& node_inputs = m_node_inputs[node_index]; for (size_t i = 0, n = node_inputs.size(); i < n; i++) { if (node_inputs[i].m_input_name == input_name) { return node_inputs[i].m_node; @@ -684,8 +683,6 @@ struct AnimGraph { assert(node_resource.m_socket_accessor != nullptr); result.m_node_inputs.push_back(std::vector()); std::vector& node_inputs = result.m_node_inputs.back(); - result.m_node_anim_inputs.push_back(std::vector()); - std::vector& node_anim_inputs = result.m_node_anim_inputs.back(); for (int j = 0, n = node_resource.m_socket_accessor->m_inputs.size(); j < n; @@ -699,10 +696,6 @@ struct AnimGraph { input.m_input_name = input_socket.m_name; node_inputs.push_back(input); - - if (input_socket.m_type == SocketType::SocketTypeAnimation) { - node_anim_inputs.push_back(input); - } } } @@ -838,14 +831,6 @@ struct AnimGraph { } } - std::vector& node_anim_inputs = - result.m_node_anim_inputs[target_node_index]; - for (int j = 0, n = node_anim_inputs.size(); j < n; j++) { - if (node_anim_inputs[j].m_input_name == target_socket->m_name) { - node_anim_inputs[j].m_node = source_node; - } - } - if (target_node_accessor != result.m_socket_accessor) { delete target_node_accessor; } diff --git a/tests/AnimGraphResourceTests.cc b/tests/AnimGraphResourceTests.cc index e2f32a2..cdb8df6 100644 --- a/tests/AnimGraphResourceTests.cc +++ b/tests/AnimGraphResourceTests.cc @@ -94,11 +94,12 @@ TEST_CASE("BasicGraph", "[AnimGraphResource]") { size_t anim_sampler_index1 = graph.getAnimNodeIndex(anim_sampler_instance1); size_t blend_index = graph.getAnimNodeIndex(blend2_instance); - CHECK(graph.m_node_anim_inputs[anim_sampler_index0].size() == 0); - CHECK(graph.m_node_anim_inputs[anim_sampler_index1].size() == 0); - CHECK(graph.m_node_anim_inputs[blend_index].size() == 2); - CHECK(graph.m_node_anim_inputs[blend_index][0].m_node == anim_sampler_instance0); - CHECK(graph.m_node_anim_inputs[blend_index][1].m_node == anim_sampler_instance1); + CHECK(graph.m_node_inputs[anim_sampler_index0].size() == 0); + CHECK(graph.m_node_inputs[anim_sampler_index1].size() == 0); + CHECK(graph.m_node_inputs[blend_index].size() == 3); + CHECK(graph.m_node_inputs[blend_index][0].m_node == anim_sampler_instance0); + CHECK(graph.m_node_inputs[blend_index][1].m_node == anim_sampler_instance1); + CHECK(graph.m_node_inputs[blend_index][2].m_node == nullptr); } TEST_CASE("InputAttributeConversion", "[AnimGraphResource]") {