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
path: root/source
diff options
context:
space:
mode:
authorPablo Dobarro <pablodp606@gmail.com>2019-11-17 03:09:08 +0300
committerPablo Dobarro <pablodp606@gmail.com>2019-11-21 20:41:58 +0300
commit186bd1759f05c71c5c44391a5925b0f43cbd3383 (patch)
tree56b8abcb5e985375769cea8a7df1ca711ff631f8 /source
parent470fe59f7e87fc01c9ff86a65c591ea9833ba1aa (diff)
Pose brush: Smooth Iterations Brush Property
The smooth iterations of the pose factor were hardcoded to 4. This works fine in most situations when you are posing a low poly mesh, which is the main use case of this tool. I added the smooth iterations as a brush property in case you need to pose a high poly mesh directly without producing artifacts. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D6157
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/brush.c1
-rw-r--r--source/blender/blenloader/intern/versioning_280.c8
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c9
-rw-r--r--source/blender/makesdna/DNA_brush_defaults.h1
-rw-r--r--source/blender/makesdna/DNA_brush_types.h3
-rw-r--r--source/blender/makesrna/intern/rna_brush.c9
6 files changed, 28 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 794876ec444..15a9b0b9c6a 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -981,6 +981,7 @@ void BKE_brush_sculpt_reset(Brush *br)
br->flag &= ~BRUSH_SPACE_ATTEN;
break;
case SCULPT_TOOL_POSE:
+ br->pose_smooth_iterations = 4;
br->flag &= ~BRUSH_ALPHA_PRESSURE;
br->flag &= ~BRUSH_SPACE;
br->flag &= ~BRUSH_SPACE_ATTEN;
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 488cf6b0213..33a0da7457f 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -3934,7 +3934,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
/* Versioning code until next subversion bump goes here. */
-
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
sa->flag &= ~AREA_FLAG_UNUSED_6;
@@ -3972,5 +3971,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
br->dash_samples = 20;
}
}
+
+ /* Pose brush smooth iterations */
+ if (!DNA_struct_elem_find(fd->filesdna, "Brush", "float", "pose_smooth_itereations")) {
+ for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
+ br->pose_smooth_iterations = 4;
+ }
+ }
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 6cda6ccac06..b7fb49d357f 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3940,7 +3940,7 @@ static void sculpt_pose_brush_init(
};
/* Smooth the pose brush factor for cleaner deformation */
- for (int i = 0; i < 4; i++) {
+ for (int i = 0; i < br->pose_smooth_iterations; i++) {
PBVHParallelSettings settings;
BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode);
BKE_pbvh_parallel_range(0, totnode, &data, pose_brush_init_task_cb_ex, &settings);
@@ -5705,7 +5705,12 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
}
else if (brush->sculpt_tool == SCULPT_TOOL_POSE) {
- float final_radius = ss->cache->radius * (1 + brush->pose_offset);
+ /* After smoothing the pose factor an arbitrary number of times, the pose factor values can
+ * expand to nodes that are not inside the original radius of the brush. Using a slightly
+ * bigger radius should prevent those artifacts. */
+ /* We can optimize this further by removing the nodes that have all 0 values in the pose factor
+ * after calculating it. */
+ float final_radius = ss->cache->radius * 1.5f * (1.0f + brush->pose_offset);
SculptSearchSphereData data = {
.ss = ss,
.sd = sd,
diff --git a/source/blender/makesdna/DNA_brush_defaults.h b/source/blender/makesdna/DNA_brush_defaults.h
index ff1f8c9a1c0..9d3689ce4ee 100644
--- a/source/blender/makesdna/DNA_brush_defaults.h
+++ b/source/blender/makesdna/DNA_brush_defaults.h
@@ -95,6 +95,7 @@
\
/* sculpting defaults to the draw tool for new brushes */ \
.sculpt_tool = SCULPT_TOOL_DRAW, \
+ .pose_smooth_iterations = 4, \
\
/* A kernel radius of 1 has almost no effect (T63233). */ \
.blur_kernel_radius = 2, \
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index c55ab81a733..a7e15ac9547 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -334,6 +334,9 @@ typedef struct Brush {
/* pose */
float pose_offset;
+ int pose_smooth_iterations;
+
+ char _pad2[4];
/* multiplane scrape */
float multiplane_scrape_angle;
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 86b1ed92349..321f3815691 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -1887,6 +1887,15 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Plane Angle", "Angle between the planes of the crease");
RNA_def_property_update(prop, 0, "rna_Brush_update");
+ prop = RNA_def_property(srna, "pose_smooth_iterations", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_sdna(prop, NULL, "pose_smooth_iterations");
+ RNA_def_property_range(prop, 0, 100);
+ RNA_def_property_ui_text(
+ prop,
+ "Smooth Iterations",
+ "Smooth iterations applied after calculating the pose factor of each vertex");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
prop = RNA_def_property(srna, "auto_smooth_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "autosmooth_factor");
RNA_def_property_float_default(prop, 0);