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
This commit is contained in:
Sergey Sharybin
2024-04-22 14:44:42 +02:00
committed by Sergey Sharybin
parent 91f0368fe2
commit a48f685e2e

View File

@@ -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) {