diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-03-12 05:46:25 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-03-12 05:57:38 +0300 |
commit | 1966924467c901d541bfe3f510d21a20c29842e3 (patch) | |
tree | a9549221176b32af95d3d582e03790d0de28a536 /source/blender/editors/uvedit/uvedit_intern.h | |
parent | 2c9c22df26dfdcf03bb308fdf35294ed79c2d0e5 (diff) |
UV: internal changes to picking
Nothing user visible, only things needed for multi-object support,
making picking functions more flexible too.
- Support passing in an initialized hit-struct,
so it's possible to do multiple nearest calls on the same hit data.
- Replace manhattan distance w/ squared distance
so they can be compared.
- Return success to detect changes to a hit-data
which might already be initialized (also more readable).
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_intern.h')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_intern.h | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/source/blender/editors/uvedit/uvedit_intern.h b/source/blender/editors/uvedit/uvedit_intern.h index e028c08091c..b5ff46e9219 100644 --- a/source/blender/editors/uvedit/uvedit_intern.h +++ b/source/blender/editors/uvedit/uvedit_intern.h @@ -51,18 +51,31 @@ void uv_poly_center(struct BMFace *f, float r_cent[2], const int cd_loop_uv_off /* find nearest */ -typedef struct NearestHit { +typedef struct UvNearestHit { + /** Always set if we have a hit. */ struct BMFace *efa; struct MTexPoly *tf; struct BMLoop *l; struct MLoopUV *luv, *luv_next; - int lindex; /* index of loop within face */ -} NearestHit; + /** Index of loop within face. */ + int lindex; + /** Needs to be set before calling nearest functions. */ + float dist_sq; +} UvNearestHit; -void uv_find_nearest_vert(struct Scene *scene, struct Image *ima, struct BMEditMesh *em, - const float co[2], const float penalty[2], struct NearestHit *hit); -void uv_find_nearest_edge(struct Scene *scene, struct Image *ima, struct BMEditMesh *em, - const float co[2], struct NearestHit *hit); +#define UV_NEAREST_HIT_INIT { .dist_sq = FLT_MAX, } + +bool uv_find_nearest_vert( + struct Scene *scene, struct Image *ima, struct BMEditMesh *em, + const float co[2], const float penalty_dist, struct UvNearestHit *hit_final); + +bool uv_find_nearest_edge( + struct Scene *scene, struct Image *ima, struct BMEditMesh *em, + const float co[2], struct UvNearestHit *hit_final); + +bool uv_find_nearest_face( + struct Scene *scene, struct Image *ima, struct BMEditMesh *em, + const float co[2], struct UvNearestHit *hit_final); /* utility tool functions */ |