Outliner: Port metaball 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 a new tree-element class for metaball IDs.

Pull Request: https://projects.blender.org/blender/blender/pulls/108654
This commit is contained in:
Almaz Shinbay
2023-06-06 19:01:11 +02:00
committed by Julian Eisel
parent 3ecb301a20
commit c5ddf63a4a
5 changed files with 80 additions and 13 deletions

View File

@@ -60,6 +60,7 @@ set(SRC
tree/tree_element_id_curve.cc
tree/tree_element_id_library.cc
tree/tree_element_id_mesh.cc
tree/tree_element_id_metaball.cc
tree/tree_element_id_scene.cc
tree/tree_element_label.cc
tree/tree_element_nla.cc
@@ -82,6 +83,7 @@ set(SRC
tree/tree_element_id_curve.hh
tree/tree_element_id_library.hh
tree/tree_element_id_mesh.hh
tree/tree_element_id_metaball.hh
tree/tree_element_id_scene.hh
tree/tree_element_label.hh
tree/tree_element_nla.hh

View File

@@ -553,24 +553,13 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
case ID_SCE:
case ID_ME:
case ID_CU_LEGACY:
case ID_MB:
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_MB: {
MetaBall *mb = (MetaBall *)id;
if (outliner_animdata_test(mb->adt)) {
outliner_add_element(space_outliner, &te->subtree, mb, te, TSE_ANIM_DATA, 0);
}
for (int a = 0; a < mb->totcol; a++) {
outliner_add_element(space_outliner, &te->subtree, mb->mat[a], te, TSE_SOME_ID, a);
}
break;
}
case ID_MA: {
Material *ma = (Material *)id;
if (outliner_animdata_test(ma->adt)) {

View File

@@ -23,6 +23,7 @@
#include "tree_element_id_curve.hh"
#include "tree_element_id_library.hh"
#include "tree_element_id_mesh.hh"
#include "tree_element_id_metaball.hh"
#include "tree_element_id_scene.hh"
#include "tree_element_id.hh"
@@ -45,8 +46,9 @@ std::unique_ptr<TreeElementID> TreeElementID::createFromID(TreeElement &legacy_t
return std::make_unique<TreeElementIDMesh>(legacy_te, (Mesh &)id);
case ID_CU_LEGACY:
return std::make_unique<TreeElementIDCurve>(legacy_te, (Curve &)id);
case ID_OB:
case ID_MB:
return std::make_unique<TreeElementIDMetaBall>(legacy_te, (MetaBall &)id);
case ID_OB:
case ID_MA:
case ID_TE:
case ID_LT:

View File

@@ -0,0 +1,44 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup spoutliner
*/
#include "DNA_listBase.h"
#include "DNA_meta_types.h"
#include "DNA_outliner_types.h"
#include "../outliner_intern.hh"
#include "tree_element_id_metaball.hh"
namespace blender::ed::outliner {
TreeElementIDMetaBall::TreeElementIDMetaBall(TreeElement &legacy_te, MetaBall &metaball)
: TreeElementID(legacy_te, metaball.id), metaball_(metaball)
{
}
bool TreeElementIDMetaBall::isExpandValid() const
{
return true;
}
void TreeElementIDMetaBall::expand(SpaceOutliner &space_outliner) const
{
expand_animation_data(space_outliner, metaball_.adt);
expandMaterials(space_outliner);
}
void TreeElementIDMetaBall::expandMaterials(SpaceOutliner &space_outliner) const
{
for (int a = 0; a < metaball_.totcol; a++) {
outliner_add_element(
&space_outliner, &legacy_te_.subtree, metaball_.mat[a], &legacy_te_, TSE_SOME_ID, a);
}
}
} // namespace blender::ed::outliner

View File

@@ -0,0 +1,30 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup spoutliner
*/
#pragma once
#include "tree_element_id.hh"
struct MetaBall;
namespace blender::ed::outliner {
class TreeElementIDMetaBall final : public TreeElementID {
MetaBall &metaball_;
public:
TreeElementIDMetaBall(TreeElement &legacy_te, MetaBall &metaball);
void expand(SpaceOutliner &) const override;
bool isExpandValid() const override;
private:
void expandMaterials(SpaceOutliner &) const;
};
} // namespace blender::ed::outliner