Fix #119523: Missing driver bone target doesn't mark driver as invalid

If a bone was specified (but now missing), the driver would fallback to
using the object as a target (which can lead to unintended behavior).

So now check if a bone is specified, if it is missing, mark the driver
invalid. If no bone is specified at all, then use the armature object as
the target.

NOTE: `DTAR_FLAG_INVALID` is not granular enough to distinguish the
object and bone targets, so both will be marked in red in the UI (there
is already comments about it in code). If necessary, we could introduce
an additional DTAR_FLAG_BONE_INVALID and use that in a couple of places.

Pull Request: https://projects.blender.org/blender/blender/pulls/119533
This commit is contained in:
Philipp Oeser
2024-03-18 12:48:43 +01:00
committed by Philipp Oeser
parent d1cbb10d17
commit 5ba581bd0a

View File

@@ -604,11 +604,16 @@ static float dvar_eval_transChan(const AnimationEvalContext * /*anim_eval_contex
return 0.0f;
}
/* Target should be valid now. */
dtar->flag &= ~DTAR_FLAG_INVALID;
/* Try to get pose-channel. */
pchan = BKE_pose_channel_find_name(ob->pose, dtar->pchan_name);
if (dtar->pchan_name[0] != '\0' && !pchan) {
driver->flag |= DRIVER_FLAG_INVALID;
dtar->flag |= DTAR_FLAG_INVALID;
return 0.0f;
}
/* Target should be valid now. */
dtar->flag &= ~DTAR_FLAG_INVALID;
/* Check if object or bone, and get transform matrix accordingly:
* - "use_eulers" code is used to prevent the problems associated with non-uniqueness