Blender V4.3
tree_element_id_armature.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "DNA_ID.h"
10#include "DNA_armature_types.h"
11#include "DNA_listBase.h"
12#include "DNA_object_types.h"
13#include "DNA_outliner_types.h"
14
15#include "BLI_listbase.h"
16
17#include "BKE_armature.hh"
18
19#include "../outliner_intern.hh"
20#include "tree_display.hh"
21
23
24namespace blender::ed::outliner {
25
27 : TreeElementID(legacy_te, arm.id), arm_(arm)
28{
29}
30
32{
34
35 if (arm_.edbo) {
36 expand_edit_bones();
37 }
38 else {
39 /* Do not extend Armature when we have pose-mode. */
41 if (TSE_IS_REAL_ID(tselem) && GS(tselem->id->name) == ID_OB &&
42 ((Object *)tselem->id)->mode & OB_MODE_POSE)
43 {
44 /* pass */
45 }
46 else {
47 expand_bones(space_outliner);
48 }
49 }
50
51 if (arm_.collection_array_num > 0) {
53 }
54}
55
56void TreeElementIDArmature::expand_edit_bones() const
57{
58 int a = 0;
59 LISTBASE_FOREACH_INDEX (EditBone *, ebone, arm_.edbo, a) {
61 &legacy_te_.subtree, &arm_.id, ebone, &legacy_te_, TSE_EBONE, a);
62 ebone->temp.p = ten;
63 }
64 /* make hierarchy */
65 TreeElement *ten = arm_.edbo->first ?
66 static_cast<TreeElement *>(((EditBone *)arm_.edbo->first)->temp.p) :
67 nullptr;
68 while (ten) {
69 TreeElement *nten = ten->next, *par;
70 EditBone *ebone = (EditBone *)ten->directdata;
71 if (ebone->parent) {
73 par = static_cast<TreeElement *>(ebone->parent->temp.p);
74 BLI_addtail(&par->subtree, ten);
75 ten->parent = par;
76 }
77 ten = nten;
78 }
79}
80
81/* special handling of hierarchical non-lib data */
82static void outliner_add_bone(SpaceOutliner *space_outliner,
83 ListBase *lb,
84 ID *id,
85 Bone *curBone,
86 TreeElement *parent,
87 int *a)
88{
90 space_outliner, lb, id, curBone, parent, TSE_BONE, *a);
91
92 (*a)++;
93
94 LISTBASE_FOREACH (Bone *, child_bone, &curBone->childbase) {
95 outliner_add_bone(space_outliner, &te->subtree, id, child_bone, te, a);
96 }
97}
98
99void TreeElementIDArmature::expand_bones(SpaceOutliner &space_outliner) const
100{
101 int a = 0;
102 LISTBASE_FOREACH (Bone *, bone, &arm_.bonebase) {
103 outliner_add_bone(&space_outliner, &legacy_te_.subtree, &arm_.id, bone, &legacy_te_, &a);
104 }
105}
106
107} // namespace blender::ed::outliner
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:110
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:130
ID and Library types, which are fundamental for SDNA.
@ ID_OB
These structs are the foundation for all linked lists in the library system.
@ OB_MODE_POSE
Object is a sort of wrapper for general info.
#define TSE_IS_REAL_ID(_tse)
@ TSE_EBONE
@ TSE_BONE
@ TSE_BONE_COLLECTION_BASE
static TreeElement * add_element(SpaceOutliner *space_outliner, ListBase *lb, ID *owner_id, void *create_data, TreeElement *parent, short type, short index, const bool expand=true)
TreeElement * add_element(ListBase *lb, ID *owner_id, void *create_data, TreeElement *parent, short type, short index, const bool expand=true) const
TreeElementIDArmature(TreeElement &legacy_te, bArmature &arm)
void expand_animation_data(AnimData *) const
#define GS(x)
Definition iris.cc:202
static void outliner_add_bone(SpaceOutliner *space_outliner, ListBase *lb, ID *id, Bone *curBone, TreeElement *parent, int *a)
#define TREESTORE(a)
ListBase childbase
Definition DNA_ID.h:413
char name[66]
Definition DNA_ID.h:425
void * first
struct AnimData * adt
ListBase * edbo
Establish and manage Outliner trees for different display modes.