From f68242f533f77f5d29c06636ed45bb855e09a19b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paviel=20Krasko=C5=ADski?= Date: Sat, 18 Oct 2025 23:21:18 +0300 Subject: [PATCH] Fix dragging blend position --- editor/animation/animation_blend_space_1d_editor.cpp | 10 ++++++++-- editor/animation/animation_blend_space_1d_editor.h | 1 + editor/animation/animation_blend_space_2d_editor.cpp | 8 +++++++- editor/animation/animation_blend_space_2d_editor.h | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/editor/animation/animation_blend_space_1d_editor.cpp b/editor/animation/animation_blend_space_1d_editor.cpp index ff435babcea..382d00b3934 100644 --- a/editor/animation/animation_blend_space_1d_editor.cpp +++ b/editor/animation/animation_blend_space_1d_editor.cpp @@ -187,15 +187,21 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Refis_pressed() && !dragging_selected_attempt && ((tool_select->is_pressed() && mb->is_shift_pressed()) || tool_blend->is_pressed()) && mb->get_button_index() == MouseButton::LEFT) { + if (mb.is_valid() && mb->is_pressed() && !dragging_selected_attempt && ((tool_select->is_pressed() && mb->is_shift_pressed()) || tool_blend->is_pressed()) && mb->get_button_index() == MouseButton::LEFT) { float blend_pos = mb->get_position().x / blend_space_draw->get_size().x; blend_pos *= blend_space->get_max_space() - blend_space->get_min_space(); blend_pos += blend_space->get_min_space(); tree->set(get_blend_position_path(), blend_pos); + + dragging_blend_position = true; blend_space_draw->queue_redraw(); } + if (mb.is_valid() && !mb->is_pressed() && dragging_blend_position && mb->get_button_index() == MouseButton::LEFT) { + dragging_blend_position = false; + } + Ref mm = p_event; if (mm.is_valid() && dragging_selected_attempt) { @@ -205,7 +211,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Refis_pressed() && mm->is_shift_pressed()) || tool_blend->is_pressed()) && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { + if (mm.is_valid() && dragging_blend_position && !dragging_selected_attempt && ((tool_select->is_pressed() && mm->is_shift_pressed()) || tool_blend->is_pressed()) && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { float blend_pos = mm->get_position().x / blend_space_draw->get_size().x; blend_pos *= blend_space->get_max_space() - blend_space->get_min_space(); blend_pos += blend_space->get_min_space(); diff --git a/editor/animation/animation_blend_space_1d_editor.h b/editor/animation/animation_blend_space_1d_editor.h index 8a4968d43de..44e357195cd 100644 --- a/editor/animation/animation_blend_space_1d_editor.h +++ b/editor/animation/animation_blend_space_1d_editor.h @@ -98,6 +98,7 @@ class AnimationNodeBlendSpace1DEditor : public AnimationTreeNodeEditorPlugin { float add_point_pos = 0.0f; Vector points; + bool dragging_blend_position = false; bool dragging_selected_attempt = false; bool dragging_selected = false; Vector2 drag_from; diff --git a/editor/animation/animation_blend_space_2d_editor.cpp b/editor/animation/animation_blend_space_2d_editor.cpp index b9d86de9b1f..de6da8b6191 100644 --- a/editor/animation/animation_blend_space_2d_editor.cpp +++ b/editor/animation/animation_blend_space_2d_editor.cpp @@ -288,9 +288,14 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Refset(get_blend_position_path(), blend_pos); + dragging_blend_position = true; blend_space_draw->queue_redraw(); } + if (mb.is_valid() && !mb->is_pressed() && dragging_blend_position && mb->get_button_index() == MouseButton::LEFT) { + dragging_blend_position = false; + } + Ref mm = p_event; if (mm.is_valid() && dragging_selected_attempt) { @@ -311,7 +316,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Refqueue_redraw(); } - if (mm.is_valid() && !dragging_selected_attempt && ((tool_select->is_pressed() && mm->is_shift_pressed()) || tool_blend->is_pressed()) && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { + if (mm.is_valid() && dragging_blend_position && !dragging_selected_attempt && ((tool_select->is_pressed() && mm->is_shift_pressed()) || tool_blend->is_pressed()) && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { Vector2 blend_pos = (mm->get_position() / blend_space_draw->get_size()); blend_pos.y = 1.0 - blend_pos.y; blend_pos *= (blend_space->get_max_space() - blend_space->get_min_space()); @@ -1118,4 +1123,5 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() { dragging_selected = false; dragging_selected_attempt = false; + dragging_blend_position = false; } diff --git a/editor/animation/animation_blend_space_2d_editor.h b/editor/animation/animation_blend_space_2d_editor.h index 008356cfa31..684e7c4524b 100644 --- a/editor/animation/animation_blend_space_2d_editor.h +++ b/editor/animation/animation_blend_space_2d_editor.h @@ -103,6 +103,7 @@ class AnimationNodeBlendSpace2DEditor : public AnimationTreeNodeEditorPlugin { Vector2 add_point_pos; Vector points; + bool dragging_blend_position; bool dragging_selected_attempt; bool dragging_selected; Vector2 drag_from;