Fixed setting location of new nodes and minor connection rejection refactor.

RefactorUnifiedBlendTreeStateMachineHandling
Martin Felis 2024-05-01 13:03:57 +02:00
parent 84fc49af30
commit da431a3879
1 changed files with 56 additions and 63 deletions

View File

@ -454,7 +454,6 @@ void AnimGraphEditorUpdate(ax::NodeEditor::EditorContext* context) {
ax::NodeEditor::PinId input_pin_id, output_pin_id;
if (ax::NodeEditor::QueryNewLink(&input_pin_id, &output_pin_id)) {
if (input_pin_id && output_pin_id) {
if (ax::NodeEditor::AcceptNewItem()) {
int source_node_index;
int source_node_socket_index;
@ -498,26 +497,21 @@ void AnimGraphEditorUpdate(ax::NodeEditor::EditorContext* context) {
target_node,
target_node_socket_index);
if (source_socket == nullptr || target_socket == nullptr) {
if (source_socket == nullptr || target_socket == nullptr
|| !sEditorState.hierarchyStack[sEditorState.hierarchyStackIndex]
->m_blend_tree_resource.IsConnectionValid(
source_node,
source_socket->m_name,
target_node,
target_socket->m_name)) {
ax::NodeEditor::RejectNewItem();
} else {
const std::string& source_socket_name =
source_node->m_socket_accessor
->m_outputs[source_node_socket_index]
.m_name;
const std::string& target_socket_name =
target_node->m_socket_accessor
->m_inputs[target_node_socket_index]
.m_name;
} else if (ax::NodeEditor::AcceptNewItem()) {
sEditorState.hierarchyStack[sEditorState.hierarchyStackIndex]
->m_blend_tree_resource.ConnectSockets(
source_node,
source_socket_name,
source_socket->m_name,
target_node,
target_socket_name);
}
target_socket->m_name);
}
}
}
@ -574,10 +568,9 @@ void AnimGraphEditorUpdate(ax::NodeEditor::EditorContext* context) {
if (!node_type_name.empty()) {
AnimNodeResource* node_resource =
AnimNodeResourceFactory(node_type_name);
size_t node_id =
sEditorState.hierarchyStack[sEditorState.hierarchyStackIndex]
->m_blend_tree_resource.GetNumNodes();
ax::NodeEditor::SetNodePosition(node_id, sEditorState.mousePopupStart);
ax::NodeEditor::SetNodePosition(
ax::NodeEditor::NodeId(node_resource),
sEditorState.mousePopupStart);
sEditorState.hierarchyStack[sEditorState.hierarchyStackIndex]
->m_blend_tree_resource.AddNode(node_resource);
}