BlendTree node names are now always unique.

This commit is contained in:
Martin Felis 2025-03-02 12:46:26 +01:00
parent feb5f57a86
commit 55bcd9cd99

View File

@ -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();