[Bf-blender-cvs] [1a26ae0fec7] PSketch-279: Push Brush: First attempt at a brush to modify Bendy Bone shape

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


Commit: 1a26ae0fec7573f6844aa53d683bf71c24bd8cf2
Author: Joshua Leung
Date:   Sun Dec 31 17:20:31 2017 +1300
Branches: PSketch-279
https://developer.blender.org/rB1a26ae0fec7573f6844aa53d683bf71c24bd8cf2

Push Brush: First attempt at a brush to modify Bendy Bone shape

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

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 aeb29a22a72..6f988f86a8b 100644
--- a/source/blender/editors/armature/pose_sculpt.c
+++ b/source/blender/editors/armature/pose_sculpt.c
@@ -1509,7 +1509,87 @@ static void psculpt_brush_restore_apply(tPoseSculptingOp *pso, bPoseChannel *pch
 /* "push" brush - for bendy bones */
 static void psculpt_brush_push_apply(tPoseSculptingOp *pso, bPoseChannel *pchan, float dist, float sco1[2], float sco2[2])
 {
-	// TODO: Adjust bendy bones only
+	PSculptBrushData *brush = pso->brush;
+	tAffectedBone *tab = NULL;
+	
+	float imat[4][4], mat[4][4];
+	float delta[3], vec[3];
+	
+	float d1, d2, dm;
+	float mid[2];
+	float fac;
+	
+	/* when invert is true, we don't restrict ourselves to the initial set only (i.e. "push") */
+	if ((brush->flag & PSCULPT_BRUSH_FLAG_GRAB_INITIAL) && (pso->invert == false)) {
+		tab = verify_bone_is_affected(pso, pchan, pso->is_first);
+		
+		/* if one couldn't be found or added, then it didn't exist the first time round,
+		 * so we shouldn't proceed (to avoid clobbering additional bones)
+		 */
+		if (tab == NULL) {
+			return;
+		}
+#if 0 // XXX: Save values below!
+		else if (pso->is_first) {
+			/* store factor for later */
+			tab->fac = fac;
+		}
+		else {
+			/* use stored falloff */
+			// XXX: it was better for chains if we didn't use the stored falloff...
+			fac = tab->fac;
+		}
+#endif
+	}
+	
+	/* compute inverse matrix to convert from screen-space to bone space */
+	mul_m4_m4m4(mat, pso->ob->obmat, pchan->bone->arm_mat);
+	invert_m4_m4(imat, mat);
+	
+	/* apply deforms to based on amount mouse moves */
+	copy_v3_v3(delta, pso->dvec);
+	mul_mat3_m4_v3(imat, delta);
+	
+	/* figure out which end is affected more */
+	d1 = len_v2v2(pso->mval, sco1);
+	d2 = len_v2v2(pso->mval, sco2);
+	
+	mid_v2_v2v2(mid, sco1, sco2);
+	dm = len_v2v2(pso->mval, mid);
+	
+	/* apply the components directly (since it should be in bone space):
+	 *   - vec.x = bone.x
+	 *   - vec.z = bone.y
+	 *
+	 *   - vec.y = ease in/out (proportional to bone length?)
+	 */
+	if (d1 < d2) {
+		/* Head (In) */
+		fac = psculpt_brush_calc_influence(pso, d1);
+		mul_v3_v3fl(vec, delta, fac);
+		
+		pchan->curveInX += vec[0];
+		pchan->curveInY += vec[2];
+	}
+	else if (d2 < d1) {
+		/* Tail (Out) */
+		fac = psculpt_brush_calc_influence(pso, d2);
+		mul_v3_v3fl(vec, delta, fac);
+		
+		pchan->curveOutX += vec[0];
+		pchan->curveOutY += vec[2];
+	}
+	else {
+		/* Affect both by the same amount */
+		fac = psculpt_brush_calc_influence(pso, dist);
+		mul_v3_v3fl(vec, delta, fac);
+		
+		pchan->curveInX += vec[0];
+		pchan->curveInY += vec[2];
+		
+		pchan->curveOutX += vec[0];
+		pchan->curveOutY += vec[2];
+	}
 }



More information about the Bf-blender-cvs mailing list