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