[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54926] trunk/blender/source/blender/ blenkernel/intern/fcurve.c: Bugfix: Invalid target tagging for "Distance" driver variable type only

Joshua Leung aligorith at gmail.com
Thu Feb 28 11:50:13 CET 2013


Revision: 54926
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54926
Author:   aligorith
Date:     2013-02-28 10:50:13 +0000 (Thu, 28 Feb 2013)
Log Message:
-----------
Bugfix: Invalid target tagging for "Distance" driver variable type only
highlighted the first target if/when both targets were empty.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/fcurve.c

Modified: trunk/blender/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/fcurve.c	2013-02-28 10:27:04 UTC (rev 54925)
+++ trunk/blender/source/blender/blenkernel/intern/fcurve.c	2013-02-28 10:50:13 UTC (rev 54926)
@@ -1192,28 +1192,54 @@
 {
 	float loc1[3] = {0.0f, 0.0f, 0.0f};
 	float loc2[3] = {0.0f, 0.0f, 0.0f};
+	short valid_targets = 0;
 	
-	/* get two location values */
-	/* NOTE: for now, these are all just worldspace */
+	/* Perform two passes
+	 *
+	 * FIRST PASS - to just check that everything works... 
+	 * NOTE: we use loops here to reduce code duplication, though in practice, 
+	 *       there can only be 2 items or else we run into some problems later
+	 */
 	DRIVER_TARGETS_USED_LOOPER(dvar)
 	{
-		/* get pointer to loc values to store in */
 		Object *ob = (Object *)dtar_id_ensure_proxy_from(dtar->id);
-		bPoseChannel *pchan;
-		float tmp_loc[3];
 		
 		/* check if this target has valid data */
 		if ((ob == NULL) || (GS(ob->id.name) != ID_OB)) {
 			/* invalid target, so will not have enough targets */
 			driver->flag |= DRIVER_FLAG_INVALID;
 			dtar->flag   |= DTAR_FLAG_INVALID;
-			return 0.0f;
 		}
 		else {
 			/* target seems to be OK now... */
 			dtar->flag &= ~DTAR_FLAG_INVALID;
+			valid_targets++;
 		}
+	}
+	DRIVER_TARGETS_LOOPER_END
+	
+	/* make sure we have enough valid targets to use - all or nothing for now... */
+	if (valid_targets < dvar->num_targets) {
+		if (G.debug & G_DEBUG) {
+			printf("LocDiff DVar: not enough valid targets (n = %d) (a = %p, b = %p)\n",
+			        valid_targets, dvar->targets[0].id, dvar->targets[1].id);
+		}
+		return 0.0f;
+	}
+	
+	
+	/* SECOND PASS: get two location values */
+	/* NOTE: for now, these are all just worldspace */
+	DRIVER_TARGETS_USED_LOOPER(dvar)
+	{
+		/* get pointer to loc values to store in */
+		Object *ob = (Object *)dtar_id_ensure_proxy_from(dtar->id);
+		bPoseChannel *pchan;
+		float tmp_loc[3];
 		
+		/* after the checks above, the targets should be valid here... */
+		BLI_assert((ob != NULL) && (GS(ob->id.name) != ID_OB));
+		
 		/* try to get posechannel */
 		pchan = BKE_pose_channel_find_name(ob->pose, dtar->pchan_name);
 		




More information about the Bf-blender-cvs mailing list