fix set anim_cam resolution if not there

master
ChristopheSeux 2023-09-28 16:25:58 +02:00
parent 73e82b1cad
commit 3bd39cbed4
1 changed files with 9 additions and 5 deletions

View File

@ -10,8 +10,6 @@ from .. import core
def set_resolution_from_cam_prop(cam=None):
rd = bpy.context.scene.render
if not cam:
cam = bpy.context.scene.camera
if not cam:
@ -19,9 +17,9 @@ def set_resolution_from_cam_prop(cam=None):
res = cam.get('resolution')
if not res:
cam['resolution'] = [rd.resolution_x, rd.resolution_y]
return ('INFO', 'Cam resolution set from scene')
return ('ERROR', 'Cam has no resolution attribute')
rd = bpy.context.scene.render
if rd.resolution_x == res[0] and rd.resolution_y == res[1]:
return ('INFO', f'Resolution already at {res[0]}x{res[1]}')
else:
@ -40,6 +38,8 @@ class BPM_OT_swap_cams(Operator):
return True
def execute(self, context):
rd = bpy.context.scene.render
anim_cam = bpy.context.scene.objects.get('anim_cam')
bg_cam = bpy.context.scene.objects.get('bg_cam')
@ -47,12 +47,16 @@ class BPM_OT_swap_cams(Operator):
self.report({'ERROR'}, 'anim_cam or bg_cam is missing')
return {"CANCELLED"}
if anim_cam:
res = anim_cam.get('resolution')
if not res:
anim_cam['resolution'] = [rd.resolution_x, rd.resolution_y]
cam = context.scene.camera
if not cam:
context.scene.camera = anim_cam
set_resolution_from_cam_prop()
return {"FINISHED"}
in_draw = False
if cam.parent and cam.name in ('draw_cam', 'action_cam'):