diff options
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_mirror.c')
-rw-r--r-- | source/blender/blenkernel/intern/mesh_mirror.c | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/source/blender/blenkernel/intern/mesh_mirror.c b/source/blender/blenkernel/intern/mesh_mirror.c index 6df13e71e72..2d4308945fc 100644 --- a/source/blender/blenkernel/intern/mesh_mirror.c +++ b/source/blender/blenkernel/intern/mesh_mirror.c @@ -130,14 +130,11 @@ void BKE_mesh_mirror_apply_mirror_on_axis(struct Main *bmain, BM_mesh_free(bm); } -/** - * \warning This should _not_ be used to modify original meshes since - * it doesn't handle shape-keys, use #BKE_mesh_mirror_apply_mirror_on_axis instead. - */ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd, Object *ob, const Mesh *mesh, - const int axis) + const int axis, + const bool use_correct_order_on_merge) { const float tolerance_sq = mmd->tolerance * mmd->tolerance; const bool do_vtargetmap = (mmd->flag & MOD_MIR_NO_MERGE) == 0; @@ -266,23 +263,46 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd, * Always merge from the copied into the original vertices so it's possible to * generate a 1:1 mapping by scanning vertices from the beginning of the array * as is done in #BKE_editmesh_vert_coords_when_deformed. Without this, - * the coordinates returned will sometimes point to the copied vertex locations, see: T91444. + * the coordinates returned will sometimes point to the copied vertex locations, see: + * T91444. + * + * However, such a change also affects non-versionable things like some modifiers binding, so + * we cannot enforce that behavior on existing modifiers, in which case we keep using the + * old, incorrect behavior of merging the source vertex into its copy. */ - if (UNLIKELY(len_squared_v3v3(mv_prev->co, mv->co) < tolerance_sq)) { - *vtmap_b = i; - tot_vtargetmap++; + if (use_correct_order_on_merge) { + if (UNLIKELY(len_squared_v3v3(mv_prev->co, mv->co) < tolerance_sq)) { + *vtmap_b = i; + tot_vtargetmap++; + + /* average location */ + mid_v3_v3v3(mv->co, mv_prev->co, mv->co); + copy_v3_v3(mv_prev->co, mv->co); + } + else { + *vtmap_b = -1; + } - /* average location */ - mid_v3_v3v3(mv->co, mv_prev->co, mv->co); - copy_v3_v3(mv_prev->co, mv->co); + /* Fill here to avoid 2x loops. */ + *vtmap_a = -1; } else { + if (UNLIKELY(len_squared_v3v3(mv_prev->co, mv->co) < tolerance_sq)) { + *vtmap_a = maxVerts + i; + tot_vtargetmap++; + + /* average location */ + mid_v3_v3v3(mv->co, mv_prev->co, mv->co); + copy_v3_v3(mv_prev->co, mv->co); + } + else { + *vtmap_a = -1; + } + + /* Fill here to avoid 2x loops. */ *vtmap_b = -1; } - /* Fill here to avoid 2x loops. */ - *vtmap_a = -1; - vtmap_a++; vtmap_b++; } |