Update for Depsgraph API changes master
authorPhilipp Oeser <info@graphics-engineer.com>
Fri, 17 May 2019 13:39:43 +0000 (15:39 +0200)
committerPhilipp Oeser <info@graphics-engineer.com>
Fri, 17 May 2019 13:56:45 +0000 (15:56 +0200)
Reviewers: sergey

Differential Revision: https://developer.blender.org/D4885

add_dimension.py
cmu_mocap_browser/makehuman.py
io_scene_fpx/fpx_import.py
io_scene_fpx/fpx_ui.py
np_station/np_point_array.py
np_station/np_point_copy.py
np_station/np_point_instance.py
np_station/np_shader_brush.py
space_view3d_enhanced_3d_cursor.py

index bd8f78f..b716584 100644 (file)
@@ -1472,7 +1472,7 @@ def setBezierHandles(obj, mode = 'VECTOR'):
     bpy.ops.curve.select_all(action = 'SELECT')
     bpy.ops.curve.handle_type_set(type = mode)
     bpy.ops.object.mode_set(mode = 'OBJECT', toggle = True)
-    bpy.context.scene.update()
+    view_layer.update()
 
 ##------------------------------------------------------------
 #### Add units
@@ -1767,13 +1767,13 @@ def createCurve(vertArray, self, align_matrix):
         const =  DimensionCurve.constraints.new(type='CHILD_OF')
         const.target =  bpy.data.objects[self.Dimension_parent]
         const.inverse_matrix = bpy.data.objects[self.Dimension_parent].matrix_world.inverted()
-        bpy.context.scene.update()
+        bpy.context.view_layer.update()
 
     bpy.ops.object.select_all(action='DESELECT')
     DimensionCurve.select_set(True)
     DimensionText.select_set(True)
     bpy.context.view_layer.objects.active = DimensionCurve
-    bpy.context.scene.update()
+    bpy.context.view_layer.update()
 
     DimensionCurve["Dimension_Name"] = self.Dimension_Name
     DimensionCurve["Dimension_Type"] = self.Dimension_Type
@@ -2063,12 +2063,12 @@ def main(self, align_matrix):
 #### Delete dimension group
 def DimensionDelete(self, context):
 
-    bpy.context.scene.update()
+    bpy.context.view_layer.update()
     bpy.ops.object.mode_set(mode = 'OBJECT')
 
     bpy.ops.object.select_grouped(extend=True, type='CHILDREN_RECURSIVE')
     bpy.ops.object.delete()
-    bpy.context.scene.update()
+    bpy.context.view_layer.update()
 
     return
 
@@ -2653,7 +2653,7 @@ class Dimension(bpy.types.Operator):
         #go to object mode
         if bpy.ops.object.mode_set.poll():
             bpy.ops.object.mode_set(mode = 'OBJECT')
-            bpy.context.scene.update()
+            bpy.context.view_layer.update()
 
         # turn off undo
         undo = bpy.context.preferences.edit.use_global_undo
@@ -2670,7 +2670,7 @@ class Dimension(bpy.types.Operator):
 
     ##### INVOKE #####
     def invoke(self, context, event):
-        bpy.context.scene.update()
+        bpy.context.view_layer.update()
         if self.Dimension_Change:
             bpy.context.scene.cursor.location = self.Dimension_startlocation
         else:
index 381d598..4110f72 100644 (file)
@@ -215,7 +215,7 @@ class CMUMocapTransferer(bpy.types.Operator):
             self.dst.pose.bones[db].matrix = S * self.inverses[db]
             self.dst.pose.bones[db].keyframe_insert('rotation_quaternion', -1, frame, db)
             self.dst.pose.bones[db].keyframe_insert('location', -1, frame, db)
-            bpy.context.scene.update()  # recalculate constraints
+            bpy.context.view_layer.update()  # recalculate constraints
         # get locrot of fk bones and locally set them
         # ... TODO
 #        bpy.ops.anim.keyframe_insert_menu(type='BUILTIN_KSI_LocRot')
