From 306a2cb4d8a5f353339bf8665ed571477f9e32b5 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Tue, 22 Feb 2022 22:49:12 +0100 Subject: [PATCH] Minor fix to node input splitting. Not sure it is a good idea anymore, though... --- src/AnimGraphResource.cc | 24 ++++++++---------------- src/AnimGraphResource.h | 22 ++++++++++++++++------ 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/AnimGraphResource.cc b/src/AnimGraphResource.cc index 1695d20..3b211e9 100644 --- a/src/AnimGraphResource.cc +++ b/src/AnimGraphResource.cc @@ -392,18 +392,9 @@ void AnimGraph::MarkActiveNodes() { m_nodes[i]->m_state = AnimNodeEvalState::Deactivated; } - const std::vector graph_output_anim_inputs = m_node_anim_inputs[0]; - for (size_t i = 0, n = graph_output_anim_inputs.size(); i < n; i++) { - const NodeInput& graph_input = graph_output_anim_inputs[i]; - AnimNode* node = graph_input.m_node; - if (node != nullptr) { - node->m_state = AnimNodeEvalState::Activated; - } - } - - const std::vector graph_output_data_inputs = m_node_data_inputs[0]; - for (size_t i = 0, n = graph_output_data_inputs.size(); i < n; i++) { - const NodeInput& graph_input = graph_output_data_inputs[i]; + const std::vector graph_output_inputs = m_node_inputs[0]; + for (size_t i = 0, n = graph_output_inputs.size(); i < n; i++) { + const NodeInput& graph_input = graph_output_inputs[i]; AnimNode* node = graph_input.m_node; if (node != nullptr) { node->m_state = AnimNodeEvalState::Activated; @@ -416,10 +407,11 @@ void AnimGraph::MarkActiveNodes() { int node_index = getAnimNodeIndex(node); node->MarkActiveInputs(m_node_anim_inputs[node_index]); - for (size_t j = 0, nj = m_node_data_inputs[node_index].size(); j < nj; j++) { - const NodeInput& data_input = m_node_data_inputs[node_index][j]; - if (data_input.m_node != nullptr) { - data_input.m_node->m_state = AnimNodeEvalState::Activated; + // Non-animation data inputs are always active. + for (size_t j = 0, nj = m_node_inputs[node_index].size(); j < nj; j++) { + const NodeInput& input = m_node_inputs[node_index][j]; + if (input.m_node != nullptr && input.m_type != SocketType::SocketTypeAnimation) { + input.m_node->m_state = AnimNodeEvalState::Activated; } } } diff --git a/src/AnimGraphResource.h b/src/AnimGraphResource.h index 9d4e666..da5d912 100644 --- a/src/AnimGraphResource.h +++ b/src/AnimGraphResource.h @@ -84,6 +84,7 @@ struct AnimNodeResource { struct NodeInput { AnimNode* m_node; + SocketType m_type = SocketType::SocketTypeUndefined; std::string m_input_name; }; @@ -611,8 +612,8 @@ struct AnimGraph { std::vector m_nodes; std::vector m_eval_ordered_nodes; + std::vector > m_node_inputs; std::vector > m_node_anim_inputs; - std::vector > m_node_data_inputs; NodeSocketAccessorBase* m_socket_accessor; char* m_input_buffer = nullptr; char* m_output_buffer = nullptr; @@ -681,10 +682,10 @@ struct AnimGraph { result.m_nodes.push_back(node); 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()); - result.m_node_data_inputs.push_back(std::vector()); std::vector& node_anim_inputs = result.m_node_anim_inputs.back(); - std::vector& node_data_inputs = result.m_node_data_inputs.back(); for (int j = 0, n = node_resource.m_socket_accessor->m_inputs.size(); j < n; @@ -694,12 +695,13 @@ struct AnimGraph { NodeInput input; input.m_node = nullptr; + input.m_type = input_socket.m_type; 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); - } else { - node_data_inputs.push_back(input); } } } @@ -829,13 +831,21 @@ struct AnimGraph { size_t target_node_index = result.getAnimNodeIndex(target_node); std::vector& node_inputs = - result.m_node_anim_inputs[target_node_index]; + result.m_node_inputs[target_node_index]; for (int j = 0, n = node_inputs.size(); j < n; j++) { if (node_inputs[j].m_input_name == target_socket->m_name) { node_inputs[j].m_node = source_node; } } + 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; }