22 #define DNA_DEPRECATED_ALLOW
168 const int cb_flag = ((parent->collection !=
NULL &&
193 BLI_assert(!
"Embedded collection with no owner. Critical Main inconsistency.");
232 #ifdef USE_COLLECTION_COMPAT_28
259 #ifdef USE_COLLECTION_COMPAT_28
262 if (collection->collection !=
NULL) {
267 if (collection->view_layer !=
NULL) {
284 if (cob->ob ==
NULL) {
294 #ifdef USE_COLLECTION_COMPAT_28
312 #ifdef USE_COLLECTION_COMPAT_28
313 if (collection->collection) {
317 if (collection->view_layer) {
331 #ifdef USE_COLLECTION_COMPAT_28
355 #ifdef USE_COLLECTION_COMPAT_28
356 if (collection->collection !=
NULL) {
373 .name =
"Collection",
374 .name_plural =
"collections",
383 .foreach_cache =
NULL,
391 .blend_read_undo_preserve =
NULL,
393 .lib_override_apply_post =
NULL,
405 const char *name_custom)
424 if (collection_parent) {
453 bool is_instantiated =
false;
458 is_instantiated =
true;
463 if (!is_instantiated) {
481 bool is_instantiated =
false;
486 is_instantiated =
true;
491 is_instantiated =
true;
496 if (!is_instantiated) {
524 BLI_assert(!
"Scene master collection can't be deleted");
531 while (cob !=
NULL) {
538 while (child !=
NULL) {
553 while (cob !=
NULL) {
586 bool do_full_process =
false;
591 if (is_collection_master) {
595 collection_new = collection_old;
596 do_full_process =
true;
600 bmain, (
ID *)collection_old, duplicate_flags);
602 if (collection_new == collection_old) {
603 return collection_new;
606 do_full_process =
true;
614 if (parent !=
NULL) {
620 if (child && child_new) {
630 if (!do_full_process) {
631 return collection_new;
668 Collection *child_collection_old = child->collection;
671 bmain, collection_new, child_collection_old, duplicate_flags, duplicate_options);
672 if (child_collection_new != child_collection_old) {
677 return collection_new;
697 if (!is_subprocess) {
711 bmain, parent, collection, duplicate_flags, duplicate_options);
713 if (!is_subprocess) {
739 return collection_new;
755 if (!collection_parent) {
764 const int max_len =
sizeof(collection_parent->
id.
name) - 1 -
779 return IFACE_(
"Scene Collection");
782 return collection->
id.
name + 2;
796 int child_restrict = collection->
flag | parent_restrict;
805 if (with_instances && cob->ob->instance_collection) {
807 lb, cob->ob->instance_collection, child_restrict, with_instances);
900 return master_collection;
912 Collection *dup_collection =
object->instance_collection;
920 if (dup_collection == collection) {
987 return collection->
id.
next;
1005 while (collection) {
1058 return collection_parent->collection;
1061 collection_parent->collection);
1062 if (editable_collection !=
NULL) {
1063 return editable_collection;
1145 if (collection ==
NULL) {
1170 bool is_instantiated =
false;
1176 is_instantiated =
true;
1181 if (!is_instantiated) {
1222 bool removed =
false;
1224 if (collection_skip ==
NULL) {
1229 if (collection != collection_skip) {
1255 bool changed =
false;
1258 cob_next = cob->next;
1260 if (cob->ob ==
NULL) {
1278 collection = collection->id.next) {
1286 child = child_next) {
1287 child_next = child->next;
1289 if (child->collection ==
NULL) {
1298 parent = parent_next) {
1299 parent_next = parent->next;
1322 if (child_collection ==
NULL) {
1323 if (parent_collection !=
NULL) {
1332 child_collection = child_collection->
id.
next) {
1341 child_collection = child_collection->
id.
next) {
1350 parent = parent_next) {
1351 parent_next = parent->next;
1372 if (collection_src !=
NULL) {
1424 if (collection_object->ob !=
NULL &&
1426 ELEM(collection_object->ob->instance_collection, instance_collection, collection)) {
1432 if (collection_child->collection !=
NULL &&
1452 if (collection == new_ancestor) {
1456 if (collection ==
NULL) {
1457 collection = new_ancestor;
1474 bool cycles_found =
false;
1477 if (collection_object->ob !=
NULL &&
1478 collection_object->ob->instance_collection == collection) {
1480 collection_object->ob->instance_collection =
NULL;
1481 cycles_found =
true;
1487 cycles_found =
true;
1491 return cycles_found;
1498 bool cycles_found =
false;
1503 cycles_found =
true;
1506 cycles_found =
true;
1510 return cycles_found;
1533 if (child->collection == collection) {
1591 if (child ==
NULL) {
1641 if (other_child != child) {
1654 BLI_addtail(&child->collection->parents, cparent);
1675 collection = collection->id.next) {
1694 collection = collection->id.next) {
1714 if (index == (*index_current)) {
1722 if (nested !=
NULL) {
1736 int index_current = 0;
1743 bool changed =
false;
1786 if (layer_collection !=
NULL) {
1816 flag->flag = layer_collection->
flag;
1839 if (layer_collection ==
NULL) {
1877 child_flag = child_flag->
next;
1909 if (layer_collection !=
NULL) {
1922 bool relative_after,
1944 if (relative_child) {
1947 if (relative_after) {
2017 **
array = collection;
2023 int *r_collections_array_len)
2025 *r_collections_array =
NULL;
2026 *r_collections_array_len = 0;
2039 *r_collections_array_len,
sizeof(
Collection *),
"CollectionArray");
2040 *r_collections_array =
array;
2073 iter->
valid =
false;
2087 iter->
valid =
false;
2106 if (visited_objects !=
NULL) {
2107 data->visited = visited_objects;
2134 for (; cob !=
NULL; cob = cob->
next) {
2160 collection =
data->scene_collection_iter.current;
2169 }
while (
data->scene_collection_iter.valid);
2171 if (!
data->scene_collection_iter.valid) {
2172 iter->
valid =
false;
2200 while (iter.
valid) {
#define FOREACH_COLLECTION_OBJECT_RECURSIVE_END
#define FOREACH_SCENE_COLLECTION_END
void(* BKE_scene_collections_Cb)(struct Collection *ob, void *data)
void BKE_collection_compat_blend_read_lib(struct BlendLibReader *reader, struct Library *lib, struct SceneCollection *sc)
void BKE_collection_compat_blend_read_expand(struct BlendExpander *expander, struct SceneCollection *sc)
#define FOREACH_SCENE_COLLECTION_BEGIN(scene, _instance)
void BKE_collection_compat_blend_read_data(struct BlendDataReader *reader, struct SceneCollection *sc)
#define FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(_collection, _object)
void BKE_previewimg_free(struct PreviewImage **prv)
void BKE_previewimg_id_copy(struct ID *new_id, const struct ID *old_id)
void BKE_previewimg_blend_read(struct BlendDataReader *reader, struct PreviewImage *prv)
void BKE_previewimg_blend_write(struct BlendWriter *writer, const struct PreviewImage *prv)
@ IDTYPE_FLAGS_NO_ANIMDATA
bool BKE_layer_collection_objects_select(struct ViewLayer *view_layer, struct LayerCollection *lc, bool deselect)
void BKE_main_collection_sync(const struct Main *bmain)
void BKE_view_layer_blend_read_data(struct BlendDataReader *reader, struct ViewLayer *view_layer)
struct Base * BKE_view_layer_base_find(struct ViewLayer *view_layer, struct Object *ob)
struct LayerCollection * BKE_layer_collection_first_from_scene_collection(struct ViewLayer *view_layer, const struct Collection *collection)
void BKE_view_layer_blend_read_lib(struct BlendLibReader *reader, struct Library *lib, struct ViewLayer *view_layer)
void id_us_min(struct ID *id)
void BKE_libblock_free_data(struct ID *id, const bool do_id_user) ATTR_NONNULL()
void BKE_main_id_tag_all(struct Main *mainvar, const int tag, const bool value)
@ LIB_ID_CREATE_NO_USER_REFCOUNT
void * BKE_libblock_alloc(struct Main *bmain, short type, const char *name, const int flag) ATTR_WARN_UNUSED_RESULT
void BKE_main_id_clear_newpoins(struct Main *bmain)
void id_us_plus(struct ID *id)
struct ID * BKE_id_copy_for_duplicate(struct Main *bmain, struct ID *id, const uint duplicate_flags)
void BKE_id_blend_write(struct BlendWriter *writer, struct ID *id)
void BKE_main_id_tag_listbase(struct ListBase *lb, const int tag, const bool value)
void BKE_id_delete(struct Main *bmain, void *idv) ATTR_NONNULL()
@ LIB_ID_DUPLICATE_IS_ROOT_ID
@ LIB_ID_DUPLICATE_IS_SUBPROCESS
void * BKE_id_new(struct Main *bmain, const short type, const char *name)
void BKE_id_free_us(struct Main *bmain, void *idv) ATTR_NONNULL()
#define BKE_LIB_FOREACHID_PROCESS(_data, _id_super, _cb_flag)
void void BKE_libblock_relink_to_newid(struct ID *id) ATTR_NONNULL()
#define FOREACH_MAIN_ID_END
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
General operations, lookup, etc. for blender objects.
struct Object * BKE_object_duplicate(struct Main *bmain, struct Object *ob, uint dupflag, const uint duplicate_options)
API for Blender-side Rigid Body stuff.
void BKE_rigidbody_main_collection_object_add(struct Main *bmain, struct Collection *collection, struct Object *object)
struct Scene * BKE_scene_find_from_collection(const struct Main *bmain, const struct Collection *collection)
void BKE_scene_remove_rigidbody_object(struct Main *bmain, struct Scene *scene, struct Object *ob, const bool free_us)
bool BLI_gset_ensure_p_ex(GSet *gs, const void *key, void ***r_key)
GSet * BLI_gset_ptr_new(const char *info)
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
#define BLI_ITERATOR_INIT(iter)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH(type, var, list)
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_insertlinkbefore(struct ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findptr(const struct ListBase *listbase, const void *ptr, const int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int integer_digits_i(const int i)
size_t size_t char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
#define STRNCPY(dst, src)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
#define BLI_MUTEX_INITIALIZER
void BLI_mutex_lock(ThreadMutex *mutex)
void BLI_mutex_unlock(ThreadMutex *mutex)
pthread_mutex_t ThreadMutex
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
#define BLO_read_data_address(reader, ptr_p)
#define BLO_write_id_struct(writer, struct_name, id_address, id)
#define BLO_write_struct(writer, struct_name, data_ptr)
void BLO_read_list(BlendDataReader *reader, struct ListBase *list)
#define BLO_read_id_address(reader, lib, id_ptr_p)
#define BLO_expand(expander, id)
bool BLO_write_is_undo(BlendWriter *writer)
#define BLT_I18NCONTEXT_ID_COLLECTION
void DEG_id_tag_update_ex(struct Main *bmain, struct ID *id, int flag)
void DEG_id_tag_update(struct ID *id, int flag)
ID and Library types, which are fundamental for sdna.
@ ID_RECALC_COPY_ON_WRITE
#define ID_IS_LINKED(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
Object groups, one object can be in many groups at once.
struct Collection Collection
@ COLLECTION_RESTRICT_RENDER
@ COLLECTION_HAS_OBJECT_CACHE_INSTANCED
@ COLLECTION_RESTRICT_VIEWPORT
@ COLLECTION_HAS_OBJECT_CACHE
@ COLLECTION_RESTRICT_SELECT
@ COLLECTION_TAG_RELATION_REBUILD
#define DNA_struct_default_get(struct_name)
@ LAYER_COLLECTION_EXCLUDE
Object is a sort of wrapper for general info.
Types and defines for representing Rigid Body entities.
#define FIRSTBASE(_view_layer)
Read Guarded memory(de)allocation.
static void init_data(ModifierData *md)
static void collection_object_cache_fill(ListBase *lb, Collection *collection, int parent_restrict, bool with_instances)
static bool collection_cycle_fix_recursive(Main *bmain, Collection *parent_collection, Collection *collection)
static bool collection_find_child_recursive(Collection *parent, Collection *collection)
bool BKE_collection_has_object_recursive_instanced(Collection *collection, Object *ob)
static void scene_collections_count(Collection *UNUSED(collection), void *data)
static CollectionParent * collection_find_parent(Collection *child, Collection *collection)
bool BKE_collection_has_object_recursive(Collection *collection, Object *ob)
Collection * BKE_collection_from_index(Scene *scene, const int index)
void BKE_collection_add_from_collection(Main *bmain, Scene *scene, Collection *collection_src, Collection *collection_dst)
static void layer_collection_flags_store(Main *bmain, const Collection *collection, ListBase *r_layer_level_list)
void BKE_collection_free(Collection *collection)
static bool collection_child_remove(Collection *parent, Collection *collection)
const char * BKE_collection_ui_name_get(struct Collection *collection)
void BKE_collection_blend_write_nolib(BlendWriter *writer, Collection *collection)
bool BKE_collection_child_remove(Main *bmain, Collection *parent, Collection *child)
static bool collection_child_add(Collection *parent, Collection *collection, const int flag, const bool add_us)
Collection * BKE_collection_master_add()
static CollectionObject * object_base_unique(GSet *gs, CollectionObject *cob)
static bool collection_object_remove(Main *bmain, Collection *collection, Object *ob, const bool free_us)
static bool collection_instance_find_recursive(Collection *collection, Collection *instance_collection)
bool BKE_collection_has_object(Collection *collection, const Object *ob)
ListBase BKE_collection_object_cache_instanced_get(Collection *collection)
static void collection_object_cache_free(Collection *collection)
static void collection_blend_read_lib(BlendLibReader *reader, ID *id)
Collection * BKE_collection_duplicate(Main *bmain, Collection *parent, Collection *collection, eDupli_ID_Flags duplicate_flags, eLibIDDuplicateFlags duplicate_options)
static bool collection_object_add(Main *bmain, Collection *collection, Object *ob, int flag, const bool add_us)
static void collection_blend_read_expand(BlendExpander *expander, ID *id)
GSet * BKE_scene_objects_as_gset(Scene *scene, GSet *objects_gset)
static void layer_collection_flags_restore_recursive(LayerCollection *layer_collection, LayerCollectionFlag *flag)
bool BKE_collection_child_add_no_sync(Collection *parent, Collection *child)
Collection * BKE_collection_object_find(Main *bmain, Scene *scene, Collection *collection, Object *ob)
void BKE_scene_objects_iterator_end(BLI_Iterator *iter)
bool BKE_collection_is_empty(const Collection *collection)
static void collection_parents_rebuild_recursive(Collection *collection)
bool BKE_collection_move(Main *bmain, Collection *to_parent, Collection *from_parent, Collection *relative, bool relative_after, Collection *collection)
bool BKE_collection_is_in_scene(Collection *collection)
struct LayerCollectionFlag LayerCollectionFlag
static void scene_collection_callback(Collection *collection, BKE_scene_collections_Cb callback, void *data)
static void layer_collection_flags_free_recursive(LayerCollectionFlag *flag)
bool BKE_collection_child_add(Main *bmain, Collection *parent, Collection *child)
static ID * collection_owner_get(Main *bmain, ID *id)
void BKE_collection_object_move(Main *bmain, Scene *scene, Collection *collection_dst, Collection *collection_src, Object *ob)
void BKE_collection_add_from_object(Main *bmain, Scene *scene, const Object *ob_src, Collection *collection_dst)
void BKE_collection_blend_read_expand(BlendExpander *expander, Collection *collection)
static bool collection_object_cyclic_check_internal(Object *object, Collection *collection)
static Collection * collection_next_find(Main *bmain, Scene *scene, Collection *collection)
bool BKE_scene_collections_object_remove(Main *bmain, Scene *scene, Object *ob, const bool free_us)
bool BKE_collection_objects_select(ViewLayer *view_layer, Collection *collection, bool deselect)
void BKE_collections_child_remove_nulls(Main *bmain, Collection *parent_collection, Collection *child_collection)
static void collection_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int flag)
static Collection * collection_add(Main *bmain, Collection *collection_parent, const char *name_custom)
bool BKE_collection_has_collection(Collection *parent, Collection *collection)
void BKE_collection_object_cache_free(Collection *collection)
bool BKE_collection_object_remove(Main *bmain, Collection *collection, Object *ob, const bool free_us)
static void lib_link_collection_data(BlendLibReader *reader, Library *lib, Collection *collection)
void BKE_scene_collections_iterator_begin(BLI_Iterator *iter, void *data_in)
void BKE_collection_new_name_get(Collection *collection_parent, char *rname)
Base * BKE_collection_or_layer_objects(const ViewLayer *view_layer, Collection *collection)
Collection * BKE_collection_add(Main *bmain, Collection *collection_parent, const char *name_custom)
static CollectionChild * collection_find_child(Collection *parent, Collection *collection)
bool BKE_collection_cycles_fix(Main *bmain, Collection *collection)
struct SceneObjectsIteratorData SceneObjectsIteratorData
static void collection_free_data(ID *id)
static bool collection_instance_fix_recursive(Collection *parent_collection, Collection *collection)
static void collection_object_remove_nulls(Collection *collection)
void BKE_collection_object_add_from(Main *bmain, Scene *scene, Object *ob_src, Object *ob_dst)
static void collection_blend_read_data(BlendDataReader *reader, ID *id)
static void scene_collections_array(Scene *scene, Collection ***r_collections_array, int *r_collections_array_len)
static Collection * collection_duplicate_recursive(Main *bmain, Collection *parent, Collection *collection_old, const eDupli_ID_Flags duplicate_flags, const eLibIDDuplicateFlags duplicate_options)
void BKE_collection_blend_read_lib(BlendLibReader *reader, Collection *collection)
static void layer_collection_flags_restore(ListBase *flags, const Collection *collection)
bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy)
void BKE_collections_object_remove_nulls(Main *bmain)
bool BKE_collection_cycle_find(Collection *new_ancestor, Collection *collection)
static void scene_objects_iterator_begin(BLI_Iterator *iter, Scene *scene, GSet *visited_objects)
static void collection_null_children_remove(Collection *collection)
static void collection_blend_write(BlendWriter *writer, ID *id, const void *id_address)
static Collection * collection_from_index_recursive(Collection *collection, const int index, int *index_current)
bool BKE_collection_object_cyclic_check(Main *bmain, Object *object, Collection *collection)
void BKE_collection_blend_read_data(BlendDataReader *reader, Collection *collection)
static void collection_missing_parents_remove(Collection *collection)
void BKE_collections_after_lib_link(Main *bmain)
static void scene_collections_build_array(Collection *collection, void *data)
struct CollectionsIteratorData CollectionsIteratorData
static bool scene_collections_object_remove(Main *bmain, Scene *scene, Object *ob, const bool free_us, Collection *collection_skip)
static void collection_init_data(ID *id)
ListBase BKE_collection_object_cache_get(Collection *collection)
void BKE_scene_collections_iterator_end(struct BLI_Iterator *iter)
void BKE_scene_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
void BKE_scene_collections_iterator_next(struct BLI_Iterator *iter)
void BKE_collection_parent_relations_rebuild(Collection *collection)
static void layer_collection_flags_store_recursive(const LayerCollection *layer_collection, LayerCollectionFlag *flag)
static Collection * collection_parent_editable_find_recursive(Collection *collection)
static void collection_tag_update_parent_recursive(Main *bmain, Collection *collection, const int flag)
void BKE_scene_objects_iterator_next(BLI_Iterator *iter)
static void collection_foreach_id(ID *id, LibraryForeachIDData *data)
void BKE_main_collections_parent_relations_rebuild(Main *bmain)
static bool collection_objects_select(ViewLayer *view_layer, Collection *collection, bool deselect)
bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob)
DEGForeachIDComponentCallback callback
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
struct Collection * collection
struct CollectionObject * next
struct Collection * collection
struct PreviewImage * preview
ListBase object_cache_instanced
struct LayerCollectionFlag * next
struct LayerCollectionFlag * prev
ListBase layer_collections
struct Collection * collection
struct Collection * instance_collection
ListBase scene_collections
BLI_Iterator scene_collection_iter
CollectionObject * cob_next
struct Collection * master_collection