[Bf-blender-cvs] [9ea77f5232c] master: Sculpt: Option to lock the rotation in the Pose Brush scale deform mode

Pablo Dobarro noreply at git.blender.org
Wed Aug 5 22:59:49 CEST 2020


Commit: 9ea77f5232c7a07b529c9f0d6417112a20d441aa
Author: Pablo Dobarro
Date:   Tue Aug 4 17:19:27 2020 +0200
Branches: master
https://developer.blender.org/rB9ea77f5232c7a07b529c9f0d6417112a20d441aa

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

===================================================================

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	source/blender/editors/sculpt_paint/sculpt_pose.c
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesrna/intern/rna_brush.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 62c5bac91f8..d2b02c4c40b 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -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")
diff --git a/source/blender/editors/sculpt_paint/sculpt_pose.c b/source/blender/editors/sculpt_paint/sculpt_pose.c
index 976006b3958..f099dc0a6c1 100644
--- a/source/blender/editors/sculpt_paint/sculpt_pose.c
+++ b/source/blender/editors/sculpt_paint/sculpt_pose.c
@@ -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));
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 6d56db4b0e0..5cd7443900f 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -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 {
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 73ffff07c6c..7772912e261 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -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");



More information about the Bf-blender-cvs mailing list