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.
This commit is contained in:
Dalai Felinto
2017-12-14 11:46:49 -02:00
parent 7402b8ec74
commit 1f5106de61
38 changed files with 252 additions and 307 deletions

View File

@@ -37,7 +37,7 @@ class UnitTesting(ViewLayerTesting):
layer_collection_mom = layer.collections.link(scene_collection_mom)
layer_collection_kid = layer.collections.link(scene_collection_kid)
layer_collection_mom.hide = True
layer_collection_mom.enabled = False
bpy.context.scene.update() # update depsgraph
cube.select_set('SELECT')

View File

@@ -39,8 +39,8 @@ class UnitTesting(ViewLayerTesting):
bpy.context.scene.update() # update depsgraph
cube.select_set('SELECT')
layer_collection_mom.collections[layer_collection_kid.name].hide = True
layer_collection_kid.hide = True
layer_collection_mom.collections[layer_collection_kid.name].enabled = False
layer_collection_kid.enabled = False
bpy.context.scene.update() # update depsgraph
self.assertFalse(cube.visible_get(), "Cube should be invisible")

View File

@@ -37,7 +37,7 @@ class UnitTesting(ViewLayerTesting):
layer_collection_mom = layer.collections.link(scene_collection_mom)
layer_collection_kid = layer.collections.link(scene_collection_kid)
layer_collection_mom.hide = False
layer_collection_mom.enabled = True
bpy.context.scene.update() # update depsgraph
cube.select_set('SELECT')

View File

@@ -37,11 +37,11 @@ class UnitTesting(ViewLayerTesting):
layer_collection_mom = layer.collections.link(scene_collection_mom)
layer_collection_kid = layer.collections.link(scene_collection_kid)
layer_collection_mom.hide = False
layer_collection_mom.enabled = True
bpy.context.scene.update() # update depsgraph
cube.select_set('SELECT')
layer_collection_mom.collections[layer_collection_kid.name].hide_select = True
layer_collection_mom.collections[layer_collection_kid.name].selectable = False
bpy.context.scene.update() # update depsgraph
self.assertTrue(cube.visible_get(), "Cube should be visible")

View File

@@ -37,10 +37,10 @@ class UnitTesting(ViewLayerTesting):
layer_collection_mom = layer.collections.link(scene_collection_mom)
layer_collection_kid = layer.collections.link(scene_collection_kid)
layer_collection_mom.hide = False
layer_collection_mom.enabled = True
cube.select_set('SELECT')
layer_collection_mom.collections[layer_collection_kid.name].hide_select = True
layer_collection_kid.hide = True
layer_collection_mom.collections[layer_collection_kid.name].selectable = False
layer_collection_kid.enabled = False
bpy.context.scene.update() # update depsgraph
self.assertTrue(cube.visible_get(), "Cube should be visible")

View File

@@ -26,8 +26,8 @@ class UnitTesting(ViewLayerTesting):
scene_collection.objects.link(cube)
self.assertFalse(layer_collection.hide)
self.assertFalse(layer_collection.hide_select)
self.assertTrue(layer_collection.enabled)
self.assertTrue(layer_collection.selectable)
bpy.context.scene.update() # update depsgraph
cube.select_set(action='SELECT')

View File

@@ -38,8 +38,8 @@ class UnitTesting(ViewLayerTesting):
layer_collection_mom = layer.collections.link(scene_collection_mom)
layer_collection_kid = layer.collections.link(scene_collection_kid)
layer_collection_mom.hide = True
layer_collection_kid.hide = False
layer_collection_mom.enabled = False
layer_collection_kid.enabled = True
bpy.context.scene.update() # update depsgraph
self.assertTrue(cube.visible_get(), "Object should be visible")

View File

@@ -37,9 +37,9 @@ class UnitTesting(ViewLayerTesting):
layer_collection_mom = layer.collections.link(scene_collection_mom)
layer_collection_kid = layer.collections.link(scene_collection_kid)
layer_collection_mom.hide = False
layer_collection_mom.collections[layer_collection_kid.name].hide = True
layer_collection_kid.hide = True
layer_collection_mom.enabled = True
layer_collection_mom.collections[layer_collection_kid.name].enabled = False
layer_collection_kid.enabled = False
bpy.context.scene.update() # update depsgraph
self.assertFalse(cube.visible_get(), "Object should be invisible")

View File

