From 47459e6ca32f3132846f1a939f8fce8cf0844c23 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 27 Mar 2024 17:51:08 +0100 Subject: [PATCH] WIP: Fix #119773: Tracking slide zones are not intuitive 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). --- 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) { -- 2.30.2