Page MenuHome

Fix T92930: Outliner "Show Active" bone fails in certain situations
ClosedPublic

Authored by Philipp Oeser (lichtwerk) on Nov 9 2021, 12:27 PM.

Details

Summary

Outliner would frame the armature object instead of the bone if the bone
was on a hidden armature layer.

Similar to issues reported in e.g. T58068 and T80464, this is due to the
fact that BKE_pose_channel_active always checks for the armature layer
(and returns NULL if a bone is not on a visible armature layer).

Now propose to make this layer check optional (and e.g. from the
Outliner be more permissive). This also introduces
BKE_pose_channel_active_if_layer_visible which just wraps
BKE_pose_channel_active with the check being ON.

Diff Detail

Repository
rB Blender

Event Timeline

Philipp Oeser (lichtwerk) requested review of this revision.Nov 9 2021, 12:27 PM
Philipp Oeser (lichtwerk) created this revision.
Sybren A. Stüvel (sybren) requested changes to this revision.Nov 11 2021, 12:41 PM

I'm not a big fan of boolean parameters. Basically they turn a function into two functions, showing that it was doing too many things at the same time to begin with. It's probably better to do this:

  • Remove the layer-is-visible check from BKE_pose_channel_active()
  • Add bool BKE_pose_is_layer_visible(const struct Object *ob, const struct bPoseChannel *pchan)
  • Add struct bPoseChannel * BKE_pose_channel_active_if_layer_visible(const struct Object *ob, const struct bPose *pose) that uses those two functions to return either the pose channel or NULL.
  • Replace existing calls to BKE_pose_channel_active() with BKE_pose_channel_active_if_layer_visible()

I'm not yet 100% convinced myself that BKE_pose_channel_active_if_layer_visible is a good name, so certainly open to improvements ;-) I'm mostly struggling with the _and_layer_visible part, as individual bones can also be hidden and for some reason this isn't taken into account by the current BKE_pose_channel_active function, and thus simply BKE_pose_channel_active_if_visible would be misleading.

This revision now requires changes to proceed.Nov 11 2021, 12:41 PM
Philipp Oeser (lichtwerk) edited the summary of this revision. (Show Details)
  • introduce BKE_pose_is_layer_visible (this could be used in more places later)
  • introduce BKE_pose_channel_active_if_layer_visible
  • kept the optional parameter to BKE_pose_channel_active though (since we need the visibility check in the loop, I dont see a nice way to combine BKE_pose_is_layer_visible & a potential BKE_pose_channel_active without such a parameter to behave as desired)

typo in doxy section

This revision is now accepted and ready to land.Dec 21 2021, 1:53 PM