[Bf-blender-cvs] [b85886f8d52] blender2.8: LayerCollection RNA API util functions
Dalai Felinto
noreply at git.blender.org
Thu Nov 15 14:52:48 CET 2018
Commit: b85886f8d5242afe669c787c1b5f30f1a2350411
Author: Dalai Felinto
Date: Thu Nov 15 11:13:26 2018 -0200
Branches: blender2.8
https://developer.blender.org/rBb85886f8d5242afe669c787c1b5f30f1a2350411
LayerCollection RNA API util functions
* has_objects()
* has_visible_objects(view_layer)
* has_selected_objects(view_layer)
===================================================================
M source/blender/makesrna/intern/rna_layer.c
===================================================================
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)
More information about the Bf-blender-cvs
mailing list