Sculpt: Option to lock the rotation in the Pose Brush scale deform mode

The scale deform mode includes rotation by default, so when when scaling
down a part of the models it becomes harder to control as the effect of
the rotation less predictable (similar to using trackball rotation in a
very small radius). This locks the rotation of the segment, so parts of
the model can be scaled down in a more predictable way.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8465
This commit is contained in:
Pablo Dobarro 2020-08-04 17:19:27 +02:00
parent 3474b0968a
commit 9ea77f5232
4 changed files with 14 additions and 2 deletions

View File

@ -646,6 +646,8 @@ def brush_settings(layout, context, brush, popover=False):
layout.prop(brush, "pose_smooth_iterations")
if brush.pose_deform_type == 'ROTATE_TWIST' and brush.pose_origin_type in {'TOPOLOGY', 'FACE_SETS'}:
layout.prop(brush, "pose_ik_segments")
if brush.pose_deform_type == 'SCALE_TRANSLATE':
layout.prop(brush, "use_pose_lock_rotation")
layout.prop(brush, "use_pose_ik_anchored")
layout.prop(brush, "use_connected_only")
layout.prop(brush, "disconnected_distance_max")

View File

@ -1025,8 +1025,10 @@ static void sculpt_pose_do_scale_deform(SculptSession *ss, Brush *brush)
copy_v3_v3(ik_target, ss->cache->true_location);
add_v3_v3(ik_target, ss->cache->grab_delta);
/* Solve the IK for the first segment to include rotation as part of scale. */
pose_solve_ik_chain(ik_chain, ik_target, brush->flag2 & BRUSH_POSE_IK_ANCHORED);
/* Solve the IK for the first segment to include rotation as part of scale if enabled. */
if (!(brush->flag2 & BRUSH_POSE_USE_LOCK_ROTATION)) {
pose_solve_ik_chain(ik_chain, ik_target, brush->flag2 & BRUSH_POSE_IK_ANCHORED);
}
float scale[3];
copy_v3_fl(scale, sculpt_pose_get_scale_from_grab_delta(ss, ik_target));

View File

@ -739,6 +739,7 @@ typedef enum eBrushFlags2 {
BRUSH_POSE_IK_ANCHORED = (1 << 2),
BRUSH_USE_CONNECTED_ONLY = (1 << 3),
BRUSH_CLOTH_PIN_SIMULATION_BOUNDARY = (1 << 4),
BRUSH_POSE_USE_LOCK_ROTATION = (1 << 5),
} eBrushFlags2;
typedef enum {

View File

@ -2803,6 +2803,13 @@ static void rna_def_brush(BlenderRNA *brna)
prop, "Keep Anchor Point", "Keep the position of the last segment in the IK chain fixed");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "use_pose_lock_rotation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag2", BRUSH_POSE_USE_LOCK_ROTATION);
RNA_def_property_ui_text(prop,
"Lock Rotation When Scaling",
"Do not rotate the segment when using the scale deform mode");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "use_connected_only", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag2", BRUSH_USE_CONNECTED_ONLY);
RNA_def_property_ui_text(prop, "Connected Only", "Affect only topologically connected elements");