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:
authorPhilipp Oeser <info@graphics-engineer.com>2020-05-07 13:34:13 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2020-05-07 13:48:58 +0300
commit2a2aa6abd0ae45133b083368be4bee77a1a420c4 (patch)
tree006cd68130ccfc4e54322c548c28fe705964c70e /source/blender/blenkernel/intern/mesh_mirror.c
parent3fed85f9d2cfcd120c58599e55b4518e62281ee1 (diff)
Fix T75793: Mirror modifier UV flip only works on first UDIM Tile
Was flipping around the 0-1 range, now (optionally) flip around each tile. Also added this option for BMesh bmo_mirror. Reviewed By: campbellbarton Maniphest Tasks: T75793 Differential Revision: https://developer.blender.org/D7460
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_mirror.c')
-rw-r--r--source/blender/blenkernel/intern/mesh_mirror.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/mesh_mirror.c b/source/blender/blenkernel/intern/mesh_mirror.c
index 49ffa9561ce..d9be9a99b2b 100644
--- a/source/blender/blenkernel/intern/mesh_mirror.c
+++ b/source/blender/blenkernel/intern/mesh_mirror.c
@@ -290,6 +290,8 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis(MirrorModifierData *mmd,
(is_zero_v2(mmd->uv_offset_copy) == false)) {
const bool do_mirr_u = (mmd->flag & MOD_MIR_MIRROR_U) != 0;
const bool do_mirr_v = (mmd->flag & MOD_MIR_MIRROR_V) != 0;
+ /* If set, flip around center of each tile. */
+ const bool do_mirr_udim = (mmd->flag & MOD_MIR_MIRROR_UDIM) != 0;
const int totuv = CustomData_number_of_layers(&result->ldata, CD_MLOOPUV);
@@ -299,10 +301,22 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis(MirrorModifierData *mmd,
dmloopuv += j; /* second set of loops only */
for (; j-- > 0; dmloopuv++) {
if (do_mirr_u) {
- dmloopuv->uv[0] = 1.0f - dmloopuv->uv[0] + mmd->uv_offset[0];
+ float u = dmloopuv->uv[0];
+ if (do_mirr_udim) {
+ dmloopuv->uv[0] = ceilf(u) - fmodf(u, 1.0f) + mmd->uv_offset[0];
+ }
+ else {
+ dmloopuv->uv[0] = 1.0f - u + mmd->uv_offset[0];
+ }
}
if (do_mirr_v) {
- dmloopuv->uv[1] = 1.0f - dmloopuv->uv[1] + mmd->uv_offset[1];
+ float v = dmloopuv->uv[1];
+ if (do_mirr_udim) {
+ dmloopuv->uv[1] = ceilf(v) - fmodf(v, 1.0f) + mmd->uv_offset[1];
+ }
+ else {
+ dmloopuv->uv[1] = 1.0f - v + mmd->uv_offset[1];
+ }
}
dmloopuv->uv[0] += mmd->uv_offset_copy[0];
dmloopuv->uv[1] += mmd->uv_offset_copy[1];