Blender V4.3
tree_element_pose.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
10#include "DNA_object_types.h"
11#include "DNA_outliner_types.h"
12
13#include "BLI_listbase.h"
14
15#include "BLT_translation.hh"
16
17#include "../outliner_intern.hh"
18
19#include "tree_element_pose.hh"
20
21struct bConstraint;
22
23namespace blender::ed::outliner {
24
26 : AbstractTreeElement(legacy_te), object_(object)
27{
29 legacy_te.name = IFACE_("Pose");
30}
31
32void TreeElementPoseBase::expand(SpaceOutliner & /*space_outliner*/) const
33{
34 bArmature *arm = static_cast<bArmature *>(object_.data);
35
36 /* channels undefined in editmode, but we want the 'tenla' pose icon itself */
37 if ((arm->edbo == nullptr) && (object_.mode & OB_MODE_POSE)) {
38 int const_index = 1000; /* ensure unique id for bone constraints */
39 int a;
40 LISTBASE_FOREACH_INDEX (bPoseChannel *, pchan, &object_.pose->chanbase, a) {
42 &legacy_te_.subtree, &object_.id, pchan, &legacy_te_, TSE_POSE_CHANNEL, a);
43 pchan->temp = (void *)ten;
44
45 if (!BLI_listbase_is_empty(&pchan->constraints)) {
46 // Object *target;
47 TreeElement *tenla1 = add_element(
48 &ten->subtree, &object_.id, nullptr, ten, TSE_CONSTRAINT_BASE, 0);
49 // char *str;
50
51 LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
52 add_element(&tenla1->subtree, &object_.id, con, tenla1, TSE_CONSTRAINT, const_index);
53 /* possible add all other types links? */
54 }
55 const_index++;
56 }
57 }
58 /* make hierarchy */
59 TreeElement *ten = static_cast<TreeElement *>(legacy_te_.subtree.first);
60 while (ten) {
61 TreeElement *nten = ten->next, *par;
62 TreeStoreElem *tselem = TREESTORE(ten);
63 if (tselem->type == TSE_POSE_CHANNEL) {
64 bPoseChannel *pchan = (bPoseChannel *)ten->directdata;
65 if (pchan->parent) {
67 par = (TreeElement *)pchan->parent->temp;
68 BLI_addtail(&par->subtree, ten);
69 ten->parent = par;
70 }
71 }
72 ten = nten;
73 }
74 }
75}
76
77/* -------------------------------------------------------------------- */
78
80 Object & /*object*/,
81 bPoseChannel &pchan)
82 : AbstractTreeElement(legacy_te), /* object_(object), */ pchan_(pchan)
83{
85 legacy_te.name = pchan_.name;
86 legacy_te.directdata = &pchan_;
87}
88
89} // namespace blender::ed::outliner
#define BLI_assert(a)
Definition BLI_assert.h:50
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#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
#define IFACE_(msgid)
@ OB_MODE_POSE
Object is a sort of wrapper for general info.
@ TSE_POSE_CHANNEL
@ TSE_CONSTRAINT_BASE
@ TSE_CONSTRAINT
@ 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
TreeElementPoseBase(TreeElement &legacy_te, Object &object)
void expand(SpaceOutliner &) const override
TreeElementPoseChannel(TreeElement &legacy_te, Object &object, bPoseChannel &pchan)
#define TREESTORE(a)
void * first
struct bPose * pose
ListBase * edbo
struct bPoseChannel * parent
ListBase chanbase