diff --git a/src/AnimGraph/AnimGraphResource.h b/src/AnimGraph/AnimGraphResource.h index 8fbec99..fb19cc3 100644 --- a/src/AnimGraph/AnimGraphResource.h +++ b/src/AnimGraph/AnimGraphResource.h @@ -101,7 +101,33 @@ struct BlendTreeResource { return -1; } + void CreateUniqueNodeName(AnimNodeResource* node_resource) { + std::string node_name = node_resource->m_name; + if (node_name.empty()) { + node_name = node_resource->m_node_type_name; + } + + int index = 0; + bool node_with_name_exists = false; + std::string node_base_name = node_name; + + do { + node_with_name_exists = false; + node_resource->m_name = node_name; + + for (AnimNodeResource* tree_node_resource : m_nodes) { + if (tree_node_resource->m_name == node_name) { + node_with_name_exists = true; + continue; + } + } + + node_name = node_base_name + std::to_string(++index); + } while (node_with_name_exists); + } + [[maybe_unused]] size_t AddNode(AnimNodeResource* node_resource) { + CreateUniqueNodeName(node_resource); m_nodes.push_back(node_resource); m_node_input_connection_indices.emplace_back(); m_node_inputs_subtree.emplace_back();