Blender V5.3
layer.cc File Reference
#include <atomic>
#include <cstring>
#include "CLG_log.h"
#include "BLI_listbase.hh"
#include "BLI_mempool.hh"
#include "BLI_string.hh"
#include "BLI_string_utf8.hh"
#include "BLI_string_utils.hh"
#include "BLI_threads.hh"
#include "BLT_translation.hh"
#include "BKE_animsys.hh"
#include "BKE_collection.hh"
#include "BKE_freestyle.h"
#include "BKE_idprop.hh"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_library.hh"
#include "BKE_main.hh"
#include "BKE_node.hh"
#include "BKE_node_legacy_types.hh"
#include "BKE_node_runtime.hh"
#include "BKE_object.hh"
#include "DNA_ID.h"
#include "DNA_collection_types.h"
#include "DNA_layer_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_world_types.h"
#include "RNA_path.hh"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_debug.hh"
#include "DEG_depsgraph_query.hh"
#include "SEQ_relations.hh"
#include "DRW_engine.hh"
#include "RE_engine.h"
#include "MEM_guardedalloc.h"
#include "BLO_read_write.hh"

Go to the source code of this file.

Classes

struct  blender::LayerCollectionResync
struct  blender::LayerObjectBaseIteratorData

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define DNA_DEPRECATED_ALLOW

Functions

