Blender  V2.93
Classes | Macros
collection.c File Reference
#include <string.h>
#include "BLI_blenlib.h"
#include "BLI_iterator.h"
#include "BLI_listbase.h"
#include "BLI_math_base.h"
#include "BLI_threads.h"
#include "BLT_translation.h"
#include "BKE_anim_data.h"
#include "BKE_collection.h"
#include "BKE_icons.h"
#include "BKE_idprop.h"
#include "BKE_idtype.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
#include "BKE_lib_query.h"
#include "BKE_lib_remap.h"
#include "BKE_main.h"
#include "BKE_object.h"
#include "BKE_rigidbody.h"
#include "BKE_scene.h"
#include "DNA_defaults.h"
#include "DNA_ID.h"
#include "DNA_collection_types.h"
#include "DNA_layer_types.h"
#include "DNA_object_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "MEM_guardedalloc.h"
#include "BLO_read_write.h"

Go to the source code of this file.

Classes

struct  LayerCollectionFlag
 
struct  CollectionsIteratorData
 
struct  SceneObjectsIteratorData
 

Macros

#define DNA_DEPRECATED_ALLOW
 

Functions

Prototypes
static bool collection_child_add (Collection *parent, Collection *collection, const int flag, const bool add_us)
 
static bool collection_child_remove (Collection *parent, Collection *collection)
 
static bool collection_object_add (Main *bmain, Collection *collection, Object *ob, int flag, const bool add_us)
 
static bool collection_object_remove (Main *bmain, Collection *collection, Object *ob, const bool free_us)
 
static CollectionChildcollection_find_child (Collection *parent, Collection *collection)
 
static CollectionParentcollection_find_parent (Collection *child, Collection *collection)
 
static bool collection_find_child_recursive (Collection *parent, Collection *collection)
 
Add Collection
static Collectioncollection_add (Main *bmain, Collection *collection_parent, const char *name_custom)
 
CollectionBKE_collection_add (Main *bmain, Collection *collection_parent, const char *name_custom)
 
void BKE_collection_add_from_object (Main *bmain, Scene *scene, const Object *ob_src, Collection *collection_dst)
 
void BKE_collection_add_from_collection (Main *bmain, Scene *scene, Collection *collection_src, Collection *collection_dst)
 
Free and Delete Collection
void BKE_collection_free (Collection *collection)
 
bool BKE_collection_delete (Main *bmain, Collection *collection, bool hierarchy)
 
Collection Copy
static Collectioncollection_duplicate_recursive (Main *bmain, Collection *parent, Collection *collection_old, const eDupli_ID_Flags duplicate_flags, const eLibIDDuplicateFlags duplicate_options)
 
CollectionBKE_collection_duplicate (Main *bmain, Collection *parent, Collection *collection, eDupli_ID_Flags duplicate_flags, eLibIDDuplicateFlags duplicate_options)
 
Collection Naming
void BKE_collection_new_name_get (Collection *collection_parent, char *rname)
 
const char * BKE_collection_ui_name_get (struct Collection *collection)
 
Object List Cache
static void collection_object_cache_fill (ListBase *lb, Collection *collection, int parent_restrict, bool with_instances)
 
ListBase BKE_collection_object_cache_get (Collection *collection)
 
ListBase BKE_collection_object_cache_instanced_get (Collection *collection)
 
static void collection_object_cache_free (Collection *collection)
 
void BKE_collection_object_cache_free (Collection *collection)
 
BaseBKE_collection_or_layer_objects (const ViewLayer *view_layer, Collection *collection)
 
Scene Master Collection
CollectionBKE_collection_master_add ()
 
Cyclic Checks
static bool collection_object_cyclic_check_internal (Object *object, Collection *collection)
 
bool BKE_collection_object_cyclic_check (Main *bmain, Object *object, Collection *collection)
 
Collection Object Membership
bool BKE_collection_has_object (Collection *collection, const Object *ob)
 
bool BKE_collection_has_object_recursive (Collection *collection, Object *ob)
 
bool BKE_collection_has_object_recursive_instanced (Collection *collection, Object *ob)
 
static Collectioncollection_next_find (Main *bmain, Scene *scene, Collection *collection)
 
CollectionBKE_collection_object_find (Main *bmain, Scene *scene, Collection *collection, Object *ob)
 
bool BKE_collection_is_empty (const Collection *collection)
 
Collection Objects
static void collection_tag_update_parent_recursive (Main *bmain, Collection *collection, const int flag)
 
