diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index 4ec91175d99..f8c5b7896cc 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_constraint.cc tree/tree_element_defgroup.cc tree/tree_element_driver.cc tree/tree_element_edit_bone.cc @@ -86,6 +87,7 @@ set(SRC tree/tree_element_anim_data.hh tree/tree_element_bone.hh tree/tree_element_collection.hh + tree/tree_element_constraint.hh tree/tree_element_defgroup.hh tree/tree_element_driver.hh tree/tree_element_edit_bone.hh diff --git a/source/blender/editors/space_outliner/outliner_intern.hh b/source/blender/editors/space_outliner/outliner_intern.hh index e3901435164..8f73fc8f9f2 100644 --- a/source/blender/editors/space_outliner/outliner_intern.hh +++ b/source/blender/editors/space_outliner/outliner_intern.hh @@ -31,6 +31,7 @@ struct ShaderFxData; struct TreeStoreElem; struct ViewLayer; struct bActionGroup; +struct bConstraint; struct bContext; struct bContextDataResult; struct bDeformGroup; @@ -301,6 +302,11 @@ struct EditBoneElementCreateData { EditBone *ebone; }; +struct ConstraintElementCreateData { + Object *object; + bConstraint *con; +}; + struct DeformGroupElementCreateData { Object *object; bDeformGroup *defgroup; diff --git a/source/blender/editors/space_outliner/outliner_tree.cc b/source/blender/editors/space_outliner/outliner_tree.cc index 21266c1ff3b..97f6927dc50 100644 --- a/source/blender/editors/space_outliner/outliner_tree.cc +++ b/source/blender/editors/space_outliner/outliner_tree.cc @@ -258,6 +258,9 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, else if (type == TSE_LINKED_PSYS) { id = &static_cast(idv)->object->id; } + else if (type == TSE_CONSTRAINT) { + id = &static_cast(idv)->object->id; + } else if (type == TSE_POSEGRP) { id = &static_cast(idv)->object->id; } @@ -331,6 +334,9 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, else if (type == TSE_LINKED_PSYS) { /* pass */ } + else if (ELEM(type, TSE_CONSTRAINT, TSE_CONSTRAINT_BASE)) { + /* pass */ + } else if (type == TSE_POSE_BASE) { /* pass */ } @@ -395,6 +401,8 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, TSE_DEFGROUP_BASE, TSE_GPENCIL_EFFECT, TSE_GPENCIL_EFFECT_BASE, + TSE_CONSTRAINT, + TSE_CONSTRAINT_BASE, TSE_POSE_BASE, TSE_POSEGRP, TSE_POSEGRP_BASE, diff --git a/source/blender/editors/space_outliner/tree/tree_element.cc b/source/blender/editors/space_outliner/tree/tree_element.cc index 1a72c9665c1..5f7f5918736 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_constraint.hh" #include "tree_element_defgroup.hh" #include "tree_element_driver.hh" #include "tree_element_edit_bone.hh" @@ -147,6 +148,12 @@ std::unique_ptr AbstractTreeElement::createFromType(const i return std::make_unique( legacy_te, *psys_data->object, *psys_data->psys); } + case TSE_CONSTRAINT_BASE: + return std::make_unique(legacy_te, *static_cast(idv)); + case TSE_CONSTRAINT: { + ConstraintElementCreateData *con_data = static_cast(idv); + return std::make_unique(legacy_te, *con_data->object, *con_data->con); + } case TSE_POSE_BASE: return std::make_unique(legacy_te, *static_cast(idv)); case TSE_POSEGRP_BASE: diff --git a/source/blender/editors/space_outliner/tree/tree_element_constraint.cc b/source/blender/editors/space_outliner/tree/tree_element_constraint.cc new file mode 100644 index 00000000000..b6f8c84c6bf --- /dev/null +++ b/source/blender/editors/space_outliner/tree/tree_element_constraint.cc @@ -0,0 +1,38 @@ +/* SPDX-FileCopyrightText: 2023 Blender Foundation + * + * SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup spoutliner + */ + +#include "DNA_constraint_types.h" +#include "DNA_object_types.h" +#include "DNA_outliner_types.h" + +#include "BLT_translation.h" + +#include "../outliner_intern.hh" + +#include "tree_element_constraint.hh" + +namespace blender::ed::outliner { + +TreeElementConstraintBase::TreeElementConstraintBase(TreeElement &legacy_te, Object & /* object */) + : AbstractTreeElement(legacy_te) /* , object_(object) */ +{ + BLI_assert(legacy_te.store_elem->type == TSE_CONSTRAINT_BASE); + legacy_te.name = IFACE_("Constraints"); +} + +TreeElementConstraint::TreeElementConstraint(TreeElement &legacy_te, + Object & /* object */, + bConstraint &con) + : AbstractTreeElement(legacy_te), /* object_(object), */ con_(con) +{ + BLI_assert(legacy_te.store_elem->type == TSE_CONSTRAINT); + legacy_te.name = con_.name; + legacy_te.directdata = &con_; +} + +} // namespace blender::ed::outliner diff --git a/source/blender/editors/space_outliner/tree/tree_element_constraint.hh b/source/blender/editors/space_outliner/tree/tree_element_constraint.hh new file mode 100644 index 00000000000..ba6457986a2 --- /dev/null +++ b/source/blender/editors/space_outliner/tree/tree_element_constraint.hh @@ -0,0 +1,34 @@ +/* SPDX-FileCopyrightText: 2023 Blender Foundation + * + * SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup spoutliner + */ + +#pragma once + +#include "tree_element.hh" + +struct bConstraint; + +namespace blender::ed::outliner { + +class TreeElementConstraintBase final : public AbstractTreeElement { + /* Not needed right now, avoid unused member variable warning. */ + // Object &object_; + + public: + TreeElementConstraintBase(TreeElement &legacy_te, Object &object); +}; + +class TreeElementConstraint final : public AbstractTreeElement { + /* Not needed right now, avoid unused member variable warning. */ + // Object &object_; + bConstraint &con_; + + public: + TreeElementConstraint(TreeElement &legacy_te, Object &object, bConstraint &con); +}; + +} // 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 85e3b34ce84..dd081c79070 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 @@ -87,14 +87,13 @@ void TreeElementIDObject::expand_constraints(SpaceOutliner &space_outliner) cons } TreeElement *tenla = outliner_add_element( &space_outliner, &legacy_te_.subtree, &object_, &legacy_te_, TSE_CONSTRAINT_BASE, 0); - tenla->name = IFACE_("Constraints"); int index; LISTBASE_FOREACH_INDEX (bConstraint *, con, &object_.constraints, index) { - TreeElement *ten = outliner_add_element( - &space_outliner, &tenla->subtree, &object_, tenla, TSE_CONSTRAINT, index); - ten->name = con->name; - ten->directdata = con; + ConstraintElementCreateData con_data = {&object_, con}; + + outliner_add_element( + &space_outliner, &tenla->subtree, &con_data, tenla, TSE_CONSTRAINT, index); /* possible add all other types links? */ } }