[Bf-blender-cvs] [ccb3ca41cde] sculpt-dev: Sculpt: Add a curve brush channel type
Joseph Eagar
noreply at git.blender.org
Fri Sep 24 01:13:27 CEST 2021
Commit: ccb3ca41cde01a975a8177745cef79299648d9ef
Author: Joseph Eagar
Date: Thu Sep 23 16:11:29 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rBccb3ca41cde01a975a8177745cef79299648d9ef
Sculpt: Add a curve brush channel type
* Added a new curve brush channel type
* Added a BKE_brush_curve_strength_ex method
that just takes preset and curve as arguments,
instead of pulling them from Brush.
* Autosmooth and topology rake now have their
own falloff curves.
===================================================================
M release/scripts/startup/bl_ui/properties_paint_common.py
M source/blender/blenkernel/BKE_brush.h
M source/blender/blenkernel/BKE_brush_engine.h
M source/blender/blenkernel/intern/brush.c
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/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_smooth.c
M source/blender/makesdna/DNA_sculpt_brush_types.h
M source/blender/makesrna/intern/rna_brush.c
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 38a43f195e5..4168b920055 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -31,6 +31,22 @@ channel_name_map = {
};
expand_channels = {"direction"}
+def template_curve(layout, base, propname, full_path):
+ layout.template_curve_mapping(base, propname, brush=True)
+
+ path = full_path
+
+ col = layout.column(align=True)
+ row = col.row(align=True)
+
+ shapes = ['SMOOTH', 'ROUND', 'ROOT', 'SHARP', 'LINE', 'MAX']
+ icons = ['SMOOTHCURVE', 'SPHERECURVE', 'ROOTCURVE', 'SHARPCURVE', 'LINCURVE', 'NOCURVE']
+
+ for i, shape in enumerate(shapes):
+ props = row.operator("brush.curve_preset_load", icon=icons[i], text="")
+ props.shape = shape
+ props.path = path
+
class UnifiedPaintPanel:
# subclass must set
# bl_space_type = 'IMAGE_EDITOR'
@@ -144,7 +160,7 @@ class UnifiedPaintPanel:
typeprop = "color3_value"
elif ch.type == "VEC4":
typeprop = "color4_value"
-
+
if text is None:
s = prop_name.lower().replace("_", " ").split(" ");
text = ''
@@ -181,7 +197,13 @@ class UnifiedPaintPanel:
row.prop(ch, "show_in_workspace", text="", icon="HIDE_OFF")
#row.prop(ch, "ui_order", text="")
- if ch.type == "BITMASK":
+ if ch.type == "CURVE":
+ row.prop(finalch.curve, "curve_preset")
+ if finalch.curve.curve_preset == "CUSTOM":
+ path2 = path + ".curve.curve"
+ template_curve(layout, finalch.curve, "curve", path2)
+
+ elif ch.type == "BITMASK":
row.label(text=text)
if header:
@@ -201,7 +223,7 @@ class UnifiedPaintPanel:
else:
row.prop(finalch, typeprop, icon=icon, text=text, slider=slider)
- pressure = pressure and ch.type not in ["BOOL", "ENUM", "BITMASK"]
+ pressure = pressure and ch.type not in ["BOOL", "ENUM", "BITMASK", "CURVE"]
if pressure:
row.prop(finalch.mappings["PRESSURE"], "enabled", text="", icon="STYLUS_PRESSURE")
@@ -213,14 +235,14 @@ class UnifiedPaintPanel:
#if unified_name and not header:
# # NOTE: We don't draw UnifiedPaintSettings in the header to reduce clutter. D5928#136281
# row.prop(ups, unified_name, text="", icon='BRUSHES_ALL')
- if not header: # and ch.type != "BOOL":
+ if not header:
if ch.type == "BITMASK" and not toolsettings_only and ch == finalch:
row.prop(ch, "inherit_if_unset", text="Combine With Defaults")
if not toolsettings_only:
row.prop(ch, "inherit", text="", icon='BRUSHES_ALL')
- if ch.type == "BITMASK" or ch.type == "BOOL":
+ if ch.type in ["BITMASK", "BOOL", "CURVE"]:
return
if not ui_editing and not show_reorder:
@@ -792,12 +814,18 @@ def brush_settings(layout, context, brush, popover=False):
"auto_smooth_radius_factor",
slider=True
)
+ UnifiedPaintPanel.channel_unified(
+ box,
+ context,
+ brush,
+ "autosmooth_falloff_curve"
+ )
elif brush.sculpt_tool == "SMOOTH":
UnifiedPaintPanel.prop_unified(
layout,
context,
brush,
- "auto_smooth_projection",
+ "projection",
slider=True
)
@@ -847,7 +875,21 @@ def brush_settings(layout, context, brush, popover=False):
slider=True
)
- box.prop(brush, "use_curvature_rake")
+ UnifiedPaintPanel.channel_unified(
+ box,
+ context,
+ brush,
+ "topology_rake_mode",
+ expand=True
+ )
+ UnifiedPaintPanel.channel_unified(
+ box,
+ context,
+ brush,
+ "topology_rake_falloff_curve"
+ )
+
+ #box.prop(brush, "use_curvature_rake")
box.prop(brush, "ignore_falloff_for_topology_rake")
if context.sculpt_object.use_dynamic_topology_sculpting:
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index 795f220871b..13b15e31967 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -38,6 +38,7 @@ struct ToolSettings;
struct UnifiedPaintSettings;
struct DynTopoSettings;
struct Sculpt;
+struct CurveMapping;
// enum eCurveMappingPreset;
@@ -166,6 +167,10 @@ bool BKE_brush_hard_edge_mode_get(const struct Scene *scene, const struct Brush
void BKE_brush_hard_edge_mode_set(struct Scene *scene, struct Brush *brush, bool val);
float BKE_brush_fset_slide_get(const struct Scene *scene, const struct Brush *brush);
+float BKE_brush_curve_strength_ex(int curve_preset,
+ const struct CurveMapping *curve,
+ float p,
+ const float len);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index 3accc74af59..c5048692c01 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -65,6 +65,8 @@ struct Sculpt;
BKE_brush_channelset_get_float(chset, MAKE_BUILTIN_CH_NAME(channel), mapdata)
#define BRUSHSET_GET_INT(chset, channel, mapdata) \
BKE_brush_channelset_get_int(chset, MAKE_BUILTIN_CH_NAME(channel), mapdata)
+#define BRUSHSET_ENSURE_BUILTIN(chset, channel) \
+ BKE_brush_channelset_ensure_builtin(chset, MAKE_BUILTIN_CH_NAME(channel))
//#define DEBUG_CURVE_MAPPING_ALLOC
#ifdef DEBUG_CURVE_MAPPING_ALLOC
@@ -109,6 +111,7 @@ typedef struct BrushChannelType {
int ivalue;
float fvalue;
float vector[4];
+ int curve_preset;
BrushEnumDef enumdef[MAX_BRUSH_ENUM_DEF]; // for enum/bitmask types
EnumPropertyItem *rna_enumdef;
@@ -165,8 +168,8 @@ BrushChannel *BKE_brush_channelset_lookup(BrushChannelSet *chset, const char *id
bool BKE_brush_channelset_has(BrushChannelSet *chset, const char *idname);
-void BKE_brush_channelset_add_builtin(BrushChannelSet *chset, const char *idname);
-bool BKE_brush_channelset_ensure_builtin(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_channelset_merge(BrushChannelSet *dst,
BrushChannelSet *child,
@@ -217,6 +220,11 @@ void BKE_brush_channelset_set_final_float(BrushChannelSet *child,
void BKE_brush_channel_set_vector(BrushChannel *ch, float vec[4]);
int BKE_brush_channel_get_vector_size(BrushChannel *ch);
+float BKE_brush_channel_curve_evaluate(BrushChannel *ch, float val, const float maxval);
+CurveMapping *BKE_brush_channel_curvemapping_get(BrushCurve *curve, bool force_create);
+bool BKE_brush_channel_curve_ensure_write(BrushCurve *curve);
+void BKE_brush_channel_curve_assign(BrushChannel *ch, BrushCurve *curve);
+
/* returns size of vector */
int BKE_brush_channel_get_vector(BrushChannel *ch, float out[4], BrushMappingData *mapdata);
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index d65713f7389..5c8616f5aac 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -2675,8 +2675,10 @@ void BKE_brush_randomize_texture_coords(UnifiedPaintSettings *ups, bool mask)
}
}
-/* Uses the brush curve control to find a strength value */
-ATTR_NO_OPT float BKE_brush_curve_strength(const Brush *br, float p, const float len)
+ATTR_NO_OPT float BKE_brush_curve_strength_ex(int curve_preset,
+ const CurveMapping *curve,
+ float p,
+ const float len)
{
float strength = 1.0f;
@@ -2687,9 +2689,9 @@ ATTR_NO_OPT float BKE_brush_curve_strength(const Brush *br, float p, const float
p = p / len;
p = 1.0f - p;
- switch (br->curve_preset) {
+ switch (curve_preset) {
case BRUSH_CURVE_CUSTOM:
- strength = BKE_curvemapping_evaluateF(br->curve, 0, 1.0f - p);
+ strength = BKE_curvemapping_evaluateF(curve, 0, 1.0f - p);
break;
case BRUSH_CURVE_SHARP:
strength = p * p;
@@ -2723,6 +2725,12 @@ ATTR_NO_OPT float BKE_brush_curve_strength(const Brush *br, float p, const float
return strength;
}
+/* Uses the brush curve control to find a strength value */
+ATTR_NO_OPT float BKE_brush_curve_strength(const Brush *br, float p, const float len)
+{
+ return BKE_brush_curve_strength_ex(br->curve_preset, br->curve, p, len);
+}
+
/* Uses the brush curve control to find a strength value between 0 and 1 */
float BKE_brush_curve_strength_clamped(Brush *br, float p, const float len)
{
diff --git a/source/blender/blenkernel/intern/brush_channel_define.h b/source/blender/blenkernel/intern/brush_channel_define.h
index 8a57caf3349..4344adf829c 100644
--- a/source/blender/blenkernel/intern/brush_channel_define.h
+++ b/source/blender/blenkernel/intern/brush_channel_define.h
@@ -58,6 +58,9 @@ places in rna_engine_codebase are relevent:
# ifdef MAKE_FLAGS_EX
# undef MAKE_FLAGS_EX
# endif
+# ifdef MAKE_CURVE
+# undef MAKE_CURVE
+# endif
# ifdef MAKE_BUILTIN_CH_DEF
# undef MAKE_BUILTIN_CH_DEF
@@ -90,7 +93,7 @@ places in rna_engine_codebase are relevent:
# define MAKE_FLAGS(idname1, name1, tooltip1, value1, enumdef1) MAKE_BUILTIN_CH_DEF(idname1);
# define MAKE_FLAGS_EX(idname1, name1, tooltip1, value1, enumdef1, flag1) \
MAKE_BUILTIN_CH_DEF(idname1);
-
+# define MAKE_CURVE(idname1, name1, t
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list