Links can now be removed by hovering link and pressing the Delete key.

RefactorUnifiedBlendTreeStateMachineHandling
Martin Felis 2024-05-01 13:11:54 +02:00
parent da431a3879
commit fd032c273b
1 changed files with 24 additions and 1 deletions

View File

@ -446,7 +446,10 @@ void AnimGraphEditorUpdate(ax::NodeEditor::EditorContext* context) {
static_cast<int>(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<BlendTreeConnectionResource>();
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);
}