Fix T54685: EditMesh UV's transform snapping only checks active object
Reviewers: dfelinto https://developer.blender.org/D3653
This commit is contained in:
parent
8fc6609cc0
commit
a1a58c8d0a
Notes:
blender-bot
2023-02-14 08:06:35 +01:00
Referenced by issue #54685, Multi-Object-Mode: EditMesh UV's transform snapping only checks active object
|
@ -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);
|
||||
|
||||
|
|
|
@ -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]))
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
|
Loading…
Reference in New Issue