diff options
author | Alan <Al@AlanTroth.me.uk> | 2018-09-18 22:20:14 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-09-18 22:26:22 +0300 |
commit | a1a58c8d0a95005d84484b2db90ce2cbabc73316 (patch) | |
tree | 22291e4d4357d5fbb12f0cd7be241470802f2c38 /source | |
parent | 8fc6609cc0085b9c29fbf46bab7742e31fa4af25 (diff) |
Fix T54685: EditMesh UV's transform snapping only checks active object
Reviewers: dfelinto
https://developer.blender.org/D3653
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/include/ED_uvedit.h | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 2 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 8 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_ops.c | 24 |
4 files changed, 34 insertions, 3 deletions
diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index 434e9cfe2ac..efe294d621e 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -112,6 +112,9 @@ void uvedit_uv_select_disable( bool ED_uvedit_nearest_uv( struct Scene *scene, struct Object *obedit, struct Image *ima, const float co[2], float r_uv[2]); +bool ED_uvedit_nearest_uv_multi( + struct Scene *scene, struct Image *ima, struct Object **objects_edit, + const uint objects_len, const float co[2], float r_uv[2]); void ED_uvedit_get_aspect(struct Scene *scene, struct Object *ob, struct BMesh *em, float *aspx, float *aspy); diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 3b19618405a..e015015085d 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -904,8 +904,6 @@ bool checkUseAxisMatrix(TransInfo *t); /* Temp macros. */ -/* This is to be replaced, just to get things compiling early on. */ -#define TRANS_DATA_CONTAINER_FIRST_EVIL(t) (&(t)->data_container[0]) #define TRANS_DATA_CONTAINER_FIRST_OK(t) (&(t)->data_container[0]) /* For cases we _know_ there is only one handle. */ #define TRANS_DATA_CONTAINER_FIRST_SINGLE(t) (BLI_assert((t)->data_container_len == 1), (&(t)->data_container[0])) diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 8188cb3f51c..23daee61d71 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -53,6 +53,7 @@ #include "GPU_state.h" #include "BKE_global.h" +#include "BKE_layer.h" #include "BKE_object.h" #include "BKE_anim.h" /* for duplis */ #include "BKE_context.h" @@ -991,7 +992,11 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)) UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], &co[0], &co[1]); - if (ED_uvedit_nearest_uv(t->scene, TRANS_DATA_CONTAINER_FIRST_EVIL(t)->obedit, ima, co, t->tsnap.snapPoint)) { + uint objects_len = 0; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs( + t->view_layer, &objects_len); + + if (ED_uvedit_nearest_uv_multi(t->scene, ima, objects, objects_len, co, t->tsnap.snapPoint)) { t->tsnap.snapPoint[0] *= t->aspect[0]; t->tsnap.snapPoint[1] *= t->aspect[1]; @@ -1000,6 +1005,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)) else { t->tsnap.status &= ~POINT_INIT; } + MEM_freeN(objects); } } else if (t->spacetype == SPACE_NODE) { diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index c2cbbf06665..050e40c2ece 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -945,6 +945,30 @@ bool ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, const float return found; } +bool ED_uvedit_nearest_uv_multi( + struct Scene *scene, struct Image *ima, struct Object **objects_edit, + const uint objects_len, const float co[2], float r_uv[2]) +{ + bool found = false; + + float mindist = FLT_MAX; + float uv_nearest[2]; + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects_edit[ob_index]; + + if (ED_uvedit_nearest_uv(scene, obedit, ima, co, uv_nearest)) { + float dist = len_manhattan_v2v2(co, uv_nearest); + if (dist < mindist) { + mindist = dist; + copy_v2_v2(r_uv, uv_nearest); + found = true; + } + } + } + + return found; +} + /** \} */ /* -------------------------------------------------------------------- */ |