From 53c0bff7a62b760ad10d302b720a55123e2006aa Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Sun, 21 Apr 2024 12:47:19 +0200 Subject: [PATCH] Minor cleanup. --- src/AnimGraph/AnimGraphResource.cc | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/AnimGraph/AnimGraphResource.cc b/src/AnimGraph/AnimGraphResource.cc index d94e104..cfc14f3 100644 --- a/src/AnimGraph/AnimGraphResource.cc +++ b/src/AnimGraph/AnimGraphResource.cc @@ -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 =