Outliner: Port grease pencil effect 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 new classes for grease pencil effect elements.

Pull Request: https://projects.blender.org/blender/blender/pulls/110371
This commit is contained in:
Almaz-Shinbay
2023-07-27 18:42:09 +02:00
committed by Julian Eisel
parent 9a150b95c5
commit 790cbeda2c
7 changed files with 121 additions and 20 deletions

View File

@@ -53,6 +53,7 @@ set(SRC
tree/tree_element_defgroup.cc
tree/tree_element_driver.cc
tree/tree_element_edit_bone.cc
tree/tree_element_gpencil_effect.cc
tree/tree_element_gpencil_layer.cc
tree/tree_element_id.cc
tree/tree_element_id_armature.cc
@@ -91,6 +92,7 @@ set(SRC
tree/tree_element_id_armature.hh
tree/tree_element_id_collection.hh
tree/tree_element_id_curve.hh
tree/tree_element_gpencil_effect.hh
tree/tree_element_id_gpencil_legacy.hh
tree/tree_element_id_library.hh
tree/tree_element_id_linestyle.hh

View File

@@ -25,6 +25,7 @@ struct ListBase;
struct Main;
struct Object;
struct Scene;
struct ShaderFxData;
struct TreeStoreElem;
struct ViewLayer;
struct bContext;
@@ -303,6 +304,11 @@ struct DeformGroupElementCreateData {
bDeformGroup *defgroup;
};
struct GPencilEffectElementCreateData {
Object *object;
ShaderFxData *fx;
};
struct ParticleSystemElementCreateData {
Object *object;
ParticleSystem *psys;

View File

@@ -245,6 +245,9 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
else if (type == TSE_EBONE) {
id = static_cast<EditBoneElementCreateData *>(idv)->armature_id;
}
else if (type == TSE_GPENCIL_EFFECT) {
id = &static_cast<GPencilEffectElementCreateData *>(idv)->object->id;
}
else if (type == TSE_DEFGROUP) {
id = &static_cast<DeformGroupElementCreateData *>(idv)->object->id;
}
@@ -309,6 +312,9 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
else if (ELEM(type, TSE_BONE, TSE_EBONE)) {
/* pass */
}
else if (ELEM(type, TSE_GPENCIL_EFFECT_BASE, TSE_GPENCIL_EFFECT)) {
/* pass */
}
else if (ELEM(type, TSE_DEFGROUP, TSE_DEFGROUP_BASE)) {
/* pass */
}
@@ -365,7 +371,8 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
TSE_SEQ_STRIP,
TSE_SEQUENCE_DUP,
TSE_GENERIC_LABEL) ||
ELEM(type, TSE_DEFGROUP, TSE_DEFGROUP_BASE))
ELEM(
type, TSE_DEFGROUP, TSE_DEFGROUP_BASE, TSE_GPENCIL_EFFECT, TSE_GPENCIL_EFFECT_BASE))
{
BLI_assert_msg(false, "Element type should already use new AbstractTreeElement design");
}

View File

