diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index 78163b13fcb..7ab9582775c 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -56,6 +56,7 @@ set(SRC tree/tree_element_gpencil_layer.cc tree/tree_element_id.cc tree/tree_element_id_library.cc + tree/tree_element_id_mesh.cc tree/tree_element_id_scene.cc tree/tree_element_label.cc tree/tree_element_nla.cc @@ -76,6 +77,7 @@ set(SRC tree/tree_element_gpencil_layer.hh tree/tree_element_id.hh tree/tree_element_id_library.hh + tree/tree_element_id_mesh.hh tree/tree_element_id_scene.hh tree/tree_element_label.hh tree/tree_element_nla.hh diff --git a/source/blender/editors/space_outliner/outliner_tree.cc b/source/blender/editors/space_outliner/outliner_tree.cc index c98fdfdfe92..66db3ad5d63 100644 --- a/source/blender/editors/space_outliner/outliner_tree.cc +++ b/source/blender/editors/space_outliner/outliner_tree.cc @@ -550,27 +550,13 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner, switch (GS(id->name)) { case ID_LI: case ID_SCE: + case ID_ME: BLI_assert_msg(0, "ID type expected to be expanded through new tree-element design"); break; case ID_OB: { outliner_add_object_contents(space_outliner, te, tselem, (Object *)id); break; } - case ID_ME: { - Mesh *me = (Mesh *)id; - - if (outliner_animdata_test(me->adt)) { - outliner_add_element(space_outliner, &te->subtree, me, te, TSE_ANIM_DATA, 0); - } - - outliner_add_element(space_outliner, &te->subtree, me->key, te, TSE_SOME_ID, 0); - for (int a = 0; a < me->totcol; a++) { - outliner_add_element(space_outliner, &te->subtree, me->mat[a], te, TSE_SOME_ID, a); - } - /* could do tfaces with image links, but the images are not grouped nicely. - * would require going over all tfaces, sort images in use. etc... */ - break; - } case ID_CU_LEGACY: { Curve *cu = (Curve *)id; diff --git a/source/blender/editors/space_outliner/tree/tree_element_id.cc b/source/blender/editors/space_outliner/tree/tree_element_id.cc index 668d0966bc6..53bec7a5340 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_id.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_id.cc @@ -19,6 +19,7 @@ #include "../outliner_intern.hh" #include "common.hh" #include "tree_element_id_library.hh" +#include "tree_element_id_mesh.hh" #include "tree_element_id_scene.hh" #include "tree_element_id.hh" @@ -37,8 +38,9 @@ std::unique_ptr TreeElementID::createFromID(TreeElement &legacy_t return std::make_unique(legacy_te, (Library &)id); case ID_SCE: return std::make_unique(legacy_te, (Scene &)id); - case ID_OB: case ID_ME: + return std::make_unique(legacy_te, (Mesh &)id); + case ID_OB: case ID_CU_LEGACY: case ID_MB: case ID_MA: diff --git a/source/blender/editors/space_outliner/tree/tree_element_id_mesh.cc b/source/blender/editors/space_outliner/tree/tree_element_id_mesh.cc new file mode 100644 index 00000000000..a0d1e40d757 --- /dev/null +++ b/source/blender/editors/space_outliner/tree/tree_element_id_mesh.cc @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup spoutliner + */ + +#include "DNA_listBase.h" +#include "DNA_mesh_types.h" +#include "DNA_outliner_types.h" + +#include "../outliner_intern.hh" + +#include "tree_element_id_mesh.hh" + +namespace blender::ed::outliner { + +TreeElementIDMesh::TreeElementIDMesh(TreeElement &legacy_te_, Mesh &mesh) + : TreeElementID(legacy_te_, mesh.id), mesh_(mesh) +{ +} + +bool TreeElementIDMesh::isExpandValid() const +{ + return true; +} + +void TreeElementIDMesh::expand(SpaceOutliner &space_outliner) const +{ + expand_animation_data(space_outliner, mesh_.adt); + + expandKey(space_outliner); + expandMaterials(space_outliner); +} + +void TreeElementIDMesh::expandKey(SpaceOutliner &space_outliner) const +{ + outliner_add_element( + &space_outliner, &legacy_te_.subtree, mesh_.key, &legacy_te_, TSE_SOME_ID, 0); +} + +void TreeElementIDMesh::expandMaterials(SpaceOutliner &space_outliner) const +{ + for (int a = 0; a < mesh_.totcol; a++) { + outliner_add_element( + &space_outliner, &legacy_te_.subtree, mesh_.mat[a], &legacy_te_, TSE_SOME_ID, a); + } +} + +} // namespace blender::ed::outliner diff --git a/source/blender/editors/space_outliner/tree/tree_element_id_mesh.hh b/source/blender/editors/space_outliner/tree/tree_element_id_mesh.hh new file mode 100644 index 00000000000..d3f99982db0 --- /dev/null +++ b/source/blender/editors/space_outliner/tree/tree_element_id_mesh.hh @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup spoutliner + */ + +#pragma once + +#include "tree_element_id.hh" + +namespace blender::ed::outliner { + +class TreeElementIDMesh final : public TreeElementID { + Mesh &mesh_; + + public: + TreeElementIDMesh(TreeElement &legacy_te_, Mesh &mesh); + + void expand(SpaceOutliner &) const override; + bool isExpandValid() const override; + + private: + void expandKey(SpaceOutliner &) const; + void expandMaterials(SpaceOutliner &) const; +}; + +} // namespace blender::ed::outliner