Outliner: Port pose channel elements to new tree-element code design
No user visible changes expected. Part of #96713, continuation of work started in249e4df110and2e221de4ce. Refer to these for a motivation and design overview. Adds a new class for pose channel elements. Pull Request: https://projects.blender.org/blender/blender/pulls/111167
This commit is contained in:
committed by
Julian Eisel
parent
607adbca47
commit
ed5110c0ef
@@ -330,6 +330,11 @@ struct ParticleSystemElementCreateData {
|
||||
ParticleSystem *psys;
|
||||
};
|
||||
|
||||
struct PoseChannelElementCreateData {
|
||||
Object *object;
|
||||
bPoseChannel *pchan;
|
||||
};
|
||||
|
||||
struct PoseGroupElementCreateData {
|
||||
Object *object;
|
||||
bActionGroup *agrp;
|
||||
|
||||
@@ -271,6 +271,9 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
|
||||
else if (type == TSE_R_LAYER) {
|
||||
id = &static_cast<ViewLayerElementCreateData *>(idv)->scene->id;
|
||||
}
|
||||
else if (type == TSE_POSE_CHANNEL) {
|
||||
id = &static_cast<PoseChannelElementCreateData *>(idv)->object->id;
|
||||
}
|
||||
else if (type == TSE_LAYER_COLLECTION) {
|
||||
id = &static_cast<LayerCollection *>(idv)->collection->id;
|
||||
}
|
||||
@@ -347,7 +350,7 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
|
||||
else if (ELEM(type, TSE_CONSTRAINT, TSE_CONSTRAINT_BASE)) {
|
||||
/* pass */
|
||||
}
|
||||
else if (type == TSE_POSE_BASE) {
|
||||
else if (ELEM(type, TSE_POSE_BASE, TSE_POSE_CHANNEL)) {
|
||||
/* pass */
|
||||
}
|
||||
else if (ELEM(type, TSE_POSEGRP, TSE_POSEGRP_BASE)) {
|
||||
@@ -420,6 +423,7 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
|
||||
TSE_CONSTRAINT,
|
||||
TSE_CONSTRAINT_BASE,
|
||||
TSE_POSE_BASE,
|
||||
TSE_POSE_CHANNEL,
|
||||
TSE_POSEGRP,
|
||||
TSE_POSEGRP_BASE,
|
||||
TSE_R_LAYER,
|
||||
@@ -427,9 +431,8 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
|
||||
TSE_MODIFIER,
|
||||
TSE_MODIFIER_BASE,
|
||||
TSE_GREASE_PENCIL_NODE,
|
||||
TSE_LINKED_OB,
|
||||
TSE_VIEW_COLLECTION_BASE) ||
|
||||
ELEM(type, TSE_LAYER_COLLECTION))
|
||||
TSE_LINKED_OB) ||
|
||||
ELEM(type, TSE_LAYER_COLLECTION, TSE_VIEW_COLLECTION_BASE))
|
||||
{
|
||||
BLI_assert_msg(false, "Element type should already use new AbstractTreeElement design");
|
||||
}
|
||||
|
||||
@@ -165,6 +165,11 @@ std::unique_ptr<AbstractTreeElement> AbstractTreeElement::createFromType(const i
|
||||
}
|
||||
case TSE_POSE_BASE:
|
||||
return std::make_unique<TreeElementPoseBase>(legacy_te, *static_cast<Object *>(idv));
|
||||
case TSE_POSE_CHANNEL: {
|
||||
PoseChannelElementCreateData *pchan_data = static_cast<PoseChannelElementCreateData *>(idv);
|
||||
return std::make_unique<TreeElementPoseChannel>(
|
||||
legacy_te, *pchan_data->object, *pchan_data->pchan);
|
||||
}
|
||||
case TSE_POSEGRP_BASE:
|
||||
return std::make_unique<TreeElementPoseGroupBase>(legacy_te, *static_cast<Object *>(idv));
|
||||
case TSE_POSEGRP: {
|
||||
|
||||
@@ -37,10 +37,10 @@ void TreeElementPoseBase::expand(SpaceOutliner &space_outliner) const
|
||||
int const_index = 1000; /* ensure unique id for bone constraints */
|
||||
int a;
|
||||
LISTBASE_FOREACH_INDEX (bPoseChannel *, pchan, &object_.pose->chanbase, a) {
|
||||
PoseChannelElementCreateData pchan_data = {&object_, pchan};
|
||||
|
||||
TreeElement *ten = outliner_add_element(
|
||||
&space_outliner, &legacy_te_.subtree, &object_, &legacy_te_, TSE_POSE_CHANNEL, a);
|
||||
ten->name = pchan->name;
|
||||
ten->directdata = pchan;
|
||||
&space_outliner, &legacy_te_.subtree, &pchan_data, &legacy_te_, TSE_POSE_CHANNEL, a);
|
||||
pchan->temp = (void *)ten;
|
||||
|
||||
if (!BLI_listbase_is_empty(&pchan->constraints)) {
|
||||
@@ -78,4 +78,16 @@ void TreeElementPoseBase::expand(SpaceOutliner &space_outliner) const
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
TreeElementPoseChannel::TreeElementPoseChannel(TreeElement &legacy_te,
|
||||
Object & /* object */,
|
||||
bPoseChannel &pchan)
|
||||
: AbstractTreeElement(legacy_te), /* object_(object), */ pchan_(pchan)
|
||||
{
|
||||
BLI_assert(legacy_te.store_elem->type == TSE_POSE_CHANNEL);
|
||||
legacy_te.name = pchan_.name;
|
||||
legacy_te.directdata = &pchan_;
|
||||
}
|
||||
|
||||
} // namespace blender::ed::outliner
|
||||
|
||||
@@ -22,4 +22,13 @@ class TreeElementPoseBase final : public AbstractTreeElement {
|
||||
void expand(SpaceOutliner &) const override;
|
||||
};
|
||||
|
||||
class TreeElementPoseChannel final : public AbstractTreeElement {
|
||||
/* Not needed right now, avoid unused member variable warning. */
|
||||
// Object &object_;
|
||||
bPoseChannel &pchan_;
|
||||
|
||||
public:
|
||||
TreeElementPoseChannel(TreeElement &legacy_te, Object &object, bPoseChannel &pchan);
|
||||
};
|
||||
|
||||
} // namespace blender::ed::outliner
|
||||
|
||||
Reference in New Issue
Block a user