From 4e53406ec5800b440b5cf1eb366c2875c9c727e0 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Thu, 26 Jun 2025 18:54:09 +0200 Subject: [PATCH] Failsafe in foveation for weird application FoV --- server/driver/wivrn_foveation.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/driver/wivrn_foveation.cpp b/server/driver/wivrn_foveation.cpp index 717aaacc..3c6da424 100644 --- a/server/driver/wivrn_foveation.cpp +++ b/server/driver/wivrn_foveation.cpp @@ -173,7 +173,11 @@ static float angles_to_center(float e, float l, float r) e = tan(e); l = tan(l); r = tan(r); - return (e - l) / (r - l) * 2 - 1; + float res = (e - l) / (r - l) * 2 - 1; + // If the center isn't in the FoV, fallback to middle of image + if (res < -1 or res > 1 or std::isnan(res)) + return 0; + return res; } static float convergence_angle(float distance, float eye_x, float gaze_yaw)