diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index ec400455b88..b8182ce5e10 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -50,6 +50,7 @@ set(SRC tree/tree_element_anim_data.cc tree/tree_element_bone.cc tree/tree_element_collection.cc + tree/tree_element_defgroup.cc tree/tree_element_driver.cc tree/tree_element_edit_bone.cc tree/tree_element_gpencil_layer.cc @@ -82,6 +83,7 @@ set(SRC tree/tree_element_anim_data.hh tree/tree_element_bone.hh tree/tree_element_collection.hh + tree/tree_element_defgroup.hh tree/tree_element_driver.hh tree/tree_element_edit_bone.hh tree/tree_element_gpencil_layer.hh diff --git a/source/blender/editors/space_outliner/outliner_intern.hh b/source/blender/editors/space_outliner/outliner_intern.hh index 566097c935c..0fea06fec8f 100644 --- a/source/blender/editors/space_outliner/outliner_intern.hh +++ b/source/blender/editors/space_outliner/outliner_intern.hh @@ -29,6 +29,7 @@ struct TreeStoreElem; struct ViewLayer; struct bContext; struct bContextDataResult; +struct bDeformGroup; struct bPoseChannel; struct ParticleSystem; struct View2D; @@ -297,6 +298,11 @@ struct EditBoneElementCreateData { EditBone *ebone; }; +struct DeformGroupElementCreateData { + Object *object; + bDeformGroup *defgroup; +}; + struct ParticleSystemElementCreateData { Object *object; ParticleSystem *psys; diff --git a/source/blender/editors/space_outliner/outliner_tree.cc b/source/blender/editors/space_outliner/outliner_tree.cc index 8e9356dffdd..d3c6808ac3a 100644 --- a/source/blender/editors/space_outliner/outliner_tree.cc +++ b/source/blender/editors/space_outliner/outliner_tree.cc @@ -245,6 +245,9 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, else if (type == TSE_EBONE) { id = static_cast(idv)->armature_id; } + else if (type == TSE_DEFGROUP) { + id = &static_cast(idv)->object->id; + } else if (type == TSE_LINKED_PSYS) { id = &static_cast(idv)->object->id; } @@ -306,6 +309,9 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, else if (ELEM(type, TSE_BONE, TSE_EBONE)) { /* pass */ } + else if (ELEM(type, TSE_DEFGROUP, TSE_DEFGROUP_BASE)) { + /* pass */ + } else if (type == TSE_LINKED_PSYS) { /* pass */ } @@ -358,7 +364,8 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP, - TSE_GENERIC_LABEL)) + TSE_GENERIC_LABEL) || + ELEM(type, TSE_DEFGROUP, TSE_DEFGROUP_BASE)) { BLI_assert_msg(false, "Element type should already use new AbstractTreeElement design"); } diff --git a/source/blender/editors/space_outliner/tree/tree_element.cc b/source/blender/editors/space_outliner/tree/tree_element.cc index 550ad121a93..8380b9fdf00 100644 --- a/source/blender/editors/space_outliner/tree/tree_element.cc +++ b/source/blender/editors/space_outliner/tree/tree_element.cc @@ -20,6 +20,7 @@ #include "tree_element_anim_data.hh" #include "tree_element_bone.hh" #include "tree_element_collection.hh" +#include "tree_element_defgroup.hh" #include "tree_element_driver.hh" #include "tree_element_edit_bone.hh" #include "tree_element_gpencil_layer.hh" @@ -115,6 +116,14 @@ std::unique_ptr AbstractTreeElement::createFromType(const i return std::make_unique( legacy_te, *ebone_data->armature_id, *ebone_data->ebone); } + case TSE_DEFGROUP_BASE: + return std::make_unique(legacy_te, *static_cast(idv)); + case TSE_DEFGROUP: { + DeformGroupElementCreateData *defgroup_data = static_cast( + idv); + return std::make_unique( + legacy_te, *defgroup_data->object, *defgroup_data->defgroup); + } case TSE_LINKED_PSYS: { ParticleSystemElementCreateData *psys_data = static_cast( idv); diff --git a/source/blender/editors/space_outliner/tree/tree_element_defgroup.cc b/source/blender/editors/space_outliner/tree/tree_element_defgroup.cc new file mode 100644 index 00000000000..298bce79f87 --- /dev/null +++ b/source/blender/editors/space_outliner/tree/tree_element_defgroup.cc @@ -0,0 +1,51 @@ +/* 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 "BKE_deform.h" + +#include "BLT_translation.h" + +#include "../outliner_intern.hh" + +#include "tree_element_defgroup.hh" + +namespace blender::ed::outliner { + +TreeElementDeformGroupBase::TreeElementDeformGroupBase(TreeElement &legacy_te, Object &object) + : AbstractTreeElement(legacy_te), object_(object) +{ + legacy_te.name = IFACE_("Vertex Groups"); +} + +void TreeElementDeformGroupBase::expand(SpaceOutliner &space_outliner) const +{ + const ListBase *defbase = BKE_object_defgroup_list(&object_); + + int index; + LISTBASE_FOREACH_INDEX (bDeformGroup *, defgroup, defbase, index) { + + DeformGroupElementCreateData defgroup_data = {&object_, defgroup}; + + outliner_add_element( + &space_outliner, &legacy_te_.subtree, &defgroup_data, &legacy_te_, TSE_DEFGROUP, index); + } +} + +TreeElementDeformGroup::TreeElementDeformGroup(TreeElement &legacy_te, + Object & /* object */, + bDeformGroup &defgroup) + : AbstractTreeElement(legacy_te), /* object_(object), */ defgroup_(defgroup) +{ + legacy_te.name = defgroup_.name; + legacy_te.directdata = &defgroup_; +} + +} // namespace blender::ed::outliner diff --git a/source/blender/editors/space_outliner/tree/tree_element_defgroup.hh b/source/blender/editors/space_outliner/tree/tree_element_defgroup.hh new file mode 100644 index 00000000000..9e3f59c3c9a --- /dev/null +++ b/source/blender/editors/space_outliner/tree/tree_element_defgroup.hh @@ -0,0 +1,35 @@ +/* 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 bDeformGroup; + +namespace blender::ed::outliner { + +class TreeElementDeformGroupBase final : public AbstractTreeElement { + Object &object_; + + public: + TreeElementDeformGroupBase(TreeElement &legacy_te, Object &object); + void expand(SpaceOutliner &) const override; +}; + +class TreeElementDeformGroup final : public AbstractTreeElement { + /* Not needed right now, avoid unused member variable warning. */ + // Object &object_; + bDeformGroup &defgroup_; + + public: + TreeElementDeformGroup(TreeElement &legacy_te, Object &object, bDeformGroup &defgroup); +}; + +} // namespace blender::ed::outliner diff --git a/source/blender/editors/space_outliner/tree/tree_element_id_object.cc b/source/blender/editors/space_outliner/tree/tree_element_id_object.cc index cb44a360d84..d6b5eb51c91 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_id_object.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_id_object.cc @@ -290,17 +290,8 @@ void TreeElementIDObject::expand_vertex_groups(SpaceOutliner &space_outliner) co if (BLI_listbase_is_empty(defbase)) { return; } - TreeElement *tenla = outliner_add_element( + outliner_add_element( &space_outliner, &legacy_te_.subtree, &object_, &legacy_te_, TSE_DEFGROUP_BASE, 0); - tenla->name = IFACE_("Vertex Groups"); - - int index; - LISTBASE_FOREACH_INDEX (bDeformGroup *, defgroup, defbase, index) { - TreeElement *ten = outliner_add_element( - &space_outliner, &tenla->subtree, &object_, tenla, TSE_DEFGROUP, index); - ten->name = defgroup->name; - ten->directdata = defgroup; - } } void TreeElementIDObject::expand_duplicated_group(SpaceOutliner &space_outliner) const