Outliner: Port deform group elements to new tree-element code design
No user visible changes expected. Part of #96713, continuation of work started in249e4df110and2e221de4ce. Refer to these for a motivation and design overview. Adds new classes for deform group elements. Pull Request: https://projects.blender.org/blender/blender/pulls/110003
This commit is contained in:
committed by
Julian Eisel
parent
ca1066faf3
commit
8214109778
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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_DEFGROUP) {
|
||||
id = &static_cast<DeformGroupElementCreateData *>(idv)->object->id;
|
||||
}
|
||||
else if (type == TSE_LINKED_PSYS) {
|
||||
id = &static_cast<ParticleSystemElementCreateData *>(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");
|
||||
}
|
||||
|
||||
@@ -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> AbstractTreeElement::createFromType(const i
|
||||
return std::make_unique<TreeElementEditBone>(
|
||||
legacy_te, *ebone_data->armature_id, *ebone_data->ebone);
|
||||
}
|
||||
case TSE_DEFGROUP_BASE:
|
||||
return std::make_unique<TreeElementDeformGroupBase>(legacy_te, *static_cast<Object *>(idv));
|
||||
case TSE_DEFGROUP: {
|
||||
DeformGroupElementCreateData *defgroup_data = static_cast<DeformGroupElementCreateData *>(
|
||||
idv);
|
||||
return std::make_unique<TreeElementDeformGroup>(
|
||||
legacy_te, *defgroup_data->object, *defgroup_data->defgroup);
|
||||
}
|
||||
case TSE_LINKED_PSYS: {
|
||||
ParticleSystemElementCreateData *psys_data = static_cast<ParticleSystemElementCreateData *>(
|
||||
idv);
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user