[Bf-blender-cvs] [33e8db94b1e] master: Fix (unreported) missing updates in scripts/docs after `scene.update()` removal.

Bastien Montagne noreply at git.blender.org
Tue Jun 4 14:40:39 CEST 2019


Commit: 33e8db94b1e7df2bd7fdbf15b96368c8d16d3b4e
Author: Bastien Montagne
Date:   Tue Jun 4 14:36:53 2019 +0200
Branches: master
https://developer.blender.org/rB33e8db94b1e7df2bd7fdbf15b96368c8d16d3b4e

Fix (unreported) missing updates in scripts/docs after `scene.update()` removal.

This should really have been done together with API changes, simple
usage of grep does the trick to catch most places needing updates.

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

M	doc/python_api/rst/info_gotcha.rst
M	release/scripts/modules/bpy/ops.py
M	release/scripts/templates_py/background_job.py
M	tests/python/view_layer/test_background_set.py
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_evaluation_visibility_j.py
M	tests/python/view_layer/test_group_a.py
M	tests/python/view_layer/test_group_b.py
M	tests/python/view_layer/test_group_c.py
M	tests/python/view_layer/test_group_e.py
M	tests/python/view_layer/test_make_single_user.py
M	tests/python/view_layer/test_scene_collection_delete.py
M	tests/python/view_layer/test_scene_copy_f.py
M	tests/python/view_layer/view_layer_common.py

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

diff --git a/doc/python_api/rst/info_gotcha.rst b/doc/python_api/rst/info_gotcha.rst
index fd978e235c1..df4cd0d256b 100644
--- a/doc/python_api/rst/info_gotcha.rst
+++ b/doc/python_api/rst/info_gotcha.rst
@@ -102,16 +102,16 @@ To avoid expensive recalculations every time a property is modified,
 Blender defers making the actual calculations until they are needed.
 
 However, while the script runs you may want to access the updated values.
-In this case you need to call :class:`bpy.types.Scene.update` after modifying values, for example:
+In this case you need to call :class:`bpy.types.ViewLayer.update` after modifying values, for example:
 
 .. code-block:: python
 
    bpy.context.object.location = 1, 2, 3
-   bpy.context.scene.update()
+   bpy.context.view_layer.update()
 
 
 Now all dependent data (child objects, modifiers, drivers... etc)
-has been recalculated and is available to the script.
+has been recalculated and is available to the script within active view layer.
 
 
 Can I redraw during the script?
diff --git a/release/scripts/modules/bpy/ops.py b/release/scripts/modules/bpy/ops.py
index 41fb0e411de..0697b7fddc9 100644
--- a/release/scripts/modules/bpy/ops.py
+++ b/release/scripts/modules/bpy/ops.py
@@ -160,7 +160,8 @@ class BPyOpsSubModOp:
         else:
             import bpy
             for scene in bpy.data.scenes:
-                scene.update()
+                for view_layer in scene.view_layers:
+                    view_layer.update()
 
     __doc__ = property(_get_doc)
 
diff --git a/release/scripts/templates_py/background_job.py b/release/scripts/templates_py/background_job.py
index c28c7275fce..5410a7d649f 100644
--- a/release/scripts/templates_py/background_job.py
+++ b/release/scripts/templates_py/background_job.py
@@ -48,7 +48,7 @@ def example_function(text, save_path, render_path):
     scene.collection.objects.link(light_ob)
     light_ob.location = 2.0, 2.0, 5.0
 
-    scene.update()
+    bpy.context.view_layer.update()
 
     if save_path:
         bpy.ops.wm.save_as_mainfile(filepath=save_path)
diff --git a/tests/python/view_layer/test_background_set.py b/tests/python/view_layer/test_background_set.py
index a26229d53a9..f522f425920 100644
--- a/tests/python/view_layer/test_background_set.py
+++ b/tests/python/view_layer/test_background_set.py
@@ -25,7 +25,7 @@ class UnitTesting(ViewLayerTesting):
         bpy.context.window.scene = main_scene
 
         # Update depsgraph.