@@ -23,6 +23,7 @@
#include "tree_element_defgroup.hh"
#include "tree_element_driver.hh"
#include "tree_element_edit_bone.hh"
#include "tree_element_gpencil_effect.hh"
#include "tree_element_gpencil_layer.hh"
#include "tree_element_id.hh"
#include "tree_element_label.hh"
@@ -116,6 +117,14 @@ std::unique_ptr<AbstractTreeElement> AbstractTreeElement::createFromType(const i
return std::make_unique<TreeElementEditBone>(
legacy_te, *ebone_data->armature_id, *ebone_data->ebone);
}
case TSE_GPENCIL_EFFECT: {
GPencilEffectElementCreateData *gp_effect_data =
static_cast<GPencilEffectElementCreateData *>(idv);
return std::make_unique<TreeElementGPencilEffect>(
legacy_te, *gp_effect_data->object, *gp_effect_data->fx);
}
case TSE_GPENCIL_EFFECT_BASE:
return std::make_unique<TreeElementGPencilEffectBase>(legacy_te, static_cast<Object *>(idv));
case TSE_DEFGROUP_BASE:
return std::make_unique<TreeElementDeformGroupBase>(legacy_te, *static_cast<Object *>(idv));
case TSE_DEFGROUP: {

View File

@@ -0,0 +1,59 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup spoutliner
*/
#include "DNA_object_types.h"
#include "DNA_outliner_types.h"
#include "DNA_shader_fx_types.h"
#include "BLI_listbase.h"
#include "BLT_translation.h"
#include "../outliner_intern.hh"
#include "tree_element_gpencil_effect.hh"
namespace blender::ed::outliner {
TreeElementGPencilEffectBase::TreeElementGPencilEffectBase(TreeElement &legacy_te, Object &object)
: AbstractTreeElement(legacy_te), object_(object)
{
legacy_te.name = IFACE_("Effects");
}
void TreeElementGPencilEffectBase::expand(SpaceOutliner &space_outliner) const
{
int index;
LISTBASE_FOREACH_INDEX (ShaderFxData *, fx, &object_.shader_fx, index) {
outliner_add_element(
&space_outliner, &legacy_te_.subtree, &object_, &legacy_te_, TSE_GPENCIL_EFFECT, index);
}
}
TreeElementGPencilEffect::TreeElementGPencilEffect(TreeElement &legacy_te,
Object & /* object */,
ShaderFxData &fx)
: AbstractTreeElement(legacy_te), /* object_(object), */ fx_(fx)
{
legacy_te.name = fx_.name;
legacy_te.directdata = &fx_;
}
void TreeElementGPencilEffect::expand(SpaceOutliner &space_outliner) const
{
if (fx_.type == eShaderFxType_Swirl) {
outliner_add_element(&space_outliner,
&legacy_te_.subtree,
((SwirlShaderFxData *)(&fx_))->object,
&legacy_te_,
TSE_LINKED_OB,
0);
}
}
} // namespace blender::ed::outliner

View File

@@ -0,0 +1,36 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup spoutliner
*/
#pragma once
#include "tree_element.hh"
struct Object;
struct ShaderFxData;
namespace blender::ed::outliner {
class TreeElementGPencilEffectBase final : public AbstractTreeElement {
Object &object_;
public:
TreeElementGPencilEffectBase(TreeElement &legacy_te, Object &object);
void expand(SpaceOutliner &) const override;
};
class TreeElementGPencilEffect final : public AbstractTreeElement {
/* Not needed right now, avoid unused member variable warning. */
// Object &object_;
ShaderFxData &fx_;
public:
TreeElementGPencilEffect(TreeElement &legacy_te, Object &object, ShaderFxData &fx);
void expand(SpaceOutliner &) const override;
};
} // namespace blender::ed::outliner

View File

@@ -259,26 +259,8 @@ void TreeElementIDObject::expand_gpencil_effects(SpaceOutliner &space_outliner)
if (BLI_listbase_is_empty(&object_.shader_fx)) {
return;
}
TreeElement *ten_fx = outliner_add_element(
outliner_add_element(
&space_outliner, &legacy_te_.subtree, &object_, &legacy_te_, TSE_GPENCIL_EFFECT_BASE, 0);
ten_fx->name = IFACE_("Effects");
int index;
LISTBASE_FOREACH_INDEX (ShaderFxData *, fx, &object_.shader_fx, index) {
TreeElement *ten = outliner_add_element(
&space_outliner, &ten_fx->subtree, &object_, ten_fx, TSE_GPENCIL_EFFECT, index);
ten->name = fx->name;
ten->directdata = fx;
if (fx->type == eShaderFxType_Swirl) {
outliner_add_element(&space_outliner,
&ten->subtree,
((SwirlShaderFxData *)fx)->object,
ten,
TSE_LINKED_OB,
0);
}
}
}
void TreeElementIDObject::expand_vertex_groups(SpaceOutliner &space_outliner) const