Outliner: Port curve elements to new tree-element code design #108498

Merged
Julian Eisel merged 3 commits from :temp-id-curve-refactor into main 2023-06-01 12:44:05 +02:00
5 changed files with 78 additions and 13 deletions

View File

@ -57,6 +57,7 @@ set(SRC
tree/tree_element_driver.cc
tree/tree_element_gpencil_layer.cc
tree/tree_element_id.cc
tree/tree_element_id_curve.cc
tree/tree_element_id_library.cc
tree/tree_element_id_mesh.cc
tree/tree_element_id_scene.cc
@ -78,6 +79,7 @@ set(SRC
tree/tree_element_driver.hh
tree/tree_element_gpencil_layer.hh
tree/tree_element_id.hh
tree/tree_element_id_curve.hh
tree/tree_element_id_library.hh
tree/tree_element_id_mesh.hh
tree/tree_element_id_scene.hh

View File

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

View File

@ -20,6 +20,7 @@
#include "../outliner_intern.hh"
#include "common.hh"
#include "tree_element_id_curve.hh"
#include "tree_element_id_library.hh"
#include "tree_element_id_mesh.hh"
#include "tree_element_id_scene.hh"
@ -42,8 +43,9 @@ std::unique_ptr<TreeElementID> TreeElementID::createFromID(TreeElement &legacy_t
return std::make_unique<TreeElementIDScene>(legacy_te, (Scene &)id);
case ID_ME:
return std::make_unique<TreeElementIDMesh>(legacy_te, (Mesh &)id);
case ID_OB:
case ID_CU_LEGACY:
return std::make_unique<TreeElementIDCurve>(legacy_te, (Curve &)id);
case ID_OB:
case ID_MB:
case ID_MA:
case ID_TE:

View File

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

View File

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