static Collectioncollection_parent_editable_find_recursive (Collection *collection)
 
bool BKE_collection_object_add (Main *bmain, Collection *collection, Object *ob)
 
void BKE_collection_object_add_from (Main *bmain, Scene *scene, Object *ob_src, Object *ob_dst)
 
bool BKE_collection_object_remove (Main *bmain, Collection *collection, Object *ob, const bool free_us)
 
static bool scene_collections_object_remove (Main *bmain, Scene *scene, Object *ob, const bool free_us, Collection *collection_skip)
 
bool BKE_scene_collections_object_remove (Main *bmain, Scene *scene, Object *ob, const bool free_us)
 
static void collection_object_remove_nulls (Collection *collection)
 
void BKE_collections_object_remove_nulls (Main *bmain)
 
static void collection_null_children_remove (Collection *collection)
 
static void collection_missing_parents_remove (Collection *collection)
 
void BKE_collections_child_remove_nulls (Main *bmain, Collection *parent_collection, Collection *child_collection)
 
void BKE_collection_object_move (Main *bmain, Scene *scene, Collection *collection_dst, Collection *collection_src, Object *ob)
 
Collection Scene Membership
bool BKE_collection_is_in_scene (Collection *collection)
 
void BKE_collections_after_lib_link (Main *bmain)
 
Collection Children
static bool collection_instance_find_recursive (Collection *collection, Collection *instance_collection)
 
bool BKE_collection_cycle_find (Collection *new_ancestor, Collection *collection)
 
static bool collection_instance_fix_recursive (Collection *parent_collection, Collection *collection)
 
static bool collection_cycle_fix_recursive (Main *bmain, Collection *parent_collection, Collection *collection)
 
bool BKE_collection_cycles_fix (Main *bmain, Collection *collection)
 
bool BKE_collection_has_collection (Collection *parent, Collection *collection)
 
bool BKE_collection_child_add (Main *bmain, Collection *parent, Collection *child)
 
bool BKE_collection_child_add_no_sync (Collection *parent, Collection *child)
 
bool BKE_collection_child_remove (Main *bmain, Collection *parent, Collection *child)
 
void BKE_collection_parent_relations_rebuild (Collection *collection)
 
static void collection_parents_rebuild_recursive (Collection *collection)
 
void BKE_main_collections_parent_relations_rebuild (Main *bmain)
 
Collection Index
static Collectioncollection_from_index_recursive (Collection *collection, const int index, int *index_current)
 
CollectionBKE_collection_from_index (Scene *scene, const int index)
 
static bool collection_objects_select (ViewLayer *view_layer, Collection *collection, bool deselect)
 
bool BKE_collection_objects_select (ViewLayer *view_layer, Collection *collection, bool deselect)
 

Collection move (outliner drag & drop)

typedef struct LayerCollectionFlag LayerCollectionFlag
 
static void layer_collection_flags_store_recursive (const LayerCollection *layer_collection, LayerCollectionFlag *flag)
 
static void layer_collection_flags_store (Main *bmain, const Collection *collection, ListBase *r_layer_level_list)
 
static void layer_collection_flags_free_recursive (LayerCollectionFlag *flag)
 
static void layer_collection_flags_restore_recursive (LayerCollection *layer_collection, LayerCollectionFlag *flag)
 
static void layer_collection_flags_restore (ListBase *flags, const Collection *collection)
 
bool BKE_collection_move (Main *bmain, Collection *to_parent, Collection *from_parent, Collection *relative, bool relative_after, Collection *collection)
 

Iterators

typedef struct CollectionsIteratorData CollectionsIteratorData
 
typedef struct SceneObjectsIteratorData SceneObjectsIteratorData
 
static void scene_collection_callback (Collection *collection, BKE_scene_collections_Cb callback, void *data)
 
static void scene_collections_count (Collection *UNUSED(collection), void *data)
 
static void scene_collections_build_array (Collection *collection, void *data)
 
static void scene_collections_array (Scene *scene, Collection ***r_collections_array, int *r_collections_array_len)
 
void BKE_scene_collections_iterator_begin (BLI_Iterator *iter, void *data_in)
 
void BKE_scene_collections_iterator_next (struct BLI_Iterator *iter)
 
void BKE_scene_collections_iterator_end (struct BLI_Iterator *iter)
 
static void scene_objects_iterator_begin (BLI_Iterator *iter, Scene *scene, GSet *visited_objects)
 
