diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-11-06 19:20:49 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-11-06 19:20:49 +0300 |
commit | 7b38df41ae8b2903eb65dc72e506ba0b0c58453d (patch) | |
tree | 61b841a5f634a1b6806688c1fb4b563b92b7e99a /source/blender/makesrna/intern/rna_layer.c | |
parent | aa9912ec045e3209bc87c48801fd955c59bd0908 (diff) |
Fix/cleanup RNA viewlayer API.
RNA's ViewLayer would present 'first level' of layer collection as a
list (collection property), when it is actually now only a single item,
same as the scene's master collection.
Note: did not try to update view_layer python tests, those are already
fully broken for quiet some time I guess (they still assume
view_layer.collections to be mutable e.g.)...
Diffstat (limited to 'source/blender/makesrna/intern/rna_layer.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_layer.c | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c index df86a45b1a9..727364a5bda 100644 --- a/source/blender/makesrna/intern/rna_layer.c +++ b/source/blender/makesrna/intern/rna_layer.c @@ -70,19 +70,21 @@ /***********************************/ -static PointerRNA rna_LayerCollections_active_collection_get(PointerRNA *ptr) +static PointerRNA rna_ViewLayer_active_layer_collection_get(PointerRNA *ptr) { ViewLayer *view_layer = (ViewLayer *)ptr->data; LayerCollection *lc = view_layer->active_collection; return rna_pointer_inherit_refine(ptr, &RNA_LayerCollection, lc); } -static void rna_LayerCollections_active_collection_set(PointerRNA *ptr, PointerRNA value) +static void rna_ViewLayer_active_layer_collection_set(PointerRNA *ptr, PointerRNA value) { ViewLayer *view_layer = (ViewLayer *)ptr->data; LayerCollection *lc = (LayerCollection *)value.data; const int index = BKE_layer_collection_findindex(view_layer, lc); - if (index != -1) BKE_layer_collection_activate(view_layer, lc); + if (index != -1) { + BKE_layer_collection_activate(view_layer, lc); + } } static PointerRNA rna_LayerObjects_active_object_get(PointerRNA *ptr) @@ -240,29 +242,12 @@ 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_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Indirect Only", "Objects in collection only contribute indirectly (through shadows and reflections) in the view layer"); + RNA_def_property_ui_text(prop, "Indirect Only", + "Objects in collection only contribute indirectly (through shadows and reflections) " + "in the view layer"); RNA_def_property_update(prop, NC_SCENE | ND_LAYER, "rna_LayerCollection_use_update"); } -static void rna_def_layer_collections(BlenderRNA *brna, PropertyRNA *cprop) -{ - StructRNA *srna; - PropertyRNA *prop; - - RNA_def_property_srna(cprop, "LayerCollections"); - srna = RNA_def_struct(brna, "LayerCollections", NULL); - RNA_def_struct_sdna(srna, "ViewLayer"); - RNA_def_struct_ui_text(srna, "Layer Collections", "Collections of render layer"); - - prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "LayerCollection"); - RNA_def_property_pointer_funcs(prop, "rna_LayerCollections_active_collection_get", - "rna_LayerCollections_active_collection_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); - RNA_def_property_ui_text(prop, "Active Layer Collection", "Active Layer Collection"); - RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL); -} - static void rna_def_layer_objects(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; @@ -275,7 +260,8 @@ static void rna_def_layer_objects(BlenderRNA *brna, PropertyRNA *cprop) prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_pointer_funcs(prop, "rna_LayerObjects_active_object_get", "rna_LayerObjects_active_object_set", NULL, NULL); + RNA_def_property_pointer_funcs(prop, "rna_LayerObjects_active_object_get", + "rna_LayerObjects_active_object_set", NULL, NULL); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Active Object", "Active object for this layer"); /* Could call: ED_object_base_activate(C, rl->basact); @@ -329,11 +315,22 @@ void RNA_def_view_layer(BlenderRNA *brna) RNA_def_function_ui_description(func, "Requery the enabled render passes from the render engine"); RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_NO_SELF); - prop = RNA_def_property(srna, "collections", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "layer_collections", NULL); + prop = RNA_def_property(srna, "layer_collection", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "LayerCollection"); - RNA_def_property_ui_text(prop, "Layer Collections", ""); - rna_def_layer_collections(brna, prop); + RNA_def_property_pointer_sdna(prop, NULL, "layer_collections.first"); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_ui_text(prop, "Layer Collection", + "Root of collections hierarchy of this view layer," + "its 'collection' pointer property is the same as the scene's master collection"); + + prop = RNA_def_property(srna, "active_layer_collection", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "LayerCollection"); + RNA_def_property_pointer_funcs(prop, "rna_ViewLayer_active_layer_collection_get", + "rna_ViewLayer_active_layer_collection_set", NULL, NULL); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); + RNA_def_property_ui_text(prop, "Active Layer Collection", + "Active layer collection in this view layer's hierarchy"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER, NULL); prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "object_bases", NULL); |