Skip to content

Commit

Permalink
blender: Fetch camera based on selected camera name
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vkoskiv committed Oct 28, 2024
1 parent a86e8b9 commit e90bc6c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bindings/blender_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def view_draw(self, context, depsgraph):
self.tag_update()
new_dims = (context.region.width, context.region.height)
if not self.old_dims or self.old_dims != new_dims:
cr_cam = self.cr_scene.cameras['Camera']
cr_cam = self.cr_scene.cameras[context.scene.camera.name]
cr_cam.opts.res_x = context.region.width
cr_cam.opts.res_y = context.region.height
self.cr_renderer.restart()
Expand Down Expand Up @@ -429,7 +429,11 @@ def view_update(self, context, depsgraph):
self.cr_renderer.prefs.bounces = depsgraph.scene.c_ray.bounces
self.cr_renderer.prefs.node_list = depsgraph.scene.c_ray.node_list
self.cr_renderer.prefs.is_iterative = 1
cr_cam = self.cr_scene.cameras['Camera']

# For reasons I can't fathom, depsgraph.updates doesn't let us know if the
# viewport camera changed, so we'll just assume that it did and fetch the whole
# thing manually instead.
cr_cam = self.cr_scene.cameras[context.scene.camera.name]
mtx = context.region_data.view_matrix.inverted()
euler = mtx.to_euler('XYZ')
loc = mtx.to_translation()
Expand Down

0 comments on commit e90bc6c

Please sign in to comment.