Fix T75089: Missing pmap when using Face Sets in the mesh filter

When using Face Sets to mask the mesh filter the pmap needs to be
initialized to check the face sets of each vertex, otherwise it will
crash because it is null.

Probably now we should just initalize the pmap when building the PBVH as
almost all tools need it, so we can avoid these crashes in the future.

Reviewed By: jbakker

Maniphest Tasks: T75089

Differential Revision: https://developer.blender.org/D7236
This commit is contained in:
Pablo Dobarro 2020-03-26 00:16:22 +01:00
parent 7ed3ebbc6e
commit 4ff3d5aded
Notes: blender-bot 2023-02-14 05:25:44 +01:00
Referenced by issue #75089, Crash when using Mesh Filter sculpt tool
1 changed files with 9 additions and 5 deletions

View File

@ -9198,9 +9198,10 @@ static EnumPropertyItem prop_mesh_filter_deform_axis_items[] = {
{0, NULL, 0, NULL, NULL},
};
static bool sculpt_mesh_filter_needs_pmap(int filter_type)
static bool sculpt_mesh_filter_needs_pmap(int filter_type, bool use_face_sets)
{
return ELEM(filter_type, MESH_FILTER_SMOOTH, MESH_FILTER_RELAX, MESH_FILTER_RELAX_FACE_SETS);
return use_face_sets ||
ELEM(filter_type, MESH_FILTER_SMOOTH, MESH_FILTER_RELAX, MESH_FILTER_RELAX_FACE_SETS);
}
static void mesh_filter_task_cb(void *__restrict userdata,
@ -9360,6 +9361,7 @@ static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
int filter_type = RNA_enum_get(op->ptr, "type");
float filter_strength = RNA_float_get(op->ptr, "strength");
const bool use_face_sets = RNA_boolean_get(op->ptr, "use_face_sets");
if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
sculpt_filter_cache_free(ss);
@ -9377,7 +9379,7 @@ static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *
SCULPT_vertex_random_access_init(ss);
bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type);
bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type, use_face_sets);
BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false);
SculptThreadedTaskData data = {
@ -9432,9 +9434,11 @@ static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent
SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
}
const bool use_face_sets = RNA_boolean_get(op->ptr, "use_face_sets");
SCULPT_vertex_random_access_init(ss);
bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type);
bool needs_pmap = sculpt_mesh_filter_needs_pmap(filter_type, use_face_sets);
BKE_sculpt_update_object_for_edit(depsgraph, ob, needs_pmap, false);
if (BKE_pbvh_type(pbvh) == PBVH_FACES && needs_pmap && !ob->sculpt->pmap) {
@ -9445,7 +9449,7 @@ static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent
sculpt_filter_cache_init(ob, sd);
if (RNA_boolean_get(op->ptr, "use_face_sets")) {
if (use_face_sets) {
ss->filter_cache->active_face_set = SCULPT_vertex_face_set_get(ss,
SCULPT_active_vertex_get(ss));
}