index e7212e3..409198c 100644 (file)
@@ -1419,7 +1419,7 @@ class FptImporter():
 
         blender_object.select_set(True)
         self.__view_layer.objects.active = blender_object
-        self.__scene.update()
+        self.__view_layer.update()
         if ops.object.convert.poll():
             ops.object.convert()
 
@@ -1649,7 +1649,7 @@ class FptImporter():
             cu.texspace_size = Vector((self.__table_width / 2.0, self.__table_length / 2.0, 0))
         else:
             cu.use_auto_texspace = False
-            self.__scene.update()
+            self.__view_layer.update()
             cu.texspace_location = Vector(obj.bound_box[0]) + (obj.dimensions / 2.0)
             cu.texspace_size = Vector(obj.dimensions / 2.0)
 
@@ -1819,7 +1819,7 @@ class FptImporter():
             cu.texspace_size = Vector((self.__table_width / 2.0, self.__table_length / 2.0, 0))
         else:
             cu.use_auto_texspace = False
-            self.__scene.update()
+            self.__view_layer.update()
             cu.texspace_location = Vector(obj.bound_box[0]) + (obj.dimensions / 2.0)
             cu.texspace_size = Vector(obj.dimensions / 2.0)
 
@@ -1873,14 +1873,14 @@ class FptImporter():
                 cu.texspace_size = Vector((self.__table_width / 2.0, self.__table_length / 2.0, 0))
             else:
                 cu.use_auto_texspace = False
-                self.__scene.update()
+                self.__view_layer.update()
                 cu.texspace_location = Vector(obj.bound_box[0]) + (obj.dimensions / 2.0)
                 cu.texspace_size = Vector(obj.dimensions / 2.0)
         else:
             self.append_texture_material(obj, DEFAULT_LAMP_TEXTURE, light_on=True)
             cu.use_auto_texspace = False
             #obj.update_from_editmode()
-            self.__scene.update()
+            self.__view_layer.update()
             cu.texspace_location = Vector(obj.bound_box[0]) + (obj.dimensions / 2.0)
             size = max(obj.dimensions)
             cu.texspace_size = (size, size, 0)
@@ -1919,14 +1919,14 @@ class FptImporter():
                 cu.texspace_size = Vector((self.__table_width / 2.0, self.__table_length / 2.0, 0))
             else:
                 cu.use_auto_texspace = False
-                self.__scene.update()
+                self.__view_layer.update()
                 cu.texspace_location = Vector(obj.bound_box[0]) + (obj.dimensions / 2.0)
                 cu.texspace_size = Vector(obj.dimensions / 2.0)
         else:
             self.append_texture_material(obj, DEFAULT_LAMP_TEXTURE, light_on=True)
             cu.use_auto_texspace = False
             #obj.update_from_editmode()
-            self.__scene.update()
+            self.__view_layer.update()
             cu.texspace_location = Vector(obj.bound_box[0]) + (obj.dimensions / 2.0)
             size = max(obj.dimensions)
             cu.texspace_size = (size, size, 0)
