Blender V4.3
tree_element_id_object.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 "BLI_listbase.h"
10
11#include "DNA_ID.h"
12#include "DNA_action_types.h"
13#include "DNA_armature_types.h"
14#include "DNA_object_types.h"
15#include "DNA_outliner_types.h"
16
17#include "BKE_deform.hh"
18
19#include "../outliner_intern.hh"
20
22
23struct bConstraint;
24
25namespace blender::ed::outliner {
26
28 : TreeElementID(legacy_te, object.id), object_(object)
29{
30}
31
32void TreeElementIDObject::expand(SpaceOutliner & /*space_outliner*/) const
33{
34 /* tuck pointer back in object, to construct hierarchy */
35 object_.id.newid = (ID *)(&legacy_te_);
36
38 expand_pose();
39 expand_data();
40 expand_materials();
41 expand_constraints();
42 expand_modifiers();
43 expand_gpencil_modifiers();
44 expand_gpencil_effects();
45 expand_vertex_groups();
46 expand_duplicated_group();
47}
48
49void TreeElementIDObject::expand_data() const
50{
52 &legacy_te_.subtree, static_cast<ID *>(object_.data), nullptr, &legacy_te_, TSE_SOME_ID, 0);
53}
54
55void TreeElementIDObject::expand_pose() const
56{
57 if (!object_.pose) {
58 return;
59 }
60 add_element(&legacy_te_.subtree, &object_.id, nullptr, &legacy_te_, TSE_POSE_BASE, 0);
61}
62
63void TreeElementIDObject::expand_materials() const
64{
65 for (int a = 0; a < object_.totcol; a++) {
67 reinterpret_cast<ID *>(object_.mat[a]),
68 nullptr,
71 a);
72 }
73}
74
75void TreeElementIDObject::expand_constraints() const
76{
77 if (BLI_listbase_is_empty(&object_.constraints)) {
78 return;
79 }
80 TreeElement *tenla = add_element(
81 &legacy_te_.subtree, &object_.id, nullptr, &legacy_te_, TSE_CONSTRAINT_BASE, 0);
82
83 int index;
84 LISTBASE_FOREACH_INDEX (bConstraint *, con, &object_.constraints, index) {
85 add_element(&tenla->subtree, &object_.id, con, tenla, TSE_CONSTRAINT, index);
86 /* possible add all other types links? */
87 }
88}
89
90void TreeElementIDObject::expand_modifiers() const
91{
92 if (BLI_listbase_is_empty(&object_.modifiers)) {
93 return;
94 }
96}
97
98void TreeElementIDObject::expand_gpencil_modifiers() const
99{
101 return;
102 }
103 add_element(&legacy_te_.subtree, &object_.id, nullptr, &legacy_te_, TSE_MODIFIER_BASE, 0);
104}
105
106void TreeElementIDObject::expand_gpencil_effects() const
107{
108 if (BLI_listbase_is_empty(&object_.shader_fx)) {
109 return;
110 }
112}
113
114void TreeElementIDObject::expand_vertex_groups() const
115{
116 if (!ELEM(object_.type, OB_MESH, OB_GPENCIL_LEGACY, OB_LATTICE)) {
117 return;
118 }
119 const ListBase *defbase = BKE_object_defgroup_list(&object_);
120 if (BLI_listbase_is_empty(defbase)) {
121 return;
122 }
123 add_element(&legacy_te_.subtree, &object_.id, nullptr, &legacy_te_, TSE_DEFGROUP_BASE, 0);
124}
125
126void TreeElementIDObject::expand_duplicated_group() const
127{
128 if (object_.instance_collection && (object_.transflag & OB_DUPLICOLLECTION)) {
130 reinterpret_cast<ID *>(object_.instance_collection),
131 nullptr,
132 &legacy_te_,
134 0);
135 }
136}
137
138} // namespace blender::ed::outliner
support for deformation groups and hooks.
const ListBase * BKE_object_defgroup_list(const Object *ob)
Definition deform.cc:579
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
#define ELEM(...)
ID and Library types, which are fundamental for SDNA.
Object is a sort of wrapper for general info.
@ OB_LATTICE
@ OB_MESH
@ OB_GPENCIL_LEGACY
@ OB_DUPLICOLLECTION
@ TSE_CONSTRAINT_BASE
@ TSE_MODIFIER_BASE
@ TSE_DEFGROUP_BASE
@ TSE_CONSTRAINT
@ TSE_GPENCIL_EFFECT_BASE
@ TSE_SOME_ID
@ TSE_POSE_BASE
TreeElement * add_element(ListBase *lb, ID *owner_id, void *create_data, TreeElement *parent, short type, short index, const bool expand=true) const
TreeElementIDObject(TreeElement &legacy_te, Object &object)
void expand(SpaceOutliner &) const override
void expand_animation_data(AnimData *) const
Definition DNA_ID.h:413
struct ID * newid
Definition DNA_ID.h:417
short transflag
ListBase constraints
struct Collection * instance_collection
struct bPose * pose
ListBase modifiers
ListBase greasepencil_modifiers
struct Material ** mat
ListBase shader_fx
struct AnimData * adt