Minor fix to node input splitting. Not sure it is a good idea anymore, though...

AnimGraphEditor
Martin Felis 2022-02-22 22:49:12 +01:00
parent ef74f39cf4
commit 306a2cb4d8
2 changed files with 24 additions and 22 deletions

View File

@ -392,18 +392,9 @@ void AnimGraph::MarkActiveNodes() {
m_nodes[i]->m_state = AnimNodeEvalState::Deactivated; m_nodes[i]->m_state = AnimNodeEvalState::Deactivated;
} }
const std::vector<NodeInput> graph_output_anim_inputs = m_node_anim_inputs[0]; const std::vector<NodeInput> graph_output_inputs = m_node_inputs[0];
for (size_t i = 0, n = graph_output_anim_inputs.size(); i < n; i++) { for (size_t i = 0, n = graph_output_inputs.size(); i < n; i++) {
const NodeInput& graph_input = graph_output_anim_inputs[i]; const NodeInput& graph_input = graph_output_inputs[i];
AnimNode* node = graph_input.m_node;
if (node != nullptr) {
node->m_state = AnimNodeEvalState::Activated;
}
}
const std::vector<NodeInput> 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];
AnimNode* node = graph_input.m_node; AnimNode* node = graph_input.m_node;
if (node != nullptr) { if (node != nullptr) {
node->m_state = AnimNodeEvalState::Activated; node->m_state = AnimNodeEvalState::Activated;
@ -416,10 +407,11 @@ void AnimGraph::MarkActiveNodes() {
int node_index = getAnimNodeIndex(node); int node_index = getAnimNodeIndex(node);
node->MarkActiveInputs(m_node_anim_inputs[node_index]); node->MarkActiveInputs(m_node_anim_inputs[node_index]);
for (size_t j = 0, nj = m_node_data_inputs[node_index].size(); j < nj; j++) { // Non-animation data inputs are always active.
const NodeInput& data_input = m_node_data_inputs[node_index][j]; for (size_t j = 0, nj = m_node_inputs[node_index].size(); j < nj; j++) {
if (data_input.m_node != nullptr) { const NodeInput& input = m_node_inputs[node_index][j];
data_input.m_node->m_state = AnimNodeEvalState::Activated; if (input.m_node != nullptr && input.m_type != SocketType::SocketTypeAnimation) {
input.m_node->m_state = AnimNodeEvalState::Activated;
} }
} }
} }

View File

@ -84,6 +84,7 @@ struct AnimNodeResource {
struct NodeInput { struct NodeInput {
AnimNode* m_node; AnimNode* m_node;
SocketType m_type = SocketType::SocketTypeUndefined;
std::string m_input_name; std::string m_input_name;
}; };
@ -611,8 +612,8 @@ struct AnimGraph {
std::vector<AnimNode*> m_nodes; std::vector<AnimNode*> m_nodes;
std::vector<AnimNode*> m_eval_ordered_nodes; std::vector<AnimNode*> m_eval_ordered_nodes;
std::vector<std::vector<NodeInput> > m_node_inputs;
std::vector<std::vector<NodeInput> > m_node_anim_inputs; std::vector<std::vector<NodeInput> > m_node_anim_inputs;
std::vector<std::vector<NodeInput> > m_node_data_inputs;
NodeSocketAccessorBase* m_socket_accessor; NodeSocketAccessorBase* m_socket_accessor;
char* m_input_buffer = nullptr; char* m_input_buffer = nullptr;
char* m_output_buffer = nullptr; char* m_output_buffer = nullptr;
@ -681,10 +682,10 @@ struct AnimGraph {
result.m_nodes.push_back(node); result.m_nodes.push_back(node);
assert(node_resource.m_socket_accessor != nullptr); assert(node_resource.m_socket_accessor != nullptr);
result.m_node_inputs.push_back(std::vector<NodeInput>());
std::vector<NodeInput>& node_inputs = result.m_node_inputs.back();
result.m_node_anim_inputs.push_back(std::vector<NodeInput>()); result.m_node_anim_inputs.push_back(std::vector<NodeInput>());
result.m_node_data_inputs.push_back(std::vector<NodeInput>());
std::vector<NodeInput>& node_anim_inputs = result.m_node_anim_inputs.back(); std::vector<NodeInput>& node_anim_inputs = result.m_node_anim_inputs.back();
std::vector<NodeInput>& node_data_inputs = result.m_node_data_inputs.back();
for (int j = 0, n = node_resource.m_socket_accessor->m_inputs.size(); for (int j = 0, n = node_resource.m_socket_accessor->m_inputs.size();
j < n; j < n;
@ -694,12 +695,13 @@ struct AnimGraph {
NodeInput input; NodeInput input;
input.m_node = nullptr; input.m_node = nullptr;
input.m_type = input_socket.m_type;
input.m_input_name = input_socket.m_name; input.m_input_name = input_socket.m_name;
node_inputs.push_back(input);
if (input_socket.m_type == SocketType::SocketTypeAnimation) { if (input_socket.m_type == SocketType::SocketTypeAnimation) {
node_anim_inputs.push_back(input); 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); size_t target_node_index = result.getAnimNodeIndex(target_node);
std::vector<NodeInput>& node_inputs = std::vector<NodeInput>& 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++) { for (int j = 0, n = node_inputs.size(); j < n; j++) {
if (node_inputs[j].m_input_name == target_socket->m_name) { if (node_inputs[j].m_input_name == target_socket->m_name) {
node_inputs[j].m_node = source_node; node_inputs[j].m_node = source_node;
} }
} }
std::vector<NodeInput>& 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) { if (target_node_accessor != result.m_socket_accessor) {
delete target_node_accessor; delete target_node_accessor;
} }