diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2020-05-07 13:53:19 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2020-05-07 13:53:19 +0300 |
commit | 4f846d9d2a3792dd1cc4dbf1a39fe58aacd2609c (patch) | |
tree | 44a569496f972e23d5e260de30ef3eb1c7ef82a6 /source/blender/bmesh | |
parent | 45a77ba09dbe8c51084c0aaa80f884a9954459cf (diff) | |
parent | 2a2aa6abd0ae45133b083368be4bee77a1a420c4 (diff) |
Merge branch 'blender-v2.83-release'
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_opdefines.c | 1 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_mirror.c | 17 |
2 files changed, 16 insertions, 2 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 45666a21a2c..255a52971bb 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -320,6 +320,7 @@ static BMOpDefine bmo_mirror_def = { {"axis", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_axis_xyz}, /* the axis to use. */ {"mirror_u", BMO_OP_SLOT_BOOL}, /* mirror UVs across the u axis */ {"mirror_v", BMO_OP_SLOT_BOOL}, /* mirror UVs across the v axis */ + {"mirror_udim", BMO_OP_SLOT_BOOL}, /* mirror UVs in each tile */ {{'\0'}}, }, /* slots_out */ diff --git a/source/blender/bmesh/operators/bmo_mirror.c b/source/blender/bmesh/operators/bmo_mirror.c index 36297b3f816..b5b56f4432d 100644 --- a/source/blender/bmesh/operators/bmo_mirror.c +++ b/source/blender/bmesh/operators/bmo_mirror.c @@ -48,6 +48,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op) int axis = BMO_slot_int_get(op->slots_in, "axis"); bool mirror_u = BMO_slot_bool_get(op->slots_in, "mirror_u"); bool mirror_v = BMO_slot_bool_get(op->slots_in, "mirror_v"); + bool mirror_udim = BMO_slot_bool_get(op->slots_in, "mirror_udim"); BMOpSlot *slot_targetmap; ototvert = bm->totvert; @@ -94,10 +95,22 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op) for (i = 0; i < totlayer; i++) { luv = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPUV, i); if (mirror_u) { - luv->uv[0] = 1.0f - luv->uv[0]; + float uv_u = luv->uv[0]; + if (mirror_udim) { + luv->uv[0] = ceilf(uv_u) - fmodf(uv_u, 1.0f); + } + else { + luv->uv[0] = 1.0f - uv_u; + } } if (mirror_v) { - luv->uv[1] = 1.0f - luv->uv[1]; + float uv_v = luv->uv[1]; + if (mirror_udim) { + luv->uv[1] = ceilf(uv_v) - fmodf(uv_v, 1.0f); + } + else { + luv->uv[1] = 1.0f - uv_v; + } } } } |