[Bf-blender-cvs] [556084f45ae] sculpt-dev: Sculpt: fix versioning error and add cutoff option for square and cutoff mapping functions.
Joseph Eagar
noreply at git.blender.org
Sun Oct 17 00:52:46 CEST 2021
Commit: 556084f45ae2088987a3b5bdb6682560d7c8118c
Author: Joseph Eagar
Date: Sat Oct 16 15:52:05 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB556084f45ae2088987a3b5bdb6682560d7c8118c
Sculpt: fix versioning error and add cutoff option
for square and cutoff mapping functions.
===================================================================
M release/scripts/startup/bl_ui/properties_paint_common.py
M source/blender/blenkernel/BKE_brush_engine.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/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 d948c16cc6e..a6c28e7452c 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -575,6 +575,9 @@ class UnifiedPaintPanel:
row.prop(mp, "premultiply")
row.prop(mp, "mapfunc")
+ if mp.mapfunc in ("SQUARE", "CUTOFF"):
+ col.prop(mp, "func_cutoff")
+
col.label(text="Output Mapping")
row = col.row()
row.prop(mp, "min")
diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index 621cbeb51fa..387dc902b2e 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -104,6 +104,7 @@ typedef struct BrushMappingDef {
bool inv;
float min, max;
int blendmode;
+ float func_cutoff;
float factor; // if 0, will default to 1.0
bool no_default;
} BrushMappingDef;
diff --git a/source/blender/blenkernel/intern/brush_engine.c b/source/blender/blenkernel/intern/brush_engine.c
index f1f7bd6a0e7..684ab5fdc56 100644
--- a/source/blender/blenkernel/intern/brush_engine.c
+++ b/source/blender/blenkernel/intern/brush_engine.c
@@ -449,6 +449,7 @@ void BKE_brush_channel_init(BrushChannel *ch, BrushChannelType *def)
mp->blendmode = !mdef->no_default ? MA_RAMP_MULT : mdef->blendmode;
mp->factor = mdef->factor == 0.0f ? 1.0f : mdef->factor;
mp->premultiply = 1.0f;
+ mp->func_cutoff = mdef->func_cutoff != 0.0f ? mdef->func_cutoff : 0.5f;
if (i == BRUSH_MAPPING_STROKE_T) {
mp->mapfunc = BRUSH_MAPFUNC_COS;
@@ -956,10 +957,6 @@ double BKE_brush_channel_eval_mappings(BrushChannel *ch,
switch ((BrushMappingFunc)mp->mapfunc) {
case BRUSH_MAPFUNC_NONE:
break;
- case BRUSH_MAPFUNC_SQUARE:
- inputf -= floorf(inputf);
- inputf = (float)(inputf > 0.5f);
- break;
case BRUSH_MAPFUNC_SAW:
inputf -= floorf(inputf);
break;
@@ -976,7 +973,11 @@ double BKE_brush_channel_eval_mappings(BrushChannel *ch,
user confusion we just do it here instead of making
them check the inverse checkbox.*/
inputf = 1.0f - inputf;
- CLAMP(inputf, 0.0f, 1.0f);
+ CLAMP(inputf, 0.0f, mp->func_cutoff * 2.0f);
+ break;
+ case BRUSH_MAPFUNC_SQUARE:
+ inputf -= floorf(inputf);
+ inputf = inputf > mp->func_cutoff ? 1.0f : 0.0f; //(float)(inputf > 0.5f);
break;
default:
break;
@@ -1812,11 +1813,15 @@ void BKE_brush_channelset_read(BlendDataReader *reader, BrushChannelSet *chset)
mp->premultiply = 1.0f;
}
+ if (mp->func_cutoff == 0.0f) {
+ mp->func_cutoff = 0.5f;
+ }
+
if (mp->factor == 0.0f) {
mp->factor = 1.0f;
}
- if (mp->min == mp->max == 0.0f) {
+ if (mp->min == mp->max) {
mp->max = 1.0f;
}
diff --git a/source/blender/blenkernel/intern/brush_engine_presets.c b/source/blender/blenkernel/intern/brush_engine_presets.c
index a57e084c112..e6f0758b1d0 100644
--- a/source/blender/blenkernel/intern/brush_engine_presets.c
+++ b/source/blender/blenkernel/intern/brush_engine_presets.c
@@ -1675,6 +1675,7 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
GETCH(slide_deform_type)->ivalue = BRUSH_SLIDE_DEFORM_DRAG;
break;
case SCULPT_TOOL_PAINT: {
+ BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
BRUSHSET_SET_BOOL(chset, dyntopo_disabled, true);
BRUSHSET_SET_FLOAT(chset, hardness, 0.4f);
BRUSHSET_SET_FLOAT(chset, spacing, 10.0f);
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 9603068dfa8..5ac5dabc8a6 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -1949,6 +1949,8 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
ch->mappings[i].blendmode = MA_RAMP_MULT;
}
+ ch->mappings[i].func_cutoff = 0.5f;
+
if (ch->mappings[i].min == ch->mappings[i].max) {
ch->mappings[i].min = 0.0f;
ch->mappings[i].max = 1.0f;
@@ -1969,6 +1971,10 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
continue;
}
+ if (brush->sculpt_tool == SCULPT_TOOL_PAINT) {
+ BRUSHSET_SET_BOOL(brush->channels, use_space_attenuation, false);
+ }
+
LISTBASE_FOREACH (BrushChannel *, ch, &brush->channels->channels) {
for (int i = 0; i < BRUSH_MAPPING_MAX; i++) {
ch->mappings[i].premultiply = 1.0f;
@@ -1976,6 +1982,7 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
BrushMapping *mp = ch->mappings + BRUSH_MAPPING_STROKE_T;
+ mp->func_cutoff = 0.5f;
mp->blendmode = MA_RAMP_MULT;
mp->max = 1.0f;
mp->mapfunc = BRUSH_MAPFUNC_COS;
diff --git a/source/blender/makesdna/DNA_sculpt_brush_types.h b/source/blender/makesdna/DNA_sculpt_brush_types.h
index 58a7573a44b..8db0202ce45 100644
--- a/source/blender/makesdna/DNA_sculpt_brush_types.h
+++ b/source/blender/makesdna/DNA_sculpt_brush_types.h
@@ -42,6 +42,8 @@ typedef struct BrushMapping {
float min, max;
float premultiply; // premultiply input data
int mapfunc;
+ float func_cutoff;
+ int _pad[1];
} BrushMapping;
typedef struct BrushCurve {
diff --git a/source/blender/makesrna/intern/rna_brush_engine.c b/source/blender/makesrna/intern/rna_brush_engine.c
index 6913c7cb8be..8eb8605440c 100644
--- a/source/blender/makesrna/intern/rna_brush_engine.c
+++ b/source/blender/makesrna/intern/rna_brush_engine.c
@@ -672,6 +672,12 @@ void RNA_def_brush_mapping(BlenderRNA *brna)
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Pre-Multiply", "Multiply input data by this amount");
+ prop = RNA_def_property(srna, "func_cutoff", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, "BrushMapping", "func_cutoff");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
+ RNA_def_property_ui_text(prop, "Cutoff", "Cutoff for square and cutoff modes");
+
prop = RNA_def_property(srna, "min", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, "BrushMapping", "min");
RNA_def_property_range(prop, -100000, 100000);
More information about the Bf-blender-cvs
mailing list