Allow -1 to be passed for auto focal length

This commit is contained in:
Camden Dixie O'Brien
2025-09-23 03:17:13 +01:00
parent a6b70503f7
commit 35c6d4a784

View File

@@ -12,6 +12,9 @@ camera_t camera_init(
vec3_t pos, vec3_t target, double fov, uint32_t img_width,
uint32_t img_height, double aperture, double focal_len)
{
if (focal_len = -1)
focal_len = vec3_len(vec3_sub(target, pos));
const double fov_rad = M_PI * fov / 180.0;
const double aspect = (double)img_width / (double)img_height;
const double viewport_height = focal_len * tan(fov_rad / 2);