Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/collection.c
| Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | for (SceneCollection *sc = sc_parent->scene_collections.first; sc; sc = sc->next) { | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| /** | /** | ||||
| * Recursively remove any instance of this SceneCollection | * Recursively remove any instance of this SceneCollection | ||||
| */ | */ | ||||
| static void layer_collection_remove(SceneLayer *sl, ListBase *lb, const SceneCollection *sc) | static void layer_collection_remove(ViewLayer *view_layer, ListBase *lb, const SceneCollection *sc) | ||||
| { | { | ||||
| LayerCollection *lc = lb->first; | LayerCollection *lc = lb->first; | ||||
| while (lc) { | while (lc) { | ||||
| if (lc->scene_collection == sc) { | if (lc->scene_collection == sc) { | ||||
| BKE_layer_collection_free(sl, lc); | BKE_layer_collection_free(view_layer, lc); | ||||
| BLI_remlink(lb, lc); | BLI_remlink(lb, lc); | ||||
| LayerCollection *lc_next = lc->next; | LayerCollection *lc_next = lc->next; | ||||
| MEM_freeN(lc); | MEM_freeN(lc); | ||||
| lc = lc_next; | lc = lc_next; | ||||
| /* only the "top-level" layer collections may have the | /* only the "top-level" layer collections may have the | ||||
| * same SceneCollection in a sibling tree. | * same SceneCollection in a sibling tree. | ||||
| */ | */ | ||||
| if (lb != &sl->layer_collections) { | if (lb != &view_layer->layer_collections) { | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| layer_collection_remove(sl, &lc->layer_collections, sc); | layer_collection_remove(view_layer, &lc->layer_collections, sc); | ||||
| lc = lc->next; | lc = lc->next; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Remove a collection from the scene, and syncronize all render layers | * Remove a collection from the scene, and syncronize all render layers | ||||
| */ | */ | ||||
| Show All 10 Lines | bool BKE_collection_remove(Scene *scene, SceneCollection *sc) | ||||
| if (!collection_remlink(sc_master, sc)) { | if (!collection_remlink(sc_master, sc)) { | ||||
| BLI_assert(false); | BLI_assert(false); | ||||
| } | } | ||||
| /* clear the collection items */ | /* clear the collection items */ | ||||
| collection_free(sc, true); | collection_free(sc, true); | ||||
| /* check all layers that use this collection and clear them */ | /* check all layers that use this collection and clear them */ | ||||
| for (SceneLayer *sl = scene->render_layers.first; sl; sl = sl->next) { | for (ViewLayer *view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) { | ||||
| layer_collection_remove(sl, &sl->layer_collections, sc); | layer_collection_remove(view_layer, &view_layer->layer_collections, sc); | ||||
| sl->active_collection = 0; | view_layer->active_collection = 0; | ||||
| } | } | ||||
| MEM_freeN(sc); | MEM_freeN(sc); | ||||
| return true; | return true; | ||||
| } | } | ||||
| /** | /** | ||||
| * Returns the master collection | * Returns the master collection | ||||
| ▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | void BKE_collection_object_add_from(Scene *scene, Object *ob_src, Object *ob_dst) | ||||
| FOREACH_SCENE_COLLECTION(scene, sc) | FOREACH_SCENE_COLLECTION(scene, sc) | ||||
| { | { | ||||
| if (BLI_findptr(&sc->objects, ob_src, offsetof(LinkData, data))) { | if (BLI_findptr(&sc->objects, ob_src, offsetof(LinkData, data))) { | ||||
| collection_object_add(scene, sc, ob_dst); | collection_object_add(scene, sc, ob_dst); | ||||
| } | } | ||||
| } | } | ||||
| FOREACH_SCENE_COLLECTION_END | FOREACH_SCENE_COLLECTION_END | ||||
| for (SceneLayer *sl = scene->render_layers.first; sl; sl = sl->next) { | for (ViewLayer *view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) { | ||||
| Base *base_src = BKE_scene_layer_base_find(sl, ob_src); | Base *base_src = BKE_view_layer_base_find(view_layer, ob_src); | ||||
| if (base_src != NULL) { | if (base_src != NULL) { | ||||
| if (base_src->collection_properties == NULL) { | if (base_src->collection_properties == NULL) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| Base *base_dst = BKE_scene_layer_base_find(sl, ob_dst); | Base *base_dst = BKE_view_layer_base_find(view_layer, ob_dst); | ||||
| IDP_MergeGroup(base_dst->collection_properties, base_src->collection_properties, true); | IDP_MergeGroup(base_dst->collection_properties, base_src->collection_properties, true); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Remove object from collection. | * Remove object from collection. | ||||
| * \param bmain: Can be NULL if free_us is false. | * \param bmain: Can be NULL if free_us is false. | ||||
| ▲ Show 20 Lines • Show All 375 Lines • Show Last 20 Lines | |||||