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