[Bf-blender-cvs] [8ff3d12fcd8] PSketch-279: Twist Brush: Support for Bendy Bones

Joshua Leung noreply at git.blender.org
Tue May 8 18:03:52 CEST 2018


Commit: 8ff3d12fcd85341c7966a6f586a21e48a67c5671
Author: Joshua Leung
Date:   Tue Jan 2 19:07:48 2018 +1300
Branches: PSketch-279
https://developer.blender.org/rB8ff3d12fcd85341c7966a6f586a21e48a67c5671

Twist Brush: Support for Bendy Bones

* Split the Twist brush eval function into 2 parts - the "normal" bone
  version, and a "bendy bone" version.

* The BBone version is more sensitive for now, since it's annoying to
  sit and wait for it to change. Then again, maybe artists prefer the
  slower one to have more control?

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

M	source/blender/editors/armature/pose_sculpt.c

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

diff --git a/source/blender/editors/armature/pose_sculpt.c b/source/blender/editors/armature/pose_sculpt.c
index 130ac6a85c3..92ea3d66481 100644
--- a/source/blender/editors/armature/pose_sculpt.c
+++ b/source/blender/editors/armature/pose_sculpt.c
@@ -1275,8 +1275,8 @@ static void psculpt_brush_curl_apply(tPoseSculptingOp *pso, bPoseChannel *pchan,
 
 /* Twist ----------------------------------------------- */
 
-/* "Twist" brush - Rotate bone around its primary axis */
-static void psculpt_brush_twist_apply(tPoseSculptingOp *pso, bPoseChannel *pchan, float dist, float sco1[2], float sco2[2])
+/* "Twist" brush - Whole bone */
+static void psculpt_brush_twist_apply_bone(tPoseSculptingOp *pso, bPoseChannel *pchan, float dist)
 {
 	short locks = pchan->protectflag;
 	float eul[3] = {0.0f};
@@ -1299,10 +1299,48 @@ static void psculpt_brush_twist_apply(tPoseSculptingOp *pso, bPoseChannel *pchan
 	/* just rotate on y, unless locked */
 	if ((locks & OB_LOCK_ROTY) == 0) {
 		eul[1] += angle;
+		
+		/* flush values */
+		set_pchan_eul_rotation(eul, pchan);
 	}
+}
+
+/* "Twist" brush - Bendy Bone */
+static void psculpt_brush_twist_apply_bendybone(tPoseSculptingOp *pso, bPoseChannel *pchan, float dist, float sco1[2], float sco2[2])
+{
+	bool do_head = false, do_tail = false;
+	float fac = psculpt_brush_calc_bendybone_influence(pso, dist, sco1, sco2, &do_head, &do_tail);
 	
-	/* flush values */
-	set_pchan_eul_rotation(eul, pchan);
+	/* Amount to rotate depends on the strength of the brush 
+	 * - The current calculation results in 0.xy degree values. Multiplying by even 2.5
+	 *   however is much too strong for controllability. So, leaving it as-is.
+	 * - Rotations are internally represented using radians, which are very sensitive
+	 */
+	float angle = psculpt_brush_calc_influence(pso, dist);
+	angle = DEG2RAD(angle);
+	
+	if (pso->invert) angle = -angle;
+	
+	/* Affect head or tail? */
+	if (do_head) {
+		pchan->roll1 += angle;
+	}
+	if (do_tail) {
+		pchan->roll2 += angle;
+	}
+}
+
+/* "Twist" brush - Rotate bone around its primary axis */
+static void psculpt_brush_twist_apply(tPoseSculptingOp *pso, bPoseChannel *pchan, float dist, float sco1[2], float sco2[2])
+{
+	/* For now, B-Bone handling is mutually exclusive with normal twisting... */
+	/* TODO: Add extra options to control which of these we use? */
+	if ((pchan->bone) && (pchan->bone->segments > 1)) {
+		psculpt_brush_twist_apply_bendybone(pso, pchan, dist, sco1, sco2);
+	}
+	else {
+		psculpt_brush_twist_apply_bone(pso, pchan, dist);
+	}
 }
 
 /* Stretch --------------------------------------------- */



More information about the Bf-blender-cvs mailing list