From 43190ac90bb24c79fba67d3fac1dffa1a1f30e11 Mon Sep 17 00:00:00 2001 From: vaner-org <9658355+vaner-org@users.noreply.github.com> Date: Fri, 13 Mar 2026 00:30:43 +0530 Subject: [PATCH] Limit dragging BlendSpace points to bounds --- editor/animation/animation_blend_space_1d_editor.cpp | 3 +++ editor/animation/animation_blend_space_2d_editor.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/editor/animation/animation_blend_space_1d_editor.cpp b/editor/animation/animation_blend_space_1d_editor.cpp index 04666cdc1a..ec80f5cccc 100644 --- a/editor/animation/animation_blend_space_1d_editor.cpp +++ b/editor/animation/animation_blend_space_1d_editor.cpp @@ -189,6 +189,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Refis_pressed()) { point = Math::snapped(point, blend_space->get_snap()); } + point = CLAMP(point, blend_space->get_min_space(), blend_space->get_max_space()); updating = true; EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); @@ -334,6 +335,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() { if (snap->is_pressed()) { point = Math::snapped(point, blend_space->get_snap()); } + point = CLAMP(point, blend_space->get_min_space(), blend_space->get_max_space()); } point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space()); @@ -566,6 +568,7 @@ void AnimationNodeBlendSpace1DEditor::_update_edited_point_pos() { if (snap->is_pressed()) { pos = Math::snapped(pos, blend_space->get_snap()); } + pos = CLAMP(pos, blend_space->get_min_space(), blend_space->get_max_space()); } updating = true; diff --git a/editor/animation/animation_blend_space_2d_editor.cpp b/editor/animation/animation_blend_space_2d_editor.cpp index f882c2f7ae..a2e8ec3881 100644 --- a/editor/animation/animation_blend_space_2d_editor.cpp +++ b/editor/animation/animation_blend_space_2d_editor.cpp @@ -286,6 +286,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Refis_pressed()) { point = point.snapped(blend_space->get_snap()); } + point = point.clamp(blend_space->get_min_space(), blend_space->get_max_space()); if (!read_only) { updating = true; @@ -598,6 +599,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { if (snap->is_pressed()) { point = point.snapped(blend_space->get_snap()); } + point = point.clamp(blend_space->get_min_space(), blend_space->get_max_space()); } point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space()); point *= s; @@ -634,6 +636,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { if (snap->is_pressed()) { point = point.snapped(blend_space->get_snap()); } + point = point.clamp(blend_space->get_min_space(), blend_space->get_max_space()); } point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space()); @@ -865,6 +868,7 @@ void AnimationNodeBlendSpace2DEditor::_update_edited_point_pos() { if (snap->is_pressed()) { pos = pos.snapped(blend_space->get_snap()); } + pos = pos.clamp(blend_space->get_min_space(), blend_space->get_max_space()); } updating = true; edit_x->set_value(pos.x);