[Bf-blender-cvs] [c692b93fcf0] temp-sculpt-cavity-mask: temp-sculpt-cavity-mask: patch update
Joseph Eagar
noreply at git.blender.org
Sat Aug 6 00:29:43 CEST 2022
Commit: c692b93fcf00d95ec42554251433d684f7278358
Author: Joseph Eagar
Date: Fri Aug 5 15:17:52 2022 -0700
Branches: temp-sculpt-cavity-mask
https://developer.blender.org/rBc692b93fcf00d95ec42554251433d684f7278358
temp-sculpt-cavity-mask: patch update
* Merge master
* Invert curve behavior in invert mode
* Invert and normal cavity mask are now seperate modes
and mutually exclusive.
* Automask bake operator now has option to use scene
defaults.
* The automask boolean properties are now defined in
a EnumPropertyItem list to avoid three sets of duplicate
code. We might want to consider
making automasking flags a bitflag enum property in
the future. For now the EnumPropertyList is simply
read to build the boolean properties.
* Added a "Mask from cavity" menu operator.
===================================================================
M release/scripts/startup/bl_ui/properties_paint_common.py
M release/scripts/startup/bl_ui/space_view3d.py
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_automasking.cc
M source/blender/editors/sculpt_paint/sculpt_intern.h
M source/blender/editors/sculpt_paint/sculpt_ops.c
M source/blender/makesdna/DNA_brush_enums.h
M source/blender/makesrna/RNA_access.h
M source/blender/makesrna/intern/rna_brush.c
M source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 7ee1df7d736..953d8c33fdb 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -943,14 +943,14 @@ def brush_settings_advanced(layout, context, brush, popover=False):
# boundary edges/face sets automasking
col.prop(brush, "use_automasking_boundary_edges", text="Mesh Boundary")
col.prop(brush, "use_automasking_boundary_face_sets", text="Face Sets Boundary")
- col.prop(brush, "use_automasking_cavity", text="Cavity Masking")
+ col.prop(brush, "use_automasking_cavity", text="Cavity")
+ col.prop(brush, "use_automasking_cavity_inverted", text="Cavity (Inverted)")
col.separator()
- if brush.use_automasking_cavity:
+ if brush.use_automasking_cavity or brush.use_automasking_cavity_inverted:
sculpt = context.tool_settings.sculpt
- col.prop(brush, "invert_automasking_cavity", text="Invert Cavity")
col.prop(sculpt, "automasking_cavity_factor", text="Cavity Factor")
col.prop(sculpt, "automasking_cavity_blur_steps", text="Cavity Blur")
col.prop(sculpt, "use_automasking_custom_cavity_curve", text="Use Curve")
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index ee2f81bc556..d5c7b7f70cb 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -3282,6 +3282,11 @@ class VIEW3D_MT_mask(Menu):
props = layout.operator("sculpt.dirty_mask", text='Dirty Mask')
+ props = layout.operator("sculpt.bake_automask", text="Mask From Cavity")
+
+ props.use_scene_settings = False
+ props.use_automasking_cavity = True
+
layout.separator()
layout.menu("VIEW3D_MT_random_mask", text="Random Mask")
@@ -5475,6 +5480,7 @@ class VIEW3D_MT_sculpt_automasking_pie(Menu):
pie.prop(sculpt, "use_automasking_boundary_edges", text="Mesh Boundary")
pie.prop(sculpt, "use_automasking_boundary_face_sets", text="Face Sets Boundary")
pie.prop(sculpt, "use_automasking_cavity", text="Cavity")
+ pie.prop(sculpt, "use_automasking_cavity_inverted", text="Cavity (Inverted)")
class VIEW3D_MT_sculpt_face_sets_edit_pie(Menu):
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 1b8c89de140..4946410f3c0 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -970,12 +970,12 @@ class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
col.prop(sculpt, "use_automasking_face_sets", text="Face Sets")
col.prop(sculpt, "use_automasking_boundary_edges", text="Mesh Boundary")
col.prop(sculpt, "use_automasking_boundary_face_sets", text="Face Sets Boundary")
- col.prop(sculpt, "use_automasking_cavity", text="Cavity Masking")
+ col.prop(sculpt, "use_automasking_cavity", text="Cavity")
+ col.prop(sculpt, "use_automasking_cavity_inverted", text="Cavity (Inverted)")
col.separator()
- if sculpt.use_automasking_cavity:
- col.prop(sculpt, "invert_automasking_cavity", text="Invert Cavity")
+ if sculpt.use_automasking_cavity or sculpt.use_automasking_cavity_inverted:
col.prop(sculpt, "automasking_cavity_factor", text="Cavity Factor")
col.prop(sculpt, "automasking_cavity_blur_steps", text="Cavity Blur")
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 9644f359841..11f4f72916c 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4326,6 +4326,10 @@ static void sculpt_update_cache_invariants(
cache->original = true;
}
+ if (SCULPT_automasking_needs_original(sd, brush)) {
+ cache->original = true;
+ }
+
/* Draw sharp does not need the original coordinates to produce the accumulate effect, so it
* should work the opposite way. */
if (brush->sculpt_tool == SCULPT_TOOL_DRAW_SHARP) {
diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
index 07a159f7945..17105c610c0 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
@@ -73,10 +73,8 @@ bool SCULPT_is_automasking_mode_enabled(const Sculpt *sd,
int automasking = sd->automasking_flags;
if (br) {
- /* Do not inherit secondary cavity mask flags if BRUSH_AUTOMASKING_CAVITY is unset.*/
-
- if (!(sd->automasking_flags & BRUSH_AUTOMASKING_CAVITY)) {
- automasking &= ~BRUSH_AUTOMASKING_CAVITY_INVERT;
+ /* Do not inherit secondary cavity mask flags if cavity mask is not enabled.*/
+ if (!(sd->automasking_flags & BRUSH_AUTOMASKING_CAVITY_ALL)) {
automasking &= ~BRUSH_AUTOMASKING_CAVITY_USE_CURVE;
}
@@ -103,7 +101,7 @@ bool SCULPT_is_automasking_enabled(const Sculpt *sd, const SculptSession *ss, co
if (SCULPT_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS)) {
return true;
}
- if (SCULPT_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_CAVITY)) {
+ if (SCULPT_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_CAVITY_ALL)) {
return true;
}
@@ -181,7 +179,8 @@ static float sculpt_cavity_calc_factor(SculptSession *ss,
factor = factor * sign * 0.5f + 0.5f;
CLAMP(factor, 0.0f, 1.0f);
- return (automasking->settings.flags & BRUSH_AUTOMASKING_CAVITY_INVERT) ? 1.0f - factor : factor;
+ return (automasking->settings.flags & BRUSH_AUTOMASKING_CAVITY_INVERTED) ? 1.0f - factor :
+ factor;
}
struct CavityBlurVert {
@@ -369,6 +368,10 @@ static float sculpt_automasking_cavity_factor(AutomaskingCache *automasking,
if (automasking->settings.flags & BRUSH_AUTOMASKING_CAVITY_USE_CURVE) {
factor = BKE_curvemapping_evaluateF(automasking->settings.cavity_curve, 0, factor);
+
+ if (automasking->settings.flags & BRUSH_AUTOMASKING_CAVITY_INVERTED) {
+ factor = 1.0f - factor;
+ }
}
return factor;
@@ -390,7 +393,7 @@ float SCULPT_automasking_factor_get(AutomaskingCache *automasking,
if (automasking->factor) {
float factor = automasking->factor[index];
- if (automasking->settings.flags & BRUSH_AUTOMASKING_CAVITY) {
+ if (automasking->settings.flags & BRUSH_AUTOMASKING_CAVITY_ALL) {
factor *= sculpt_automasking_cavity_factor(automasking, ss, vert);
}
@@ -415,7 +418,7 @@ float SCULPT_automasking_factor_get(AutomaskingCache *automasking,
}
}
- if (automasking->settings.flags & BRUSH_AUTOMASKING_CAVITY) {
+ if (automasking->settings.flags & BRUSH_AUTOMASKING_CAVITY_ALL) {
return sculpt_automasking_cavity_factor(automasking, ss, vert);
}
@@ -650,7 +653,7 @@ AutomaskingCache *SCULPT_automasking_cache_init(Sculpt *sd, Brush *brush, Object
SCULPT_automasking_cache_settings_update(automasking, ss, sd, brush);
SCULPT_boundary_info_ensure(ob);
- if (SCULPT_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_CAVITY)) {
+ if (SCULPT_is_automasking_mode_enabled(sd, brush, BRUSH_AUTOMASKING_CAVITY_ALL)) {
SCULPT_vertex_random_access_ensure(ss);
sculpt_cavity_automasking_init(sd, ob, automasking);
}
@@ -690,3 +693,8 @@ AutomaskingCache *SCULPT_automasking_cache_init(Sculpt *sd, Brush *brush, Object
return automasking;
}
+
+bool SCULPT_automasking_needs_original(const Sculpt *sd, const Brush *brush)
+{
+ return sculpt_automasking_mode_effective_bits(sd, brush) & BRUSH_AUTOMASKING_CAVITY_ALL;
+}
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 2cf97e6e6df..44b085dc0eb 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -1306,6 +1306,8 @@ float *SCULPT_boundary_automasking_init(Object *ob,
eBoundaryAutomaskMode mode,
int propagation_steps,
float *automask_factor);
+bool SCULPT_automasking_needs_original(const struct Sculpt *sd, const struct Brush *brush);
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.c b/source/blender/editors/sculpt_paint/sculpt_ops.c
index f82f9a402e2..da8f70d1ad0 100644
--- a/source/blender/editors/sculpt_paint/sculpt_ops.c
+++ b/source/blender/editors/sculpt_paint/sculpt_ops.c
@@ -1078,6 +1078,28 @@ static int sculpt_bake_automask_exec(bContext *C, wmOperator *op)
tdata.nodes = nodes;
tdata.automasking = SCULPT_automasking_cache_init(sd, brush, ob);
+ if (!RNA_boolean_get(op->ptr, "use_scene_settings")) {
+ tdata.automasking->settings.flags = 0;
+
+ const EnumPropertyItem *entry = RNA_automasking_flags;
+ do {
+ if (entry->value & (BRUSH_AUTOMASKING_FACE_SETS | BRUSH_AUTOMASKING_TOPOLOGY)) {
+ /* These two modes require an active vertex. */
+ continue;
+ }
+
+ if (RNA_boolean_get(op->ptr, entry->identifier)) {
+ tdata.automasking->settings.flags |= entry->value;
+ }
+ } while ((++entry)->identifier);
+
+ if (tdata.automasking->settings.flags & BRUSH_AUTOMASKING_CAVITY_ALL) {
+ tdata.automasking->settings.cavity_blur_steps = RNA_int_get(op->ptr, "cavity_blur_steps");
+ tdata.automasking->settings.cavity_factor = RNA_float_get(op->ptr, "cavity_factor");
+ tdata.automasking->settings.cavity_curve = sd->automasking_cavity_curve;
+ }
+ }
+
ss->stroke_id++;
TaskParallelSettings settings;
@@ -1108,10 +1130,10 @@ static void SCULPT_OT_bake_automask(wmOperatorType *ot)
static EnumPropertyItem mix_modes[] = {
{AUTOMASK_BAKE_MIX, "MIX", ICON
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list