Fix T101946: Outliner data-block counter treats bones as collection

Mistake in own rBb6a35a8153c3 which caused code to always recurse into
bone hierarchies (no matter which collapsed level an armature was
found).
This led to bone counts always being displayed even outside a collapsed
armature (e.g. if an armature was somewhere down a object or collection,
the collapsed object or collection would show this bonecount).
This is inconsistent with other data counting in the Outliner, e.g.
vertexgroups or bonegroups do have their indicator at object level,
however the counter only shows if `Vertex Groups` or `Bone Groups` line
shows (so if the object is not collapsed).

And this also led to the bug reported in T101946 which was that the bone
counts would be treated as collections when further down a collapsed
hierarchy.
Background: The whole concept of `MergedIconRow` is based on the concept
of counting **objects types or collectinons/groups**. If other things
like overrides, vertexgroups or bonegroups are displayed in a counted/
merged manner, then these will always be counted in the array spots that
are usually reserved for groups/collections. But for things this is not
a problem (since these are only displayed below their respective
outliner entry -- and will never be reached otherwise).

So to correct all this, we now only recurse into a bone hierarchy if a
bone is at the "root-level" of a collapsed subtree (direct child of the
collapsed element to merge into).

NOTE: there are certainly other candidates for counted/merged display
further up the hierarchy (not just bones -- constraints come to my mind
here, but that is for another commit)

Maniphest Tasks: T101946

Differential Revision: https://developer.blender.org/D16319
This commit is contained in:
Philipp Oeser 2022-10-21 16:24:53 +02:00
parent 0584a88046
commit 9fc000cc6f
Notes: blender-bot 2023-02-14 12:01:57 +01:00
Referenced by issue #100749, Blender LTS: Maintenance Task 3.3
Referenced by issue #101946, Outliner data-block counter treats bones as collection
1 changed files with 15 additions and 3 deletions

View File

@ -3054,6 +3054,7 @@ static void outliner_draw_iconrow(bContext *C,
int *offsx,
int ys,
float alpha_fac,
bool in_bone_hierarchy,
MergedIconRow *merged)
{
eOLDrawState active = OL_DRAWSEL_NONE;
@ -3063,8 +3064,12 @@ static void outliner_draw_iconrow(bContext *C,
te->flag &= ~(TE_ICONROW | TE_ICONROW_MERGED);
/* object hierarchy always, further constrained on level */
/* Bones are also hierarchies and get a merged count, but we only start recursing into them if
* an they are at the root level of a collapsed subtree (e.g. not "hidden" in a collapsed
* collection). */
const bool is_bone = ELEM(tselem->type, TSE_BONE, TSE_EBONE, TSE_POSE_CHANNEL);
if ((level < 1) || ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) ||
ELEM(tselem->type, TSE_BONE, TSE_EBONE, TSE_POSE_CHANNEL)) {
(in_bone_hierarchy && is_bone)) {
/* active blocks get white circle */
if (tselem->type == TSE_SOME_ID) {
if (te->idcode == ID_OB) {
@ -3107,8 +3112,13 @@ static void outliner_draw_iconrow(bContext *C,
}
}
/* this tree element always has same amount of branches, so don't draw */
if (tselem->type != TSE_R_LAYER) {
/* TSE_R_LAYER tree element always has same amount of branches, so don't draw. */
/* Also only recurse into bone hierarchies if a direct child of the collapsed element to merge
* into. */
const bool is_root_level_bone = is_bone && (level == 0);
in_bone_hierarchy |= is_root_level_bone;
if (!ELEM(tselem->type, TSE_R_LAYER, TSE_BONE, TSE_EBONE, TSE_POSE_CHANNEL) ||
in_bone_hierarchy) {
outliner_draw_iconrow(C,
block,
fstyle,
@ -3120,6 +3130,7 @@ static void outliner_draw_iconrow(bContext *C,
offsx,
ys,
alpha_fac,
in_bone_hierarchy,
merged);
}
}
@ -3381,6 +3392,7 @@ static void outliner_draw_tree_element(bContext *C,
&tempx,
*starty,
alpha_fac,
false,
&merged);
GPU_blend(GPU_BLEND_NONE);