Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2019-05-31 19:17:16 +0300
committerDalai Felinto <dfelinto@gmail.com>2019-05-31 20:02:26 +0300
commitd0258abdd7db5aee66da78008df897d8f444b987 (patch)
tree31677457c0365f554fd99211d5d9c145199d4402 /source
parent3f23299403d4f20fa5c8ef799bde940d0c291228 (diff)
Fix Outliner: New collections are hidden
Users could change the master collection flags, but they should not. That would not effectively affect the master collection objects (depsgraph flag evaluation ignores master collection flags). However we use the layer collection flags of the parent collection when creating a new child collection. We *could* solve this differently by creating a new RNA type for the master collection (and layer collection) and hook this with rna refine. But this patch seems to work well enough and it is simpler. Reviewers: brecht Differential Revision: https://developer.blender.org/D4981
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenloader/intern/versioning_280.c8
-rw-r--r--source/blender/makesrna/intern/rna_collection.c34
-rw-r--r--source/blender/makesrna/intern/rna_layer.c41
3 files changed, 83 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 1f543a92c04..c4436cc8128 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -3505,5 +3505,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
/* Versioning code until next subversion bump goes here. */
+
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ if (scene->master_collection != NULL) {
+ scene->master_collection->flag &= ~(COLLECTION_RESTRICT_VIEWPORT |
+ COLLECTION_RESTRICT_SELECT |
+ COLLECTION_RESTRICT_RENDER);
+ }
+ }
}
}
diff --git a/source/blender/makesrna/intern/rna_collection.c b/source/blender/makesrna/intern/rna_collection.c
index ae944f59a35..99606a929a9 100644
--- a/source/blender/makesrna/intern/rna_collection.c
+++ b/source/blender/makesrna/intern/rna_collection.c
@@ -267,6 +267,37 @@ static bool rna_Collection_children_override_apply(Main *bmain,
return true;
}
+static void rna_Collection_flag_set(PointerRNA *ptr, const bool value, const int flag)
+{
+ Collection *collection = (Collection *)ptr->data;
+
+ if (collection->flag & COLLECTION_IS_MASTER) {
+ return;
+ }
+
+ if (value) {
+ collection->flag |= flag;
+ }
+ else {
+ collection->flag &= ~flag;
+ }
+}
+
+static void rna_Collection_hide_select_set(PointerRNA *ptr, bool value)
+{
+ rna_Collection_flag_set(ptr, value, COLLECTION_RESTRICT_SELECT);
+}
+
+static void rna_Collection_hide_viewport_set(PointerRNA *ptr, bool value)
+{
+ rna_Collection_flag_set(ptr, value, COLLECTION_RESTRICT_VIEWPORT);
+}
+
+static void rna_Collection_hide_render_set(PointerRNA *ptr, bool value)
+{
+ rna_Collection_flag_set(ptr, value, COLLECTION_RESTRICT_RENDER);
+}
+
static void rna_Collection_flag_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Collection *collection = (Collection *)ptr->data;
@@ -402,6 +433,7 @@ void RNA_def_collections(BlenderRNA *brna)
/* Flags */
prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_SELECT);
+ RNA_def_property_boolean_funcs(prop, NULL, "rna_Collection_hide_select_set");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, -1);
@@ -410,6 +442,7 @@ void RNA_def_collections(BlenderRNA *brna)
prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_VIEWPORT);
+ RNA_def_property_boolean_funcs(prop, NULL, "rna_Collection_hide_viewport_set");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, -1);
@@ -418,6 +451,7 @@ void RNA_def_collections(BlenderRNA *brna)
prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_RENDER);
+ RNA_def_property_boolean_funcs(prop, NULL, "rna_Collection_hide_render_set");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, -1);
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index 55009aa660d..a8682632e0c 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -212,6 +212,43 @@ int rna_LayerCollection_name_length(PointerRNA *ptr)
return strlen(id->name + 2);
}
+static void rna_LayerCollection_flag_set(PointerRNA *ptr, const bool value, const int flag)
+{
+ LayerCollection *layer_collection = (LayerCollection *)ptr->data;
+ Collection *collection = layer_collection->collection;
+
+ if (collection->flag & COLLECTION_IS_MASTER) {
+ return;
+ }
+
+ if (value) {
+ layer_collection->flag |= flag;
+ }
+ else {
+ layer_collection->flag &= ~flag;
+ }
+}
+
+static void rna_LayerCollection_exclude_set(PointerRNA *ptr, bool value)
+{
+ rna_LayerCollection_flag_set(ptr, value, LAYER_COLLECTION_EXCLUDE);
+}
+
+static void rna_LayerCollection_holdout_set(PointerRNA *ptr, bool value)
+{
+ rna_LayerCollection_flag_set(ptr, value, LAYER_COLLECTION_HOLDOUT);
+}
+
+static void rna_LayerCollection_indirect_only_set(PointerRNA *ptr, bool value)
+{
+ rna_LayerCollection_flag_set(ptr, value, LAYER_COLLECTION_INDIRECT_ONLY);
+}
+
+static void rna_LayerCollection_hide_viewport_set(PointerRNA *ptr, bool value)
+{
+ rna_LayerCollection_flag_set(ptr, value, LAYER_COLLECTION_HIDE);
+}
+
static void rna_LayerCollection_exclude_update_recursive(ListBase *lb, const bool exclude)
{
for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
@@ -299,6 +336,7 @@ static void rna_def_layer_collection(BlenderRNA *brna)
/* Restriction flags. */
prop = RNA_def_property(srna, "exclude", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", LAYER_COLLECTION_EXCLUDE);
+ RNA_def_property_boolean_funcs(prop, NULL, "rna_LayerCollection_exclude_set");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Exclude from View Layer", "Exclude from view layer");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -307,6 +345,7 @@ static void rna_def_layer_collection(BlenderRNA *brna)
prop = RNA_def_property(srna, "holdout", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", LAYER_COLLECTION_HOLDOUT);
+ RNA_def_property_boolean_funcs(prop, NULL, "rna_LayerCollection_holdout_set");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_icon(prop, ICON_HOLDOUT_OFF, 1);
RNA_def_property_ui_text(prop, "Holdout", "Mask out objects in collection from view layer");
@@ -314,6 +353,7 @@ static void rna_def_layer_collection(BlenderRNA *brna)
prop = RNA_def_property(srna, "indirect_only", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", LAYER_COLLECTION_INDIRECT_ONLY);
+ RNA_def_property_boolean_funcs(prop, NULL, "rna_LayerCollection_indirect_only_set");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_icon(prop, ICON_INDIRECT_ONLY_OFF, 1);
RNA_def_property_ui_text(
@@ -325,6 +365,7 @@ static void rna_def_layer_collection(BlenderRNA *brna)
prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", LAYER_COLLECTION_HIDE);
+ RNA_def_property_boolean_funcs(prop, NULL, "rna_LayerCollection_hide_viewport_set");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1);
RNA_def_property_ui_text(prop, "Hide in Viewport", "Temporarily hide in viewport");