diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-09-20 15:15:35 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-09-20 15:15:35 +0300 |
commit | f2db6cefa0869fe474b4fbbb467d63bff8c0935b (patch) | |
tree | 27667ef838b293e01c337cf43d47771dbe9b9814 /source/blender/makesrna/intern/rna_scene.c | |
parent | 42c174d1a5c6a45552210ca1d40018bc1a549c42 (diff) |
Layer collection enable flag
Right now this is exposed in the outliner, though all this
(visible/selectable/enable) should be moved to a new panel soon.
This removes objects from the depsgraph when the collection is disabled.
It allows you to "hide" lamps but still having them lighting the scene.
Same for light probes and other support objects.
Pending tasks:
* Have depsgraph to include invisible objects in the DEG_OBJECTS_ITER, and
then have Eevee and other engines to make a distinction between an
invisible and a visible object.
(for example, we probably want invisible objects to not show in the
viewport, but cast shadows and show up in light probes).
* Change how we evaluate collection settings so that an invisible
collection can force an object to be invisible.
Reviewers: campbellbarton
Subscribers: sergey
Differential Revision: https://developer.blender.org/D2848
Diffstat (limited to 'source/blender/makesrna/intern/rna_scene.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 119432f7ed3..9887da153e8 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2899,6 +2899,39 @@ static void rna_LayerCollection_flag_update(bContext *C, PointerRNA *UNUSED(ptr) WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } +static void rna_LayerCollection_enable_set( + ID *id, LayerCollection *layer_collection, Main *bmain, bContext *C, ReportList *reports, int value) +{ + Scene *scene = (Scene *)id; + SceneLayer *scene_layer = BKE_scene_layer_find_from_collection(scene, layer_collection); + + if (layer_collection->flag & COLLECTION_DISABLED) { + if (value == 1) { + BKE_collection_enable(scene_layer, layer_collection); + } + else { + BKE_reportf(reports, RPT_ERROR, "Layer collection '%s' is already disabled", + layer_collection->scene_collection->name); + return; + } + } + else { + if (value == 0) { + BKE_collection_disable(scene_layer, layer_collection); + } + else { + BKE_reportf(reports, RPT_ERROR, "Layer collection '%s' is already enabled", + layer_collection->scene_collection->name); + } + } + + DEG_relations_tag_update(bmain); + /* TODO(sergey): Use proper flag for tagging here. */ + DEG_id_tag_update(&scene->id, 0); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene); +} + static int rna_LayerCollections_active_collection_index_get(PointerRNA *ptr) { SceneLayer *sl = (SceneLayer *)ptr->data; @@ -6991,7 +7024,17 @@ static void rna_def_layer_collection(BlenderRNA *brna) parm = RNA_def_boolean(func, "result", false, "Result", "Whether the operation succeded"); RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "enable_set", "rna_LayerCollection_enable_set"); + RNA_def_function_ui_description(func, "Enable or disable a collection"); + parm = RNA_def_boolean(func, "value", 1, "Enable", ""); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS); + /* Flags */ + prop = RNA_def_property(srna, "is_enabled", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_DISABLED); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Enabled", "Enable or disable collection from depsgraph"); + prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_VISIBLE); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); |