diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/transform/transform_convert_mesh.c | 21 |
1 files changed, 14 insertions, 7 deletions
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]); |