[Bf-blender-cvs] [07be162dd54] sculpt-dev: Sculpt: brush input mappings improvements
Joseph Eagar
noreply at git.blender.org
Sat Oct 16 10:16:44 CEST 2021
Commit: 07be162dd54323c4ffcebc735617dc253183199d
Author: Joseph Eagar
Date: Sat Oct 16 01:16:21 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB07be162dd54323c4ffcebc735617dc253183199d
Sculpt: brush input mappings improvements
Cleaned up brush channel input mappings:
* BrushMapping now stores .min/.max
* BrushMappingDef .min/max now sets BrushMapping min/max
instead of changing the curve preset bounds.
* Fixed how BKE_brush_channel_eval_mappings evaluates
the mappings stack. Mappings now blend directly
with channel value instead of accumulating a multiplier
that's applied at the end.
* Consequently, BrushMapping->blendmode now defaults to MA_BLEND_MULT.
* Exposed BrushMapping->blendmode in RNA and UI.
Note that it doesn't support every MA_BLEND_ type,
it provides its own EnumPropertyItem list of
supported blendmodes.
* Added a random input method, BRUSH_MAPPING_RANDOM.
* Fixed BRUSH_MAPPING_ANGLE being given data in the wrong
range (all channels should be 0..1, not -pi..pi).
Other changes:
* Improved the uv smooth brush. It's still hidden behind an
experimental pref.
* Added a SCULPT_temp_customlayer_has function to check if a temporary
customdata attribute layer exists.
* Fixed a bunch of broken sliders in the paint_toolsystem_common.py.
===================================================================
M release/scripts/startup/bl_ui/properties_paint_common.py
M source/blender/blenkernel/BKE_brush_engine.h
M source/blender/blenkernel/intern/brush_channel_define.h
M source/blender/blenkernel/intern/brush_engine.c
M source/blender/blenkernel/intern/brush_engine_presets.c
M source/blender/blenloader/intern/versioning_300.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
M source/blender/editors/sculpt_paint/sculpt_paint_color.c
M source/blender/makesdna/DNA_sculpt_brush_types.h
M source/blender/makesrna/intern/rna_brush_engine.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index d2f314c07b7..49a89c5d75a 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -114,7 +114,6 @@ class DynamicPaintPanelGen:
}
def callback():
- print("creating panel")
DynamicPaintPanelGen.createPanel(group)
pass
@@ -353,11 +352,14 @@ class UnifiedPaintPanel:
@staticmethod
- def channel_unified(layout, context, brush, prop_name, icon='NONE', pressure=None, text=None,
+ def channel_unified(layout, context, brush, prop_name, icon='NONE', pressure=None, text=None, baselayout=None,
slider=False, header=False, show_reorder=False, expand=None, toolsettings_only=False, ui_editing=None):
""" Generalized way of adding brush options to the UI,
along with their pen pressure setting and global toggle"""
+ if baselayout is None:
+ baselayout = layout
+
if slider is None:
slider = False
@@ -527,6 +529,8 @@ class UnifiedPaintPanel:
row.prop(ch, "ui_expanded", text="", icon="TRIA_DOWN" if ch.ui_expanded else "TRIA_RIGHT")
if ch.ui_expanded:
+ layout = baselayout.column()
+
for i, mp in enumerate(ch.mappings):
mp0 = mp
if mp.inherit:
@@ -563,6 +567,12 @@ class UnifiedPaintPanel:
props.shape = shape
props.path = path2
+ col.prop(mp, "factor")
+ col.prop(mp, "blendmode")
+ row = col.row()
+ row.prop(mp, "min")
+ row.prop(mp, "max")
+
#row2.prop(mp, "curve")
return row
@@ -1341,12 +1351,12 @@ def brush_settings(layout, context, brush, popover=False):
# Per sculpt tool options.
- def doprop(col, prop, slider=None):
+ def doprop(col, prop, slider=None, text=None, baselayout=None):
UnifiedPaintPanel.channel_unified(col,
context,
brush,
prop,
- slider=slider)
+ slider=slider, text=text, baselayout=baselayout)
if sculpt_tool == "VCOL_BOUNDARY":
row = layout.row()
@@ -1480,17 +1490,18 @@ def brush_settings(layout, context, brush, popover=False):
elif sculpt_tool == 'SCRAPE':
row = layout.row(align=True)
- doprop(row, "area_radius_factor")
- doprop(row, "use_pressure_area_radius", text="")
+ doprop(row, "area_radius_factor", baselayout=layout)
+ #doprop(row, "use_pressure_area_radius", text="",
+ #baselayout=layout)
row = layout.row()
- doprop(row, "invert_to_scrape_fill", text="Invert to Fill")
+ doprop(row, "invert_to_scrape_fill", text="Invert to Fill", baselayout=layout)
elif sculpt_tool == 'FILL':
row = layout.row(align=True)
- doprop(row, "area_radius_factor")
- doprop(row, "use_pressure_area_radius", text="")
+ doprop(row, "area_radius_factor", baselayout=layout)
+ #doprop(row, "use_pressure_area_radius", text="")
row = layout.row()
- doprop(row, "invert_to_scrape_fill", text="Invert to Scrape")
+ doprop(row, "invert_to_scrape_fill", text="Invert to Scrape", baselayout=layout)
elif sculpt_tool == 'GRAB':
doprop(layout, "use_grab_active_vertex")
@@ -1499,33 +1510,31 @@ def brush_settings(layout, context, brush, popover=False):
elif sculpt_tool == 'PAINT':
row = layout.row(align=True)
- doprop(row, "flow")
- doprop(row, "invert_flow_pressure", text="")
- doprop(row, "use_flow_pressure", text="")
+ doprop(row, "flow", baselayout=layout)
+ row.prop(brush.channels["flow"].mappings["PRESSURE"], "invert", text="")
row = layout.row(align=True)
- row.prop(brush, "wet_mix")
- row.prop(brush, "invert_wet_mix_pressure", text="")
- row.prop(brush, "use_wet_mix_pressure", text="")
+ doprop(row, "wet_mix", baselayout=layout)
+ row.prop(brush.channels["wet_mix"].mappings["PRESSURE"], "invert", text="")
row = layout.row(align=True)
- doprop(row, "wet_persistence")
- doprop(row, "invert_wet_persistence_pressure", text="")
- doprop(row, "use_wet_persistence_pressure", text="")
+ doprop(row, "wet_persistence", baselayout=layout)
+ row.prop(brush.channels["wet_persistence"].mappings["PRESSURE"], "invert", text="")
row = layout.row(align=True)
- doprop(row, "wet_paint_radius_factor")
+ doprop(row, "wet_paint_radius_factor", baselayout=layout)
row = layout.row(align=True)
- doprop(row, "density")
- doprop(row, "invert_density_pressure", text="")
- doprop(row, "use_density_pressure", text="")
+ doprop(row, "density", baselayout=layout)
+ row.prop(brush.channels["density"].mappings["PRESSURE"], "invert", text="")
row = layout.row()
- doprop(row, "tip_roundness")
+ doprop(row, "tip_roundness", baselayout=layout)
row = layout.row()
- doprop(row, "tip_scale_x")
+ doprop(row, "tip_scale_x", baselayout=layout)
+
+ doprop(layout.column(), "hue_offset", baselayout=layout)
elif sculpt_tool == 'SMEAR':
col = layout.column()
@@ -1602,7 +1611,7 @@ def brush_settings(layout, context, brush, popover=False):
doprop(col, "smear_deform_type")
elif sculpt_tool == 'MASK':
- doprop(layout.row(), "mask_tool", expand=True)
+ doprop(layout.row(), "mask_tool", expand=True, baselayout=layout)
# End sculpt_tool interface.
@@ -1813,6 +1822,7 @@ class ReorderBrushChannel(Operator):
return {'FINISHED'}
+classes.append(ReorderBrushChannel)
def brush_settings_channels(layout, context, brush, ui_editing=False, popover=False, show_reorder=None, filterkey="show_in_workspace",
parent="VIEW3D_PT_tools_brush_settings_channels", prefix="VIEW3D_PT_brush_category_"):
diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index 9c63450e960..96cbb4982e2 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -105,15 +105,16 @@ typedef struct BrushMappingDef {
float min, max;
int blendmode;
float factor; // if 0, will default to 1.0
+ bool no_default;
} BrushMappingDef;
typedef struct BrushMappingPreset {
// must match order of BRUSH_MAPPING_XXX enums
- struct BrushMappingDef pressure, xtilt, ytilt, angle, speed;
+ struct BrushMappingDef pressure, xtilt, ytilt, angle, speed, random;
} BrushMappingPreset;
typedef struct BrushMappingData {
- float pressure, xtilt, ytilt, angle, speed;
+ float pressure, xtilt, ytilt, angle, speed, random;
} BrushMappingData;
#define MAX_BRUSH_ENUM_DEF 32
@@ -227,6 +228,7 @@ bool BKE_brush_channelset_has(BrushChannelSet *chset, const char *idname);
BrushChannel *BKE_brush_channelset_add_builtin(BrushChannelSet *chset, const char *idname);
BrushChannel *BKE_brush_channelset_ensure_builtin(BrushChannelSet *chset, const char *idname);
+void BKE_brush_mapping_reset(BrushChannel *ch, int tool, int mapping);
void BKE_brush_channelset_merge(BrushChannelSet *dst,
BrushChannelSet *child,
diff --git a/source/blender/blenkernel/intern/brush_channel_define.h b/source/blender/blenkernel/intern/brush_channel_define.h
index d66a6f403b3..a9fb64a8960 100644
--- a/source/blender/blenkernel/intern/brush_channel_define.h
+++ b/source/blender/blenkernel/intern/brush_channel_define.h
@@ -302,6 +302,10 @@ MAKE_FLOAT_EX(rate, "Rate", "", 0.1f, 0.0001f, 10000.0f, 0.01f, 1.0f, false)
MAKE_FLOAT(flow, "Flow", "Amount of paint that is applied per stroke sample", 1.0f, 0.0f, 1.0f)
MAKE_FLOAT(wet_mix, "Wet Mix", "Amount of paint that is picked from the surface into the brush color", 0.0f, 0.0f, 1.0f)
MAKE_FLOAT(wet_persistence, "Wet Persistence", "Amount of wet paint that stays in the brush after applying paint to the surface", 0.0f, 0.0f, 1.0f)
+MAKE_FLOAT_EX(hue_offset, "Hue", "Offset Applied To Hue", 0.5f, -3.0f, 3.0f, 0.0f, 1.0f, false)
+MAKE_FLOAT(wet_paint_radius_factor, "Wet Paint Radius",
+ "Ratio between the brush radius and the radius that is going to be "
+ "used to sample the color to blend in wet paint", 0.5f, 0.0f, 2.0f)
MAKE_FLOAT(density, "Density", "Amount of random elements that are going to be affected by the brush", 1.0f, 0.0f, 1.0f)
MAKE_FLOAT(tip_scale_x, "Tip Scale X", "Scale of the brush tip in the X axis", 1.0f, 0.0f, 1.0f)
MAKE_FLOAT(dash_ratio, "Dash Ratio", "Ratio of samples in a cycle that the brush is enabled", 1.0f, 0.0f, 1.0f)
diff --git a/source/blender/blenkernel/intern/brush_engine.c b/source/blender/blenkernel/intern/brush_engine.c
index fec5b0b33f0..87c34ccf5ad 100644
--- a/source/blender/blenkernel/intern/brush_engine.c
+++ b/source/blender/blenkernel/intern/brush_engine.c
@@ -416,14 +416,14 @@ void BKE_brush_channel_init(BrushChannel *ch, BrushChannelType *def)
BrushMappingDef *mdef = (&def->mappings.pressure) + i;
- if (mdef->min != mdef->max) {
- min = mdef->min;
- max = mdef->max;
- }
- else {
+ if (!mdef->no_default) {
min = 0.0f;
max = 1.0f;
}
+ else {
+ min = mdef->min;
+ max = mdef->max;
+ }
if (mdef->inv) {
mp->flag |= BRUSH_MAPPING_INVERT;
@@ -431,20 +431,22 @@ void BKE_brush_channel_init(BrushChannel *ch, BrushChannelType *def)
int slope = CURVEMAP_SLOPE_POSITIVE;
- BKE_curvem
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list