@@ -3159,7 +3159,7 @@ def adjust_position(blender_context, blender_scene, fpx_model, fpx_model_type=No
     if blender_location:
         blender_view_layer.objects.active = blender_parent
         blender_view_layer.objects.active.location = blender_location
-        blender_scene.update()
+        blender_view_layer.update()
 
 def remove_material(blender_context):
     if not blender_context.active_object:
index 50e8a59..6fb63e1 100644 (file)
@@ -391,7 +391,8 @@ class FpmImportOperator(Operator, ImportHelper):
 
         for scene in blender_context.blend_data.scenes:
             scene.layers = (True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False)
-            scene.update()
+            for view_layer in scene.view_layers:
+                view_layer.update()
 
         return {"FINISHED"}
 
@@ -602,7 +603,8 @@ class FplImportOperator(Operator, ImportHelper):
 
         for scene in blender_context.blend_data.scenes:
             scene.layers = (True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False)
-            scene.update()
+            for view_layer in scene.view_layers:
+                view_layer.update()
 
         return {"FINISHED"}
 
@@ -914,7 +916,8 @@ class FptImportOperator(Operator, ImportHelper):
 
         for scene in blender_context.blend_data.scenes:
             scene.layers = (True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False)
-            scene.update()
+            for view_layer in scene.view_layers:
+                view_layer.update()
 
         return {"FINISHED"}
 
index 8d12a3d..b708b64 100644 (file)
@@ -740,7 +740,7 @@ class NPPAArrayTranslate(bpy.types.Operator):
                 ardict[ob][2] = count
             NP020PA.fit_type = ar.fit_type
             NP020PA.count = count
-            bpy.context.scene.update()
+            bpy.context.view_layer.update()
 
         elif event.ctrl and event.type == 'WHEELDOWNMOUSE' or event.type == 'DOWN_ARROW' and event.value == 'PRESS':
             for ob in arob:
@@ -761,7 +761,7 @@ class NPPAArrayTranslate(bpy.types.Operator):
                 ardict[ob][2] = count
             NP020PA.fit_type = ar.fit_type
             NP020PA.count = count
-            bpy.context.scene.update()
+            bpy.context.view_layer.update()
 
         elif event.type in ('RET', 'NUMPAD_ENTER') and event.value == 'PRESS':
             bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
index 969c0cc..b082ed0 100644 (file)
@@ -819,7 +819,7 @@ class NPPCArrayTranslate(bpy.types.Operator):
                 ardict[ob][2] = count
             NP020PC.fit_type = ar.fit_type
             NP020PC.count = count
-            bpy.context.scene.update()
+            bpy.context.view_layer.update()
 
         elif event.ctrl and event.type == 'WHEELDOWNMOUSE' or event.type == 'DOWN_ARROW' and event.value == 'PRESS':
             for ob in arob:
@@ -840,7 +840,7 @@ class NPPCArrayTranslate(bpy.types.Operator):
                 ardict[ob][2] = count
             NP020PC.fit_type = ar.fit_type
             NP020PC.count = count
-            bpy.context.scene.update()
+            bpy.context.view_layer.update()
 
         elif event.type in ('RET', 'NUMPAD_ENTER') and event.value == 'PRESS':
             bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
index 715b754..cb4921b 100644 (file)
@@ -829,7 +829,7 @@ class NPPIArrayTranslate(bpy.types.Operator):
                 ardict[ob][2] = count
             NP020PI.fit_type = ar.fit_type
             NP020PI.count = count
-            bpy.context.scene.update()
+            bpy.context.view_layer.update()
 
         elif event.ctrl and event.type == 'WHEELDOWNMOUSE' or event.type == 'DOWN_ARROW' and event.value == 'PRESS':
             for ob in arob:
@@ -850,7 +850,7 @@ class NPPIArrayTranslate(bpy.types.Operator):
                 ardict[ob][2] = count
             NP020PI.fit_type = ar.fit_type
             NP020PI.count = count
-            bpy.context.scene.update()
+            bpy.context.view_layer.update()
 
         elif event.type in ('RET', 'NUMPAD_ENTER') and event.value == 'PRESS':
             bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
index 1ea55e0..248474f 100644 (file)
@@ -97,7 +97,7 @@ def draw_callback1_px(self, context):
                     if self.shader is not None:
                         ob.data.materials.append(self.shader)
             bpy.context.view_layer.objects.active = acob
-            #bpy.context.scene.update()
+            #bpy.context.view_layer.update()
             np_print('040')
 
     elif mode == 5:
index 42d70e5..2e06505 100644 (file)
@@ -3198,7 +3198,7 @@ class MeshCache:
         # Make Blender recognize object as having geometry
         # (is there a simpler way to do this?)
         self.collection.objects.link(tmp_obj)
-        self.scene.update()
+        bpy.context.view_layer.update()
         # We don't need this object in scene
         self.collection.objects.unlink(tmp_obj)