void BKE_scene_objects_iterator_begin (BLI_Iterator *iter, void *data_in)
 
static CollectionObjectobject_base_unique (GSet *gs, CollectionObject *cob)
 
void BKE_scene_objects_iterator_next (BLI_Iterator *iter)
 
void BKE_scene_objects_iterator_end (BLI_Iterator *iter)
 
GSetBKE_scene_objects_as_gset (Scene *scene, GSet *objects_gset)
 

Collection Data-Block

IDTypeInfo IDType_ID_GR
 
static void collection_init_data (ID *id)
 
static void collection_copy_data (Main *bmain, ID *id_dst, const ID *id_src, const int flag)
 
static void collection_free_data (ID *id)
 
static void collection_foreach_id (ID *id, LibraryForeachIDData *data)
 
static IDcollection_owner_get (Main *bmain, ID *id)
 
void BKE_collection_blend_write_nolib (BlendWriter *writer, Collection *collection)
 
static void collection_blend_write (BlendWriter *writer, ID *id, const void *id_address)
 
void BKE_collection_blend_read_data (BlendDataReader *reader, Collection *collection)
 
static void collection_blend_read_data (BlendDataReader *reader, ID *id)
 
static void lib_link_collection_data (BlendLibReader *reader, Library *lib, Collection *collection)
 
void BKE_collection_blend_read_lib (BlendLibReader *reader, Collection *collection)
 
static void collection_blend_read_lib (BlendLibReader *reader, ID *id)
 
void BKE_collection_blend_read_expand (BlendExpander *expander, Collection *collection)
 
static void collection_blend_read_expand (BlendExpander *expander, ID *id)
 

Macro Definition Documentation

◆ DNA_DEPRECATED_ALLOW

#define DNA_DEPRECATED_ALLOW

Definition at line 22 of file collection.c.

Typedef Documentation

◆ CollectionsIteratorData

◆ LayerCollectionFlag

◆ SceneObjectsIteratorData

Function Documentation

◆ BKE_collection_add()

Collection* BKE_collection_add ( Main bmain,
Collection collection_parent,
const char *  name_custom 
)

◆ BKE_collection_add_from_collection()

void BKE_collection_add_from_collection ( Main bmain,
Scene scene,
Collection collection_src,
Collection collection_dst 
)

Add collection_dst to all scene collections that reference collection collection_src is in.

Logic is very similar to BKE_collection_object_add_from().

Definition at line 476 of file collection.c.

References BKE_main_collection_sync(), collection_child_add(), collection_find_child(), FOREACH_SCENE_COLLECTION_BEGIN, FOREACH_SCENE_COLLECTION_END, ID_IS_LINKED, Scene::master_collection, and scene.

Referenced by lib_override_library_create_post_process().

◆ BKE_collection_add_from_object()

void BKE_collection_add_from_object ( Main bmain,
Scene scene,
const Object ob_src,
Collection collection_dst 
)

Add collection_dst to all scene collections that reference object ob_src is in. Used to replace an instance object with a collection (library override operator).

Logic is very similar to BKE_collection_object_add_from().

Definition at line 448 of file collection.c.

References BKE_collection_has_object(), BKE_main_collection_sync(), collection_child_add(), FOREACH_SCENE_COLLECTION_BEGIN, FOREACH_SCENE_COLLECTION_END, ID_IS_LINKED, Scene::master_collection, and scene.

◆ BKE_collection_blend_read_data()

void BKE_collection_blend_read_data ( BlendDataReader reader,
Collection collection 
)

◆ BKE_collection_blend_read_expand()

void BKE_collection_blend_read_expand ( BlendExpander expander,
Collection collection 
)

◆ BKE_collection_blend_read_lib()

void BKE_collection_blend_read_lib ( BlendLibReader reader,
Collection collection 
)

◆ BKE_collection_blend_write_nolib()

void BKE_collection_blend_write_nolib ( BlendWriter writer,
Collection collection 
)

◆ BKE_collection_child_add()

bool BKE_collection_child_add ( Main bmain,
Collection parent,
Collection child 
)

◆ BKE_collection_child_add_no_sync()

bool BKE_collection_child_add_no_sync ( Collection parent,
Collection child 
)

Definition at line 1616 of file collection.c.

References collection_child_add().

Referenced by single_object_users_collection().

◆ BKE_collection_child_remove()

bool BKE_collection_child_remove ( Main bmain,
Collection parent,
Collection child 
)

◆ BKE_collection_cycle_find()

