Outliner: Port modifier 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 new classes for modifier elements. Pull Request: https://projects.blender.org/blender/blender/pulls/111114
This commit is contained in:
committed by
Julian Eisel
parent
d308f35896
commit
28f4bb2007
@@ -73,6 +73,7 @@ set(SRC
|
|||||||
tree/tree_element_label.cc
|
tree/tree_element_label.cc
|
||||||
tree/tree_element_linked_object.cc
|
tree/tree_element_linked_object.cc
|
||||||
tree/tree_element_nla.cc
|
tree/tree_element_nla.cc
|
||||||
|
tree/tree_element_modifier.cc
|
||||||
tree/tree_element_overrides.cc
|
tree/tree_element_overrides.cc
|
||||||
tree/tree_element_particle_system.cc
|
tree/tree_element_particle_system.cc
|
||||||
tree/tree_element_pose.cc
|
tree/tree_element_pose.cc
|
||||||
@@ -113,6 +114,7 @@ set(SRC
|
|||||||
tree/tree_element_label.hh
|
tree/tree_element_label.hh
|
||||||
tree/tree_element_linked_object.hh
|
tree/tree_element_linked_object.hh
|
||||||
tree/tree_element_nla.hh
|
tree/tree_element_nla.hh
|
||||||
|
tree/tree_element_modifier.hh
|
||||||
tree/tree_element_overrides.hh
|
tree/tree_element_overrides.hh
|
||||||
tree/tree_element_particle_system.hh
|
tree/tree_element_particle_system.hh
|
||||||
tree/tree_element_pose.hh
|
tree/tree_element_pose.hh
|
||||||
|
|||||||
@@ -21,10 +21,13 @@ struct ARegion;
|
|||||||
struct Bone;
|
struct Bone;
|
||||||
struct Collection;
|
struct Collection;
|
||||||
struct EditBone;
|
struct EditBone;
|
||||||
|
struct GpencilModifierData;
|
||||||
struct ID;
|
struct ID;
|
||||||
struct LayerCollection;
|
struct LayerCollection;
|
||||||
struct ListBase;
|
struct ListBase;
|
||||||
struct Main;
|
struct Main;
|
||||||
|
struct ModifierData;
|
||||||
|
struct ModifierDataStoreElem;
|
||||||
struct Object;
|
struct Object;
|
||||||
struct Scene;
|
struct Scene;
|
||||||
struct ShaderFxData;
|
struct ShaderFxData;
|
||||||
@@ -317,6 +320,11 @@ struct GPencilEffectElementCreateData {
|
|||||||
ShaderFxData *fx;
|
ShaderFxData *fx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ModifierCreateElementData {
|
||||||
|
Object *object;
|
||||||
|
ModifierDataStoreElem *md;
|
||||||
|
};
|
||||||
|
|
||||||
struct ParticleSystemElementCreateData {
|
struct ParticleSystemElementCreateData {
|
||||||
Object *object;
|
Object *object;
|
||||||
ParticleSystem *psys;
|
ParticleSystem *psys;
|
||||||
|
|||||||
@@ -271,6 +271,9 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
|
|||||||
else if (type == TSE_R_LAYER) {
|
else if (type == TSE_R_LAYER) {
|
||||||
id = &static_cast<ViewLayerElementCreateData *>(idv)->scene->id;
|
id = &static_cast<ViewLayerElementCreateData *>(idv)->scene->id;
|
||||||
}
|
}
|
||||||
|
else if (type == TSE_MODIFIER) {
|
||||||
|
id = &static_cast<ModifierCreateElementData *>(idv)->object->id;
|
||||||
|
}
|
||||||
|
|
||||||
/* exceptions */
|
/* exceptions */
|
||||||
if (ELEM(type, TSE_ID_BASE, TSE_GENERIC_LABEL)) {
|
if (ELEM(type, TSE_ID_BASE, TSE_GENERIC_LABEL)) {
|
||||||
@@ -350,6 +353,9 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
|
|||||||
else if (ELEM(type, TSE_R_LAYER, TSE_R_LAYER_BASE)) {
|
else if (ELEM(type, TSE_R_LAYER, TSE_R_LAYER_BASE)) {
|
||||||
/* pass */
|
/* pass */
|
||||||
}
|
}
|
||||||
|
else if (ELEM(type, TSE_MODIFIER, TSE_MODIFIER_BASE)) {
|
||||||
|
/* pass */
|
||||||
|
}
|
||||||
else if (type == TSE_LINKED_OB) {
|
else if (type == TSE_LINKED_OB) {
|
||||||
/* pass */
|
/* pass */
|
||||||
}
|
}
|
||||||
@@ -415,6 +421,8 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
|
|||||||
TSE_POSEGRP_BASE,
|
TSE_POSEGRP_BASE,
|
||||||
TSE_R_LAYER,
|
TSE_R_LAYER,
|
||||||
TSE_R_LAYER_BASE,
|
TSE_R_LAYER_BASE,
|
||||||
|
TSE_MODIFIER,
|
||||||
|
TSE_MODIFIER_BASE,
|
||||||
TSE_GREASE_PENCIL_NODE,
|
TSE_GREASE_PENCIL_NODE,
|
||||||
TSE_LINKED_OB))
|
TSE_LINKED_OB))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include "tree_element_id.hh"
|
#include "tree_element_id.hh"
|
||||||
#include "tree_element_label.hh"
|
#include "tree_element_label.hh"
|
||||||
#include "tree_element_linked_object.hh"
|
#include "tree_element_linked_object.hh"
|
||||||
|
#include "tree_element_modifier.hh"
|
||||||
#include "tree_element_nla.hh"
|
#include "tree_element_nla.hh"
|
||||||
#include "tree_element_overrides.hh"
|
#include "tree_element_overrides.hh"
|
||||||
#include "tree_element_particle_system.hh"
|
#include "tree_element_particle_system.hh"
|
||||||
@@ -169,6 +170,12 @@ std::unique_ptr<AbstractTreeElement> AbstractTreeElement::createFromType(const i
|
|||||||
return std::make_unique<TreeElementPoseGroup>(
|
return std::make_unique<TreeElementPoseGroup>(
|
||||||
legacy_te, *posegrp_data->object, *posegrp_data->agrp);
|
legacy_te, *posegrp_data->object, *posegrp_data->agrp);
|
||||||
}
|
}
|
||||||
|
case TSE_MODIFIER_BASE:
|
||||||
|
return std::make_unique<TreeElementModifierBase>(legacy_te, *static_cast<Object *>(idv));
|
||||||
|
case TSE_MODIFIER: {
|
||||||
|
ModifierCreateElementData *md_data = static_cast<ModifierCreateElementData *>(idv);
|
||||||
|
return std::make_unique<TreeElementModifier>(legacy_te, *md_data->object, *md_data->md);
|
||||||
|
}
|
||||||
case TSE_LINKED_OB:
|
case TSE_LINKED_OB:
|
||||||
return std::make_unique<TreeElementLinkedObject>(legacy_te, *static_cast<ID *>(idv));
|
return std::make_unique<TreeElementLinkedObject>(legacy_te, *static_cast<ID *>(idv));
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -103,54 +103,8 @@ void TreeElementIDObject::expand_modifiers(SpaceOutliner &space_outliner) const
|
|||||||
if (BLI_listbase_is_empty(&object_.modifiers)) {
|
if (BLI_listbase_is_empty(&object_.modifiers)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TreeElement *ten_mod = outliner_add_element(
|
outliner_add_element(
|
||||||
&space_outliner, &legacy_te_.subtree, &object_, &legacy_te_, TSE_MODIFIER_BASE, 0);
|
&space_outliner, &legacy_te_.subtree, &object_, &legacy_te_, TSE_MODIFIER_BASE, 0);
|
||||||
ten_mod->name = IFACE_("Modifiers");
|
|
||||||
|
|
||||||
int index;
|
|
||||||
LISTBASE_FOREACH_INDEX (ModifierData *, md, &object_.modifiers, index) {
|
|
||||||
TreeElement *ten = outliner_add_element(
|
|
||||||
&space_outliner, &ten_mod->subtree, &object_, ten_mod, TSE_MODIFIER, index);
|
|
||||||
ten->name = md->name;
|
|
||||||
ten->directdata = md;
|
|
||||||
|
|
||||||
if (md->type == eModifierType_Lattice) {
|
|
||||||
outliner_add_element(&space_outliner,
|
|
||||||
&ten->subtree,
|
|
||||||
((LatticeModifierData *)md)->object,
|
|
||||||
ten,
|
|
||||||
TSE_LINKED_OB,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
else if (md->type == eModifierType_Curve) {
|
|
||||||
outliner_add_element(&space_outliner,
|
|
||||||
&ten->subtree,
|
|
||||||
((CurveModifierData *)md)->object,
|
|
||||||
ten,
|
|
||||||
TSE_LINKED_OB,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
else if (md->type == eModifierType_Armature) {
|
|
||||||
outliner_add_element(&space_outliner,
|
|
||||||
&ten->subtree,
|
|
||||||
((ArmatureModifierData *)md)->object,
|
|
||||||
ten,
|
|
||||||
TSE_LINKED_OB,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
else if (md->type == eModifierType_Hook) {
|
|
||||||
outliner_add_element(
|
|
||||||
&space_outliner, &ten->subtree, ((HookModifierData *)md)->object, ten, TSE_LINKED_OB, 0);
|
|
||||||
}
|
|
||||||
else if (md->type == eModifierType_ParticleSystem) {
|
|
||||||
ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
|
|
||||||
|
|
||||||
ParticleSystemElementCreateData psys_data = {&object_, psys};
|
|
||||||
|
|
||||||
outliner_add_element(
|
|
||||||
&space_outliner, &ten->subtree, &psys_data, &legacy_te_, TSE_LINKED_PSYS, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeElementIDObject::expand_gpencil_modifiers(SpaceOutliner &space_outliner) const
|
void TreeElementIDObject::expand_gpencil_modifiers(SpaceOutliner &space_outliner) const
|
||||||
@@ -158,42 +112,8 @@ void TreeElementIDObject::expand_gpencil_modifiers(SpaceOutliner &space_outliner
|
|||||||
if (BLI_listbase_is_empty(&object_.greasepencil_modifiers)) {
|
if (BLI_listbase_is_empty(&object_.greasepencil_modifiers)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TreeElement *ten_mod = outliner_add_element(
|
outliner_add_element(
|
||||||
&space_outliner, &legacy_te_.subtree, &object_, &legacy_te_, TSE_MODIFIER_BASE, 0);
|
&space_outliner, &legacy_te_.subtree, &object_, &legacy_te_, TSE_MODIFIER_BASE, 0);
|
||||||
ten_mod->name = IFACE_("Modifiers");
|
|
||||||
|
|
||||||
int index;
|
|
||||||
LISTBASE_FOREACH_INDEX (GpencilModifierData *, md, &object_.greasepencil_modifiers, index) {
|
|
||||||
TreeElement *ten = outliner_add_element(
|
|
||||||
&space_outliner, &ten_mod->subtree, &object_, ten_mod, TSE_MODIFIER, index);
|
|
||||||
ten->name = md->name;
|
|
||||||
ten->directdata = md;
|
|
||||||
|
|
||||||
if (md->type == eGpencilModifierType_Armature) {
|
|
||||||
outliner_add_element(&space_outliner,
|
|
||||||
&ten->subtree,
|
|
||||||
((ArmatureGpencilModifierData *)md)->object,
|
|
||||||
ten,
|
|
||||||
TSE_LINKED_OB,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
else if (md->type == eGpencilModifierType_Hook) {
|
|
||||||
outliner_add_element(&space_outliner,
|
|
||||||
&ten->subtree,
|
|
||||||
((HookGpencilModifierData *)md)->object,
|
|
||||||
ten,
|
|
||||||
TSE_LINKED_OB,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
else if (md->type == eGpencilModifierType_Lattice) {
|
|
||||||
outliner_add_element(&space_outliner,
|
|
||||||
&ten->subtree,
|
|
||||||
((LatticeGpencilModifierData *)md)->object,
|
|
||||||
ten,
|
|
||||||
TSE_LINKED_OB,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeElementIDObject::expand_gpencil_effects(SpaceOutliner &space_outliner) const
|
void TreeElementIDObject::expand_gpencil_effects(SpaceOutliner &space_outliner) const
|
||||||
|
|||||||
@@ -0,0 +1,140 @@
|
|||||||
|
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \ingroup spoutliner
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "DNA_gpencil_modifier_types.h"
|
||||||
|
#include "DNA_modifier_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_modifier.hh"
|
||||||
|
|
||||||
|
namespace blender::ed::outliner {
|
||||||
|
|
||||||
|
TreeElementModifierBase::TreeElementModifierBase(TreeElement &legacy_te, Object &object)
|
||||||
|
: AbstractTreeElement(legacy_te), object_(object)
|
||||||
|
{
|
||||||
|
legacy_te.name = IFACE_("Modifiers");
|
||||||
|
}
|
||||||
|
|
||||||
|
void TreeElementModifierBase::expand(SpaceOutliner &space_outliner) const
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
LISTBASE_FOREACH_INDEX (ModifierData *, md, &object_.modifiers, index) {
|
||||||
|
ModifierDataStoreElem md_store(md);
|
||||||
|
|
||||||
|
ModifierCreateElementData md_data = {&object_, &md_store};
|
||||||
|
|
||||||
|
outliner_add_element(
|
||||||
|
&space_outliner, &legacy_te_.subtree, &md_data, &legacy_te_, TSE_MODIFIER, index);
|
||||||
|
}
|
||||||
|
LISTBASE_FOREACH_INDEX (GpencilModifierData *, md, &object_.greasepencil_modifiers, index) {
|
||||||
|
ModifierDataStoreElem md_store(md);
|
||||||
|
|
||||||
|
ModifierCreateElementData md_data = {&object_, &md_store};
|
||||||
|
|
||||||
|
outliner_add_element(
|
||||||
|
&space_outliner, &legacy_te_.subtree, &md_data, &legacy_te_, TSE_MODIFIER, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TreeElementModifier::TreeElementModifier(TreeElement &legacy_te,
|
||||||
|
Object &object,
|
||||||
|
ModifierDataStoreElem &md)
|
||||||
|
: AbstractTreeElement(legacy_te), object_(object), md_(md)
|
||||||
|
{
|
||||||
|
if (md_.type == MODIFIER_TYPE) {
|
||||||
|
legacy_te.name = md_.md->name;
|
||||||
|
legacy_te.directdata = md_.md;
|
||||||
|
}
|
||||||
|
if (md_.type == GPENCIL_MODIFIER_TYPE) {
|
||||||
|
legacy_te.name = md_.gp_md->name;
|
||||||
|
legacy_te.directdata = md_.gp_md;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TreeElementModifier::expand(SpaceOutliner &space_outliner) const
|
||||||
|
{
|
||||||
|
if (md_.type == MODIFIER_TYPE) {
|
||||||
|
ModifierData *md = md_.md;
|
||||||
|
if (md->type == eModifierType_Lattice) {
|
||||||
|
outliner_add_element(&space_outliner,
|
||||||
|
&legacy_te_.subtree,
|
||||||
|
((LatticeModifierData *)md)->object,
|
||||||
|
&legacy_te_,
|
||||||
|
TSE_LINKED_OB,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
else if (md->type == eModifierType_Curve) {
|
||||||
|
outliner_add_element(&space_outliner,
|
||||||
|
&legacy_te_.subtree,
|
||||||
|
((CurveModifierData *)md)->object,
|
||||||
|
&legacy_te_,
|
||||||
|
TSE_LINKED_OB,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
else if (md->type == eModifierType_Armature) {
|
||||||
|
outliner_add_element(&space_outliner,
|
||||||
|
&legacy_te_.subtree,
|
||||||
|
((ArmatureModifierData *)md)->object,
|
||||||
|
&legacy_te_,
|
||||||
|
TSE_LINKED_OB,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
else if (md->type == eModifierType_Hook) {
|
||||||
|
outliner_add_element(&space_outliner,
|
||||||
|
&legacy_te_.subtree,
|
||||||
|
((HookModifierData *)md)->object,
|
||||||
|
&legacy_te_,
|
||||||
|
TSE_LINKED_OB,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
else if (md->type == eModifierType_ParticleSystem) {
|
||||||
|
ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
|
||||||
|
|
||||||
|
ParticleSystemElementCreateData psys_data = {&object_, psys};
|
||||||
|
|
||||||
|
outliner_add_element(
|
||||||
|
&space_outliner, &legacy_te_.subtree, &psys_data, &legacy_te_, TSE_LINKED_PSYS, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (md_.type == GPENCIL_MODIFIER_TYPE) {
|
||||||
|
GpencilModifierData *md = md_.gp_md;
|
||||||
|
if (md->type == eGpencilModifierType_Armature) {
|
||||||
|
outliner_add_element(&space_outliner,
|
||||||
|
&legacy_te_.subtree,
|
||||||
|
((ArmatureGpencilModifierData *)md)->object,
|
||||||
|
&legacy_te_,
|
||||||
|
TSE_LINKED_OB,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
else if (md->type == eGpencilModifierType_Hook) {
|
||||||
|
outliner_add_element(&space_outliner,
|
||||||
|
&legacy_te_.subtree,
|
||||||
|
((HookGpencilModifierData *)md)->object,
|
||||||
|
&legacy_te_,
|
||||||
|
TSE_LINKED_OB,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
else if (md->type == eGpencilModifierType_Lattice) {
|
||||||
|
outliner_add_element(&space_outliner,
|
||||||
|
&legacy_te_.subtree,
|
||||||
|
((LatticeGpencilModifierData *)md)->object,
|
||||||
|
&legacy_te_,
|
||||||
|
TSE_LINKED_OB,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace blender::ed::outliner
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \ingroup spoutliner
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "tree_element.hh"
|
||||||
|
|
||||||
|
struct GpencilModifierData;
|
||||||
|
struct ModifierData;
|
||||||
|
struct Object;
|
||||||
|
|
||||||
|
enum ModifierDataStoreType { MODIFIER_TYPE, GPENCIL_MODIFIER_TYPE };
|
||||||
|
|
||||||
|
struct ModifierDataStoreElem {
|
||||||
|
union {
|
||||||
|
ModifierData *md;
|
||||||
|
GpencilModifierData *gp_md;
|
||||||
|
};
|
||||||
|
ModifierDataStoreType type;
|
||||||
|
|
||||||
|
ModifierDataStoreElem(ModifierData *md_) : md(md_), type(MODIFIER_TYPE) {}
|
||||||
|
ModifierDataStoreElem(GpencilModifierData *md_) : gp_md(md_), type(GPENCIL_MODIFIER_TYPE) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace blender::ed::outliner {
|
||||||
|
|
||||||
|
class TreeElementModifierBase final : public AbstractTreeElement {
|
||||||
|
Object &object_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TreeElementModifierBase(TreeElement &legacy_te, Object &object);
|
||||||
|
void expand(SpaceOutliner &) const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TreeElementModifier final : public AbstractTreeElement {
|
||||||
|
/* Not needed right now, avoid unused member variable warning. */
|
||||||
|
Object &object_;
|
||||||
|
// std::variant<ModifierData *, GpencilModifierData *> md_;
|
||||||
|
ModifierDataStoreElem &md_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TreeElementModifier(TreeElement &legacy_te, Object &object, ModifierDataStoreElem &md);
|
||||||
|
void expand(SpaceOutliner &) const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace blender::ed::outliner
|
||||||
Reference in New Issue
Block a user