2017-02-17 13:08:24 +01:00
|
|
|
# ############################################################
|
|
|
|
# Importing - Same For All Render Layer Tests
|
|
|
|
# ############################################################
|
|
|
|
|
|
|
|
import unittest
|
2017-03-22 15:22:58 +01:00
|
|
|
import os
|
|
|
|
import sys
|
2017-02-17 13:08:24 +01:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
from view_layer_common import *
|
2017-02-17 13:08:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
# ############################################################
|
|
|
|
# Testing
|
|
|
|
# ############################################################
|
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
class UnitTesting(ViewLayerTesting):
|
2017-02-17 13:08:24 +01:00
|
|
|
def test_visibility(self):
|
|
|
|
"""
|
2017-03-20 18:06:50 +01:00
|
|
|
See if the depsgraph evaluation is correct
|
2017-02-17 13:08:24 +01:00
|
|
|
"""
|
|
|
|
import bpy
|
|
|
|
|
|
|
|
scene = bpy.context.scene
|
2017-12-01 16:08:45 -02:00
|
|
|
window = bpy.context.window
|
2017-02-17 13:08:24 +01:00
|
|
|
cube = bpy.data.objects.new('guinea pig', bpy.data.meshes.new('mesh'))
|
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
layer = scene.view_layers.new('Visibility Test')
|
2017-02-17 13:08:24 +01:00
|
|
|
layer.collections.unlink(layer.collections[0])
|
2017-12-01 16:08:45 -02:00
|
|
|
window.view_layer = layer
|
2017-02-17 13:08:24 +01:00
|
|
|
|
2017-03-20 18:06:50 +01:00
|
|
|
scene_collection_mom = scene.master_collection.collections.new("Mom")
|
|
|
|
scene_collection_kid = scene_collection_mom.collections.new("Kid")
|
2017-02-17 13:08:24 +01:00
|
|
|
|
|
|
|
scene_collection_kid.objects.link(cube)
|
|
|
|
|
|
|
|
layer_collection_mom = layer.collections.link(scene_collection_mom)
|
|
|
|
layer_collection_kid = layer.collections.link(scene_collection_kid)
|
|
|
|
|
2017-12-14 11:46:49 -02:00
|
|
|
layer_collection_mom.enabled = True
|
|
|
|
layer_collection_mom.collections[layer_collection_kid.name].enabled = False
|
|
|
|
layer_collection_kid.enabled = False
|
2017-02-17 13:08:24 +01:00
|
|
|
|
2019-06-04 14:36:53 +02:00
|
|
|
layer.update() # update depsgraph
|
2017-03-20 18:06:50 +01:00
|
|
|
self.assertFalse(cube.visible_get(), "Object should be invisible")
|
2017-02-17 13:08:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
# ############################################################
|
|
|
|
# Main - Same For All Render Layer Tests
|
|
|
|
# ############################################################
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2017-06-19 16:12:11 +10:00
|
|
|
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
2017-02-17 13:08:24 +01:00
|
|
|
unittest.main()
|