diff --git a/orthographic/camera.lua b/orthographic/camera.lua index ffa1910..34b3d8c 100644 --- a/orthographic/camera.lua +++ b/orthographic/camera.lua @@ -727,6 +727,10 @@ function M.window_to_world(camera_id, window) local view = camera.view or MATRIX4 local projection = camera.projection or MATRIX4 local viewport = camera.viewport or VECTOR4 + local viewport_width = viewport.z * DISPLAY_WIDTH / WINDOW_WIDTH + local viewport_height = viewport.w * DISPLAY_HEIGHT / WINDOW_HEIGHT + local viewport_left = viewport.x * DISPLAY_WIDTH / WINDOW_WIDTH + local viewport_bottom = viewport.y * DISPLAY_HEIGHT / WINDOW_HEIGHT local scale_x = window.x * dpi_ratio * DISPLAY_WIDTH / WINDOW_WIDTH local scale_y = window.y * dpi_ratio * DISPLAY_HEIGHT / WINDOW_HEIGHT @@ -823,7 +827,6 @@ function M.screen_to_world_bounds(camera_id) local camera = cameras[camera_id] local view = camera.view or MATRIX4 local projection = camera.projection or MATRIX4 - local viewport = camera.viewport or VECTOR4 local inv = vmath.inv(projection * view) local bl_x, bl_y = unproject_xyz(inv, 0, 0, 0) local br_x, br_y = unproject_xyz(inv, DISPLAY_WIDTH, 0, 0)