bool BKE_collection_cycle_find ( Collection new_ancestor,
Collection collection 
)

Find potential cycles in collections.

Parameters
new_ancestorthe potential new owner of given collection, or the collection to check if the later is NULL.
collectionthe collection we want to add to new_ancestor, may be NULL if we just want to ensure new_ancestor does not already have cycles.
Returns
true if a cycle is found.

Definition at line 1450 of file collection.c.

References BKE_collection_cycle_find(), collection_instance_find_recursive(), LISTBASE_FOREACH, NULL, and Collection::parents.

Referenced by BKE_collection_cycle_find(), BKE_collection_move(), BKE_collection_parent_relations_rebuild(), collection_child_add(), collection_cycle_fix_recursive(), collection_instance_add_exec(), and collection_instance_exec().

◆ BKE_collection_cycles_fix()

bool BKE_collection_cycles_fix ( Main bmain,
Collection collection 
)

Find and fix potential cycles in collections.

Parameters
collectionThe collection to check for existing cycles.
Returns
true if cycles are found and fixed.

Definition at line 1519 of file collection.c.

References collection_cycle_fix_recursive(), and collection_instance_fix_recursive().

Referenced by do_versions_after_linking_290().

◆ BKE_collection_delete()

bool BKE_collection_delete ( Main bmain,
Collection collection,
bool  hierarchy 
)

◆ BKE_collection_duplicate()

Collection* BKE_collection_duplicate ( Main bmain,
Collection parent,
Collection collection,
eDupli_ID_Flags  duplicate_flags,
eLibIDDuplicateFlags  duplicate_options 
)

Make a deep copy (aka duplicate) of the given collection and all of its children, recursively.

Warning
This functions will clear all bmain #ID.idnew pointers, unless LIB_ID_DUPLICATE_IS_SUBPROCESS duplicate option is passed on, in which case caller is responsible to reconstruct collection dependencies information's (i.e. call BKE_main_collection_sync).

Definition at line 688 of file collection.c.

References BKE_libblock_relink_to_newid(), BKE_main_collection_sync(), BKE_main_id_clear_newpoins(), BKE_main_id_tag_all(), BLI_assert, collection_duplicate_recursive(), FOREACH_MAIN_ID_BEGIN, FOREACH_MAIN_ID_END, Collection::id, ID_IS_LINKED, LIB_ID_DUPLICATE_IS_ROOT_ID, LIB_ID_DUPLICATE_IS_SUBPROCESS, LIB_TAG_NEW, ID::tag, and USER_DUP_LINKED_ID.

◆ BKE_collection_free()

void BKE_collection_free ( Collection collection)

Free (or release) any data used by this collection (does not free the collection itself).

Definition at line 510 of file collection.c.

References BKE_libblock_free_data(), collection_free_data(), and Collection::id.

Referenced by scene_free_data().

◆ BKE_collection_from_index()

Collection* BKE_collection_from_index ( Scene scene,
const int  index 
)

Return Scene Collection for a given index.

The index is calculated from top to bottom counting the children before the siblings.

Definition at line 1734 of file collection.c.

References collection_from_index_recursive(), Scene::master_collection, and scene.

Referenced by move_to_collection_exec(), and move_to_collection_invoke().

◆ BKE_collection_has_collection()

bool BKE_collection_has_collection ( Collection parent,
Collection collection 
)

Definition at line 1545 of file collection.c.

References collection_find_child_recursive().

Referenced by outliner_collection_is_isolated().

◆ BKE_collection_has_object()

bool BKE_collection_has_object ( Collection collection,
const Object ob 
)

◆ BKE_collection_has_object_recursive()

bool BKE_collection_has_object_recursive ( Collection collection,
Object ob 
)

◆ BKE_collection_has_object_recursive_instanced()

bool BKE_collection_has_object_recursive_instanced ( Collection collection,
Object ob 
)

◆ BKE_collection_is_empty()

bool BKE_collection_is_empty ( const Collection collection)

Definition at line 1014 of file collection.c.

References BLI_listbase_is_empty(), Collection::children, and Collection::gobject.

◆ BKE_collection_is_in_scene()

bool BKE_collection_is_in_scene ( Collection collection)

◆ BKE_collection_master_add()

Collection* BKE_collection_master_add ( void  )

◆ BKE_collection_move()

bool BKE_collection_move ( Main bmain,
Collection to_parent,
Collection from_parent,
Collection relative,
bool  relative_after,
Collection collection 
)

