Blender V5.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
8
10#include "DNA_object_types.h"
11#include "DNA_outliner_types.h"
12
13#include "BLI_listbase.hh"
14
15#include "BLT_translation.hh"
16
17#include "../outliner_intern.hh"
18
19#include "tree_display.hh"
21#include "tree_element_pose.hh"
22
23namespace blender {
24
25struct bConstraint;
26
27namespace ed::outliner {
28
30 : AbstractTreeElement(legacy_te), object_(object)
31{
33 legacy_te.name = IFACE_("Pose");
34}
35
37{
38 return &object.id;
39}
40
41void TreeElementPoseBase::expand(SpaceOutliner & /*space_outliner*/) const
42{
43 bArmature *arm = id_cast<bArmature *>(object_.data);
44
45 /* channels undefined in editmode, but we want the 'tenla' pose icon itself */
46 if ((arm->edbo == nullptr) && (object_.mode & OB_MODE_POSE)) {
47 int const_index = 1000; /* ensure unique id for bone constraints */
48
49 for (const auto [a, pchan] : object_.pose->chanbase.enumerate()) {
50 TreeElement *ten = add_element<TreeElementPoseChannel>({.index = a}, object_, pchan);
51 pchan.temp = static_cast<void *>(ten);
52
53 if (!pchan.constraints.is_empty()) {
54 // Object *target;
55 TreeElement *tenla1 = add_element<TreeElementConstraintBase>({.parent = ten}, object_);
56 // char *str;
57
58 for (bConstraint &con : pchan.constraints) {
60 {.parent = tenla1, .index = const_index}, object_, con);
61 /* possible add all other types links? */
62 }
63 const_index++;
64 }
65 }
66 /* make hierarchy */
67 TreeElement *ten = legacy_te_.subtree.first();
68 while (ten) {
69 TreeElement *nten = ten->next, *par;
70 TreeStoreElem *tselem = TREESTORE(ten);
71 if (tselem->type == TSE_POSE_CHANNEL) {
72 bPoseChannel *pchan = static_cast<bPoseChannel *>(ten->directdata);
73 if (pchan->parent) {
75 par = static_cast<TreeElement *>(pchan->parent->temp);
76 BLI_addtail(&par->subtree, ten);
77 ten->parent = par;
78 }
79 }
80 ten = nten;
81 }
82 }
83}
84
85/* -------------------------------------------------------------------- */
86
88 Object & /*object*/,
89 bPoseChannel &pchan)
90 : AbstractTreeElement(legacy_te), /* object_(object), */ pchan_(pchan)
91{
93 legacy_te.name = pchan_.name;
94 legacy_te.directdata = &pchan_;
95}
96
98{
99 return &object.id;
100}
101
102} // namespace ed::outliner
103} // namespace blender
#define IFACE_(msgid)
Object is a sort of wrapper for general info.
TreeElement * add_element(const TreeElementAddParams &params, Args &&...args) const
TreeElementPoseBase(TreeElement &legacy_te, Object &object)
void expand(SpaceOutliner &) const override
TreeElementPoseChannel(TreeElement &legacy_te, Object &object, bPoseChannel &pchan)
static ID * owner_id(Object &object, bPoseChannel &pchan)
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
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
#define TREESTORE(a)
ListBaseT< EditBone > * edbo
struct bPoseChannel * parent
Establish and manage Outliner trees for different display modes.