From fd032c273bc97cbb1bdb8fa94b3059f02f2f0ee7 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Wed, 1 May 2024 13:11:54 +0200 Subject: [PATCH] Links can now be removed by hovering link and pressing the Delete key. --- src/AnimGraph/AnimGraphEditor.cc | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/AnimGraph/AnimGraphEditor.cc b/src/AnimGraph/AnimGraphEditor.cc index dd34997..66f435c 100644 --- a/src/AnimGraph/AnimGraphEditor.cc +++ b/src/AnimGraph/AnimGraphEditor.cc @@ -446,7 +446,10 @@ void AnimGraphEditorUpdate(ax::NodeEditor::EditorContext* context) { static_cast(connection_resource->target_node_index), target_socket_index); - ax::NodeEditor::Link(link_id++, source_socket_pin_id, target_socket_pin_id); + ax::NodeEditor::Link( + ax::NodeEditor::LinkId(connection_resource), + source_socket_pin_id, + target_socket_pin_id); } // Create Connections @@ -640,6 +643,26 @@ void AnimGraphEditorUpdate(ax::NodeEditor::EditorContext* context) { } } + ax::NodeEditor::LinkId hovered_link = ax::NodeEditor::GetHoveredLink(); + if (!hovered_link.Invalid) { + BlendTreeConnectionResource* connection_resource = + hovered_link.AsPointer(); + + if (connection_resource && ImGui::IsKeyPressed(ImGuiKey_Delete)) { + BlendTreeResource* blend_tree_resource = + &sEditorState.hierarchyStack[sEditorState.hierarchyStackIndex] + ->m_blend_tree_resource; + + blend_tree_resource->DisconnectSockets( + blend_tree_resource->GetNode(connection_resource->source_node_index), + connection_resource->source_socket_name, + blend_tree_resource->GetNode(connection_resource->target_node_index), + connection_resource->target_socket_name); + + ax::NodeEditor::DeleteLink(hovered_link); + } + } + ax::NodeEditor::SetCurrentEditor(nullptr); }