◆ BKE_collection_new_name_get()

void BKE_collection_new_name_get ( Collection collection_parent,
char *  rname 
)

◆ BKE_collection_object_add()

bool BKE_collection_object_add ( Main bmain,
Collection collection,
Object ob 
)

◆ BKE_collection_object_add_from()

void BKE_collection_object_add_from ( Main bmain,
Scene scene,
Object ob_src,
Object ob_dst 
)

◆ BKE_collection_object_cache_free()

void BKE_collection_object_cache_free ( Collection collection)

◆ BKE_collection_object_cache_get()

ListBase BKE_collection_object_cache_get ( Collection collection)

◆ BKE_collection_object_cache_instanced_get()

ListBase BKE_collection_object_cache_instanced_get ( Collection collection)

◆ BKE_collection_object_cyclic_check()

bool BKE_collection_object_cyclic_check ( Main bmain,
Object object,
Collection collection 
)

◆ BKE_collection_object_find()

Collection* BKE_collection_object_find ( Main bmain,
Scene scene,
Collection collection,
Object ob 
)

◆ BKE_collection_object_move()

void BKE_collection_object_move ( Main bmain,
Scene scene,
Collection collection_dst,
Collection collection_src,
Object ob 
)

Move object from a collection into another

If source collection is NULL move it from all the existing collections.

Definition at line 1367 of file collection.c.

References BKE_collection_object_add(), BKE_collection_object_remove(), NULL, scene, and scene_collections_object_remove().

Referenced by collection_drop_invoke(), and move_to_collection_exec().

◆ BKE_collection_object_remove()

bool BKE_collection_object_remove ( Main bmain,
Collection collection,
Object ob,
const bool  free_us 
)

◆ BKE_collection_objects_select()

bool BKE_collection_objects_select ( ViewLayer view_layer,
Collection collection,
bool  deselect 
)

Select all the objects in this Collection (and its nested collections) for this ViewLayer. Return true if any object was selected.

Definition at line 1781 of file collection.c.

References BKE_layer_collection_first_from_scene_collection(), BKE_layer_collection_objects_select(), collection_objects_select(), and NULL.

◆ BKE_collection_or_layer_objects()

Base* BKE_collection_or_layer_objects ( const ViewLayer view_layer,
Collection collection 
)

Definition at line 877 of file collection.c.

References BKE_collection_object_cache_get(), ListBase::first, and FIRSTBASE.

◆ BKE_collection_parent_relations_rebuild()

void BKE_collection_parent_relations_rebuild ( Collection collection)

Rebuild parent relationships from child ones, for all children of given collection.

Note
Given collection is assumed to already have valid parents.

Definition at line 1636 of file collection.c.

References BKE_collection_cycle_find(), BLI_addtail(), BLI_freelinkN(), Collection::children, CollectionParent::collection, collection_find_child(), LISTBASE_FOREACH_MUTABLE, MEM_callocN, and NULL.

Referenced by collection_parents_rebuild_recursive().

◆ BKE_collection_ui_name_get()

const char* BKE_collection_ui_name_get ( struct Collection collection)

◆ BKE_collections_after_lib_link()

void BKE_collections_after_lib_link ( Main bmain)

Definition at line 1406 of file collection.c.

References BKE_main_collection_sync().

Referenced by blo_read_file_internal(), and library_link_end().

◆ BKE_collections_child_remove_nulls()

void BKE_collections_child_remove_nulls ( Main bmain,
Collection parent_collection,
Collection child_collection 
)

Remove all NULL children from parent collections of changed collection. This is used for library remapping, where these pointers have been set to NULL. Otherwise this should never happen.

Note
caller must ensure BKE_main_collection_sync_remap() is called afterwards!
Parameters
parent_collectionThe collection owning the pointers that were remapped. May be NULL, in which case whole bmain database of collections is checked.
child_collectionThe collection that was remapped to another pointer. May be NULL, in which case whole bmain database of collections is checked.

Definition at line 1318 of file collection.c.

References BLI_freelinkN(), collection_find_child(), collection_missing_parents_remove(), collection_null_children_remove(), Main::collections, ListBase::first, Collection::id, Scene::id, Scene::master_collection, ID::next, NULL, Collection::parents, scene, and Main::scenes.

Referenced by libblock_remap_data_postprocess_collection_update().

◆ BKE_collections_object_remove_nulls()

void BKE_collections_object_remove_nulls ( Main bmain)

