Blender V5.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
8
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.hh"
16
17#include "BKE_armature.hh"
18
19#include "../outliner_intern.hh"
20#include "tree_display.hh"
21
22#include "tree_element_bone.hh"
26
27namespace blender::ed::outliner {
28
30 : TreeElementID(legacy_te, arm.id), arm_(arm)
31{
32}
33
34void TreeElementIDArmature::expand(SpaceOutliner & /*space_outliner*/) const
35{
36 expand_animation_data(arm_.adt);
37
38 if (arm_.edbo) {
39 expand_edit_bones();
40 }
41 else {
42 /* Do not extend Armature when we have pose-mode. */
44 if (TSE_IS_REAL_ID(tselem) && GS(tselem->id->name) == ID_OB &&
45 (id_cast<Object *>(tselem->id))->mode & OB_MODE_POSE)
46 {
47 /* pass */
48 }
49 else {
50 expand_bones();
51 }
52 }
53
54 if (arm_.collection_array_num > 0) {
56 }
57}
58
59void TreeElementIDArmature::expand_edit_bones() const
60{
61
62 for (const auto [a, ebone] : (arm_.edbo)->enumerate()) {
63 TreeElement *ten = add_element<TreeElementEditBone>({.index = a}, arm_.id, ebone);
64 ebone.temp.p = ten;
65 }
66 /* make hierarchy */
67 TreeElement *ten = arm_.edbo->first() ?
68 static_cast<TreeElement *>((arm_.edbo->first())->temp.p) :
69 nullptr;
70 while (ten) {
71 TreeElement *nten = ten->next, *par;
72 EditBone *ebone = static_cast<EditBone *>(ten->directdata);
73 if (ebone->parent) {
75 par = static_cast<TreeElement *>(ebone->parent->temp.p);
76 BLI_addtail(&par->subtree, ten);
77 ten->parent = par;
78 }
79 ten = nten;
80 }
81}
82
83/* special handling of hierarchical non-lib data */
84static void outliner_add_bone(AbstractTreeDisplay &tree_display,
85 ListBaseT<TreeElement> *lb,
86 ID *id,
87 Bone *curBone,
88 TreeElement *parent,
89 int *a)
90{
91 TreeElement *te = tree_display.add_element<TreeElementBone>(
92 {.lb = lb, .parent = parent, .index = *a}, *id, *curBone);
93
94 (*a)++;
95
96 for (Bone &child_bone : curBone->childbase) {
97 outliner_add_bone(tree_display, &te->subtree, id, &child_bone, te, a);
98 }
99}
100
101void TreeElementIDArmature::expand_bones() const
102{
103 int a = 0;
104 for (Bone &bone : arm_.bonebase) {
106 }
107}
108
109} // namespace blender::ed::outliner
ID and Library types, which are fundamental for SDNA.
These structs are the foundation for all linked lists in the library system.
Object is a sort of wrapper for general info.
#define TSE_IS_REAL_ID(_tse)
TreeElement * add_element(const TreeElementAddParams &params, Args &&...args)
TreeElement * add_element(const TreeElementAddParams &params, Args &&...args) const
TreeElementIDArmature(TreeElement &legacy_te, bArmature &arm)
TreeElementID(TreeElement &legacy_te, ID &id)
void expand_animation_data(AnimData *) const
static void outliner_add_bone(AbstractTreeDisplay &tree_display, ListBaseT< TreeElement > *lb, ID *id, Bone *curBone, TreeElement *parent, int *a)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
ID_Type GS(const char *name)
Definition DNA_ID.h:410
#define TREESTORE(a)
ListBaseT< Bone > childbase
union blender::EditBone::@252003325204232231327014100071366025164067232113 temp
char name[258]
Definition DNA_ID.h:433
ListBaseT< EditBone > * edbo
ListBaseT< Bone > bonebase
Establish and manage Outliner trees for different display modes.