-        main_scene.update()
+        bpy.context.view_layer.update()
 
         # Safety check, there should be no objects in thew newly created scene.
         self.assertEqual(0, len(bpy.context.depsgraph.objects))
@@ -35,7 +35,7 @@ class UnitTesting(ViewLayerTesting):
         background_scene.objects[0].parent = background_scene.objects[1]
 
         # Update depsgraph.
-        main_scene.update()
+        bpy.context.view_layer.update()
 
         # Test if objects were properly added to depsgraph.
         self.assertEqual(3, len(bpy.context.depsgraph.objects))
@@ -50,7 +50,7 @@ class UnitTesting(ViewLayerTesting):
         main_scene.background_set = None
 
         # Update depsgraph.
-        main_scene.update()
+        bpy.context.view_layer.update()
 
         self.assertEqual(0, len(bpy.context.depsgraph.objects))
 
diff --git a/tests/python/view_layer/test_evaluation_selectability_a.py b/tests/python/view_layer/test_evaluation_selectability_a.py
index eaed40869c3..16ad38d1d7e 100644
--- a/tests/python/view_layer/test_evaluation_selectability_a.py
+++ b/tests/python/view_layer/test_evaluation_selectability_a.py
@@ -37,7 +37,7 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_kid = layer.collections.link(scene_collection_kid)
 
         layer_collection_mom.enabled = False
-        bpy.context.scene.update()  # update depsgraph
+        bpy.context.view_layer.update()  # update depsgraph
         cube.select_set(True)
 
         self.assertTrue(cube.visible_get(), "Cube should be visible")
diff --git a/tests/python/view_layer/test_evaluation_selectability_b.py b/tests/python/view_layer/test_evaluation_selectability_b.py
index 584011c672c..3828d2013ff 100644
--- a/tests/python/view_layer/test_evaluation_selectability_b.py
+++ b/tests/python/view_layer/test_evaluation_selectability_b.py
@@ -35,13 +35,13 @@ class UnitTesting(ViewLayerTesting):
 
         layer_collection_mom = layer.collections.link(scene_collection_mom)
         layer_collection_kid = layer.collections.link(scene_collection_kid)
-        bpy.context.scene.update()  # update depsgraph
+        bpy.context.view_layer.update()  # update depsgraph
         cube.select_set(True)
 
         layer_collection_mom.collections[layer_collection_kid.name].enabled = False
         layer_collection_kid.enabled = False
 
-        bpy.context.scene.update()  # update depsgraph
+        bpy.context.view_layer.update()  # update depsgraph
         self.assertFalse(cube.visible_get(), "Cube should be invisible")
         self.assertFalse(cube.select_get(), "Cube should be unselected")
 
diff --git a/tests/python/view_layer/test_evaluation_selectability_c.py b/tests/python/view_layer/test_evaluation_selectability_c.py
index 3eecaa06aeb..91c1c75c1f9 100644
--- a/tests/python/view_layer/test_evaluation_selectability_c.py
+++ b/tests/python/view_layer/test_evaluation_selectability_c.py
@@ -37,7 +37,7 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_kid = layer.collections.link(scene_collection_kid)
 
         layer_collection_mom.enabled = True
-        bpy.context.scene.update()  # update depsgraph
+        layer.update()  # update depsgraph
         cube.select_set(True)
 
         self.assertTrue(cube.visible_get(), "Cube should be visible")
diff --git a/tests/python/view_layer/test_evaluation_selectability_d.py b/tests/python/view_layer/test_evaluation_selectability_d.py
index c645551c5ed..bab3ad8c35a 100644
--- a/tests/python/view_layer/test_evaluation_selectability_d.py
+++ b/tests/python/view_layer/test_evaluation_selectability_d.py
@@ -37,12 +37,12 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_kid = layer.collections.link(scene_collection_kid)
 
         layer_collection_mom.enabled = True
-        bpy.context.scene.update()  # update depsgraph
+        bpy.context.view_layer.update()  # update depsgraph
 
         cube.select_set(True)
         layer_collection_mom.collections[layer_collection_kid.name].selectable = False
 
-        bpy.context.scene.update()  # update depsgraph
+        bpy.context.view_layer.update()  # update depsgraph
         self.assertTrue(cube.visible_get(), "Cube should be visible")
         self.assertTrue(cube.select_get(), "Cube should be selected")
 
diff --git a/tests/python/view_layer/test_evaluation_selectability_e.py b/tests/python/view_layer/test_evaluation_selectability_e.py
index e2f0e911bbe..ff75bdcddfe 100644
--- a/tests/python/view_layer/test_evaluation_selectability_e.py
+++ b/tests/python/view_layer/test_evaluation_selectability_e.py
@@ -41,7 +41,7 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_mom.collections[layer_collection_kid.name].selectable = False
         layer_collection_kid.enabled = False
 
-        bpy.context.scene.update()  # update depsgraph
+        layer.update()  # update depsgraph
         self.assertTrue(cube.visible_get(), "Cube should be visible")
         self.assertFalse(cube.select_get(), "Cube should be unselected")
 
diff --git a/tests/python/view_layer/test_evaluation_selectability_f.py b/tests/python/view_layer/test_evaluation_selectability_f.py
index a902dd1dada..16aa86a0c2a 100644
--- a/tests/python/view_layer/test_evaluation_selectability_f.py
+++ b/tests/python/view_layer/test_evaluation_selectability_f.py
@@ -23,14 +23,14 @@ class UnitTesting(ViewLayerTesting):
         scene_collection = scene.master_collection.collections.new('collection')
         layer_collection = view_layer.collections.link(scene_collection)
 
-        bpy.context.scene.update()  # update depsgraph
+        view_layer.update()  # update depsgraph
 
         scene_collection.objects.link(cube)
 
         self.assertTrue(layer_collection.enabled)
         self.assertTrue(layer_collection.selectable)
 
-        bpy.context.scene.update()  # update depsgraph
+        view_layer.update()  # update depsgraph
         cube.select_set(True)
         self.assertTrue(cube.select_get())
 
diff --git a/tests/python/view_layer/test_evaluation_visibility_a.py b/tests/python/view_layer/test_evaluation_visibility_a.py
index 666513fa85a..13c05c28744 100644
--- a/tests/python/view_layer/test_evaluation_visibility_a.py
+++ b/tests/python/view_layer/test_evaluation_visibility_a.py
@@ -40,7 +40,7 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_mom.enabled = False
         layer_collection_kid.enabled = True
 
-        bpy.context.scene.update()  # update depsgraph
+        layer.update()  # update depsgraph
         self.assertTrue(cube.visible_get(), "Object should be visible")
 
 
diff --git a/tests/python/view_layer/test_evaluation_visibility_b.py b/tests/python/view_layer/test_evaluation_visibility_b.py
index c24b7a73dab..88bf0808d1f 100644
--- a/tests/python/view_layer/test_evaluation_visibility_b.py
+++ b/tests/python/view_layer/test_evaluation_visibility_b.py
@@ -40,7 +40,7 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_mom.collections[layer_collection_kid.name].enabled = False
         layer_collection_kid.enabled = False
 
-        bpy.context.scene.update()  # update depsgraph
+        layer.update()  # update depsgraph
         self.assertFalse(cube.visible_get(), "Object should be invisible")
 
 
diff --git a/tests/python/view_layer/test_evaluation_visibility_c.py b/tests/python/view_layer/test_evaluation_visibility_c.py
index 5a8c6386265..e337a22e561 100644
--- a/tests/python/view_layer/test_evaluation_visibility_c.py
+++ b/tests/python/view_layer/test_evaluation_visibility_c.py
@@ -40,7 +40,7 @@ class UnitTesting(ViewLayerTesting):
         layer_collection_mom.collections[layer_collection_kid.name].enabled = False
         layer_collection_kid.enabled = True
 
-        bpy.context.scene.update()  # update depsgraph
+        lay

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list