fix leak in BM_face_split() with multires if the split failed.

also remove redundant normal copy.

only triangulate the mesh if its needed when enabling dyntopo.
This commit is contained in:
2013-08-23 13:00:43 +00:00
parent f560d25666
commit d6b9fb36d8
3 changed files with 11 additions and 7 deletions

View File

@@ -794,6 +794,7 @@ void BM_elem_attrs_copy_ex(BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v,
BMHeader *ele_dst = ele_dst_v;
BLI_assert(ele_src->htype == ele_dst->htype);
BLI_assert(ele_src != ele_dst);
if ((hflag_mask & BM_ELEM_SELECT) == 0) {
/* First we copy select */

View File

@@ -356,10 +356,9 @@ BMFace *BM_face_split(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **r_l
if (f_new) {
BM_elem_attrs_copy(bm, bm, f, f_new);
copy_v3_v3(f_new->no, f->no);
/* handle multires update */
if (has_mdisp && (f_new != f)) {
if (has_mdisp) {
BMLoop *l_iter;
BMLoop *l_first;
@@ -373,8 +372,6 @@ BMFace *BM_face_split(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **r_l
BM_loop_interp_multires(bm, l_iter, f_tmp);
} while ((l_iter = l_iter->next) != l_first);
BM_face_kill(bm, f_tmp);
#if 0
/* BM_face_multires_bounds_smooth doesn't flip displacement correct */
BM_face_multires_bounds_smooth(bm, f);
@@ -383,6 +380,10 @@ BMFace *BM_face_split(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **r_l
}
}
if (has_mdisp) {
BM_face_kill(bm, f_tmp);
}
return f_new;
}

View File

@@ -4568,7 +4568,9 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot)
static void sculpt_dynamic_topology_triangulate(BMesh *bm)
{
BM_mesh_triangulate(bm, false, false, NULL, NULL);
if (bm->totloop != bm->totface * 3) {
BM_mesh_triangulate(bm, false, false, NULL, NULL);
}
}
void sculpt_pbvh_clear(Object *ob)
@@ -4807,8 +4809,8 @@ static int sculpt_symmetrize_exec(bContext *C, wmOperator *UNUSED(op))
/* Symmetrize and re-triangulate */
BMO_op_callf(ss->bm, BMO_FLAG_DEFAULTS,
"symmetrize input=%avef direction=%i",
sd->symmetrize_direction);
"symmetrize input=%avef direction=%i dist=%f",
sd->symmetrize_direction, 0.00001f);
sculpt_dynamic_topology_triangulate(ss->bm);
/* Finish undo */