[Bf-blender-cvs] [1a7757b0bc6] blender-v3.0-release: Fix T91444: Edge Loop Preview fails with two Mirror Modifiers

Campbell Barton noreply at git.blender.org
Fri Nov 12 08:34:57 CET 2021


Commit: 1a7757b0bc6945ab7d3b281f3e0dd7130bcf80f0
Author: Campbell Barton
Date:   Fri Nov 12 18:07:07 2021 +1100
Branches: blender-v3.0-release
https://developer.blender.org/rB1a7757b0bc6945ab7d3b281f3e0dd7130bcf80f0

Fix T91444: Edge Loop Preview fails with two Mirror Modifiers

The mirror modifiers merge option caused unnecessary re-ordering
to the vertex array with original vertices merging into their copies.

While this wasn't an error, it meant creating a 1:1 mapping from input
vertices to their final output wasn't reliable (when looping over
vertices first to last) as is done in
BKE_editmesh_vert_coords_when_deformed.

As merging in either direction is supported, keep the source meshes
vertices in-order since it allows the vertex coordinates to be extracted.

===================================================================

M	source/blender/blenkernel/intern/mesh_mirror.c

===================================================================

diff --git a/source/blender/blenkernel/intern/mesh_mirror.c b/source/blender/blenkernel/intern/mesh_mirror.c
index b20d81e7b9c..6df13e71e72 100644
--- a/source/blender/blenkernel/intern/mesh_mirror.c
+++ b/source/blender/blenkernel/intern/mesh_mirror.c
@@ -260,10 +260,16 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
     mul_m4_v3(mtx, mv->co);
 
     if (do_vtargetmap) {
-      /* compare location of the original and mirrored vertex, to see if they
-       * should be mapped for merging */
+      /* Compare location of the original and mirrored vertex,
+       * to see if they should be mapped for merging.
+       *
+       * 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.
+       */
       if (UNLIKELY(len_squared_v3v3(mv_prev->co, mv->co) < tolerance_sq)) {
-        *vtmap_a = maxVerts + i;
+        *vtmap_b = i;
         tot_vtargetmap++;
 
         /* average location */
@@ -271,10 +277,11 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
         copy_v3_v3(mv_prev->co, mv->co);
       }
       else {
-        *vtmap_a = -1;
+        *vtmap_b = -1;
       }
 
-      *vtmap_b = -1; /* fill here to avoid 2x loops */
+      /* Fill here to avoid 2x loops. */
+      *vtmap_a = -1;
 
       vtmap_a++;
       vtmap_b++;



More information about the Bf-blender-cvs mailing list