◆ BKE_main_collections_parent_relations_rebuild()

void BKE_main_collections_parent_relations_rebuild ( Main bmain)

◆ BKE_scene_collections_iterator_begin()

void BKE_scene_collections_iterator_begin ( BLI_Iterator iter,
void *  data_in 
)

Only use this in non-performance critical situations (it iterates over all scene collections twice)

Definition at line 2048 of file collection.c.

References BLI_assert, BLI_ITERATOR_INIT, BLI_Iterator::current, BLI_Iterator::data, data, MEM_callocN, scene, and scene_collections_array().

Referenced by scene_objects_iterator_begin().

◆ BKE_scene_collections_iterator_end()

void BKE_scene_collections_iterator_end ( struct BLI_Iterator iter)

Definition at line 2077 of file collection.c.

References BLI_Iterator::data, data, MEM_freeN, and BLI_Iterator::valid.

Referenced by BKE_scene_objects_iterator_end().

◆ BKE_scene_collections_iterator_next()

void BKE_scene_collections_iterator_next ( struct BLI_Iterator iter)

◆ BKE_scene_collections_object_remove()

bool BKE_scene_collections_object_remove ( Main bmain,
Scene scene,
Object ob,
const bool  free_us 
)

◆ BKE_scene_objects_as_gset()

GSet* BKE_scene_objects_as_gset ( Scene scene,
GSet objects_gset 
)

Generate a new GSet (or extend given objects_gset if not NULL) with all objects referenced by all collections of given scene.

Note
: This will include objects without a base currently (because they would belong to excluded collections only e.g.).

Definition at line 2196 of file collection.c.

References BKE_scene_objects_iterator_end(), BKE_scene_objects_iterator_next(), BLI_Iterator::data, NULL, scene, scene_objects_iterator_begin(), and BLI_Iterator::valid.

Referenced by lib_override_library_create_post_process().

◆ BKE_scene_objects_iterator_begin()

void BKE_scene_objects_iterator_begin ( BLI_Iterator iter,
void *  data_in 
)

Definition at line 2122 of file collection.c.

References NULL, scene, and scene_objects_iterator_begin().

◆ BKE_scene_objects_iterator_end()

void BKE_scene_objects_iterator_end ( BLI_Iterator iter)

◆ BKE_scene_objects_iterator_next()

void BKE_scene_objects_iterator_next ( BLI_Iterator iter)

◆ collection_add()

static Collection* collection_add ( Main bmain,
Collection collection_parent,
const char *  name_custom 
)
static

◆ collection_blend_read_data()

static void collection_blend_read_data ( BlendDataReader reader,
ID id 
)
static

Definition at line 273 of file collection.c.

References BKE_collection_blend_read_data().

◆ collection_blend_read_expand()

static void collection_blend_read_expand ( BlendExpander expander,
ID id 
)
static

Definition at line 362 of file collection.c.

References BKE_collection_blend_read_expand().

◆ collection_blend_read_lib()

static void collection_blend_read_lib ( BlendLibReader reader,
ID id 
)
static

Definition at line 325 of file collection.c.

References BKE_collection_blend_read_lib().

◆ collection_blend_write()

static void collection_blend_write ( BlendWriter writer,
ID id,
const void *  id_address 
)
static

◆ collection_child_add()

static bool collection_child_add ( Collection parent,
Collection collection,
const int  flag,
const bool  add_us 
)
static

◆ collection_child_remove()

static bool collection_child_remove ( Collection parent,
Collection collection 
)
static

◆ collection_copy_data()

static void collection_copy_data ( Main bmain,
ID id_dst,
const ID id_src,
const int  flag 
)
static

Only copy internal data of Collection ID from source to already allocated/initialized destination. You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.

WARNING! This function will not handle ID user count!

