Commit: a9cb66b856e80d0542a9ad3fec0b0fb47d28f805 Author: Joseph Eagar Date: Mon Dec 26 21:43:08 2022 -0800 Branches: master https://developer.blender.org/rBa9cb66b856e80d0542a9ad3fec0b0fb47d28f805
Sculpt: Fix expand invert mode * Invert mode now properly subtracts from mask * Added an "auto-create" mode to automatically fill in the mask if everything is unmasked. =================================================================== M source/blender/editors/sculpt_paint/sculpt_expand.c M source/blender/editors/sculpt_paint/sculpt_intern.h =================================================================== diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c b/source/blender/editors/sculpt_paint/sculpt_expand.c index a8496712c41..b90488f6df4 100644 --- a/source/blender/editors/sculpt_paint/sculpt_expand.c +++ b/source/blender/editors/sculpt_paint/sculpt_expand.c @@ -1260,7 +1260,12 @@ static void sculpt_expand_mask_update_task_cb(void *__restrict userdata, } if (expand_cache->preserve) { - new_mask = max_ff(new_mask, expand_cache->original_mask[vd.index]); + if (expand_cache->invert) { + new_mask = min_ff(new_mask, expand_cache->original_mask[vd.index]); + } + else { + new_mask = max_ff(new_mask, expand_cache->original_mask[vd.index]); + } } if (new_mask == initial_mask) { @@ -2033,6 +2038,7 @@ static void sculpt_expand_cache_initial_config_set(bContext *C, /* RNA properties. */ expand_cache->invert = RNA_boolean_get(op->ptr, "invert"); expand_cache->preserve = RNA_boolean_get(op->ptr, "use_mask_preserve"); + expand_cache->auto_mask = RNA_boolean_get(op->ptr, "use_auto_mask"); expand_cache->falloff_gradient = RNA_boolean_get(op->ptr, "use_falloff_gradient"); expand_cache->target = RNA_enum_get(op->ptr, "target"); expand_cache->modify_active_face_set = RNA_boolean_get(op->ptr, "use_modify_active"); @@ -2115,6 +2121,41 @@ static int sculpt_expand_invoke(bContext *C, wmOperator *op, const wmEvent *even if (ss->expand_cache->target == SCULPT_EXPAND_TARGET_MASK) { MultiresModifierData *mmd = BKE_sculpt_multires_active(ss->scene, ob); BKE_sculpt_mask_layers_ensure(depsgraph, CTX_data_main(C), ob, mmd); + + if (RNA_boolean_get(op->ptr, "use_auto_mask")) { + int verts_num = SCULPT_vertex_count_get(ss); + bool ok = true; + + for (int i = 0; i < verts_num; i++) { + PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i); + + if (SCULPT_vertex_mask_get(ss, vertex) != 0.0f) { + ok = false; + break; + } + } + + if (ok) { + int nodes_num; + PBVHNode **nodes; + + /* TODO: implement SCULPT_vertex_mask_set and use it here. */ + + BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &nodes_num); + for (int i = 0; i < nodes_num; i++) { + PBVHVertexIter vd; + bool update = false; + + BKE_pbvh_vertex_iter_begin (ss->pbvh, nodes[i], vd, PBVH_ITER_UNIQUE) { + *vd.mask = 1.0f; + update = true; + } + BKE_pbvh_vertex_iter_end; + + BKE_pbvh_node_mark_update_mask(nodes[i]); + } + } + } } BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true, needs_colors); @@ -2338,4 +2379,9 @@ void SCULPT_OT_expand(wmOperatorType *ot) "than this value, the falloff will be set to spherical when moving", 0, 1000000); + ot->prop = RNA_def_boolean(ot->srna, + "use_auto_mask", + false, + "Auto Create", + "Fill in mask if nothing is already masked."); } diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index e660e8fa8ac..ae23983e6c9 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -795,6 +795,9 @@ typedef struct ExpandCache { * after finishing the operation. */ bool reposition_pivot; + /* If nothing is masked set mask of every vertex to 0. */ + bool auto_mask; + /* Color target data type related data. */ float fill_color[4]; short blend_mode; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs