From a48f685e2ece8a9cc5ae192ca4f8b866292ce091 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 22 Apr 2024 14:44:42 +0200 Subject: [PATCH] Fix tracking slide zones are not intuitive under certain UI scale/zoom This is a regression caused by some previous refactor of the code, which was preparing it for transition to a tool-based tracking workflow. Some of the hot zones got tweaked, and a change in the behavior was done so that when click happens far away from any slidable marker "widget" all markers gets de-selected (which matches behavior in 3D viewport). The pixel tolerance did not apply UI scale factor, and applied zoom level after squaring (which is wrong calculation of pixel space in screen space). Ref #119773 Pull Request: https://projects.blender.org/blender/blender/pulls/119971 --- source/blender/editors/space_clip/tracking_select.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_clip/tracking_select.cc b/source/blender/editors/space_clip/tracking_select.cc index 630455d87ec..59fb3a57e52 100644 --- a/source/blender/editors/space_clip/tracking_select.cc +++ b/source/blender/editors/space_clip/tracking_select.cc @@ -13,6 +13,7 @@ #include "BLI_lasso_2d.hh" #include "BLI_listbase.h" +#include "BLI_math_base.hh" #include "BLI_math_geom.h" #include "BLI_math_vector.h" #include "BLI_math_vector_types.hh" @@ -42,6 +43,8 @@ using blender::Array; using blender::int2; using blender::Span; +namespace math = blender::math; + /* -------------------------------------------------------------------- */ /** \name Point track marker picking. * \{ */ @@ -206,7 +209,8 @@ PointTrackPick ed_tracking_pick_point_track(const TrackPickOptions *options, MovieClip *clip = ED_space_clip_get_clip(space_clip); MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking); - const float distance_tolerance_px_squared = (12.0f * 12.0f) / space_clip->zoom; + const float distance_tolerance_px_squared = math::square(12.0f / space_clip->zoom * + UI_SCALE_FAC); const bool are_disabled_markers_visible = (space_clip->flag & SC_HIDE_DISABLED) == 0; const int framenr = ED_space_clip_get_clip_frame_number(space_clip); @@ -395,7 +399,8 @@ PlaneTrackPick ed_tracking_pick_plane_track(const TrackPickOptions *options, MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking); const int framenr = ED_space_clip_get_clip_frame_number(space_clip); - const float distance_tolerance_px_squared = (12.0f * 12.0f) / space_clip->zoom; + const float distance_tolerance_px_squared = math::square(12.0f / space_clip->zoom * + UI_SCALE_FAC); PlaneTrackPick pick = plane_track_pick_make_null(); LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, &tracking_object->plane_tracks) {