Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <germano.costa@ig.com.br>2020-07-31 17:23:43 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2020-07-31 17:24:34 +0300
commit1ff1a2be9c6badc0b410a5c0e9731e505fae14ea (patch)
tree6e992df65643149fd17387c0daff3527357fd9a7 /source/blender/editors/transform/transform_convert_mesh.c
parentfeaed44ef6435c0cc9d5c539b9945a5f6455de80 (diff)
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.
Diffstat (limited to 'source/blender/editors/transform/transform_convert_mesh.c')
-rw-r--r--source/blender/editors/transform/transform_convert_mesh.c21
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]);