Minor cleanup.

RefactorUnifiedBlendTreeStateMachineHandling
Martin Felis 2024-04-21 12:47:19 +02:00
parent 91e226945c
commit 53c0bff7a6
1 changed files with 18 additions and 8 deletions

View File

@ -376,8 +376,8 @@ bool BlendTreeResource::ConnectSockets(
return false;
}
size_t source_node_index = GetNodeIndex(source_node);
size_t target_node_index = GetNodeIndex(target_node);
int source_node_index = GetNodeIndex(source_node);
int target_node_index = GetNodeIndex(target_node);
if (source_node_index >= m_nodes.size()
|| target_node_index >= m_nodes.size()) {
@ -507,14 +507,15 @@ bool BlendTreeResource::IsConnectionValid(
const std::string& source_socket_name,
const AnimNodeResource* target_node,
const std::string& target_socket_name) const {
// Check for loops
size_t source_node_index = GetNodeIndex(source_node);
size_t target_node_index = GetNodeIndex(target_node);
if (target_node_index == source_node_index) {
// Check self connection
if (source_node == target_node) {
return false;
}
// Check for loops
int source_node_index = GetNodeIndex(source_node);
int target_node_index = GetNodeIndex(target_node);
if (std::find(
m_node_inputs_subtree[source_node_index].cbegin(),
m_node_inputs_subtree[source_node_index].cend(),
@ -523,6 +524,16 @@ bool BlendTreeResource::IsConnectionValid(
return false;
}
// Check socket types
const Socket* source_socket = source_node->m_socket_accessor->GetOutputSocket(
source_socket_name.c_str());
const Socket* target_socket = target_node->m_socket_accessor->GetOutputSocket(
target_socket_name.c_str());
if (source_socket->m_type != target_socket->m_type) {
return false;
}
return true;
}
@ -813,7 +824,6 @@ void AnimGraphResource::CreateBlendTreeConnectionInstances(
instance_node_descriptors[1]->m_outputs =
instance.m_node_descriptor->m_outputs;
size_t connection_data_offset = 0;
for (const BlendTreeConnectionResource& connection :
m_blend_tree_resource.GetConnections()) {
NodeDescriptorBase* source_node_descriptor =