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
This commit is contained in:
parent
470fe59f7e
commit
186bd1759f
|
@ -426,6 +426,8 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
|
|||
elif brush.sculpt_tool == 'POSE':
|
||||
row = col.row()
|
||||
row.prop(brush, "pose_offset")
|
||||
row = col.row()
|
||||
row.prop(brush, "pose_smooth_iterations")
|
||||
elif brush.sculpt_tool == 'GRAB':
|
||||
col.separator()
|
||||
row = col.row()
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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, \
|
||||
|
|
|
@ -334,6 +334,9 @@ typedef struct Brush {
|
|||
|
||||
/* pose */
|
||||
float pose_offset;
|
||||
int pose_smooth_iterations;
|
||||
|
||||
char _pad2[4];
|
||||
|
||||
/* multiplane scrape */
|
||||
float multiplane_scrape_angle;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue