Skip to content

Commit

Permalink
Fix #111. Active view layer should be recovered after denosising.
Browse files Browse the repository at this point in the history
  • Loading branch information
ucupumar committed May 21, 2024
1 parent 9eee15e commit 86c8857
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bake_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,8 @@ def prepare_composite_settings(res_x=1024, res_y=1024, use_hdr=False):
# Remember original scene
book['ori_scene_name'] = bpy.context.scene.name

# Remember active object since sometimes active object became null after doing the compositing
# Remember active object and view layer
book['ori_viewlayer'] = bpy.context.window.view_layer.name if bpy.context.window.view_layer and is_greater_than_280() else ''
book['ori_object'] = bpy.context.object.name if bpy.context.object else ''

# Check if original viewport is using camera view
Expand Down Expand Up @@ -813,6 +814,12 @@ def recover_composite_settings(book):
if book['ori_camera_view']:
bpy.context.area.spaces[0].region_3d.view_perspective = 'CAMERA'

# Recover view layer
if is_greater_than_280():
ori_viewlayer = bpy.context.scene.view_layers.get(book['ori_viewlayer'])
if ori_viewlayer and bpy.context.window.view_layer != ori_viewlayer:
bpy.context.window.view_layer = ori_viewlayer

# Recover active object
ori_object = bpy.data.objects.get(book['ori_object'])
if ori_object and bpy.context.object != ori_object:
Expand Down

0 comments on commit 86c8857

Please sign in to comment.