Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-01-09 10:27:25 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-01-09 10:42:36 +0300
commit246efd7286f6187e4dd4b3edcc79cccb1746bb1d (patch)
treee2fd2e8c3ebc7033a913ca6cf41eff386ca1e7d0 /source/blender/editors/uvedit/uvedit_intern.h
parent645298be29601b0e772a15fe04c570a31df4a25d (diff)
Fix UV selection threshold which ignored image aspect and zoom level
Selecting UVs wasn't properly scaling based on the zoom or image aspect. This now matches vertex selection in the 3D view.
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_intern.h')
-rw-r--r--source/blender/editors/uvedit/uvedit_intern.h26
1 files changed, 23 insertions, 3 deletions
diff --git a/source/blender/editors/uvedit/uvedit_intern.h b/source/blender/editors/uvedit/uvedit_intern.h
index 28567234fab..6fef7ebcf22 100644
--- a/source/blender/editors/uvedit/uvedit_intern.h
+++ b/source/blender/editors/uvedit/uvedit_intern.h
@@ -41,13 +41,34 @@ typedef struct UvNearestHit {
/** Always set if we have a hit. */
struct BMFace *efa;
struct BMLoop *l;
- /** Needs to be set before calling nearest functions. */
+ /**
+ * Needs to be set before calling nearest functions.
+ *
+ * \note When #UV_NEAREST_HIT_INIT_DIST_PX or #UV_NEAREST_HIT_INIT_MAX are used,
+ * this value is pixels squared.
+ */
float dist_sq;
+
+ /** Scale the UV's to account for aspect ratio from the image view. */
+ float scale[2];
} UvNearestHit;
-#define UV_NEAREST_HIT_INIT \
+#define UV_NEAREST_HIT_INIT_DIST_PX(v2d, dist_px) \
+ { \
+ .dist_sq = square_f(U.pixelsize * dist_px), \
+ .scale = { \
+ UI_view2d_scale_get_x(v2d), \
+ UI_view2d_scale_get_y(v2d), \
+ }, \
+ }
+
+#define UV_NEAREST_HIT_INIT_MAX(v2d) \
{ \
.dist_sq = FLT_MAX, \
+ .scale = { \
+ UI_view2d_scale_get_x(v2d), \
+ UI_view2d_scale_get_y(v2d), \
+ }, \
}
bool uv_find_nearest_vert(struct Scene *scene,
@@ -96,7 +117,6 @@ BMLoop *uv_find_nearest_loop_from_edge(struct Scene *scene,
void uvedit_live_unwrap_update(struct SpaceImage *sima,
struct Scene *scene,
struct Object *obedit);
-void uvedit_pixel_to_float(struct SpaceImage *sima, float pixeldist, float r_dist[2]);
/* operators */