Parameters
flagCopying options (see BKE_lib_id.h's LIB_ID_COPY_... flags for more).

Definition at line 108 of file collection.c.

References BKE_previewimg_id_copy(), BLI_assert, BLI_listbase_clear(), Collection::children, collection_child_add(), COLLECTION_HAS_OBJECT_CACHE, COLLECTION_HAS_OBJECT_CACHE_INSTANCED, COLLECTION_IS_MASTER, collection_object_add(), Collection::flag, ID::flag, Collection::gobject, Collection::id, LIB_EMBEDDED_DATA, LIB_ID_COPY_NO_PREVIEW, LISTBASE_FOREACH, NULL, Collection::object_cache, Collection::object_cache_instanced, Collection::parents, and Collection::preview.

◆ collection_cycle_fix_recursive()

static bool collection_cycle_fix_recursive ( Main bmain,
Collection parent_collection,
Collection collection 
)
static

◆ collection_duplicate_recursive()

static Collection* collection_duplicate_recursive ( Main bmain,
Collection parent,
Collection collection_old,
const eDupli_ID_Flags  duplicate_flags,
const eLibIDDuplicateFlags  duplicate_options 
)
static

◆ collection_find_child()

static CollectionChild * collection_find_child ( Collection parent,
Collection collection 
)
static

◆ collection_find_child_recursive()

static bool collection_find_child_recursive ( Collection parent,
Collection collection 
)
static

Definition at line 1530 of file collection.c.

References Collection::children, and LISTBASE_FOREACH.

Referenced by BKE_collection_has_collection(), and collection_object_add().

◆ collection_find_parent()

static CollectionParent * collection_find_parent ( Collection child,
Collection collection 
)
static

Definition at line 1550 of file collection.c.

References BLI_findptr(), and Collection::parents.

Referenced by collection_child_remove().

◆ collection_foreach_id()

static void collection_foreach_id ( ID id,
LibraryForeachIDData data 
)
static

◆ collection_free_data()

static void collection_free_data ( ID id)
static

◆ collection_from_index_recursive()

static Collection* collection_from_index_recursive ( Collection collection,
const int  index,
int *  index_current 
)
static

Definition at line 1710 of file collection.c.

References Collection::children, LISTBASE_FOREACH, and NULL.

Referenced by BKE_collection_from_index().

◆ collection_init_data()

static void collection_init_data ( ID id)
static

◆ collection_instance_find_recursive()

static bool collection_instance_find_recursive ( Collection collection,
Collection instance_collection 
)
static

Definition at line 1420 of file collection.c.

References Collection::children, ELEM, Collection::gobject, LISTBASE_FOREACH, and NULL.

Referenced by BKE_collection_cycle_find().

◆ collection_instance_fix_recursive()

static bool collection_instance_fix_recursive ( Collection parent_collection,
Collection collection 
)
static

◆ collection_missing_parents_remove()

static void collection_missing_parents_remove ( Collection collection)
static

◆ collection_next_find()

static Collection* collection_next_find ( Main bmain,
Scene scene,
Collection collection 
)
static

◆ collection_null_children_remove()

static void collection_null_children_remove ( Collection collection)
static

◆ collection_object_add()

static bool collection_object_add ( Main bmain,
Collection collection,
Object ob,
int  flag,
const bool  add_us 
)
static

◆ collection_object_cache_fill()

static void collection_object_cache_fill ( ListBase lb,
Collection collection,
int  parent_restrict,
bool  with_instances 
)
static

◆ collection_object_cache_free()

static void collection_object_cache_free ( Collection collection)
static

◆ collection_object_cyclic_check_internal()

static bool collection_object_cyclic_check_internal ( Object object,
Collection collection 
)
static

◆ collection_object_remove()

static bool collection_object_remove ( Main bmain,
Collection collection,
Object ob,
const bool  free_us 
)
static

◆ collection_object_remove_nulls()

static void collection_object_remove_nulls ( Collection collection)
static

◆ collection_objects_select()

static bool collection_objects_select ( ViewLayer view_layer,
Collection collection,
bool  deselect 
)
static

◆ collection_owner_get()

static ID* collection_owner_get ( Main bmain,
ID id 
)
static

◆ collection_parent_editable_find_recursive()

static Collection* collection_parent_editable_find_recursive ( Collection collection)
static

◆ collection_parents_rebuild_recursive()

static void collection_parents_rebuild_recursive ( Collection collection)
static

◆ collection_tag_update_parent_recursive()

static void collection_tag_update_parent_recursive ( Main bmain,
Collection collection,
const int  flag 
)
static

◆ layer_collection_flags_free_recursive()

static void layer_collection_flags_free_recursive ( LayerCollectionFlag flag)
static

◆ layer_collection_flags_restore()

static void layer_collection_flags_restore ( ListBase flags,
const Collection collection 
)
static

◆ layer_collection_flags_restore_recursive()

static void layer_collection_flags_restore_recursive ( LayerCollection layer_collection,
LayerCollectionFlag flag 
)
static

◆ layer_collection_flags_store()

static void layer_collection_flags_store ( Main bmain,
const Collection collection,
ListBase r_layer_level_list 
)
static

◆ layer_collection_flags_store_recursive()

static void layer_collection_flags_store_recursive ( const LayerCollection layer_collection,
LayerCollectionFlag flag 
)
static

◆ lib_link_collection_data()

static void lib_link_collection_data ( BlendLibReader reader,
Library lib,
Collection collection 
)
static

◆ object_base_unique()

static CollectionObject* object_base_unique ( GSet gs,
CollectionObject cob 
)
static

Ensures we only get each object once, even when included in several collections.

Definition at line 2132 of file collection.c.

References BLI_gset_ensure_p_ex(), CollectionObject::next, NULL, and CollectionObject::ob.

Referenced by BKE_scene_objects_iterator_next().

◆ scene_collection_callback()

static void scene_collection_callback ( Collection collection,
BKE_scene_collections_Cb  callback,
void *  data 
)
static

Definition at line 1997 of file collection.c.

References callback, Collection::children, data, and LISTBASE_FOREACH.

Referenced by scene_collections_array().

◆ scene_collections_array()

static void scene_collections_array ( Scene scene,
Collection ***  r_collections_array,
int *  r_collections_array_len 
)
static

◆ scene_collections_build_array()

static void scene_collections_build_array ( Collection collection,
void *  data 
)
static

Definition at line 2014 of file collection.c.

References data.

Referenced by scene_collections_array().

◆ scene_collections_count()

static void scene_collections_count ( Collection UNUSEDcollection,
void *  data 
)
static

Definition at line 2008 of file collection.c.

References data.

Referenced by scene_collections_array().

◆ scene_collections_object_remove()

static bool scene_collections_object_remove ( Main bmain,
Scene scene,
Object ob,
const bool  free_us,
Collection collection_skip 
)
static

Remove object from all collections of scene

Parameters
collection_skipDon't remove base from this collection.

Definition at line 1219 of file collection.c.

References BKE_main_collection_sync(), BKE_scene_remove_rigidbody_object(), collection_object_remove(), FOREACH_SCENE_COLLECTION_BEGIN, FOREACH_SCENE_COLLECTION_END, NULL, and scene.

Referenced by BKE_collection_object_move(), and BKE_scene_collections_object_remove().

◆ scene_objects_iterator_begin()

static void scene_objects_iterator_begin ( BLI_Iterator iter,
Scene scene,
GSet visited_objects 
)
static

Variable Documentation

◆ IDType_ID_GR

IDTypeInfo IDType_ID_GR
Initial value:
= {
.id_code = ID_GR,
.id_filter = FILTER_ID_GR,
.main_listbase_index = INDEX_ID_GR,
.struct_size = sizeof(Collection),
.name = "Collection",
.name_plural = "collections",
.translation_context = BLT_I18NCONTEXT_ID_COLLECTION,
.copy_data = collection_copy_data,
.free_data = collection_free_data,
.make_local = NULL,
.foreach_id = collection_foreach_id,
.foreach_cache = NULL,
.owner_get = collection_owner_get,
.blend_write = collection_blend_write,
.blend_read_data = collection_blend_read_data,
.blend_read_lib = collection_blend_read_lib,
.blend_read_expand = collection_blend_read_expand,
.blend_read_undo_preserve = NULL,
.lib_override_apply_post = NULL,
}
@ IDTYPE_FLAGS_NO_ANIMDATA
Definition: BKE_idtype.h:51
#define BLT_I18NCONTEXT_ID_COLLECTION
#define FILTER_ID_GR
Definition: DNA_ID.h:711
@ INDEX_ID_GR
Definition: DNA_ID.h:841
@ ID_GR
Definition: DNA_ID_enums.h:77
struct Collection Collection
static void init_data(ModifierData *md)
static void collection_blend_read_lib(BlendLibReader *reader, ID *id)
Definition: collection.c:325
static void collection_blend_read_expand(BlendExpander *expander, ID *id)
Definition: collection.c:362
static ID * collection_owner_get(Main *bmain, ID *id)
Definition: collection.c:177
static void collection_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int flag)
Definition: collection.c:108
static void collection_free_data(ID *id)
Definition: collection.c:141
static void collection_blend_read_data(BlendDataReader *reader, ID *id)
Definition: collection.c:273
static void collection_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition: collection.c:213
static void collection_init_data(ID *id)
Definition: collection.c:90
static void collection_foreach_id(ID *id, LibraryForeachIDData *data)
Definition: collection.c:155

Definition at line 368 of file collection.c.