Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/layer.c
| Context not available. | |||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_node_types.h" | #include "DNA_node_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_view3d_types.h" | |||||
| #include "DNA_windowmanager_types.h" | #include "DNA_windowmanager_types.h" | ||||
| #include "DNA_workspace_types.h" | #include "DNA_workspace_types.h" | ||||
| Context not available. | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| /* Set of flags which are dependent on a collection settings. */ | /* Set of flags which are dependent on a collection settings. */ | ||||
| static const short g_base_collection_flags = (BASE_VISIBLE_DEPSGRAPH | BASE_VISIBLE_VIEWLAYER | | static const short g_base_collection_flags = (BASE_VISIBLE | BASE_SELECTABLE | | ||||
| BASE_SELECTABLE | BASE_ENABLED_VIEWPORT | | BASE_ENABLED_VIEWPORT | BASE_ENABLED_RENDER | | ||||
| BASE_ENABLED_RENDER | BASE_HOLDOUT | | BASE_HOLDOUT | BASE_INDIRECT_ONLY); | ||||
| BASE_INDIRECT_ONLY); | |||||
| /* prototype */ | /* prototype */ | ||||
| static void object_bases_iterator_next(BLI_Iterator *iter, const int flag); | static void object_bases_iterator_next(BLI_Iterator *iter, const int flag); | ||||
| Context not available. | |||||
| lc->runtime_flag = child_runtime_flag; | lc->runtime_flag = child_runtime_flag; | ||||
| } | } | ||||
| /* We separate restrict viewport and visible view layer because a layer collection can be | if (((child_restrict & COLLECTION_RESTRICT_VIEWPORT) == 0) && | ||||
| * hidden in the view layer yet (locally) visible in a viewport (if it is not restricted).*/ | |||||
| if (child_restrict & COLLECTION_RESTRICT_VIEWPORT) { | |||||
| lc->runtime_flag |= LAYER_COLLECTION_RESTRICT_VIEWPORT; | |||||
| } | |||||
| if (((lc->runtime_flag & LAYER_COLLECTION_RESTRICT_VIEWPORT) == 0) && | |||||
| ((child_layer_restrict & LAYER_COLLECTION_HIDE) == 0)) { | ((child_layer_restrict & LAYER_COLLECTION_HIDE) == 0)) { | ||||
| lc->runtime_flag |= LAYER_COLLECTION_VISIBLE_VIEW_LAYER; | lc->runtime_flag |= LAYER_COLLECTION_VISIBLE; | ||||
| } | } | ||||
| /* Sync objects, except if collection was excluded. */ | /* Sync objects, except if collection was excluded. */ | ||||
| Context not available. | |||||
| } | } | ||||
| if ((child_restrict & COLLECTION_RESTRICT_VIEWPORT) == 0) { | if ((child_restrict & COLLECTION_RESTRICT_VIEWPORT) == 0) { | ||||
| base->flag_from_collection |= (BASE_ENABLED_VIEWPORT | BASE_VISIBLE_DEPSGRAPH); | base->flag_from_collection |= BASE_ENABLED_VIEWPORT; | ||||
| if ((child_layer_restrict & LAYER_COLLECTION_HIDE) == 0) { | if ((child_layer_restrict & LAYER_COLLECTION_HIDE) == 0) { | ||||
| base->flag_from_collection |= BASE_VISIBLE_VIEWLAYER; | base->flag_from_collection |= BASE_VISIBLE; | ||||
| } | if (((child_restrict & COLLECTION_RESTRICT_SELECT) == 0)) { | ||||
| if (((child_restrict & COLLECTION_RESTRICT_SELECT) == 0)) { | base->flag_from_collection |= BASE_SELECTABLE; | ||||
| base->flag_from_collection |= BASE_SELECTABLE; | } | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) { | for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) { | ||||
| Base *base = BKE_view_layer_base_find(view_layer, cob->ob); | Base *base = BKE_view_layer_base_find(view_layer, cob->ob); | ||||
| if (base && (base->flag & BASE_SELECTED) && (base->flag & BASE_VISIBLE_DEPSGRAPH)) { | if (base && (base->flag & BASE_SELECTED) && (base->flag & BASE_VISIBLE)) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| BKE_layer_collection_sync(scene, view_layer); | BKE_layer_collection_sync(scene, view_layer); | ||||
| } | } | ||||
| bool BKE_base_is_visible(const View3D *v3d, const Base *base) | |||||
| { | |||||
| if ((base->flag & BASE_VISIBLE_DEPSGRAPH) == 0) { | |||||
| return false; | |||||
| } | |||||
| if (v3d == NULL) { | |||||
| return base->flag & BASE_VISIBLE_VIEWLAYER; | |||||
| } | |||||
| if ((v3d->localvd) && ((v3d->local_view_uuid & base->local_view_bits) == 0)) { | |||||
| return false; | |||||
| } | |||||
| if (((1 << (base->object->type)) & v3d->object_type_exclude_viewport) != 0) { | |||||
| return false; | |||||
| } | |||||
| if (v3d->flag & V3D_LOCAL_COLLECTIONS) { | |||||
| return (v3d->local_collections_uuid & base->local_collections_bits) != 0; | |||||
| } | |||||
| return base->flag & BASE_VISIBLE_VIEWLAYER; | |||||
| } | |||||
| static void layer_collection_flag_set_recursive(LayerCollection *lc, const int flag) | static void layer_collection_flag_set_recursive(LayerCollection *lc, const int flag) | ||||
| { | { | ||||
| lc->flag |= flag; | lc->flag |= flag; | ||||
| Context not available. | |||||
| * If the collection or any of its parents is disabled, make it enabled. | * If the collection or any of its parents is disabled, make it enabled. | ||||
| * Don't change the children disable state though. | * Don't change the children disable state though. | ||||
| */ | */ | ||||
| void BKE_layer_collection_isolate_global(Scene *scene, | void BKE_layer_collection_isolate(Scene *scene, | ||||
| ViewLayer *view_layer, | ViewLayer *view_layer, | ||||
| LayerCollection *lc, | LayerCollection *lc, | ||||
| bool extend) | bool extend) | ||||
| { | { | ||||
| LayerCollection *lc_master = view_layer->layer_collections.first; | LayerCollection *lc_master = view_layer->layer_collections.first; | ||||
| bool hide_it = extend && (lc->runtime_flag & LAYER_COLLECTION_VISIBLE_VIEW_LAYER); | bool hide_it = extend && (lc->runtime_flag & LAYER_COLLECTION_VISIBLE); | ||||
| if (!extend) { | if (!extend) { | ||||
| /* Hide all collections . */ | /* Hide all collections . */ | ||||
| Context not available. | |||||
| /** | /** | ||||
| * Isolate the collection locally | * Isolate the collection locally | ||||
| * | * | ||||
| * Same as BKE_layer_collection_isolate_local but for a viewport | * Same as BKE_layer_collection_local_isolate but for a viewport | ||||
| */ | */ | ||||
| void BKE_layer_collection_isolate_local(ViewLayer *view_layer, | void BKE_layer_collection_local_isolate(ViewLayer *view_layer, | ||||
| View3D *v3d, | View3D *v3d, | ||||
| LayerCollection *lc, | LayerCollection *lc, | ||||
| bool extend) | bool extend) | ||||
| Context not available. | |||||
| void BKE_view_layer_selected_objects_iterator_begin(BLI_Iterator *iter, void *data_in) | void BKE_view_layer_selected_objects_iterator_begin(BLI_Iterator *iter, void *data_in) | ||||
| { | { | ||||
| objects_iterator_begin(iter, data_in, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED); | objects_iterator_begin(iter, data_in, BASE_VISIBLE | BASE_SELECTED); | ||||
| } | } | ||||
| void BKE_view_layer_selected_objects_iterator_next(BLI_Iterator *iter) | void BKE_view_layer_selected_objects_iterator_next(BLI_Iterator *iter) | ||||
| { | { | ||||
| objects_iterator_next(iter, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED); | objects_iterator_next(iter, BASE_VISIBLE | BASE_SELECTED); | ||||
| } | } | ||||
| void BKE_view_layer_selected_objects_iterator_end(BLI_Iterator *iter) | void BKE_view_layer_selected_objects_iterator_end(BLI_Iterator *iter) | ||||
| Context not available. | |||||
| void BKE_view_layer_selected_editable_objects_iterator_begin(BLI_Iterator *iter, void *data_in) | void BKE_view_layer_selected_editable_objects_iterator_begin(BLI_Iterator *iter, void *data_in) | ||||
| { | { | ||||
| objects_iterator_begin(iter, data_in, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED); | objects_iterator_begin(iter, data_in, BASE_VISIBLE | BASE_SELECTED); | ||||
| if (iter->valid) { | if (iter->valid) { | ||||
| if (BKE_object_is_libdata((Object *)iter->current) == false) { | if (BKE_object_is_libdata((Object *)iter->current) == false) { | ||||
| // First object is valid (selectable and not libdata) -> all good. | // First object is valid (selectable and not libdata) -> all good. | ||||
| Context not available. | |||||
| { | { | ||||
| // Search while there are objects and the one we have is not editable (editable = not libdata). | // Search while there are objects and the one we have is not editable (editable = not libdata). | ||||
| do { | do { | ||||
| objects_iterator_next(iter, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED); | objects_iterator_next(iter, BASE_VISIBLE | BASE_SELECTED); | ||||
| } while (iter->valid && BKE_object_is_libdata((Object *)iter->current) != false); | } while (iter->valid && BKE_object_is_libdata((Object *)iter->current) != false); | ||||
| } | } | ||||
| Context not available. | |||||
| void BKE_view_layer_selected_bases_iterator_begin(BLI_Iterator *iter, void *data_in) | void BKE_view_layer_selected_bases_iterator_begin(BLI_Iterator *iter, void *data_in) | ||||
| { | { | ||||
| objects_iterator_begin(iter, data_in, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED); | objects_iterator_begin(iter, data_in, BASE_VISIBLE | BASE_SELECTED); | ||||
| } | } | ||||
| void BKE_view_layer_selected_bases_iterator_next(BLI_Iterator *iter) | void BKE_view_layer_selected_bases_iterator_next(BLI_Iterator *iter) | ||||
| { | { | ||||
| object_bases_iterator_next(iter, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED); | object_bases_iterator_next(iter, BASE_VISIBLE | BASE_SELECTED); | ||||
| } | } | ||||
| void BKE_view_layer_selected_bases_iterator_end(BLI_Iterator *iter) | void BKE_view_layer_selected_bases_iterator_end(BLI_Iterator *iter) | ||||
| Context not available. | |||||
| /* Evaluation */ | /* Evaluation */ | ||||
| /* Applies object's restrict flags on top of flags coming from the collection | /* Applies object's restrict flags on top of flags coming from the collection | ||||
| * and stores those in base->flag. BASE_VISIBLE_DEPSGRAPH ignores viewport flags visibility | * and stores those in base->flag. BASE_VISIBLE is based on viewport visibility. */ | ||||
| * (i.e., restriction and local collection). */ | |||||
| void BKE_base_eval_flags(Base *base) | void BKE_base_eval_flags(Base *base) | ||||
| { | { | ||||
| /* Apply collection flags. */ | /* Apply collection flags. */ | ||||
| Context not available. | |||||
| * can change these again, but for tools we always want the viewport | * can change these again, but for tools we always want the viewport | ||||
| * visibility to be in sync regardless if depsgraph was evaluated. */ | * visibility to be in sync regardless if depsgraph was evaluated. */ | ||||
| if (!(base->flag & BASE_ENABLED_VIEWPORT) || (base->flag & BASE_HIDDEN)) { | if (!(base->flag & BASE_ENABLED_VIEWPORT) || (base->flag & BASE_HIDDEN)) { | ||||
| base->flag &= ~(BASE_VISIBLE_DEPSGRAPH | BASE_VISIBLE_VIEWLAYER | BASE_SELECTABLE); | base->flag &= ~(BASE_VISIBLE | BASE_SELECTABLE); | ||||
| } | } | ||||
| /* Deselect unselectable objects. */ | /* Deselect unselectable objects. */ | ||||
| Context not available. | |||||