Allow -1 to be passed for auto focal length

This commit is contained in:
2025-09-23 15:36:09 +01:00
parent 9fb16a58c4
commit d6a2a8aa44

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);