@@ -37,9 +37,9 @@ class UnitTesting(ViewLayerTesting):
layer_collection_mom = layer.collections.link(scene_collection_mom)
layer_collection_kid = layer.collections.link(scene_collection_kid)
layer_collection_mom.hide = False
layer_collection_mom.collections[layer_collection_kid.name].hide = True
layer_collection_kid.hide = False
layer_collection_mom.enabled = True
layer_collection_mom.collections[layer_collection_kid.name].enabled = False
layer_collection_kid.enabled = True
bpy.context.scene.update() # update depsgraph
self.assertTrue(cube.visible_get(), "Object should be visible")

View File

@@ -37,7 +37,7 @@ class UnitTesting(ViewLayerTesting):
layer_collection_mom = layer.collections.link(scene_collection_mom)
layer_collection_kid = layer.collections.link(scene_collection_kid)
layer_collection_mom.hide = False
layer_collection_mom.enabled = True
bpy.context.scene.update() # update depsgraph
self.assertTrue(cube.visible_get(), "Object should be visible")

View File

@@ -38,8 +38,8 @@ class UnitTesting(ViewLayerTesting):
layer_collection_mom = layer.collections.link(scene_collection_mom)
layer_collection_kid = layer.collections.link(scene_collection_kid)
layer_collection_mom.hide = False
layer_collection_kid.hide = True
layer_collection_mom.enabled = True
layer_collection_kid.enabled = False
bpy.context.scene.update() # update depsgraph
self.assertTrue(cube.visible_get(), "Object should be visible")

View File

@@ -38,9 +38,9 @@ class UnitTesting(ViewLayerTesting):
layer_collection_mom = layer.collections.link(scene_collection_mom)
layer_collection_kid = layer.collections.link(scene_collection_kid)
layer_collection_mom.hide = False
layer_collection_mom.collections[layer_collection_kid.name].hide = True
layer_collection_kid.hide = True
layer_collection_mom.enabled = True
layer_collection_mom.collections[layer_collection_kid.name].enabled = False
layer_collection_kid.enabled = False
bpy.context.scene.update() # update depsgraph
self.assertTrue(cube.visible_get(), "Object should be visible")

View File

@@ -35,10 +35,10 @@ class UnitTesting(ViewLayerTesting):
grandma_layer_collection = scene.view_layers[0].collections.link(grandma)
mom_layer_collection = grandma_layer_collection.collections[0]
grandma_layer_collection.hide = False
grandma_layer_collection.hide = False
mom_layer_collection.hide = True
mom_layer_collection.hide_select = False
grandma_layer_collection.enabled = True
grandma_layer_collection.enabled = True
mom_layer_collection.enabled = False
mom_layer_collection.selectable = True
# update depsgraph
scene.update()
@@ -53,14 +53,14 @@ class UnitTesting(ViewLayerTesting):
self.assertEqual(len(group.view_layer.collections), 1)
grandma_group_layer = group.view_layer.collections[0]
self.assertEqual(grandma_group_layer.hide, False)
self.assertEqual(grandma_group_layer.hide_select, False)
self.assertTrue(grandma_group_layer.enabled, True)
self.assertTrue(grandma_group_layer.selectable)
self.assertEqual(len(grandma_group_layer.collections), 1)
mom_group_layer = grandma_group_layer.collections[0]
self.assertEqual(mom_group_layer.hide, True)
self.assertEqual(mom_group_layer.hide_select, False)
self.assertFalse(mom_group_layer.enabled)
self.assertTrue(mom_group_layer.selectable)
# ############################################################

View File

@@ -72,13 +72,13 @@ class UnitTesting(MoveLayerCollectionTesting):
# collection that will be moved
collection_original = self.parse_move('Layer 2.3')
collection_original.hide = False
collection_original.hide_select = True
collection_original.enabled = True
collection_original.selectable = False
# collection that will disappear
collection_old = self.parse_move('Layer 2.C.3')
collection_old.hide = True
collection_old.hide_select = False
collection_old.enabled = False
collection_old.selectable = True
# move
self.assertTrue(self.move_below('Layer 2.3', 'Layer 2.C.1'))
@@ -87,8 +87,8 @@ class UnitTesting(MoveLayerCollectionTesting):
# we expect the settings to be carried along from the
# original layer collection
collection_new = self.parse_move('Layer 2.C.3')
self.assertEqual(collection_new.hide, False)
self.assertEqual(collection_new.hide_select, True)
self.assertEqual(collection_new.enabled, True)
self.assertEqual(collection_new.selectable, False)
# ############################################################

