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); }