From 7bde2844ae8fcf5547edc495a0518cfdad49ffff Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Wed, 3 Feb 2021 20:54:30 +0100 Subject: Fix memory leak in boundary brush preview data The edge preview data of the boundary needs to be freed with the boundary data created for the brush. Also, all data for the ScultpSession preview that is used to render the cursor needs to be freed with the ##SculptSession##. Found by Jacques Lucke Reviewed By: JacquesLucke Differential Revision: https://developer.blender.org/D10173 --- source/blender/blenkernel/intern/paint.c | 8 ++++++++ source/blender/editors/sculpt_paint/sculpt_boundary.c | 1 + 2 files changed, 9 insertions(+) diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 4eecf3a3a87..7c65f118cf4 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -1487,6 +1487,14 @@ void BKE_sculptsession_free(Object *ob) MEM_SAFE_FREE(ss->pose_ik_chain_preview); } + if (ss->boundary_preview) { + MEM_SAFE_FREE(ss->boundary_preview->vertices); + MEM_SAFE_FREE(ss->boundary_preview->edges); + MEM_SAFE_FREE(ss->boundary_preview->distance); + MEM_SAFE_FREE(ss->boundary_preview->edit_info); + MEM_SAFE_FREE(ss->boundary_preview); + } + BKE_sculptsession_free_vwpaint_data(ob->sculpt); MEM_freeN(ss); diff --git a/source/blender/editors/sculpt_paint/sculpt_boundary.c b/source/blender/editors/sculpt_paint/sculpt_boundary.c index 64f2542dcbe..0cfb6f17adb 100644 --- a/source/blender/editors/sculpt_paint/sculpt_boundary.c +++ b/source/blender/editors/sculpt_paint/sculpt_boundary.c @@ -530,6 +530,7 @@ SculptBoundary *SCULPT_boundary_data_init(Object *object, void SCULPT_boundary_data_free(SculptBoundary *boundary) { MEM_SAFE_FREE(boundary->vertices); + MEM_SAFE_FREE(boundary->edges); MEM_SAFE_FREE(boundary->distance); MEM_SAFE_FREE(boundary->edit_info); MEM_SAFE_FREE(boundary->bend.pivot_positions); -- cgit v1.2.3 From 1081eee4c569a27881e864df8399a0c3a65daaee Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Wed, 3 Feb 2021 20:58:21 +0100 Subject: Fix T84370: Project tool not working with shape keys A missing flush of the deformed PBVH coordinates to the shape key. Reviewed By: JacquesLucke Maniphest Tasks: T84370 Differential Revision: https://developer.blender.org/D10174 --- source/blender/editors/sculpt_paint/paint_mask.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 92c78a674f0..17d13041f28 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -1465,6 +1465,12 @@ static void sculpt_gesture_project_apply_for_symmetry_pass(bContext *UNUSED(C), static void sculpt_gesture_project_end(bContext *C, SculptGestureContext *sgcontext) { + SculptSession *ss = sgcontext->ss; + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + if (ss->deform_modifiers_active || ss->shapekey_active) { + SCULPT_flush_stroke_deform(sd, sgcontext->vc.obact, true); + } + SCULPT_flush_update_step(C, SCULPT_UPDATE_COORDS); SCULPT_flush_update_done(C, sgcontext->vc.obact, SCULPT_UPDATE_COORDS); } -- cgit v1.2.3 From 0f238c5bcb190d5297830ed188f570fde0eb49ca Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Fri, 29 Jan 2021 18:26:12 +0100 Subject: Fix T85136: Sculpt geometry extract not using updated mesh This ensured that the sculpt mode deformation is flushed to the mesh datablock after leaving sculpt mode, so it can be duplicated and extracted correctly. Reviewed By: JacquesLucke Maniphest Tasks: T85136 Differential Revision: https://developer.blender.org/D10254 --- source/blender/editors/mesh/editmesh_mask_extract.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/editors/mesh/editmesh_mask_extract.c b/source/blender/editors/mesh/editmesh_mask_extract.c index be9314ad2fd..3e0bee3c4b8 100644 --- a/source/blender/editors/mesh/editmesh_mask_extract.c +++ b/source/blender/editors/mesh/editmesh_mask_extract.c @@ -106,6 +106,10 @@ static int geometry_extract_apply(bContext *C, BKE_sculpt_mask_layers_ensure(ob, NULL); + /* Ensures that deformation from sculpt mode is taken into accunt before duplicating the mesh to + * extract the geometry. */ + CTX_data_ensure_evaluated_depsgraph(C); + Mesh *mesh = ob->data; Mesh *new_mesh = (Mesh *)BKE_id_copy(bmain, &mesh->id); -- cgit v1.2.3 From ebd2aa789e409258cb96e30c9c42dcdea360924f Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Sat, 30 Jan 2021 16:27:08 +0100 Subject: Fix T85230: Face Set Boundary automasking not working with dyntopo Dyntopo does not have Face Sets implemented yet, so the entire mesh is considered a single Face Set. In that case, the check unique face set function should always return true. Reviewed By: JacquesLucke Maniphest Tasks: T85230 Differential Revision: https://developer.blender.org/D10259 --- source/blender/editors/sculpt_paint/sculpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 4d6330e03f8..410b83217b4 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -678,7 +678,7 @@ bool SCULPT_vertex_has_unique_face_set(SculptSession *ss, int index) return sculpt_check_unique_face_set_in_base_mesh(ss, index); } case PBVH_BMESH: - return false; + return true; case PBVH_GRIDS: { const CCGKey *key = BKE_pbvh_get_grid_key(ss->pbvh); const int grid_index = index / key->grid_area; -- cgit v1.2.3