Sculpt-dev: fix crash in mask slice

This commit is contained in:
Joseph Eagar 2022-04-18 12:38:01 -07:00
parent 185ca2912f
commit 25ae5ab2d9
2 changed files with 18 additions and 2 deletions

View File

@ -1450,7 +1450,20 @@ static void sculptsession_free_pbvh(Object *object)
}
if (ss->pbvh) {
BKE_pbvh_set_cached(object, ss->pbvh);
if (ss->needs_pbvh_rebuild) {
if (ss->pmap) {
BKE_pbvh_pmap_release(ss->pmap);
ss->pmap = NULL;
}
BKE_pbvh_cache_remove(ss->pbvh);
BKE_pbvh_free(ss->pbvh);
}
else {
BKE_pbvh_set_cached(object, ss->pbvh);
}
ss->needs_pbvh_rebuild = false;
ss->pbvh = NULL;
}

View File

@ -572,8 +572,9 @@ static int paint_mask_slice_exec(bContext *C, wmOperator *op)
if (ob->mode == OB_MODE_SCULPT) {
SculptSession *ss = ob->sculpt;
/* Assign a new Face Set ID to the new faces created by the slice operation. */
BKE_sculptsession_update_attr_refs(ob);
/* Assign a new Face Set ID to the new faces created by the slice operation. */
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_GRIDS:
case PBVH_FACES:
@ -603,6 +604,8 @@ static int paint_mask_slice_exec(bContext *C, wmOperator *op)
break;
}
}
ss->needs_pbvh_rebuild = true;
}
ED_sculpt_undo_geometry_end(ob);