[Bf-blender-cvs] [b288b55] BendyBones: Bendy Bones: Breakdowner + Pose Slide tools support for these properties

Joshua Leung noreply at git.blender.org
Tue May 17 16:40:46 CEST 2016


Commit: b288b550875ff4bfb2d22cc2031c7a3ebb9868d5
Author: Joshua Leung
Date:   Mon May 16 02:31:04 2016 +1200
Branches: BendyBones
https://developer.blender.org/rBb288b550875ff4bfb2d22cc2031c7a3ebb9868d5

Bendy Bones: Breakdowner + Pose Slide tools support for these properties

The Breakdowner and Pose Sliding tools (Push/Relax) now have support for the
bbone properties too, making it possible to use these tools for playing with
them like another other part of the pose.

Implementation Note:
I've ended up reusing a bunch of flags which we don't use, and haven't used
for at least a decade (and which were if 0'd out). When they were in use,
they would have been for runtime purposes anyway. Just to be safe, the version
patch in modern Blender will clear out all those flags so that we can use them.

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

M	source/blender/blenkernel/BKE_action.h
M	source/blender/blenkernel/intern/action.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/editors/armature/armature_intern.h
M	source/blender/editors/armature/pose_slide.c
M	source/blender/editors/armature/pose_utils.c
M	source/blender/makesdna/DNA_action_types.h

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

diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index c164cd5..cb282b4 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -79,12 +79,15 @@ typedef enum eAction_TransformFlags {
 	ACT_TRANS_ROT   = (1 << 1),
 	/* scaling */
 	ACT_TRANS_SCALE = (1 << 2),
-
+	
+	/* bbone shape - for all the parameters, provided one is set */
+	ACT_TRANS_BBONE = (1 << 3),
+	
 	/* strictly not a transform, but custom properties are also
 	 * quite often used in modern rigs
 	 */
-	ACT_TRANS_PROP  = (1 << 3),
-
+	ACT_TRANS_PROP  = (1 << 4),
+	
 	/* all flags */
 	ACT_TRANS_ONLY  = (ACT_TRANS_LOC | ACT_TRANS_ROT | ACT_TRANS_SCALE),
 	ACT_TRANS_ALL   = (ACT_TRANS_ONLY | ACT_TRANS_PROP)
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 40670de..3a31e4c 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -1282,6 +1282,18 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan,
 				}
 			}
 			
+			if ((curves) || (flags & ACT_TRANS_BBONE) == 0) {
+				/* bbone shape properties */
+				pPtr = strstr(bPtr, "bbone_");
+				if (pPtr) {
+					flags |= ACT_TRANS_BBONE;
+					
+					if (curves)
+						BLI_addtail(curves, BLI_genericNodeN(fcu));
+					continue;
+				}
+			}
+			
 			if ((curves) || (flags & ACT_TRANS_PROP) == 0) {
 				/* custom properties only */
 				pPtr = strstr(bPtr, "[\""); /* extra '"' comment here to keep my texteditor functionlist working :) */
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 7b7148b..761b83e 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -1178,6 +1178,15 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 					/* see do_version_bones_super_bbone()... */
 					pchan->scaleIn = 1.0f;
 					pchan->scaleOut = 1.0f;
+					
+					/* also make sure some legacy (unused for over a decade) flags are unset,
+					 * so that we can reuse them for stuff that matters now...
+					 * (i.e. POSE_IK_MAT, (unknown/unused x 4), POSE_HAS_IK)
+					 *
+					 * These seem to have been runtime flags used by the IK solver, but that stuff
+					 * should be able to be recalculated automatically anyway, so it should be fine.
+					 */
+					pchan->flag &= ~((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8));
 				}
 			}
 		}
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index ac150b9..02aefce 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -170,6 +170,11 @@ typedef struct tPChanFCurveLink {
 	float oldangle;
 	float oldaxis[3];
 	
+	float roll1, roll2;             /* old bbone values (to be restored along with the transform properties) */
+	float curveInX, curveInY;       /* (NOTE: we haven't renamed these this time, as their names are already long enough) */
+	float curveOutX, curveOutY;
+	float scaleIn, scaleOut;
+	
 	struct IDProperty *oldprops;    /* copy of custom properties at start of operator (to be restored before each modal step) */
 } tPChanFCurveLink;
 
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index 9ef46c6..cd0ea23 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -303,8 +303,8 @@ static void pose_slide_apply_vec3(tPoseSlideOp *pso, tPChanFCurveLink *pfl, floa
 	MEM_freeN(path);
 }
 
