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
@ -284,7 +284,8 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern):
|
|||||||
camera = bpy.data.objects[render_context.camera, None]
|
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
|
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)
|
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
|
camera.location = loc
|
||||||
# Set camera clipping accordingly to computed bbox.
|
# Set camera clipping accordingly to computed bbox.
|
||||||
min_dist = 1e24
|
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_start = min_dist / 2
|
||||||
camera.data.clip_end = max_dist * 2
|
camera.data.clip_end = max_dist * 2
|
||||||
if light:
|
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
|
light.location = loc
|
||||||
scene.update()
|
bpy.context.view_layer.update()
|
||||||
|
|
||||||
bpy.ops.render.render(write_still=True)
|
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:
|
if obname not in scene.objects:
|
||||||
scene.collection.objects.link(ob)
|
scene.collection.objects.link(ob)
|
||||||
ob.hide_render = False
|
ob.hide_render = False
|
||||||
scene.update()
|
bpy.context.view_layer.update()
|
||||||
|
|
||||||
preview_render_do(render_context, 'objects', root.name, objects)
|
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)
|
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_ob = next((ob for ob in scene.objects if ob.instance_collection and ob.instance_collection.name == grp.name))
|
||||||
grp_obname = grp_ob.name
|
grp_obname = grp_ob.name
|
||||||
scene.update()
|
bpy.context.view_layer.update()
|
||||||
|
|
||||||
offset_matrix = Matrix.Translation(grp.instance_offset).inverted()
|
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
|
has_camera = scene.camera is not None
|
||||||
bpy.context.window.scene = scene
|
bpy.context.window.scene = scene
|
||||||
render_context = render_context_create('__SCENE', objects_ignored)
|
render_context = render_context_create('__SCENE', objects_ignored)
|
||||||
scene.update()
|
bpy.context.view_layer.update()
|
||||||
|
|
||||||
objects = None
|
objects = None
|
||||||
if not has_camera:
|
if not has_camera:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user