[Bf-blender-cvs] [67771766919] sculpt-dev: Sculpt: brush input mapping improvements
Joseph Eagar
noreply at git.blender.org
Sun Oct 17 00:10:52 CEST 2021
Commit: 677717669198f1dc965c7b3a53c43b13b5c6fa9f
Author: Joseph Eagar
Date: Sat Oct 16 15:06:36 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB677717669198f1dc965c7b3a53c43b13b5c6fa9f
Sculpt: brush input mapping improvements
* Input mappings now take a premultiply factor
to scale the input data prior to evaluation;
* Mapping data can also now be fed through a
(wave) function prior to evaluation.
* The UI now has seperate inputs and outputs
sections for input mapping to avoid confusion.
* Added a distance mapping and implemented the speed
mapping.
* Also fixed original data bug in color filter.
===================================================================
M release/scripts/startup/bl_ui/properties_paint_common.py
M release/scripts/startup/bl_ui/space_view3d_toolbar.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/dyntopo.c
M source/blender/blenkernel/intern/pbvh_bmesh.c
M source/blender/blenloader/intern/versioning_300.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_filter_color.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
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 49a89c5d75a..d948c16cc6e 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -569,6 +569,13 @@ class UnifiedPaintPanel:
col.prop(mp, "factor")
col.prop(mp, "blendmode")
+
+ col.label(text="Input Mapping")
+ row = col.row()
+ row.prop(mp, "premultiply")
+ row.prop(mp, "mapfunc")
+
+ col.label(text="Output Mapping")
row = col.row()
row.prop(mp, "min")
row.prop(mp, "max")
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 579ba19f9df..06427f7bfa1 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1144,7 +1144,12 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
ch = UnifiedPaintPanel.get_channel(context, brush, "dyntopo_mode")
col2.use_property_split = False
- col2.prop_enum(ch, "flags_value", "CLEANUP", icon="CHECKBOX_HLT" if "CLEANUP" in ch.flags_value else "CHECKBOX_DEHLT")
+ row2 = col2.row()
+ row2.prop_enum(ch, "flags_value", "CLEANUP", icon="CHECKBOX_HLT" if "CLEANUP" in ch.flags_value else "CHECKBOX_DEHLT")
+
+ row3 = row2.row()
+ row3.enabled = "COLLAPSE" not in ch.flags_value
+ row3.prop_enum(ch, "flags_value", "LOCAL_COLLAPSE", icon="CHECKBOX_HLT" if "LOCAL_COLLAPSE" in ch.flags_value else "CHECKBOX_DEHLT")
"""
UnifiedPaintPanel.channel_unified(
@@ -1250,7 +1255,20 @@ class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
brush,
"smooth_strength_projection", ui_editing=False, slider=True)
- #col.prop(sculpt, "smooth_strength_factor")
+ """
+ smoothbrush = None
+
+ for ts in sculpt.tool_slots:
+ if ts.brush and ts.brush.sculpt_tool == "SMOOTH":
+ smoothbrush = ts.brush
+ break
+
+ if smoothbrush:
+ UnifiedPaintPanel.channel_unified(layout.column(),
+ context,
+ smoothbrush,
+ "dyntopo_disabled", ui_editing=False, text="Disable Dyntopo For Smooth")
+ """
col.separator()
diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index 96cbb4982e2..621cbeb51fa 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -110,11 +110,11 @@ typedef struct BrushMappingDef {
typedef struct BrushMappingPreset {
// must match order of BRUSH_MAPPING_XXX enums
- struct BrushMappingDef pressure, xtilt, ytilt, angle, speed, random;
+ struct BrushMappingDef pressure, xtilt, ytilt, angle, speed, random, stroke_t;
} BrushMappingPreset;
typedef struct BrushMappingData {
- float pressure, xtilt, ytilt, angle, speed, random;
+ float pressure, xtilt, ytilt, angle, speed, random, stroke_t;
} BrushMappingData;
#define MAX_BRUSH_ENUM_DEF 32
diff --git a/source/blender/blenkernel/intern/brush_channel_define.h b/source/blender/blenkernel/intern/brush_channel_define.h
index a9fb64a8960..0bfd25645e3 100644
--- a/source/blender/blenkernel/intern/brush_channel_define.h
+++ b/source/blender/blenkernel/intern/brush_channel_define.h
@@ -262,7 +262,7 @@ places in rna_engine_codebase are relevent:
{DYNTOPO_COLLAPSE, "COLLAPSE", "NONE", "Collapse", ""},
{DYNTOPO_SUBDIVIDE, "SUBDIVIDE", "NONE", "Subdivide", ""},
{DYNTOPO_CLEANUP, "CLEANUP", "NONE", "Cleanup", ""},
- {DYNTOPO_LOCAL_COLLAPSE, "LOCAL_COLLAPSE", "NONE", "Local Collapse", ""},
+ {DYNTOPO_LOCAL_COLLAPSE, "LOCAL_COLLAPSE", "NONE", "Local Collapse", "Cleanup edges based on local edge lengths if collapse is off."},
{DYNTOPO_LOCAL_SUBDIVIDE, "LOCAL_SUBDIVIDE", "NONE", "Local Subdivide", ""},
{-1}
})
diff --git a/source/blender/blenkernel/intern/brush_engine.c b/source/blender/blenkernel/intern/brush_engine.c
index 87c34ccf5ad..f1f7bd6a0e7 100644
--- a/source/blender/blenkernel/intern/brush_engine.c
+++ b/source/blender/blenkernel/intern/brush_engine.c
@@ -448,6 +448,11 @@ 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;
+
+ if (i == BRUSH_MAPPING_STROKE_T) {
+ mp->mapfunc = BRUSH_MAPFUNC_COS;
+ }
if (mdef->enabled) {
mp->flag |= BRUSH_MAPPING_ENABLED;
@@ -946,10 +951,39 @@ double BKE_brush_channel_eval_mappings(BrushChannel *ch,
continue;
}
- float inputf = ((float *)mapdata)[i];
+ float inputf = ((float *)mapdata)[i] * mp->premultiply;
+
+ 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;
+ case BRUSH_MAPFUNC_TENT:
+ inputf -= floorf(inputf);
+ inputf = 1.0f - fabs(inputf - 0.5f) * 2.0f;
+ break;
+ case BRUSH_MAPFUNC_COS:
+ inputf = 1.0f - (cos(inputf * (float)M_PI * 2.0f) * 0.5f + 0.5f);
+ break;
+ case BRUSH_MAPFUNC_CUTOFF:
+ /*Cutoff is meant to create a fadeout effect,
+ which requires inverting the input. To avoid
+ 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);
+ break;
+ default:
+ break;
+ }
if (mp->flag & BRUSH_MAPPING_INVERT) {
- inputf = 1.0 - inputf;
+ inputf = 1.0f - inputf;
}
double f2 = (float)BKE_curvemapping_evaluateF(mp->curve, 0, inputf);
@@ -1774,6 +1808,14 @@ void BKE_brush_channelset_read(BlendDataReader *reader, BrushChannelSet *chset)
CurveMapping *curve = mp->curve;
+ if (mp->premultiply == 0.0f) {
+ mp->premultiply = 1.0f;
+ }
+
+ if (mp->factor == 0.0f) {
+ mp->factor = 1.0f;
+ }
+
if (mp->min == mp->max == 0.0f) {
mp->max = 1.0f;
}
@@ -1846,6 +1888,8 @@ const char *BKE_brush_mapping_type_to_str(BrushMappingType mapping)
return "Y Tilt";
case BRUSH_MAPPING_RANDOM:
return "Random";
+ case BRUSH_MAPPING_STROKE_T:
+ return "Distance";
case BRUSH_MAPPING_MAX:
return "Error";
}
@@ -1868,6 +1912,8 @@ const char *BKE_brush_mapping_type_to_typename(BrushMappingType mapping)
return "YTILT";
case BRUSH_MAPPING_RANDOM:
return "RANDOM";
+ case BRUSH_MAPPING_STROKE_T:
+ return "DISTANCE";
case BRUSH_MAPPING_MAX:
return "Error";
}
diff --git a/source/blender/blenkernel/intern/dyntopo.c b/source/blender/blenkernel/intern/dyntopo.c
index 1cf930cca37..7a57e8d4299 100644
--- a/source/blender/blenkernel/intern/dyntopo.c
+++ b/source/blender/blenkernel/intern/dyntopo.c
@@ -3858,6 +3858,11 @@ static BMVert *pbvh_bmesh_collapse_edge(PBVH *pbvh,
copy_v3_v3(v_conn->co, co);
}
+ if (!v_conn->e) {
+ printf("%s: pbvh error, v_conn->e was null\n", __func__);
+ return v_conn;
+ }
+
e2 = v_conn->e;
do {
BMLoop *l = e2->l;
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 93ccc1cc757..3f66d8fbcc9 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -1901,6 +1901,11 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
BMLoop *l_first = BM_FACE_FIRST_LOOP(f);
BMLoop *l_iter = l_first;
+ // check for currupted faceset
+ if (BM_ELEM_CD_GET_INT(f, pbvh->cd_faceset_offset) == 0) {
+ BM_ELEM_CD_SET_INT(f, pbvh->cd_faceset_offset, 1);
+ }
+
BB_reset((BB *)bbc);
do {
BB_expand((BB *)bbc, l_iter->v->co);
@@ -3119,11 +3124,11 @@ static void pbvh_bmesh_balance_tree(PBVH *pbvh)
/* use higher threshold for the root node and its immediate children */
switch (BLI_array_len(stack)) {
case 0:
- factor = 0.75;
+ factor = 0.5;
break;
case 1:
case 2:
- factor = 0.5;
+ factor = 0.2;
break;
default:
factor = 0.2;
@@ -3138,7 +3143,12 @@ static void pbvh_bmesh_balance_tree(PBVH *pbvh)
printf("factor: %.3f\n", factor);
#endif
- if (overlap > volume * factor) {
+ bool bad = overlap > volume * factor;
+
+ bad |= child1->bm_faces && !BLI_table_gset_len(child1->bm_faces);
+ bad |= child2->bm_faces && !BLI_table_gset_len(child2->bm_faces);
+
+ if (bad) {
modified = true;
printf(" DELETE! %.4f %.4f %d\n", overlap, volume, BLI_array_len(stack));
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 36b8b305708..9603068dfa8 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -1907,8 +1907,7 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
BKE_brush_mapping_reset(ch, brush->sculpt_tool, BRUSH_MAPPING_PRESSURE);
}
- ch = (BrushChannel *)brush->channels->channels.first;
- for (; ch; ch = ch->next) {
+ LISTBASE_FOREACH (BrushChannel *, ch, &brush->channels->channels) {
if (!ch->mappings[BRUSH_MAPPING_RANDOM].factor) {
ch->mappings[BRUSH_MAPPING_RANDOM].factor = 1.0f;
}
@@ -1927,6 +1926,64 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!MA
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list