[Bf-blender-cvs] [98765e37009] blender2.8: RNA: LayerCollection.has_hidden_objects

Dalai Felinto noreply at git.blender.org
Fri Nov 16 00:01:10 CET 2018


Commit: 98765e370093e088022145e841421f7a7e1da368
Author: Dalai Felinto
Date:   Thu Nov 15 18:25:45 2018 -0200
Branches: blender2.8
https://developer.blender.org/rB98765e370093e088022145e841421f7a7e1da368

RNA: LayerCollection.has_hidden_objects

With this we have a way to tell that a collection has visible objects
but not all of its objects are visible.

===================================================================

M	source/blender/blenkernel/intern/layer.c
M	source/blender/makesdna/DNA_layer_types.h
M	source/blender/makesrna/intern/rna_layer.c

===================================================================

diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 0e4a38503ae..2f9c818934f 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -726,6 +726,7 @@ static short layer_collection_sync(
 
 			if (base->flag & BASE_HIDDEN) {
 				view_layer->runtime_flag |= VIEW_LAYER_HAS_HIDE;
+				lc->runtime_flag |= LAYER_COLLECTION_HAS_HIDDEN_OBJECTS;
 			}
 			else if (base->flag & BASE_VISIBLE) {
 				lc->runtime_flag |= LAYER_COLLECTION_HAS_VISIBLE_OBJECTS;
diff --git a/source/blender/makesdna/DNA_layer_types.h b/source/blender/makesdna/DNA_layer_types.h
index 3dcd31fbd7b..e363c0c54b2 100644
--- a/source/blender/makesdna/DNA_layer_types.h
+++ b/source/blender/makesdna/DNA_layer_types.h
@@ -123,7 +123,8 @@ enum {
 enum {
 	LAYER_COLLECTION_HAS_OBJECTS = (1 << 0),
 	LAYER_COLLECTION_HAS_VISIBLE_OBJECTS = (1 << 1),
-	LAYER_COLLECTION_HAS_ENABLED_OBJECTS = (1 << 2),
+	LAYER_COLLECTION_HAS_HIDDEN_OBJECTS = (1 << 2),
+	LAYER_COLLECTION_HAS_ENABLED_OBJECTS = (1 << 3),
 };
 
 /* ViewLayer->flag */
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index ffa48df010d..46d1f5bef7d 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -232,6 +232,16 @@ static bool rna_LayerCollection_has_visible_objects(LayerCollection *lc, ViewLay
 	return true;
 }
 
+static bool rna_LayerCollection_has_hidden_objects(LayerCollection *lc, ViewLayer *view_layer)
+{
+	if ((view_layer->runtime_flag & VIEW_LAYER_HAS_HIDE) &&
+	    (lc->runtime_flag & LAYER_COLLECTION_HAS_HIDDEN_OBJECTS))
+	{
+		return true;
+	}
+	return false;
+}
+
 static bool rna_LayerCollection_has_selected_objects(LayerCollection *lc, ViewLayer *view_layer)
 {
 	return BKE_layer_collection_has_selected_objects(view_layer, lc);
@@ -297,6 +307,12 @@ static void rna_def_layer_collection(BlenderRNA *brna)
 	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_hidden_objects", "rna_LayerCollection_has_hidden_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");



More information about the Bf-blender-cvs mailing list