diff options
author | Joshua Leung <aligorith@gmail.com> | 2013-02-28 14:50:13 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2013-02-28 14:50:13 +0400 |
commit | 6ac941c3f01c34a16bb478a5ac031177f2ead5f8 (patch) | |
tree | 8209645f3bbf063f165b1413e1b3547773876449 | |
parent | 1700cf87173202a4662f63d4f8514ed8c46fe65e (diff) |
Bugfix: Invalid target tagging for "Distance" driver variable type only
highlighted the first target if/when both targets were empty.
-rw-r--r-- | source/blender/blenkernel/intern/fcurve.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index e31e26f6c1d..bc396d218df 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1192,27 +1192,53 @@ static float dvar_eval_locDiff(ChannelDriver *driver, DriverVar *dvar) { 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); |