[Bf-blender-cvs] [1f5106de610] blender2.8: Group collection viewport/render options and remove collection visibility

Dalai Felinto noreply at git.blender.org
Fri Dec 15 11:59:19 CET 2017


Commit: 1f5106de610b115b87ab6121d7871d447ca48cd2
Author: Dalai Felinto
Date:   Thu Dec 14 11:46:49 2017 -0200
Branches: blender2.8
https://developer.blender.org/rB1f5106de610b115b87ab6121d7871d447ca48cd2

Group collection viewport/render options and remove collection visibility

Users can change the group collection visibility in the outliner
when looking at groups.

Regular collections on the other hand don't have any special visibility control,
if you need a collection to be invisible during render, either don't link it
into the view layer used for F12, or disable it.

This includes:
* Updated unittests - update your lib/tests/layers folder.
* Subversion bump - branches be aware of that.

Note:
Although we are using eval_ctx to determine the visibility of a group collection
when rendering, the depsgraph is still using the same depsgraph for the viewport
and the render engine, so at the moment the render visibility is ignored.

Following next is a workaround for this separately to tag the groups before and
after rendering to tackle that.

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

M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenkernel/BKE_layer.h
M	source/blender/blenkernel/intern/layer.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/depsgraph/DEG_depsgraph_query.h
M	source/blender/draw/engines/eevee/eevee_engine.c
M	source/blender/draw/engines/eevee/eevee_lightprobes.c
M	source/blender/draw/intern/draw_manager.c
M	source/blender/draw/modes/object_mode.c
M	source/blender/editors/render/render_preview.c
M	source/blender/editors/space_outliner/outliner_collections.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/makesdna/DNA_layer_types.h
M	source/blender/makesrna/intern/rna_layer.c
M	source/blender/makesrna/intern/rna_object.c
M	tests/python/view_layer/test_evaluation_selectability_a.py
M	tests/python/view_layer/test_evaluation_selectability_b.py
M	tests/python/view_layer/test_evaluation_selectability_c.py
M	tests/python/view_layer/test_evaluation_selectability_d.py
M	tests/python/view_layer/test_evaluation_selectability_e.py
M	tests/python/view_layer/test_evaluation_selectability_f.py
M	tests/python/view_layer/test_evaluation_visibility_a.py
M	tests/python/view_layer/test_evaluation_visibility_b.py
M	tests/python/view_layer/test_evaluation_visibility_c.py
M	tests/python/view_layer/test_evaluation_visibility_d.py
M	tests/python/view_layer/test_evaluation_visibility_e.py
M	tests/python/view_layer/test_evaluation_visibility_f.py
M	tests/python/view_layer/test_group_b.py
M	tests/python/view_layer/test_move_above_below_layer_collection_f.py
M	tests/python/view_layer/test_move_above_below_layer_collection_g.py
M	tests/python/view_layer/test_move_above_below_layer_collection_h.py
M	tests/python/view_layer/test_move_above_below_layer_collection_i.py
M	tests/python/view_layer/test_move_above_below_layer_collection_j.py
M	tests/python/view_layer/test_move_into_layer_collection_f.py
M	tests/python/view_layer/test_move_into_layer_collection_g.py
M	tests/python/view_layer/test_move_into_layer_collection_h.py
M	tests/python/view_layer/test_scene_copy_f.py

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

diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 8d326c6441c..27223afe4ff 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -28,7 +28,7 @@
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         280
-#define BLENDER_SUBVERSION      2
+#define BLENDER_SUBVERSION      3
 /* Several breakages with 270, e.g. constraint deg vs rad */
 #define BLENDER_MINVERSION      270
 #define BLENDER_MINSUBVERSION   6
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index e4f8b8790f6..6a762c9b711 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -102,7 +102,6 @@ struct LayerCollection *BKE_collection_link(struct ViewLayer *view_layer, struct
 void BKE_collection_unlink(struct ViewLayer *view_layer, struct LayerCollection *lc);
 
 void BKE_collection_enable(struct ViewLayer *view_layer, struct LayerCollection *lc);
-void BKE_collection_disable(struct ViewLayer *view_layer, struct LayerCollection *lc);
 
 bool BKE_view_layer_has_collection(struct ViewLayer *view_layer, const struct SceneCollection *sc);
 bool BKE_scene_has_object(struct Scene *scene, struct Object *ob);
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 84eb4ee2e33..2e6cd769db8 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -42,6 +42,8 @@
 #include "BKE_node.h"
 #include "BKE_workspace.h"
 
+#include "DEG_depsgraph.h"
+
 #include "DNA_group_types.h"
 #include "DNA_ID.h"
 #include "DNA_layer_types.h"
@@ -1018,7 +1020,8 @@ static void layer_collection_enable(ViewLayer *view_layer, LayerCollection *lc)
 /**
  * Enable collection
  * Add its objects bases to ViewLayer
- * Depsgraph needs to be rebuilt afterwards
+ *
+ * Only around for doversion.
  */
 void BKE_collection_enable(ViewLayer *view_layer, LayerCollection *lc)
 {
@@ -1030,33 +1033,6 @@ void BKE_collection_enable(ViewLayer *view_layer, LayerCollection *lc)
 	layer_collection_enable(view_layer, lc);
 }
 
-/**
- * Recursively disable nested collections
- */
-static void layer_collection_disable(ViewLayer *view_layer, LayerCollection *lc)
-{
-	layer_collection_objects_unpopulate(view_layer, lc);
-
-	for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) {
-		layer_collection_disable(view_layer, nlc);
-	}
-}
-
-/**
- * Disable collection
- * Remove all its object bases from ViewLayer
- * Depsgraph needs to be rebuilt afterwards
- */
-void BKE_collection_disable(ViewLayer *view_layer, LayerCollection *lc)
-{
-	if ((lc->flag & COLLECTION_DISABLED) != 0) {
-		return;
-	}
-
-	lc->flag |= COLLECTION_DISABLED;
-	layer_collection_disable(view_layer, lc);
-}
-
 static void layer_collection_object_add(ViewLayer *view_layer, LayerCollection *lc, Object *ob)
 {
 	Base *base = object_base_add(view_layer, ob);
@@ -1068,7 +1044,7 @@ static void layer_collection_object_add(ViewLayer *view_layer, LayerCollection *
 		return;
 	}
 
-	bool is_visible = (lc->flag & COLLECTION_VISIBLE) != 0;
+	bool is_visible = ((lc->flag & COLLECTION_VIEWPORT) != 0) && ((lc->flag & COLLECTION_DISABLED) == 0);
 	bool is_selectable = is_visible && ((lc->flag & COLLECTION_SELECTABLE) != 0);
 
 	if (is_visible) {
@@ -1117,7 +1093,7 @@ static LayerCollection *layer_collection_add(ViewLayer *view_layer, LayerCollect
 	LayerCollection *lc = MEM_callocN(sizeof(LayerCollection), "Collection Base");
 
 	lc->scene_collection = sc;
-	lc->flag = COLLECTION_VISIBLE | COLLECTION_SELECTABLE;
+	lc->flag = COLLECTION_SELECTABLE | COLLECTION_VIEWPORT | COLLECTION_RENDER;
 
 	lc->properties = IDP_New(IDP_GROUP, &val, ROOT_PROP);
 	collection_engine_settings_init(lc->properties, false);
@@ -2118,7 +2094,21 @@ static const char *collection_type_lookup[] =
     "Group Internal", /* COLLECTION_TYPE_GROUP_INTERNAL */
 };
 
-void BKE_layer_eval_layer_collection(const struct EvaluationContext *UNUSED(eval_ctx),
+static bool layer_collection_visible_get(const EvaluationContext *eval_ctx, LayerCollection *layer_collection)
+{
+	bool is_visible = (layer_collection->flag & COLLECTION_DISABLED) == 0;
+
+	if (eval_ctx->mode == DAG_EVAL_VIEWPORT) {
+		is_visible &= (layer_collection->flag & COLLECTION_VIEWPORT) != 0;
+	}
+	else {
+		is_visible &= (layer_collection->flag & COLLECTION_RENDER) != 0;
+	}
+
+	return is_visible;
+}
+
+void BKE_layer_eval_layer_collection(const EvaluationContext *eval_ctx,
                                      LayerCollection *layer_collection,
                                      LayerCollection *parent_layer_collection)
 {
@@ -2134,11 +2124,11 @@ void BKE_layer_eval_layer_collection(const struct EvaluationContext *UNUSED(eval
 
 	/* visibility */
 	layer_collection->flag_evaluated = layer_collection->flag;
-	bool is_visible = (layer_collection->flag & COLLECTION_VISIBLE) != 0;
+	bool is_visible = layer_collection_visible_get(eval_ctx, layer_collection);
 	bool is_selectable = is_visible && ((layer_collection->flag & COLLECTION_SELECTABLE) != 0);
 
 	if (parent_layer_collection != NULL) {
-		is_visible &= (parent_layer_collection->flag_evaluated & COLLECTION_VISIBLE) != 0;
+		is_visible &= layer_collection_visible_get(eval_ctx, parent_layer_collection);
 		is_selectable &= (parent_layer_collection->flag_evaluated & COLLECTION_SELECTABLE) != 0;
 		layer_collection->flag_evaluated &= parent_layer_collection->flag_evaluated;
 	}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 163df9987bb..cfe7ffe87a2 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -189,21 +189,21 @@ void do_versions_after_linking_280(Main *main)
 						.collections = {NULL},
 						.created = 0,
 						.suffix = "",
-						.flag_viewport = COLLECTION_VISIBLE | COLLECTION_SELECTABLE,
-						.flag_render = COLLECTION_VISIBLE | COLLECTION_SELECTABLE
+						.flag_viewport = COLLECTION_SELECTABLE,
+						.flag_render = COLLECTION_SELECTABLE
 					},
 					{
 						.collections = {NULL},
 						.created = 0,
 						.suffix = " - Hide Viewport",
 						.flag_viewport = COLLECTION_SELECTABLE,
-						.flag_render = COLLECTION_VISIBLE | COLLECTION_SELECTABLE
+						.flag_render = COLLECTION_SELECTABLE
 					},
 					{
 						.collections = {NULL},
 						.created = 0,
 						.suffix = " - Hide Render",
-						.flag_viewport = COLLECTION_VISIBLE | COLLECTION_SELECTABLE,
+						.flag_viewport = COLLECTION_SELECTABLE,
 						.flag_render = COLLECTION_SELECTABLE | COLLECTION_DISABLED
 					},
 					{
@@ -391,13 +391,9 @@ void do_versions_after_linking_280(Main *main)
 
 									for (int j = 1; j < 4; j++) {
 										if (collections[j].created & (1 << layer)) {
-											layer_collection_child->flag =
-												collections[j].flag_render & (~COLLECTION_DISABLED);
-
-											if (collections[j].flag_render & COLLECTION_DISABLED) {
-												BKE_collection_disable(view_layer, layer_collection_child);
-											}
-
+											layer_collection_child->flag = COLLECTION_VIEWPORT |
+											                               COLLECTION_RENDER |
+											                               collections[j].flag_render;
 											layer_collection_child = layer_collection_child->next;
 										}
 									}
@@ -450,7 +446,7 @@ void do_versions_after_linking_280(Main *main)
 
 						/* We only need to disable the parent collection. */
 						if (is_disabled) {
-							BKE_collection_disable(view_layer, layer_collection_parent);
+							layer_collection_parent->flag |= COLLECTION_DISABLED;
 						}
 
 						LayerCollection *layer_collection_child;
@@ -458,11 +454,9 @@ void do_versions_after_linking_280(Main *main)
 
 						for (int j = 1; j < 4; j++) {
 							if (collections[j].created & (1 << layer)) {
-								layer_collection_child->flag = collections[j].flag_viewport & (~COLLECTION_DISABLED);
-
-								if (collections[j].flag_viewport & COLLECTION_DISABLED) {
-									BKE_collection_disable(view_layer, layer_collection_child);
-								}
+								layer_collection_child->flag = COLLECTION_VIEWPORT |
+								                               COLLECTION_RENDER |
+								                               collections[j].flag_viewport;
 								layer_collection_child = layer_collection_child->next;
 							}
 						}
@@ -594,11 +588,9 @@ void do_versions_after_linking_280(Main *main)
 
 				if (sc_hidden != NULL) {
 					LayerCollection *layer_collection_master, *layer_collection_hidden;
-
 					layer_collection_master = group->view_layer->layer_collections.first;
 					layer_collection_hidden = layer_collection_master->layer_collections.first;
-
-					layer_collection_hidden->flag &= ~COLLECTION_VISIBLE;
+					layer_collection_hidden->flag |= COLLECTION_DISABLED;
 				}
 			}
 
@@ -629,6 +621,25 @@ static void do_version_layer_collections_idproperties(ListBase *lb)
 	}
 }
 
+static void do_version_view_layer_visibility(ViewLayer *view_layer)
+{
+	LayerCollection *layer_collection;
+	for (layer_collection = view_layer->layer_collections.first;
+	     layer_collection;
+	     layer_collection = layer_collection->next)
+	{
+		if (layer_collection->flag & COLLECTION_DISABLED) {
+			BKE_collection_enable(view_layer, layer_collection);
+			layer_collection->flag &= ~COLLECTION_DISABLED;
+		}
+
+		if ((layer_collection->flag & (1 << 0)) == 0) { /* !COLLECTION_VISIBLE */
+			layer_collection->flag |= COLLECTION_DISABLED;
+		}
+		layer_collection->flag |= COLLECTION_VIEWPORT | COLLECTION_RENDER;
+	}
+}
+
 void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
 {
 
@@ -827,4 +838,19 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
 			}
 		}
 	}
+
+	if (!MAIN_VERSION_ATLEAST(main, 280, 3)) {
+		for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+			ViewLayer *view_layer;
+			for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
+				do_version_view_layer_visibility(view_layer);


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list