diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2020-07-31 17:25:56 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2020-07-31 17:25:56 +0300 |
commit | 227e20f37004d69567b374df4f24b5d4cda8670c (patch) | |
tree | 92e12e28e24a83567f32d0c0b98e426dfba61e4c /source | |
parent | 201b4051ba6b5eed0500067b27f5fe910fe06909 (diff) | |
parent | 1ff1a2be9c6badc0b410a5c0e9731e505fae14ea (diff) |
Merge branch 'blender-v2.90-release'
Diffstat (limited to 'source')
-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 2e0f7a3a113..6f447997fb0 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]); |