From 6eb76f64304235bd91e7a226019da5424e0b28d3 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Fri, 6 Mar 2020 14:05:55 +0100 Subject: Fix T74492: Reset Face Set data when cancelling the expand operator The operator was resetting the mask data when cancelling instead of the face set data, so it was crashing because mask data was not available when starting the operator in expand face set mode. Reviewed By: brecht Maniphest Tasks: T74492 Differential Revision: https://developer.blender.org/D7043 --- source/blender/editors/sculpt_paint/sculpt.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'source') diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 0fb5897628f..443aaef85c5 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -9687,22 +9687,32 @@ static void sculpt_mask_expand_cancel(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; + const bool create_face_set = RNA_boolean_get(op->ptr, "create_face_set"); MEM_freeN(op->customdata); for (int n = 0; n < ss->filter_cache->totnode; n++) { PBVHNode *node = ss->filter_cache->nodes[n]; - PBVHVertexIter vd; - BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) - { - *vd.mask = ss->filter_cache->prev_mask[vd.index]; + if (create_face_set) { + for (int i = 0; i < ss->totpoly; i++) { + ss->face_sets[i] = ss->filter_cache->prev_face_set[i]; + } + } + else { + PBVHVertexIter vd; + BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) + { + *vd.mask = ss->filter_cache->prev_mask[vd.index]; + } + BKE_pbvh_vertex_iter_end; } - BKE_pbvh_vertex_iter_end; BKE_pbvh_node_mark_redraw(node); } - sculpt_flush_update_step(C, SCULPT_UPDATE_MASK); + if (!create_face_set) { + sculpt_flush_update_step(C, SCULPT_UPDATE_MASK); + } sculpt_filter_cache_free(ss); SCULPT_undo_push_end(); sculpt_flush_update_done(C, ob, SCULPT_UPDATE_MASK); -- cgit v1.2.3