Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/layer.c
| Show All 20 Lines | |||||
| */ | */ | ||||
| /** \file blender/blenkernel/intern/layer.c | /** \file blender/blenkernel/intern/layer.c | ||||
| * \ingroup bke | * \ingroup bke | ||||
| */ | */ | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "BLI_array.h" | |||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "BLI_string_utf8.h" | #include "BLI_string_utf8.h" | ||||
| #include "BLI_string_utils.h" | #include "BLI_string_utils.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "BKE_collection.h" | #include "BKE_collection.h" | ||||
| #include "BKE_freestyle.h" | #include "BKE_freestyle.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_group.h" | #include "BKE_group.h" | ||||
| #include "BKE_idprop.h" | #include "BKE_idprop.h" | ||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_workspace.h" | #include "BKE_workspace.h" | ||||
| #include "BKE_object.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DNA_group_types.h" | #include "DNA_group_types.h" | ||||
| #include "DNA_ID.h" | #include "DNA_ID.h" | ||||
| #include "DNA_layer_types.h" | #include "DNA_layer_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_node_types.h" | #include "DNA_node_types.h" | ||||
| ▲ Show 20 Lines • Show All 2,163 Lines • ▼ Show 20 Lines | void BKE_renderable_objects_iterator_next(BLI_Iterator *iter) | ||||
| iter->valid = false; | iter->valid = false; | ||||
| } | } | ||||
| void BKE_renderable_objects_iterator_end(BLI_Iterator *UNUSED(iter)) | void BKE_renderable_objects_iterator_end(BLI_Iterator *UNUSED(iter)) | ||||
| { | { | ||||
| /* Do nothing - iter->data was static allocated, we can't free it. */ | /* Do nothing - iter->data was static allocated, we can't free it. */ | ||||
| } | } | ||||
| /* --- */ | |||||
| void BKE_view_layer_objects_in_mode_iterator_begin(BLI_Iterator *iter, void *data_in) | |||||
| { | |||||
| struct ObjectsInModeIteratorData *data = data_in; | |||||
| Base *base = data->base_active; | |||||
| /* when there are no objects */ | |||||
| if (base == NULL) { | |||||
| iter->valid = false; | |||||
| return; | |||||
| } | |||||
| iter->data = data_in; | |||||
| iter->current = base; | |||||
| } | |||||
| void BKE_view_layer_objects_in_mode_iterator_next(BLI_Iterator *iter) | |||||
| { | |||||
| struct ObjectsInModeIteratorData *data = iter->data; | |||||
| Base *base = iter->current; | |||||
| if (base == data->base_active) { | |||||
| /* first step */ | |||||
| base = data->view_layer->object_bases.first; | |||||
| if (base == data->base_active) { | |||||
| base = base->next; | |||||
| } | |||||
| } | |||||
| else { | |||||
| base = base->next; | |||||
| } | |||||
| while (base) { | |||||
| if ((base->flag & BASE_SELECTED) != 0 && | |||||
| (base->object->type == data->base_active->object->type) && | |||||
| (base != data->base_active) && | |||||
| (BKE_object_has_mode_data(base->object, data->object_mode) == true)) | |||||
| { | |||||
| iter->current = base; | |||||
| return; | |||||
| } | |||||
| base = base->next; | |||||
| } | |||||
| iter->valid = false; | |||||
| } | |||||
| void BKE_view_layer_objects_in_mode_iterator_end(BLI_Iterator *UNUSED(iter)) | |||||
| { | |||||
| /* do nothing */ | |||||
| } | |||||
| /* --- */ | |||||
| /* Evaluation */ | /* Evaluation */ | ||||
| /** | /** | ||||
| * Reset props | * Reset props | ||||
| * | * | ||||
| * If props_ref is pasted, copy props from it | * If props_ref is pasted, copy props from it | ||||
| */ | */ | ||||
| static void idproperty_reset(IDProperty **props, IDProperty *props_ref) | static void idproperty_reset(IDProperty **props, IDProperty *props_ref) | ||||
| ▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | void BKE_layer_eval_layer_collection_post(const struct EvaluationContext *UNUSED(eval_ctx), | ||||
| /* if base is not selectabled, clear select */ | /* if base is not selectabled, clear select */ | ||||
| for (Base *base = view_layer->object_bases.first; base; base = base->next) { | for (Base *base = view_layer->object_bases.first; base; base = base->next) { | ||||
| if ((base->flag & BASE_SELECTABLED) == 0) { | if ((base->flag & BASE_SELECTABLED) == 0) { | ||||
| base->flag &= ~BASE_SELECTED; | base->flag &= ~BASE_SELECTED; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Base **BKE_view_layer_array_from_bases_in_mode_params( | |||||
| ViewLayer *view_layer, uint *r_len, | |||||
| const struct ObjectsInModeParams *params) | |||||
| { | |||||
| if (params->no_dupe_data) { | |||||
| FOREACH_BASE_IN_MODE_BEGIN(view_layer, params->object_mode, base_iter) { | |||||
| ID *id = base_iter->object->data; | |||||
| if (id) { | |||||
| id->tag |= LIB_TAG_DOIT; | |||||
| } | |||||
| } FOREACH_BASE_IN_MODE_END; | |||||
| } | |||||
| Base **base_array = NULL; | |||||
| BLI_array_declare(base_array); | |||||
| FOREACH_BASE_IN_MODE_BEGIN(view_layer, params->object_mode, base_iter) { | |||||
| if (params->no_dupe_data) { | |||||
| ID *id = base_iter->object->data; | |||||
| if (id) { | |||||
| if (id->tag & LIB_TAG_DOIT) { | |||||
| id->tag &= ~LIB_TAG_DOIT; | |||||
| } | |||||
| else { | |||||
| continue; | |||||
| } | |||||
| } | |||||
| } | |||||
| BLI_array_append(base_array, base_iter); | |||||
| } FOREACH_BASE_IN_MODE_END; | |||||
| if (base_array != NULL) { | |||||
| base_array = MEM_reallocN(base_array, sizeof(*base_array) * BLI_array_count(base_array)); | |||||
| } | |||||
| *r_len = BLI_array_count(base_array); | |||||
| return base_array; | |||||
| } | |||||
| Object **BKE_view_layer_array_from_objects_in_mode_params( | |||||
| ViewLayer *view_layer, uint *r_len, | |||||
| const struct ObjectsInModeParams *params) | |||||
| { | |||||
| Base **base_array = BKE_view_layer_array_from_bases_in_mode_params( | |||||
| view_layer, r_len, params); | |||||
| if (base_array != NULL) { | |||||
| for (uint i = 0; i < *r_len; i++) { | |||||
| ((Object **)base_array)[i] = base_array[i]->object; | |||||
| } | |||||
| } | |||||
| return (Object **)base_array; | |||||
| } | |||||
| /** | /** | ||||
| * Free any static allocated memory. | * Free any static allocated memory. | ||||
| */ | */ | ||||
| void BKE_layer_exit(void) | void BKE_layer_exit(void) | ||||
| { | { | ||||
| layer_collection_engine_settings_validate_free(); | layer_collection_engine_settings_validate_free(); | ||||
| } | } | ||||