View File

@@ -53,13 +53,13 @@ class UnitTesting(MoveLayerCollectionTesting):
# collection that will be moved
collection_original = self.parse_move('Layer 2.C.3.cat')
collection_original.hide = False
collection_original.hide_select = True
collection_original.enabled = True
collection_original.selectable = False
# collection that will disappear
collection_old = self.parse_move('Layer 2.3.cat')
collection_old.hide = True
collection_old.hide_select = False
collection_old.enabled = False
collection_old.selectable = True
# move
self.assertTrue(self.move_above('Layer 2.C.3.cat', 'Layer 2.3.dog'))
@@ -68,8 +68,8 @@ class UnitTesting(MoveLayerCollectionTesting):
# we expect the settings to be carried along from the
# original layer collection
collection_new = self.parse_move('Layer 2.3.cat')
self.assertEqual(collection_new.hide, False)
self.assertEqual(collection_new.hide_select, True)
self.assertEqual(collection_new.enabled, True)
self.assertEqual(collection_new.selectable, False)
# ############################################################

View File

@@ -38,13 +38,13 @@ class UnitTesting(MoveLayerCollectionTesting):
# collection that will be moved
collection_original = self.parse_move('Layer 2.C.3.cat')
collection_original.hide = False
collection_original.hide_select = True
collection_original.enabled = True
collection_original.selectable = False
# collection that will disappear
collection_old = self.parse_move('Layer 2.3.cat')
collection_old.hide = True
collection_old.hide_select = False
collection_old.enabled = False
collection_old.selectable = True
# move
self.assertTrue(self.move_below('Layer 2.C.3.cat', 'Layer 2.3.dog'))
@@ -53,8 +53,8 @@ class UnitTesting(MoveLayerCollectionTesting):
# we expect the settings to be carried along from the
# original layer collection
collection_new = self.parse_move('Layer 2.3.cat')
self.assertEqual(collection_new.hide, False)
self.assertEqual(collection_new.hide_select, True)
self.assertEqual(collection_new.enabled, True)
self.assertEqual(collection_new.selectable, False)
# ############################################################

View File

@@ -50,8 +50,8 @@ class UnitTesting(MoveLayerCollectionTesting):
# collection that will be moved
collection_original = self.parse_move('Layer 2.C')
collection_original.hide = False
collection_original.hide_select = True
collection_original.enabled = True
collection_original.selectable = False
# move
self.assertTrue(self.move_below('Layer 2.C', 'Layer 2.3'))
@@ -60,8 +60,8 @@ class UnitTesting(MoveLayerCollectionTesting):
# we expect the settings to be carried along from the
# original layer collection
collection_new = self.parse_move('Layer 2.C')
self.assertEqual(collection_new.hide, False)
self.assertEqual(collection_new.hide_select, True)
self.assertEqual(collection_new.enabled, True)
self.assertEqual(collection_new.selectable, False)
# ############################################################

View File

@@ -39,8 +39,8 @@ class UnitTesting(MoveLayerCollectionTesting):
# collection that will be moved
collection_original = self.parse_move('Layer 1.3.dog')
collection_original.hide = False
collection_original.hide_select = True
collection_original.enabled = True
collection_original.selectable = False
# move
self.assertTrue(self.move_below('Layer 1.3.dog', 'Layer 1.3.cat'))
@@ -50,8 +50,8 @@ class UnitTesting(MoveLayerCollectionTesting):
# we expect the settings to be carried along from the
# original layer collection
collection_new = self.parse_move('Layer 1.3.dog')
self.assertEqual(collection_new.hide, False)
self.assertEqual(collection_new.hide_select, True)
self.assertEqual(collection_new.enabled, True)
self.assertEqual(collection_new.selectable, False)
# ############################################################

View File

@@ -64,8 +64,8 @@ class UnitTesting(MoveLayerCollectionTesting):
# collection that will be moved
collection_original = self.parse_move('Layer 1.3')
collection_original.hide = False
collection_original.hide_select = True
collection_original.enabled = True
collection_original.selectable = False
self.assertTrue(self.move_into('Layer 1.3', 'Layer 1.Master Collection.A'))
self.compare_tree_maps()
@@ -73,8 +73,8 @@ class UnitTesting(MoveLayerCollectionTesting):
# we expect the settings to be carried along from the
# original layer collection
collection_new = self.parse_move('Layer 1.Master Collection.A.3')
self.assertEqual(collection_new.hide, False)
self.assertEqual(collection_new.hide_select, True)
self.assertEqual(collection_new.enabled, True)
self.assertEqual(collection_new.selectable, False)
# ############################################################

