Outliner: Port pose base elements to new tree-element code design

No user visible changes expected.

Part of #96713, continuation of work started in 249e4df110 and 2e221de4ce.
Refer to these for a motivation and design overview.

Adds a new class for pose base elements.

Pull Request: https://projects.blender.org/blender/blender/pulls/110806
This commit is contained in:
Almaz-Shinbay
2023-08-14 12:36:06 +02:00
committed by Julian Eisel
parent e878692221
commit 485c98cc2c
6 changed files with 117 additions and 49 deletions

View File

@@ -71,6 +71,7 @@ set(SRC
tree/tree_element_nla.cc
tree/tree_element_overrides.cc
tree/tree_element_particle_system.cc
tree/tree_element_pose.cc
tree/tree_element_pose_group.cc
tree/tree_element_rna.cc
tree/tree_element_scene_objects.cc
@@ -106,6 +107,7 @@ set(SRC
tree/tree_element_nla.hh
tree/tree_element_overrides.hh
tree/tree_element_particle_system.hh
tree/tree_element_pose.hh
tree/tree_element_pose_group.hh
tree/tree_element_rna.hh
tree/tree_element_scene_objects.hh

View File

@@ -331,6 +331,9 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
else if (type == TSE_LINKED_PSYS) {
/* pass */
}
else if (type == TSE_POSE_BASE) {
/* pass */
}
else if (ELEM(type, TSE_POSEGRP, TSE_POSEGRP_BASE)) {
/* pass */
}
@@ -392,6 +395,7 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
TSE_DEFGROUP_BASE,
TSE_GPENCIL_EFFECT,
TSE_GPENCIL_EFFECT_BASE,
TSE_POSE_BASE,
TSE_POSEGRP,
TSE_POSEGRP_BASE,
TSE_R_LAYER,

View File

@@ -30,6 +30,7 @@
#include "tree_element_nla.hh"
#include "tree_element_overrides.hh"
#include "tree_element_particle_system.hh"
#include "tree_element_pose.hh"
#include "tree_element_pose_group.hh"
#include "tree_element_rna.hh"
#include "tree_element_scene_objects.hh"
@@ -146,6 +147,8 @@ std::unique_ptr<AbstractTreeElement> AbstractTreeElement::createFromType(const i
return std::make_unique<TreeElementParticleSystem>(
legacy_te, *psys_data->object, *psys_data->psys);
}
case TSE_POSE_BASE:
return std::make_unique<TreeElementPoseBase>(legacy_te, *static_cast<Object *>(idv));
case TSE_POSEGRP_BASE:
return std::make_unique<TreeElementPoseGroupBase>(legacy_te, *static_cast<Object *>(idv));
case TSE_POSEGRP: {

View File

@@ -62,56 +62,8 @@ void TreeElementIDObject::expand_pose(SpaceOutliner &space_outliner) const
if (!object_.pose) {
return;
}
bArmature *arm = static_cast<bArmature *>(object_.data);
TreeElement *tenla = outliner_add_element(
outliner_add_element(
&space_outliner, &legacy_te_.subtree, &object_, &legacy_te_, TSE_POSE_BASE, 0);
tenla->name = IFACE_("Pose");
/* channels undefined in editmode, but we want the 'tenla' pose icon itself */
if ((arm->edbo == nullptr) && (object_.mode & OB_MODE_POSE)) {
int const_index = 1000; /* ensure unique id for bone constraints */
int a;
LISTBASE_FOREACH_INDEX (bPoseChannel *, pchan, &object_.pose->chanbase, a) {
TreeElement *ten = outliner_add_element(
&space_outliner, &tenla->subtree, &object_, tenla, TSE_POSE_CHANNEL, a);
ten->name = pchan->name;
ten->directdata = pchan;
pchan->temp = (void *)ten;
if (!BLI_listbase_is_empty(&pchan->constraints)) {
/* Object *target; */
TreeElement *tenla1 = outliner_add_element(
&space_outliner, &ten->subtree, &object_, ten, TSE_CONSTRAINT_BASE, 0);
tenla1->name = IFACE_("Constraints");
/* char *str; */
LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
TreeElement *ten1 = outliner_add_element(
&space_outliner, &tenla1->subtree, &object_, tenla1, TSE_CONSTRAINT, const_index);
ten1->name = con->name;
ten1->directdata = con;
/* possible add all other types links? */
}
const_index++;
}
}
/* make hierarchy */
TreeElement *ten = static_cast<TreeElement *>(tenla->subtree.first);
while (ten) {
TreeElement *nten = ten->next, *par;
TreeStoreElem *tselem = TREESTORE(ten);
if (tselem->type == TSE_POSE_CHANNEL) {
bPoseChannel *pchan = (bPoseChannel *)ten->directdata;
if (pchan->parent) {
BLI_remlink(&tenla->subtree, ten);
par = (TreeElement *)pchan->parent->temp;
BLI_addtail(&par->subtree, ten);
ten->parent = par;
}
}
ten = nten;
}
}
/* Pose Groups */
if (!BLI_listbase_is_empty(&object_.pose->agroups)) {

View File

@@ -0,0 +1,82 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup spoutliner
*/
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
#include "DNA_object_types.h"
#include "DNA_outliner_types.h"
#include "BLI_listbase.h"
#include "BLT_translation.h"
#include "../outliner_intern.hh"
#include "tree_element_pose.hh"
namespace blender::ed::outliner {
TreeElementPoseBase::TreeElementPoseBase(TreeElement &legacy_te, Object &object)
: AbstractTreeElement(legacy_te), object_(object)
{
BLI_assert(legacy_te.store_elem->type == TSE_POSE_BASE);
legacy_te.name = IFACE_("Pose");
}
void TreeElementPoseBase::expand(SpaceOutliner &space_outliner) const
{
bArmature *arm = static_cast<bArmature *>(object_.data);
/* channels undefined in editmode, but we want the 'tenla' pose icon itself */
if ((arm->edbo == nullptr) && (object_.mode & OB_MODE_POSE)) {
int const_index = 1000; /* ensure unique id for bone constraints */
int a;
LISTBASE_FOREACH_INDEX (bPoseChannel *, pchan, &object_.pose->chanbase, a) {
TreeElement *ten = outliner_add_element(
&space_outliner, &legacy_te_.subtree, &object_, &legacy_te_, TSE_POSE_CHANNEL, a);
ten->name = pchan->name;
ten->directdata = pchan;
pchan->temp = (void *)ten;
if (!BLI_listbase_is_empty(&pchan->constraints)) {
/* Object *target; */
TreeElement *tenla1 = outliner_add_element(
&space_outliner, &ten->subtree, &object_, ten, TSE_CONSTRAINT_BASE, 0);
tenla1->name = IFACE_("Constraints");
/* char *str; */
LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
TreeElement *ten1 = outliner_add_element(
&space_outliner, &tenla1->subtree, &object_, tenla1, TSE_CONSTRAINT, const_index);
ten1->name = con->name;
ten1->directdata = con;
/* possible add all other types links? */
}
const_index++;
}
}
/* make hierarchy */
TreeElement *ten = static_cast<TreeElement *>(legacy_te_.subtree.first);
while (ten) {
TreeElement *nten = ten->next, *par;
TreeStoreElem *tselem = TREESTORE(ten);
if (tselem->type == TSE_POSE_CHANNEL) {
bPoseChannel *pchan = (bPoseChannel *)ten->directdata;
if (pchan->parent) {
BLI_remlink(&legacy_te_.subtree, ten);
par = (TreeElement *)pchan->parent->temp;
BLI_addtail(&par->subtree, ten);
ten->parent = par;
}
}
ten = nten;
}
}
}
} // namespace blender::ed::outliner

View File

@@ -0,0 +1,25 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup spoutliner
*/
#pragma once
#include "tree_element.hh"
struct Object;
namespace blender::ed::outliner {
class TreeElementPoseBase final : public AbstractTreeElement {
Object &object_;
public:
TreeElementPoseBase(TreeElement &legacy_te, Object &object);
void expand(SpaceOutliner &) const override;
};
} // namespace blender::ed::outliner