Private Iterator Helpers
static void blender::object_bases_iterator_next (BLI_Iterator *iter, const int flag)
static bool blender::object_bases_iterator_is_valid (const View3D *v3d, Base *base, const int flag)
static void blender::object_bases_iterator_begin (BLI_Iterator *iter, void *data_in_v, const int flag)
static void blender::object_bases_iterator_end (BLI_Iterator *iter)
static void blender::objects_iterator_begin (BLI_Iterator *iter, void *data_in, const int flag)
static void blender::objects_iterator_next (BLI_Iterator *iter, const int flag)
static void blender::objects_iterator_end (BLI_Iterator *iter)
Layer Collections and Bases
static LayerCollection * blender::layer_collection_add (ListBaseT< LayerCollection > *lb_parent, Collection *collection)
static void blender::layer_collection_free (ViewLayer *view_layer, LayerCollection *lc)
static Base * blender::object_base_new (Object *ob)
View Layer
ViewLayer * blender::BKE_view_layer_default_view (const Scene *scene)
ViewLayer * blender::BKE_view_layer_default_render (const Scene *scene)
ViewLayer * blender::BKE_view_layer_find (const Scene *scene, const char *layer_name)
ViewLayer * blender::BKE_view_layer_context_active_PLACEHOLDER (const Scene *scene)
static ViewLayer * blender::view_layer_add (const char *name)
static void blender::layer_collection_exclude_all (LayerCollection *layer_collection)
ViewLayer * blender::BKE_view_layer_add (const Main *bmain, Scene *scene, const char *name, ViewLayer *view_layer_source, int type)
void blender::BKE_view_layer_free (ViewLayer *view_layer)
void blender::BKE_view_layer_free_ex (ViewLayer *view_layer, bool do_id_user)
void blender::BKE_view_layer_free_object_content (ViewLayer *view_layer)
void blender::BKE_view_layer_selected_objects_tag (const Main &bmain, const Scene *scene, ViewLayer *view_layer, eObject_Flag tag)
static bool blender::find_scene_collection_in_scene_collections (ListBaseT< LayerCollection > *lb, const LayerCollection *lc)
Object * blender::BKE_view_layer_camera_find (const Main &bmain, const Scene *scene, ViewLayer *view_layer)
ViewLayer * blender::BKE_view_layer_find_from_collection (const Scene *scene, LayerCollection *lc)
static void blender::view_layer_bases_hash_create (ViewLayer *view_layer, const bool do_base_duplicates_fix)
Base * blender::BKE_view_layer_base_find (ViewLayer *view_layer, Object *ob)
void blender::BKE_view_layer_base_deselect_all (const Main &bmain, const Scene *scene, ViewLayer *view_layer)
void blender::BKE_view_layer_base_select_and_set_active (ViewLayer *view_layer, Base *selbase)
Copy View Layer and Layer Collections
static void blender::layer_aov_copy_data (ViewLayer *view_layer_dst, const ViewLayer *view_layer_src, ListBaseT< ViewLayerAOV > *aovs_dst, const ListBaseT< ViewLayerAOV > *aovs_src)
static void blender::layer_lightgroup_copy_data (ViewLayer *view_layer_dst, const ViewLayer *view_layer_src, ListBaseT< ViewLayerLightgroup > *lightgroups_dst, const ListBaseT< ViewLayerLightgroup > *lightgroups_src)
static void blender::layer_collections_copy_data (ViewLayer *view_layer_dst, const ViewLayer *view_layer_src, ListBaseT< LayerCollection > *layer_collections_dst, const ListBaseT< LayerCollection > *layer_collections_src)
void blender::BKE_view_layer_copy_data (Scene *scene_dst, const Scene *scene_src, ViewLayer *view_layer_dst, const ViewLayer *view_layer_src, int flag)
void blender::BKE_view_layer_rename (Main *bmain, Scene *scene, ViewLayer *view_layer, const char *newname)
static LayerCollection * blender::collection_from_index (ListBaseT< LayerCollection > *lb, const int number, int *i)
static bool blender::layer_collection_hidden (ViewLayer *view_layer, LayerCollection *lc)
LayerCollection * blender::BKE_layer_collection_from_index (ViewLayer *view_layer, int index)
LayerCollection * blender::BKE_layer_collection_get_active (ViewLayer *view_layer)
bool blender::BKE_layer_collection_activate (ViewLayer *view_layer, LayerCollection *lc)
LayerCollection * blender::BKE_layer_collection_activate_parent (ViewLayer *view_layer, LayerCollection *lc)
LayerCollection * blender::BKE_layer_collection_get_active_editable (ViewLayer *view_layer)
static int blender::collection_count (const ListBaseT< LayerCollection > *lb)
int blender::BKE_layer_collection_count (const ViewLayer *view_layer)
static int blender::index_from_collection (ListBaseT< LayerCollection > *lb, const LayerCollection *lc, int *i)
int blender::BKE_layer_collection_findindex (ViewLayer *view_layer, const LayerCollection *lc)
Object Selection
bool blender::BKE_layer_collection_objects_select (const Main &bmain, const Scene *scene, ViewLayer *view_layer, LayerCollection *lc, bool deselect)
bool blender::BKE_layer_collection_has_selected_objects (const Main &bmain, const Scene *scene, ViewLayer *view_layer, LayerCollection *lc)
bool blender::BKE_layer_collection_has_layer_collection (LayerCollection *lc_parent, LayerCollection *lc_child)
Object Visibility
void blender::BKE_base_set_visible (const Main &bmain, Scene *scene, ViewLayer *view_layer, Base *base, bool extend)
bool blender::BKE_base_is_visible (const View3D *v3d, const Base *base)
bool blender::BKE_object_is_visible_in_viewport_ex (const View3D *v3d, const Object *ob, ObjectType ob_type)
bool blender::BKE_object_is_visible_in_viewport (const View3D *v3d, const Object *ob)
Collection Isolation & Local View
static void blender::layer_collection_flag_set_recursive (LayerCollection *lc, const eLayerCollection_Flag flag)
static void blender::layer_collection_flag_unset_recursive (LayerCollection *lc, const eLayerCollection_Flag flag)
void blender::BKE_layer_collection_isolate_global (Scene *scene, ViewLayer *view_layer, LayerCollection *lc, bool extend)
static void blender::layer_collection_local_visibility_set_recursive (LayerCollection *layer_collection, const int local_collections_uid)
static void blender::layer_collection_local_visibility_unset_recursive (LayerCollection *layer_collection, const int local_collections_uid)
static void blender::layer_collection_local_sync (const Main &bmain, const Scene *scene, ViewLayer *view_layer, LayerCollection *layer_collection, const ushort local_collections_uid, bool visible)
bool blender::BKE_layer_collection_local_sync (const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
bool blender::BKE_layer_collection_local_sync_all (const Main *bmain)
void blender::BKE_layer_collection_isolate_local (const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d, LayerCollection *lc, bool extend)
static void blender::layer_collection_bases_show_recursive (const Main &bmain, const Scene *scene, ViewLayer *view_layer, LayerCollection *lc)
static void blender::layer_collection_bases_hide_recursive (const Main &bmain, const Scene *scene, ViewLayer *view_layer, LayerCollection *lc)
void blender::BKE_layer_collection_set_visible (const Main &bmain, const Scene *scene, ViewLayer *view_layer, LayerCollection *lc, bool visible, bool hierarchy)
static void blender::layer_collection_flag_recursive_set (LayerCollection *lc, const eLayerCollection_Flag flag, const bool value, const bool restore_flag)
void blender::BKE_layer_collection_set_flag (LayerCollection *lc, eLayerCollection_Flag flag, bool value)
static LayerCollection * blender::find_layer_collection_by_scene_collection (LayerCollection *lc, const Collection *collection)
LayerCollection * blender::BKE_layer_collection_first_from_scene_collection (const ViewLayer *view_layer, const Collection *collection)
bool blender::BKE_view_layer_has_collection (const ViewLayer *view_layer, const Collection *collection)
bool blender::BKE_scene_has_object (const Main &bmain, Scene *scene, Object *ob)
BKE_view_layer_selected_objects_iterator
void blender::BKE_view_layer_selected_objects_iterator_begin (BLI_Iterator *iter, void *data_in)
void blender::BKE_view_layer_selected_objects_iterator_next (BLI_Iterator *iter)
void blender::BKE_view_layer_selected_objects_iterator_end (BLI_Iterator *iter)
BKE_view_layer_visible_objects_iterator
void blender::BKE_view_layer_visible_objects_iterator_begin (BLI_Iterator *iter, void *data_in)
void blender::BKE_view_layer_visible_objects_iterator_next (BLI_Iterator *iter)
void blender::BKE_view_layer_visible_objects_iterator_end (BLI_Iterator *iter)
BKE_view_layer_selected_editable_objects_iterator
void blender::BKE_view_layer_selected_editable_objects_iterator_begin (BLI_Iterator *iter, void *data_in)
void blender::BKE_view_layer_selected_editable_objects_iterator_next (BLI_Iterator *iter)
void blender::BKE_view_layer_selected_editable_objects_iterator_end (BLI_Iterator *iter)
BKE_view_layer_selected_bases_iterator
void blender::BKE_view_layer_selected_bases_iterator_begin (BLI_Iterator *iter, void *data_in)
void blender::BKE_view_layer_selected_bases_iterator_next (BLI_Iterator *iter)
void blender::BKE_view_layer_selected_bases_iterator_end (BLI_Iterator *iter)
BKE_view_layer_visible_bases_iterator
void blender::BKE_view_layer_visible_bases_iterator_begin (BLI_Iterator *iter, void *data_in)
void blender::BKE_view_layer_visible_bases_iterator_next (BLI_Iterator *iter)
void blender::BKE_view_layer_visible_bases_iterator_end (BLI_Iterator *iter)
BKE_view_layer_bases_in_mode_iterator
static bool blender::base_is_in_mode (ObjectsInModeIteratorData *data, Base *base)
void blender::BKE_view_layer_bases_in_mode_iterator_begin (BLI_Iterator *iter, void *data_in)
void blender::BKE_view_layer_bases_in_mode_iterator_next (BLI_Iterator *iter)
void blender::BKE_view_layer_bases_in_mode_iterator_end (BLI_Iterator *iter)
Evaluation
void blender::BKE_base_eval_flags (Base *base)
static void blender::layer_eval_view_layer (Depsgraph *depsgraph, Scene *scene, ViewLayer *view_layer)
void blender::BKE_layer_eval_view_layer_indexed (Depsgraph *depsgraph, Scene *scene, int view_layer_index)
Blend File I/O
static void blender::write_layer_collections (BlendWriter *writer, ListBaseT< LayerCollection > *lb)
void blender::BKE_view_layer_blend_write (BlendWriter *writer, const Scene *scene, ViewLayer *view_layer)
static void blender::direct_link_layer_collections (BlendDataReader *reader, ViewLayer *view_layer, ListBaseT< LayerCollection > *lb, bool master, bool &active_collection_found)
void blender::BKE_view_layer_blend_read_data (BlendDataReader *reader, ViewLayer *view_layer)
void blender::BKE_view_layer_blend_read_after_liblink (BlendLibReader *reader, ID *self_id, ViewLayer *view_layer)
Light Groups
static void blender::viewlayer_lightgroup_make_name_unique (ViewLayer *view_layer, ViewLayerLightgroup *lightgroup)
static void blender::viewlayer_lightgroup_active_set (ViewLayer *view_layer, ViewLayerLightgroup *lightgroup)
ViewLayerLightgroup * blender::BKE_view_layer_add_lightgroup (ViewLayer *view_layer, const char *name)
void blender::BKE_view_layer_remove_lightgroup (ViewLayer *view_layer, ViewLayerLightgroup *lightgroup)
void blender::BKE_view_layer_set_active_lightgroup (ViewLayer *view_layer, ViewLayerLightgroup *lightgroup)
ViewLayer * blender::BKE_view_layer_find_with_lightgroup (Scene *scene, ViewLayerLightgroup *lightgroup)
void blender::BKE_view_layer_rename_lightgroup (Scene *scene, ViewLayer *view_layer, ViewLayerLightgroup *lightgroup, const char *name)
int blender::BKE_lightgroup_membership_get (const LightgroupMembership *lgm, char *name)
int blender::BKE_lightgroup_membership_length (const LightgroupMembership *lgm)
void blender::BKE_lightgroup_membership_set (LightgroupMembership **lgm, const char *name)

Variables

static CLG_LogRef blender::LOG = {"object.layer"}
static const eBase_Flag blender::g_base_collection_flags

Shader AOV

using blender::ViewLayerAOVNameCountMap = Map<std::string, int>
static void blender::viewlayer_aov_make_name_unique (ViewLayer *view_layer)
static void blender::viewlayer_aov_active_set (ViewLayer *view_layer, ViewLayerAOV *aov)
ViewLayerAOV * blender::BKE_view_layer_add_aov (ViewLayer *view_layer)
void blender::BKE_view_layer_remove_aov (ViewLayer *view_layer, ViewLayerAOV *aov)
void blender::BKE_view_layer_set_active_aov (ViewLayer *view_layer, ViewLayerAOV *aov)
static void blender::bke_view_layer_verify_aov_cb (void *userdata, Scene *, ViewLayer *, const char *name, int, const char *, eNodeSocketDatatype)
void blender::BKE_view_layer_verify_aov (RenderEngine *engine, Scene *scene, ViewLayer *view_layer)
bool blender::BKE_view_layer_has_valid_aov (ViewLayer *view_layer)
ViewLayer * blender::BKE_view_layer_find_with_aov (Scene *scene, ViewLayerAOV *aov)

Syncing

The layer collection tree mirrors the scene collection tree. Whenever that changes we need to synchronize them so that there is a corresponding layer collection for each collection. Note that the scene collection tree can contain link or override collections, and so this is also called on .blend file load to ensure any new or removed collections are synced.

The view layer also contains a list of bases for each object that exists in at least one layer collection. That list is also synchronized here, and stores state like selection.

This API allows to temporarily forbid resync of LayerCollections.

This can greatly improve performances in cases where those functions get called a lot (e.g. during massive remappings of IDs).

Usage of these should be done very carefully though. In particular, calling code must ensures it resync LayerCollections before any UI/Event loop handling can happen.

Warning
This is not threadsafe at all, only use from main thread.
Note
It is probably needed to use #BKE_main_collection_sync_remap instead of just #BKE_main_collection_sync after disabling LayerCollection resync, unless it is absolutely certain that no ID remapping (or any other process that may invalidate the caches) will happen while it is disabled.
This is a quick and safe band-aid around the long-known issue regarding this resync process. Proper fix would be to make resync itself lazy, i.e. only happen when actually needed. See also #73411.
static constexpr int blender::no_resync_recurse_max = 16 * 256
void blender::BKE_layer_collection_resync_forbid (Main &bmain)
void blender::BKE_layer_collection_resync_allow (Main &bmain)
static LayerCollectionResync * blender::layer_collection_resync_create_recurse (LayerCollectionResync *parent_layer_resync, LayerCollection *layer, BLI_mempool *mempool)
static LayerCollectionResync * blender::layer_collection_resync_find (LayerCollectionResync *layer_resync, Collection *child_collection)
static void blender::layer_collection_resync_unused_layers_free (ViewLayer *view_layer, LayerCollectionResync *layer_resync)
void blender::BKE_view_layer_need_resync_tag (ViewLayer *view_layer)
bool blender::BKE_view_layer_is_synced (const ViewLayer &view_layer)
void blender::_BKE_view_layer_synced_ensure_or_assert (const Main *bmain, const Scene *scene, ViewLayer *view_layer)
bool blender::BKE_view_layer_synced_ensure (const Main &bmain, const Scene *scene, ViewLayer *view_layer)
bool blender::BKE_scene_view_layers_synced_ensure (const Main &bmain, const Scene *scene)
bool blender::BKE_main_view_layers_synced_ensure (const Main *bmain)
static void blender::layer_collection_objects_sync (ViewLayer *view_layer, LayerCollection *layer, ListBaseT< Base > *r_lb_new_object_bases, const short collection_restrict, const short layer_restrict, const ushort local_collections_bits)
static void blender::layer_collection_sync (ViewLayer *view_layer, LayerCollectionResync *layer_resync, BLI_mempool *layer_resync_mempool, ListBaseT< Base > *r_lb_new_object_bases, const eLayerCollection_Flag parent_layer_flag, const short parent_collection_restrict, const short parent_layer_restrict, const ushort parent_local_collections_bits)
static bool blender::view_layer_objects_base_cache_validate (ViewLayer *view_layer, LayerCollection *layer)
void blender::BKE_layer_collection_doversion_2_80 (const Scene *scene, ViewLayer *view_layer)
bool blender::BKE_layer_collection_sync (const Main &bmain, const Scene *scene, ViewLayer *view_layer)
bool blender::BKE_scene_collection_sync (const Main &bmain, const Scene *scene)
bool blender::BKE_main_collection_sync (const Main *bmain)
bool blender::BKE_main_collection_sync_remap (const Main *bmain)

Macro Definition Documentation

◆ DNA_DEPRECATED_ALLOW

#define DNA_DEPRECATED_ALLOW

Definition at line 10 of file blenkernel/intern/layer.cc.