[Bf-blender-cvs] [1ff1a2be9c6] blender-v2.90-release: Fix T78600: Crash when transforming doubles with mirroring on

Germano Cavalcante noreply at git.blender.org
Fri Jul 31 16:25:26 CEST 2020


Commit: 1ff1a2be9c6badc0b410a5c0e9731e505fae14ea
Author: Germano Cavalcante
Date:   Fri Jul 31 11:23:43 2020 -0300
Branches: blender-v2.90-release
https://developer.blender.org/rB1ff1a2be9c6badc0b410a5c0e9731e505fae14ea

Fix T78600: Crash when transforming doubles with mirroring on

`EDBM_verts_mirror_cache_begin_ex` could do a better work avoiding these
duplicates, but this is a separate problem.

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

M	source/blender/editors/transform/transform_convert_mesh.c

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

diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c
index e4960e1ec71..ad426713719 100644
--- a/source/blender/editors/transform/transform_convert_mesh.c
+++ b/source/blender/editors/transform/transform_convert_mesh.c
@@ -472,7 +472,7 @@ static void editmesh_mirror_data_calc(BMEditMesh *em,
   BMIter iter;
   int i, flag, totvert = bm->totvert;
 
-  vert_map = MEM_mallocN(totvert * sizeof(*vert_map), __func__);
+  vert_map = MEM_callocN(totvert * sizeof(*vert_map), __func__);
 
   float select_sum[3] = {0};
   BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
@@ -498,7 +498,8 @@ static void editmesh_mirror_data_calc(BMEditMesh *em,
 
   uint mirror_elem_len = 0;
   int *index[3] = {NULL, NULL, NULL};
-  bool test_selected_only = use_select && (mirror_axis[0] + mirror_axis[1] + mirror_axis[2]) == 1;
+  bool is_single_mirror_axis = (mirror_axis[0] + mirror_axis[1] + mirror_axis[2]) == 1;
+  bool test_selected_only = use_select && is_single_mirror_axis;
   for (int a = 0; a < 3; a++) {
     if (!mirror_axis[a]) {
       continue;
@@ -523,13 +524,23 @@ static void editmesh_mirror_data_calc(BMEditMesh *em,
       if (!is_in_quadrant_v3(eve->co, quadrant, TRANSFORM_MAXDIST_MIRROR)) {
         continue;
       }
+      if (vert_map[i_mirr].flag != 0) {
+        /* One mirror per element.
+         * It can happen when vertices occupy the same position. */
+        continue;
+      }
 
       vert_map[i_mirr] = (struct MirrorDataVert){i, flag};
       mirror_elem_len++;
     }
   }
 
-  if (mirror_elem_len) {
+  if (!mirror_elem_len) {
+    MEM_freeN(vert_map);
+    vert_map = NULL;
+  }
+  else if (!is_single_mirror_axis) {
+    /* Adjustment for elements that are mirrors of mirrored elements. */
     for (int a = 0; a < 3; a++) {
       if (!mirror_axis[a]) {
         continue;
@@ -551,10 +562,6 @@ static void editmesh_mirror_data_calc(BMEditMesh *em,
       }
     }
   }
-  else {
-    MEM_freeN(vert_map);
-    vert_map = NULL;
-  }
 
   MEM_SAFE_FREE(index[0]);
   MEM_SAFE_FREE(index[1]);



More information about the Bf-blender-cvs mailing list