diff --git a/source/blender/editors/space_outliner/tree/tree_element.cc b/source/blender/editors/space_outliner/tree/tree_element.cc index 19eb5d6d558..d8a583e321c 100644 --- a/source/blender/editors/space_outliner/tree/tree_element.cc +++ b/source/blender/editors/space_outliner/tree/tree_element.cc @@ -198,7 +198,9 @@ std::unique_ptr AbstractTreeElement::create_from_type(const legacy_te, *reinterpret_cast(owner_id)); case TSE_BONE_COLLECTION: return std::make_unique( - legacy_te, *static_cast(create_data)); + legacy_te, + *reinterpret_cast(owner_id), + *static_cast(create_data)); default: break; diff --git a/source/blender/editors/space_outliner/tree/tree_element_bone_collection.cc b/source/blender/editors/space_outliner/tree/tree_element_bone_collection.cc index d7feb7a8316..f82f97d464d 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_bone_collection.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_bone_collection.cc @@ -30,19 +30,32 @@ TreeElementBoneCollectionBase::TreeElementBoneCollectionBase(TreeElement &legacy void TreeElementBoneCollectionBase::expand(SpaceOutliner & /*space_outliner*/) const { - for (int index = 0; index < armature_.collection_array_num; index++) { - BoneCollection *bcoll = armature_.collection_array[index]; + int index = 0; + for (BoneCollection *bcoll : armature_.collections_roots()) { add_element( &legacy_te_.subtree, &armature_.id, bcoll, &legacy_te_, TSE_BONE_COLLECTION, index); + index++; } } -TreeElementBoneCollection::TreeElementBoneCollection(TreeElement &legacy_te, BoneCollection &bcoll) - : AbstractTreeElement(legacy_te), bcoll_(bcoll) +TreeElementBoneCollection::TreeElementBoneCollection(TreeElement &legacy_te, + bArmature &armature, + BoneCollection &bcoll) + : AbstractTreeElement(legacy_te), armature_(armature), bcoll_(bcoll) { BLI_assert(legacy_te.store_elem->type == TSE_BONE_COLLECTION); legacy_te.name = bcoll_.name; legacy_te.directdata = &bcoll_; } +void TreeElementBoneCollection::expand(SpaceOutliner & /*space_outliner*/) const +{ + int index = 0; + for (BoneCollection *child_bcoll : armature_.collection_children(&bcoll_)) { + add_element( + &legacy_te_.subtree, &armature_.id, child_bcoll, &legacy_te_, TSE_BONE_COLLECTION, index); + index++; + } +} + } // namespace blender::ed::outliner diff --git a/source/blender/editors/space_outliner/tree/tree_element_bone_collection.hh b/source/blender/editors/space_outliner/tree/tree_element_bone_collection.hh index bbfdf651ba0..3c3205852af 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_bone_collection.hh +++ b/source/blender/editors/space_outliner/tree/tree_element_bone_collection.hh @@ -24,10 +24,12 @@ class TreeElementBoneCollectionBase final : public AbstractTreeElement { }; class TreeElementBoneCollection final : public AbstractTreeElement { + bArmature &armature_; BoneCollection &bcoll_; public: - TreeElementBoneCollection(TreeElement &legacy_te, BoneCollection &bcoll); + TreeElementBoneCollection(TreeElement &legacy_te, bArmature &armature, BoneCollection &bcoll); + void expand(SpaceOutliner &) const override; }; } // namespace blender::ed::outliner