From a78e97b206b188f3da050888fa8c61b0f237902a Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Mon, 3 Apr 2017 18:42:01 +0200 Subject: Layer/Depsgraph: Update depsgraph for new objects --- source/blender/editors/object/object_add.c | 3 ++ tests/python/render_layer/CMakeLists.txt | 3 ++ tests/python/render_layer/render_layer_common.py | 36 ++++++++++++++++++++++ .../render_layer/test_evaluation_visibility_g.py | 36 ++++++++++++++++++++++ .../render_layer/test_evaluation_visibility_h.py | 36 ++++++++++++++++++++++ .../render_layer/test_evaluation_visibility_i.py | 36 ++++++++++++++++++++++ 6 files changed, 150 insertions(+) create mode 100644 tests/python/render_layer/test_evaluation_visibility_g.py create mode 100644 tests/python/render_layer/test_evaluation_visibility_h.py create mode 100644 tests/python/render_layer/test_evaluation_visibility_i.py diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index ce43f321ec9..adfd213ff3e 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -444,6 +444,9 @@ Object *ED_object_add_type( WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene); + /* TODO(sergey): Use proper flag for tagging here. */ + DAG_id_tag_update(&scene->id, 0); + return ob; } diff --git a/tests/python/render_layer/CMakeLists.txt b/tests/python/render_layer/CMakeLists.txt index 962c1f7da36..a6e159f2f96 100644 --- a/tests/python/render_layer/CMakeLists.txt +++ b/tests/python/render_layer/CMakeLists.txt @@ -64,6 +64,9 @@ RENDER_LAYER_TEST(evaluation_visibility_c) RENDER_LAYER_TEST(evaluation_visibility_d) RENDER_LAYER_TEST(evaluation_visibility_e) RENDER_LAYER_TEST(evaluation_visibility_f) +RENDER_LAYER_TEST(evaluation_visibility_g) +RENDER_LAYER_TEST(evaluation_visibility_h) +RENDER_LAYER_TEST(evaluation_visibility_i) RENDER_LAYER_TEST(evaluation_selectability_a) RENDER_LAYER_TEST(evaluation_selectability_b) RENDER_LAYER_TEST(evaluation_selectability_c) diff --git a/tests/python/render_layer/render_layer_common.py b/tests/python/render_layer/render_layer_common.py index abf0296a5c7..e1785dbd084 100644 --- a/tests/python/render_layer/render_layer_common.py +++ b/tests/python/render_layer/render_layer_common.py @@ -443,6 +443,42 @@ class RenderLayerTesting(unittest.TestCase): ), "Scene dump files differ") + def do_visibility_object_add(self, add_mode): + import bpy + + scene = bpy.context.scene + + # delete all objects of the file + for ob in bpy.data.objects: + bpy.data.objects.remove(ob, do_unlink=True) + + # real test + layer = scene.render_layers.new('Visibility Test') + layer.collections.unlink(layer.collections[0]) + scene.render_layers.active = layer + + scene_collection = scene.master_collection.collections.new("Collection") + layer.collections.link(scene_collection) + + bpy.context.scene.update() # update depsgraph + + self.assertEqual(len(bpy.data.objects), 0) + + # add new objects + if add_mode == 'EMPTY': + bpy.ops.object.add() # 'Empty' + + elif add_mode == 'CYLINDER': + bpy.ops.mesh.primitive_cylinder_add() # 'Cylinder' + + elif add_mode == 'TORUS': + bpy.ops.mesh.primitive_torus_add() # 'Torus' + + self.assertEqual(len(bpy.data.objects), 1) + + new_ob = bpy.data.objects[0] + self.assertTrue(new_ob.visible_get(), "Object should be visible") + def cleanup_tree(self): """ Remove any existent layer and collections, diff --git a/tests/python/render_layer/test_evaluation_visibility_g.py b/tests/python/render_layer/test_evaluation_visibility_g.py new file mode 100644 index 00000000000..434ec86707e --- /dev/null +++ b/tests/python/render_layer/test_evaluation_visibility_g.py @@ -0,0 +1,36 @@ +# ############################################################ +# Importing - Same For All Render Layer Tests +# ############################################################ + +import unittest +import os +import sys + +sys.path.append(os.path.dirname(__file__)) +from render_layer_common import * + + +# ############################################################ +# Testing +# ############################################################ + +class UnitTesting(RenderLayerTesting): + def test_visibility_empty(self): + """ + See if the depsgraph evaluation is correct + """ + self.do_visibility_object_add('EMPTY') + + +# ############################################################ +# Main - Same For All Render Layer Tests +# ############################################################ + +if __name__ == '__main__': + import sys + + extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [] + sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 2:] if "--" in sys.argv else []) + + UnitTesting._extra_arguments = extra_arguments + unittest.main() diff --git a/tests/python/render_layer/test_evaluation_visibility_h.py b/tests/python/render_layer/test_evaluation_visibility_h.py new file mode 100644 index 00000000000..05b77e72842 --- /dev/null +++ b/tests/python/render_layer/test_evaluation_visibility_h.py @@ -0,0 +1,36 @@ +# ############################################################ +# Importing - Same For All Render Layer Tests +# ############################################################ + +import unittest +import os +import sys + +sys.path.append(os.path.dirname(__file__)) +from render_layer_common import * + + +# ############################################################ +# Testing +# ############################################################ + +class UnitTesting(RenderLayerTesting): + def test_visibility_cylinder(self): + """ + See if the depsgraph evaluation is correct + """ + self.do_visibility_object_add('CYLINDER') + + +# ############################################################ +# Main - Same For All Render Layer Tests +# ############################################################ + +if __name__ == '__main__': + import sys + + extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [] + sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 2:] if "--" in sys.argv else []) + + UnitTesting._extra_arguments = extra_arguments + unittest.main() diff --git a/tests/python/render_layer/test_evaluation_visibility_i.py b/tests/python/render_layer/test_evaluation_visibility_i.py new file mode 100644 index 00000000000..5bc379e3a74 --- /dev/null +++ b/tests/python/render_layer/test_evaluation_visibility_i.py @@ -0,0 +1,36 @@ +# ############################################################ +# Importing - Same For All Render Layer Tests +# ############################################################ + +import unittest +import os +import sys + +sys.path.append(os.path.dirname(__file__)) +from render_layer_common import * + + +# ############################################################ +# Testing +# ############################################################ + +class UnitTesting(RenderLayerTesting): + def test_visibility_torus(self): + """ + See if the depsgraph evaluation is correct + """ + self.do_visibility_object_add('TORUS') + + +# ############################################################ +# Main - Same For All Render Layer Tests +# ############################################################ + +if __name__ == '__main__': + import sys + + extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [] + sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 2:] if "--" in sys.argv else []) + + UnitTesting._extra_arguments = extra_arguments + unittest.main() -- cgit v1.2.3