View File

@@ -49,13 +49,13 @@ class UnitTesting(MoveLayerCollectionTesting):
# collection that will be moved
collection_original = self.parse_move('Layer 2.3')
collection_original.hide = False
collection_original.hide_select = True
collection_original.enabled = True
collection_original.selectable = False
# collection that will disappear
collection_old = self.parse_move('Layer 2.C.3')
collection_old.hide = True
collection_old.hide_select = False
collection_old.enabled = False
collection_old.selectable = True
# move collection
self.assertTrue(self.move_into('Layer 2.3', 'Layer 2.C'))
@@ -64,8 +64,8 @@ class UnitTesting(MoveLayerCollectionTesting):
# we expect the settings to be carried along from the
# original layer collection
collection_new = self.parse_move('Layer 2.C.3')
self.assertEqual(collection_new.hide, False)
self.assertEqual(collection_new.hide_select, True)
self.assertEqual(collection_new.enabled, True)
self.assertEqual(collection_new.selectable, False)
# ############################################################

View File

@@ -54,8 +54,8 @@ class UnitTesting(MoveLayerCollectionTesting):
# collection that will be moved
collection_original = self.parse_move('Layer 1.3.dog')
collection_original.hide = False
collection_original.hide_select = True
collection_original.enabled = True
collection_original.selectable = False
self.assertTrue(self.move_into('Layer 1.3.dog', 'Layer 1.C.1'))
self.compare_tree_maps()
@@ -63,8 +63,8 @@ class UnitTesting(MoveLayerCollectionTesting):
# we expect the settings to be carried along from the
# original layer collection
collection_new = self.parse_move('Layer 1.C.1.dog')
self.assertEqual(collection_new.hide, False)
self.assertEqual(collection_new.hide_select, True)
self.assertEqual(collection_new.enabled, True)
self.assertEqual(collection_new.selectable, False)
# ############################################################

View File

@@ -24,11 +24,11 @@ class UnitTesting(ViewLayerTesting):
scene = bpy.context.scene
hide_lookup = [0, 1, 1, 0]
hide_lookup_sub = [1, 0, 1]
enabled_lookup = [True, False, False, True]
enabled_lookup_sub = [False, True, False]
hide_select_lookup = [0, 0, 1, 1]
hide_select_lookup_sub = [1, 0, 1, 0]
selectable_lookup = [True, True, False, False]
selectable_lookup_sub = [False, True, False, True]
new_collections = []
# clean everything
@@ -50,12 +50,12 @@ class UnitTesting(ViewLayerTesting):
layer.collections.link(collection)
self.assertEqual(layer.collections[-1], layer.collections[i])
layer.collections[i].hide = hide_lookup[i]
layer.collections[i].hide_select = hide_select_lookup[i]
layer.collections[i].enabled = enabled_lookup[i]
layer.collections[i].selectable = selectable_lookup[i]
for j, sub_collection in enumerate(layer.collections[i].collections):
sub_collection.hide = hide_lookup_sub[j]
sub_collection.hide_select = hide_select_lookup_sub[j]
sub_collection.enabled = enabled_lookup_sub[j]
sub_collection.selectable = selectable_lookup_sub[j]
# copy scene
bpy.ops.scene.new(type='FULL_COPY')
@@ -71,13 +71,13 @@ class UnitTesting(ViewLayerTesting):
for i, collection in enumerate(layer.collections):
new_collection = new_layer.collections[i]
self.assertEqual(collection.hide, new_collection.hide)
self.assertEqual(collection.hide_select, new_collection.hide_select)
self.assertEqual(collection.enabled, new_collection.enabled)
self.assertEqual(collection.selectable, new_collection.selectable)
for j, sub_collection in enumerate(layer.collections[i].collections):
new_sub_collection = new_collection.collections[j]
self.assertEqual(sub_collection.hide, new_sub_collection.hide)
self.assertEqual(sub_collection.hide_select, new_sub_collection.hide_select)
self.assertEqual(sub_collection.enabled, new_sub_collection.enabled)
self.assertEqual(sub_collection.selectable, new_sub_collection.selectable)
# ############################################################