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
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2018-11-15 16:13:26 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-11-15 16:51:57 +0300
commitb85886f8d5242afe669c787c1b5f30f1a2350411 (patch)
tree54731050dc3be1cb283ef1ddf9ccf2a45c30f4c7 /source/blender/makesrna/intern/rna_layer.c
parent570e37261da2be1ab75c8cce3f2386704aadef32 (diff)
LayerCollection RNA API util functions
* has_objects() * has_visible_objects(view_layer) * has_selected_objects(view_layer)
Diffstat (limited to 'source/blender/makesrna/intern/rna_layer.c')
-rw-r--r--source/blender/makesrna/intern/rna_layer.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index 693d7a06a79..ffa48df010d 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -217,11 +217,32 @@ static void rna_LayerCollection_use_update(Main *bmain, Scene *UNUSED(scene), Po
WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, NULL);
}
+static bool rna_LayerCollection_has_objects(LayerCollection *lc)
+{
+ return (lc->runtime_flag & LAYER_COLLECTION_HAS_OBJECTS) != 0;
+}
+
+static bool rna_LayerCollection_has_visible_objects(LayerCollection *lc, ViewLayer *view_layer)
+{
+ if ((view_layer->runtime_flag & VIEW_LAYER_HAS_HIDE) &&
+ !(lc->runtime_flag & LAYER_COLLECTION_HAS_VISIBLE_OBJECTS))
+ {
+ return false;
+ }
+ return true;
+}
+
+static bool rna_LayerCollection_has_selected_objects(LayerCollection *lc, ViewLayer *view_layer)
+{
+ return BKE_layer_collection_has_selected_objects(view_layer, lc);
+}
+
#else
static void rna_def_layer_collection(BlenderRNA *brna)
{
StructRNA *srna;
+ FunctionRNA *func;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "LayerCollection", NULL);
@@ -265,6 +286,22 @@ static void rna_def_layer_collection(BlenderRNA *brna)
"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");
+
+ func = RNA_def_function(srna, "has_objects", "rna_LayerCollection_has_objects");
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_return(func, RNA_def_boolean(func, "result", 0, "", ""));
+
+ func = RNA_def_function(srna, "has_visible_objects", "rna_LayerCollection_has_visible_objects");
+ RNA_def_function_ui_description(func, "");
+ prop = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "ViewLayer the layer collection belongs to");
+ RNA_def_parameter_flags(prop, 0, PARM_REQUIRED);
+ RNA_def_function_return(func, RNA_def_boolean(func, "result", 0, "", ""));
+
+ func = RNA_def_function(srna, "has_selected_objects", "rna_LayerCollection_has_selected_objects");
+ RNA_def_function_ui_description(func, "");
+ prop = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "ViewLayer the layer collection belongs to");
+ RNA_def_parameter_flags(prop, 0, PARM_REQUIRED);
+ RNA_def_function_return(func, RNA_def_boolean(func, "result", 0, "", ""));
}
static void rna_def_layer_objects(BlenderRNA *brna, PropertyRNA *cprop)