Fix T64827: "Batch-Generate Previews" crashes.
Missed when py API for depsgraph was changed... tsst... Based on D4917 by @lichtwerk, thanks.
This commit is contained in:
parent
c0c2f8663e
commit
1d2e4c44bd
Notes:
blender-bot
2023-02-14 06:00:44 +01:00
Referenced by issue #64827, "Batch-Generate Previews" crashes
|
@ -284,7 +284,8 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
|
|||
camera = bpy.data.objects[render_context.camera, None]
|
||||
light = bpy.data.objects[render_context.light, None] if render_context.light is not None else None
|
||||
cos = objects_bbox_calc(camera, objects, offset_matrix)
|
||||
loc, _ortho_scale = camera.camera_fit_coords(bpy.context.depsgraph, cos)
|
||||
depsgraph = bpy.context.evaluated_depsgraph_get()
|
||||
loc, _ortho_scale = camera.camera_fit_coords(depsgraph, cos)
|
||||
camera.location = loc
|
||||
# Set camera clipping accordingly to computed bbox.
|
||||
min_dist = 1e24
|
||||
|
@ -298,9 +299,9 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
|
|||
camera.data.clip_start = min_dist / 2
|
||||
camera.data.clip_end = max_dist * 2
|
||||
if light:
|
||||
loc, _ortho_scale = light.camera_fit_coords(bpy.context.depsgraph, cos)
|
||||
loc, _ortho_scale = light.camera_fit_coords(depsgraph, cos)
|
||||
light.location = loc
|
||||
scene.update()
|
||||
bpy.context.view_layer.update()
|
||||
|
||||
bpy.ops.render.render(write_still=True)
|
||||
|
||||
|
@ -350,7 +351,7 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
|
|||
if obname not in scene.objects:
|
||||
scene.collection.objects.link(ob)
|
||||
ob.hide_render = False
|
||||
scene.update()
|
||||
bpy.context.view_layer.update()
|
||||
|
||||
preview_render_do(render_context, 'objects', root.name, objects)
|
||||
|
||||
|
@ -392,7 +393,7 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
|
|||
bpy.ops.object.collection_instance_add(collection=grp.name)
|
||||
grp_ob = next((ob for ob in scene.objects if ob.instance_collection and ob.instance_collection.name == grp.name))
|
||||
grp_obname = grp_ob.name
|
||||
scene.update()
|
||||
bpy.context.view_layer.update()
|
||||
|
||||
offset_matrix = Matrix.Translation(grp.instance_offset).inverted()
|
||||
|
||||
|
@ -411,7 +412,7 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
|
|||
has_camera = scene.camera is not None
|
||||
bpy.context.window.scene = scene
|
||||
render_context = render_context_create('__SCENE', objects_ignored)
|
||||
scene.update()
|
||||
bpy.context.view_layer.update()
|
||||
|
||||
objects = None
|
||||
if not has_camera:
|
||||
|
|
Loading…
Reference in New Issue