Skip to content

Commit e90bc6c

Browse files
committed
blender: Fetch camera based on selected camera name
It was hardcoded to get the one called 'Camera', which won't work when the selected camera is not that, or one doesn't exist with that name.
1 parent a86e8b9 commit e90bc6c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

bindings/blender_init.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def view_draw(self, context, depsgraph):
369369
self.tag_update()
370370
new_dims = (context.region.width, context.region.height)
371371
if not self.old_dims or self.old_dims != new_dims:
372-
cr_cam = self.cr_scene.cameras['Camera']
372+
cr_cam = self.cr_scene.cameras[context.scene.camera.name]
373373
cr_cam.opts.res_x = context.region.width
374374
cr_cam.opts.res_y = context.region.height
375375
self.cr_renderer.restart()
@@ -429,7 +429,11 @@ def view_update(self, context, depsgraph):
429429
self.cr_renderer.prefs.bounces = depsgraph.scene.c_ray.bounces
430430
self.cr_renderer.prefs.node_list = depsgraph.scene.c_ray.node_list
431431
self.cr_renderer.prefs.is_iterative = 1
432-
cr_cam = self.cr_scene.cameras['Camera']
432+
433+
# For reasons I can't fathom, depsgraph.updates doesn't let us know if the
434+
# viewport camera changed, so we'll just assume that it did and fetch the whole
435+
# thing manually instead.
436+
cr_cam = self.cr_scene.cameras[context.scene.camera.name]
433437
mtx = context.region_data.view_matrix.inverted()
434438
euler = mtx.to_euler('XYZ')
435439
loc = mtx.to_translation()

0 commit comments

Comments
 (0)