-/* helper for apply() - perform sliding for custom properties */
-static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
+/* helper for apply() - perform sliding for custom properties or bbone properties */
+static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, const char prop_prefix[])
 {
 	PointerRNA ptr = {{NULL}};
 	LinkData *ld;
@@ -313,8 +313,10 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
 	/* setup pointer RNA for resolving paths */
 	RNA_pointer_create(NULL, &RNA_PoseBone, pfl->pchan, &ptr);
 	
-	/* custom properties are just denoted using ["..."][etc.] after the end of the base path, 
-	 * so just check for opening pair after the end of the path
+	/* - custom properties are just denoted using ["..."][etc.] after the end of the base path, 
+	 *   so just check for opening pair after the end of the path
+	 * - bbone properties are similar, but they always start with a prefix "bbone_*",
+	 *   so a similar method should work here for those too
 	 */
 	for (ld = pfl->fcurves.first; ld; ld = ld->next) {
 		FCurve *fcu = (FCurve *)ld->data;
@@ -328,7 +330,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
 		 *	- pPtr is the chunk of the path which is left over
 		 */
 		bPtr = strstr(fcu->rna_path, pfl->pchan_path) + len;
-		pPtr = strstr(bPtr, "[\"");   /* dummy " for texteditor bugs */
+		pPtr = strstr(bPtr, prop_prefix);
 		
 		if (pPtr) {
 			/* use RNA to try and get a handle on this property, then, assuming that it is just
@@ -517,9 +519,16 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
 			}
 		}
 		
+		if (pchan->flag & POSE_BBONE_SHAPE) {
+			/* bbone properties - they all start a "bbone_" prefix */
+			pose_slide_apply_props(pso, pfl, "bbone_"); 
+		}
+		
 		if (pfl->oldprops) {
-			/* not strictly a transform, but contributes to the pose produced in many rigs */
-			pose_slide_apply_props(pso, pfl);
+			/* not strictly a transform, but custom properties contribute to the pose produced in many rigs
+			 * (e.g. the facial rigs used in Sintel)
+			 */
+			pose_slide_apply_props(pso, pfl, "[\"");  /* dummy " for texteditor bugs */
 		}
 	}
 	
diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c
index 2ba1eed..b960bec 100644
--- a/source/blender/editors/armature/pose_utils.c
+++ b/source/blender/editors/armature/pose_utils.c
@@ -71,7 +71,7 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a
 	ListBase curves = {NULL, NULL};
 	int transFlags = action_get_item_transforms(act, ob, pchan, &curves);
 	
-	pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE);
+	pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE | POSE_BBONE_SHAPE);
 	
 	/* check if any transforms found... */
 	if (transFlags) {
@@ -96,6 +96,8 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a
 			pchan->flag |= POSE_ROT;
 		if (transFlags & ACT_TRANS_SCALE)
 			pchan->flag |= POSE_SIZE;
+		if (transFlags & ACT_TRANS_BBONE)
+			pchan->flag |= POSE_BBONE_SHAPE;
 			
 		/* store current transforms */
 		copy_v3_v3(pfl->oldloc, pchan->loc);
@@ -105,6 +107,16 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a
 		copy_v3_v3(pfl->oldaxis, pchan->rotAxis);
 		pfl->oldangle = pchan->rotAngle;
 		
+		/* store current bbone values */
+		pfl->roll1 = pchan->roll1;
+		pfl->roll2 = pchan->roll2;
+		pfl->curveInX = pchan->curveInX;
+		pfl->curveInY = pchan->curveInY;
+		pfl->curveOutX = pchan->curveOutX;
+		pfl->curveOutY = pchan->curveOutY;
+		pfl->scaleIn = pchan->scaleIn;
+		pfl->scaleOut = pchan->scaleOut;
+		
 		/* make copy of custom properties */
 		if (pchan->prop && (transFlags & ACT_TRANS_PROP))
 			pfl->oldprops = IDP_CopyProperty(pchan->prop);
@@ -133,6 +145,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a
 			fcurves_to_pchan_links_get(pfLinks, ob, act, pchan);
 		}
 		CTX_DATA_END;
+		
 	}
 }
 
@@ -199,6 +212,16 @@ void poseAnim_mapping_reset(ListBase *pfLinks)
 		copy_v3_v3(pchan->rotAxis, pfl->oldaxis);
 		pchan->rotAngle = pfl->oldangle;
 		
+		/* store current bbone values */
+		pchan->roll1 = pfl->roll1;
+		pchan->roll2 = pfl->roll2;
+		pchan->curveInX = pfl->curveInX;
+		pchan->curveInY = pfl->curveInY;
+		pchan->curveOutX = pfl->curveOutX;
+		pchan->curveOutY = pfl->curveOutY;
+		pchan->scaleIn = pfl->scaleIn;
+		pchan->scaleOut = pfl->scaleOut;
+		
 		/* just overwrite values of properties from the stored copies (there should be some) */
 		if (pfl->oldprops)
 			IDP_SyncGroupValues(pfl->pchan->prop, pfl->oldprops);
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 6219e0f..76b8ca0 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -259,17 +259,17 @@ typedef enum ePchan_Flag {
 	POSE_LOC        =   (1 << 0),
 	POSE_ROT        =   (1 << 1),
 	POSE_SIZE       =   (1 << 2),
-	/* old IK/cache stuff... */
-#if 0
-	POSE_IK_MAT     =   (1 << 3),
-	POSE_UNUSED2    =   (1 << 4),
-	POSE_UNUSED3    =   (1 << 5),
-	POSE_UNUSED4    =   (1 << 6),
-	POSE_UNUSED5    =   (1 << 7),
-	/* has Standard IK */
-	POSE_HAS_IK     =   (1 << 8),
-#endif
-	/* IK/Pose solving*/
+	
+	/* old IK/cache stuff
+	 * - used to be here from (1 << 3) to (1 << 8) 
+	 *   but has been repurposed since 2.77.2
+	 *   as they haven't been used in over 10 years
+	 */
+	
+	/* has BBone deforms */
+	POSE_BBONE_SHAPE =  (1 << 3),
+	
+	/* IK/Pose solving */
 	POSE_CHAIN      =   (1 << 9),
 	POSE_DONE       =   (1 << 10),
 	/* visualization */




More information about the Bf-blender-cvs mailing list