[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14230] trunk/blender/source/blender: Bugfix #8736: Follow Path constraints does not work for Bones

Joshua Leung aligorith at gmail.com
Tue Mar 25 06:32:05 CET 2008


Revision: 14230
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14230
Author:   aligorith
Date:     2008-03-25 06:32:04 +0100 (Tue, 25 Mar 2008)

Log Message:
-----------
Bugfix #8736: Follow Path constraints does not work for Bones

This appears to be a long-standing bug, and it only affected the Follow-Path constraint as it was the only one which was dependant on time-based changes. An oversight in the depsgraph code meant that Follow-Path constraints on armature bones were not evaluated, unless there was an Action or some NLA-Strips for that armature. 

I've added a new flag to pose->flag (POSE_CONSTRAINTS_TIMEDEPEND) which only gets set/cleared by update_pose_constraint_flags. This flag indicates that the depsgraph needs to do an update for such cases, and will require going in/out of EditMode to set this for old files. 
It's been implemented as such to avoid having costly searches when trying to run animations realtime (as is done for modifiers).

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/action.c
    trunk/blender/source/blender/blenkernel/intern/depsgraph.c
    trunk/blender/source/blender/makesdna/DNA_action_types.h
    trunk/blender/source/blender/src/editconstraint.c

Modified: trunk/blender/source/blender/blenkernel/intern/action.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/action.c	2008-03-24 21:01:36 UTC (rev 14229)
+++ trunk/blender/source/blender/blenkernel/intern/action.c	2008-03-25 05:32:04 UTC (rev 14230)
@@ -353,7 +353,9 @@
 	}
 }
 
-/* checks for IK constraint, can do more constraints flags later */
+/* checks for IK constraint, and also for Follow-Path constraint.
+ * can do more constraints flags later 
+ */
 /* pose should be entirely OK */
 void update_pose_constraint_flags(bPose *pose)
 {
@@ -361,13 +363,15 @@
 	bConstraint *con;
 	
 	/* clear */
-	for (pchan = pose->chanbase.first; pchan; pchan=pchan->next) {
+	for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) {
 		pchan->constflag= 0;
 	}
+	pose->flag &= ~POSE_CONSTRAINTS_TIMEDEPEND;
+	
 	/* detect */
-	for (pchan = pose->chanbase.first; pchan; pchan=pchan->next) {
-		for(con= pchan->constraints.first; con; con= con->next) {
-			if(con->type==CONSTRAINT_TYPE_KINEMATIC) {
+	for (pchan= pose->chanbase.first; pchan; pchan=pchan->next) {
+		for (con= pchan->constraints.first; con; con= con->next) {
+			if (con->type==CONSTRAINT_TYPE_KINEMATIC) {
 				bKinematicConstraint *data = (bKinematicConstraint*)con->data;
 				
 				pchan->constflag |= PCHAN_HAS_IK;
@@ -390,7 +394,20 @@
 					}
 				}
 			}
-			else pchan->constflag |= PCHAN_HAS_CONST;
+			else if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) {
+				bFollowPathConstraint *data= (bFollowPathConstraint *)con->data;
+				
+				/* for drawing constraint colors when color set allows this */
+				pchan->constflag |= PCHAN_HAS_CONST;
+				
+				/* if we have a valid target, make sure that this will get updated on frame-change
+				 * (needed for when there is no anim-data for this pose)
+				 */
+				if ((data->tar) && (data->tar->type==OB_CURVE))
+					pose->flag |= POSE_CONSTRAINTS_TIMEDEPEND;
+			}
+			else 
+				pchan->constflag |= PCHAN_HAS_CONST;
 		}
 	}
 }

Modified: trunk/blender/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/depsgraph.c	2008-03-24 21:01:36 UTC (rev 14229)
+++ trunk/blender/source/blender/blenkernel/intern/depsgraph.c	2008-03-25 05:32:04 UTC (rev 14230)
@@ -1848,6 +1848,7 @@
 	}
 	else if(modifiers_isSoftbodyEnabled(ob)) ob->recalc |= OB_RECALC_DATA;
 	else if(object_modifiers_use_time(ob)) ob->recalc |= OB_RECALC_DATA;
+	else if((ob->pose) && (ob->pose->flag & POSE_CONSTRAINTS_TIMEDEPEND)) ob->recalc |= OB_RECALC_DATA;
 	else {
 		Mesh *me;
 		Curve *cu;

Modified: trunk/blender/source/blender/makesdna/DNA_action_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_action_types.h	2008-03-24 21:01:36 UTC (rev 14229)
+++ trunk/blender/source/blender/makesdna/DNA_action_types.h	2008-03-25 05:32:04 UTC (rev 14230)
@@ -258,7 +258,9 @@
 		/* prevents any channel from getting overridden by anim from IPO */
 	POSE_LOCKED	= (1<<1),
 		/* clears the POSE_LOCKED flag for the next time the pose is evaluated */
-	POSE_DO_UNLOCK	= (1<<2)
+	POSE_DO_UNLOCK	= (1<<2),
+		/* pose has constraints which depend on time (used when depsgraph updates for a new frame) */
+	POSE_CONSTRAINTS_TIMEDEPEND = (1<<3)
 } POSE_FLAG;
 
 /* PoseChannel (transform) flags */

Modified: trunk/blender/source/blender/src/editconstraint.c
===================================================================
--- trunk/blender/source/blender/src/editconstraint.c	2008-03-24 21:01:36 UTC (rev 14229)
+++ trunk/blender/source/blender/src/editconstraint.c	2008-03-25 05:32:04 UTC (rev 14230)
@@ -661,7 +661,7 @@
 	if (owner==NULL) return;
 	
 	/* Check parents */
-	if (strlen (substring)) {
+	if (strlen(substring)) {
 		switch (owner->type) {
 			case OB_ARMATURE:
 				type = CONSTRAINT_OBTYPE_BONE;





More information about the Bf-blender-cvs mailing list