Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Eagar <joeedh@gmail.com>2021-09-09 21:06:24 +0300
committerJoseph Eagar <joeedh@gmail.com>2021-09-09 21:06:24 +0300
commitf52a03dd713e7396a948b1ca3207d57fca5610e9 (patch)
treeab2178baee256dc581279bd72b16d9126ce7b207
parenta52f89a446566381c28804f0b1150aa71b245d59 (diff)
Sculpt dyntopo: Added a 'hard edge mode' option
to forcibly set autosmooth_fset_slide to zero (i.e. treat face set boundaries as hard edges and not project them on the surface).
-rw-r--r--release/scripts/startup/bl_ui/properties_paint_common.py10
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h2
-rw-r--r--source/blender/blenkernel/BKE_brush.h5
-rw-r--r--source/blender/blenkernel/intern/brush.c33
-rw-r--r--source/blender/blenloader/intern/versioning_280.c2
-rw-r--r--source/blender/blenloader/intern/versioning_300.c9
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_smooth.c4
-rw-r--r--source/blender/makesdna/DNA_brush_enums.h3
-rw-r--r--source/blender/makesdna/DNA_scene_defaults.h2
-rw-r--r--source/blender/makesdna/DNA_scene_types.h5
-rw-r--r--source/blender/makesrna/intern/rna_brush.c6
-rw-r--r--source/blender/makesrna/intern/rna_scene.c13
12 files changed, 87 insertions, 7 deletions
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index dd8873b84c5..bc76f338c38 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -549,7 +549,17 @@ def brush_settings(layout, context, brush, popover=False):
if context.preferences.experimental.use_sculpt_tools_tilt and capabilities.has_tilt:
layout.prop(brush, "tilt_strength_factor", slider=True)
+ UnifiedPaintPanel.prop_unified(
+ layout,
+ context,
+ brush,
+ "hard_edge_mode",
+ slider=True,
+ unified_name="use_unified_hard_edge_mode",
+ )
+
row = layout.row(align=True)
+
row.prop(brush, "hardness", slider=True)
row.prop(brush, "invert_hardness_pressure", text="")
row.prop(brush, "use_hardness_pressure", text="")
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index e2788020628..d71cb559911 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -39,7 +39,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 21
+#define BLENDER_FILE_SUBVERSION 22
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and show a warning if the file
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index bf3d45d318c..4e8873f2cac 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -155,6 +155,11 @@ void BKE_brush_debug_print_state(struct Brush *br);
void BKE_brush_get_dyntopo(struct Brush *brush, struct Sculpt *sd, struct DynTopoSettings *out);
+bool BKE_brush_hard_edge_mode_get(const struct Scene *scene, const struct Brush *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);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 7c27648161e..2e2f89ea8a2 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -2755,3 +2755,36 @@ void BKE_brush_get_dyntopo(Brush *brush, Sculpt *sd, DynTopoSettings *out)
}
}
};
+
+bool BKE_brush_hard_edge_mode_get(const Scene *scene, const Brush *brush)
+{
+ UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
+ bool ret = (ups->flag & UNIFIED_PAINT_FLAG_HARD_EDGE_MODE) ? ups->hard_edge_mode :
+ brush->flag2 & BRUSH_HARD_EDGE_MODE;
+
+ return ret;
+}
+
+void BKE_brush_hard_edge_mode_set(Scene *scene, Brush *brush, bool val)
+{
+ UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
+
+ if (ups->flag & UNIFIED_PAINT_FLAG_HARD_EDGE_MODE) {
+ ups->hard_edge_mode = val;
+ }
+ else {
+ if (val) {
+ brush->flag2 |= BRUSH_HARD_EDGE_MODE;
+ }
+ else {
+ brush->flag2 &= ~BRUSH_HARD_EDGE_MODE;
+ }
+ }
+}
+
+float BKE_brush_fset_slide_get(const Scene *scene, const Brush *brush)
+{
+ UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
+
+ return BKE_brush_hard_edge_mode_get(scene, brush) ? 0.0f : brush->autosmooth_fset_slide;
+}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 2598c53a5e0..e87e201368e 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -4424,7 +4424,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
ToolSettings *ts = scene->toolsettings;
UnifiedPaintSettings *ups = &ts->unified_paint_settings;
- ups->flag &= ~(UNIFIED_PAINT_FLAG_UNUSED_0 | UNIFIED_PAINT_FLAG_UNUSED_1);
+ ups->flag &= ~(UNIFIED_PAINT_FLAG_UNUSED_1);
}
/* Set the default render pass in the viewport to Combined. */
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index f36220e2b99..15d6f9134ab 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -1169,6 +1169,15 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!MAIN_VERSION_ATLEAST(bmain, 300, 22)) {
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+ ToolSettings *ts = scene->toolsettings;
+
+ if (ts) {
+ ts->unified_paint_settings.flag |= UNIFIED_PAINT_FLAG_HARD_EDGE_MODE;
+ }
+ }
+ }
/**
* Versioning code until next subversion bump goes here.
*
diff --git a/source/blender/editors/sculpt_paint/sculpt_smooth.c b/source/blender/editors/sculpt_paint/sculpt_smooth.c
index 774496ff418..33a6fadde7f 100644
--- a/source/blender/editors/sculpt_paint/sculpt_smooth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_smooth.c
@@ -87,7 +87,7 @@ void SCULPT_neighbor_coords_average_interior(SculptSession *ss,
int bflag = SCULPT_BOUNDARY_MESH | SCULPT_BOUNDARY_SHARP;
float bound_smooth = powf(ss->cache->brush->boundary_smooth_factor, BOUNDARY_SMOOTH_EXP);
- float slide_fset = ss->cache->brush->autosmooth_fset_slide;
+ float slide_fset = BKE_brush_fset_slide_get(ss->scene, ss->cache->brush);
slide_fset = MAX2(slide_fset, bound_smooth);
@@ -1046,7 +1046,7 @@ static void do_smooth_brush_task_cb_ex(void *__restrict userdata,
bool modified = false;
const float bound_smooth = powf(ss->cache->brush->boundary_smooth_factor, BOUNDARY_SMOOTH_EXP);
- const float slide_fset = ss->cache->brush->autosmooth_fset_slide;
+ const float slide_fset = BKE_brush_fset_slide_get(ss->scene, ss->cache->brush);
SculptCustomLayer *bound_scl = data->scl2;
diff --git a/source/blender/makesdna/DNA_brush_enums.h b/source/blender/makesdna/DNA_brush_enums.h
index 0ce18c0e33a..4fba8e4d727 100644
--- a/source/blender/makesdna/DNA_brush_enums.h
+++ b/source/blender/makesdna/DNA_brush_enums.h
@@ -420,6 +420,9 @@ typedef enum eBrushFlags2 {
/*topology rake in dynamic mode*/
BRUSH_DYNAMIC_RAKE = (1 << 15),
+
+ /* sets face set slide to 0.0 */
+ BRUSH_HARD_EDGE_MODE = (1 << 16),
} eBrushFlags2;
typedef enum {
diff --git a/source/blender/makesdna/DNA_scene_defaults.h b/source/blender/makesdna/DNA_scene_defaults.h
index 61707964191..10c8e0140f9 100644
--- a/source/blender/makesdna/DNA_scene_defaults.h
+++ b/source/blender/makesdna/DNA_scene_defaults.h
@@ -290,7 +290,7 @@
.unprojected_radius = 0.29, \
.alpha = 0.5f, \
.weight = 0.5f, \
- .flag = UNIFIED_PAINT_SIZE | UNIFIED_PAINT_ALPHA, \
+ .flag = UNIFIED_PAINT_SIZE | UNIFIED_PAINT_ALPHA | UNIFIED_PAINT_FLAG_HARD_EDGE_MODE, \
}
#define _DNA_DEFAULTS_ParticleEditSettings \
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 1e5441ea420..72085957c3a 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1244,7 +1244,8 @@ typedef struct UnifiedPaintSettings {
float pixel_radius;
float initial_pixel_radius;
- char _pad[4];
+ char _pad[3];
+ char hard_edge_mode;
/* drawing pressure */
float size_pressure_value;
@@ -1268,7 +1269,7 @@ typedef enum {
/* only used if unified size is enabled, mirrors the brush flag BRUSH_LOCK_SIZE */
UNIFIED_PAINT_BRUSH_LOCK_SIZE = (1 << 2),
- UNIFIED_PAINT_FLAG_UNUSED_0 = (1 << 3),
+ UNIFIED_PAINT_FLAG_HARD_EDGE_MODE = (1 << 3),
UNIFIED_PAINT_FLAG_UNUSED_1 = (1 << 4),
} eUnifiedPaintSettingsFlags;
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index b3587df9cf3..bf9a8d3d817 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -3349,6 +3349,12 @@ static void rna_def_brush(BlenderRNA *brna)
prop, "Preserve Face Sets", "Preserve face set boundaries when smoothing");
RNA_def_property_update(prop, 0, "rna_Brush_update");
+ prop = RNA_def_property(srna, "hard_edge_mode", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", BRUSH_HARD_EDGE_MODE);
+ RNA_def_property_ui_text(
+ prop, "Hard Edge Mode", "Hard edge mode; treat all face set boundaries as hard edges");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
prop = RNA_def_property(srna, "use_grab_silhouette", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag2", BRUSH_GRAB_SILHOUETTE);
RNA_def_property_ui_text(
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 0583cdeb1bb..0ba2652f185 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -3597,6 +3597,12 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna)
"Use Unified Radius",
"Instead of per-brush radius, the radius is shared across brushes");
+ /* high-level flags to enable or disable unified paint settings */
+ prop = RNA_def_property(srna, "use_unified_hard_edge_mode", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", UNIFIED_PAINT_FLAG_HARD_EDGE_MODE);
+ RNA_def_property_ui_text(
+ prop, "Use Unified Hard Edge Mode", "Use global setting for hard edge mode");
+
prop = RNA_def_property(srna, "use_unified_strength", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", UNIFIED_PAINT_ALPHA);
RNA_def_property_ui_text(prop,
@@ -3669,6 +3675,13 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna)
RNA_def_property_enum_items(prop, brush_size_unit_items);
RNA_def_property_ui_text(
prop, "Radius Unit", "Measure brush size relative to the view or the scene");
+
+ prop = RNA_def_property(srna, "hard_edge_mode", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "hard_edge_mode", 1);
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_ui_text(
+ prop, "Hard Edge Mode", "Hard edge mode; treat all face set boundaries as hard edges");
+ RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update");
}
static void rna_def_curve_paint_settings(BlenderRNA *brna)