fix: align Quest projection bounds

This commit is contained in:
XxJSONDeruloxX committed 2026-10-15 21:37:35 -04:00
1 parent 16e083545b
commit a5d2b01635
4 files changed
+23 -2

No files matched your search

+1 -2
View File
@@ -656,8 +656,7 @@ public:
DroidDeckXrTracking xr;
if (xrMode_ && xr_.Read(&xr) && XrTrackingFile::Fresh(xr)) {
const float *fov = xr.eyes[eye == Eye_Right ? 1 : 0].fov;
*left = std::tan(fov[0]); *right = std::tan(fov[1]);
*top = -std::tan(fov[2]); *bottom = -std::tan(fov[3]);
xr_frame_projection_raw(fov, left, right, top, bottom);
return;
}
*left = -tanHalf_ * eyeAspect_; *right = tanHalf_ * eyeAspect_;
+6
View File
@@ -7,6 +7,12 @@ struct DroidDeckXrRenderView {
float fov[4];
};
inline void xr_frame_projection_raw(const float fov[4], float *left, float *right, float *top, float *bottom) {
*left = std::tan(fov[0]); *right = std::tan(fov[1]);
// OpenVR's top/bottom parameters are the lower/upper Y bounds in its projection formula.
*top = std::tan(fov[3]); *bottom = std::tan(fov[2]);
}
inline void xr_frame_eye_pose(float result[3][4], const float head[3][4], const float eyeToHead[3][4]) {
for (int row = 0; row < 3; row++) {
for (int column = 0; column < 3; column++) {
+10
View File
@@ -75,6 +75,16 @@ int main(int argc, char **argv) {
valid.projection[0][0][2] = 0.2f; valid.projection[0][1][2] = -0.1f;
view = xr_frame_view(valid, 0);
assert(std::abs(std::tan(view.fov[0]) + 0.8f) < 0.00001f && std::abs(std::tan(view.fov[2]) - 0.9f) < 0.00001f);
float left, right, top, bottom;
xr_frame_projection_raw(view.fov, &left, &right, &top, &bottom);
float xScale = 2 / (right - left), xOffset = (right + left) / (right - left);
float yScale = 2 / (bottom - top), yOffset = (bottom + top) / (bottom - top);
assert(std::abs(xScale - valid.projection[0][0][0]) < 0.00001f);
assert(std::abs(yScale - valid.projection[0][1][1]) < 0.00001f);
assert(std::abs(xOffset - valid.projection[0][0][2]) < 0.00001f);
assert(std::abs(yOffset - valid.projection[0][1][2]) < 0.00001f);
assert(std::abs(yScale * std::tan(view.fov[2]) - yOffset - 1) < 0.00001f);
assert(std::abs(yScale * std::tan(view.fov[3]) - yOffset + 1) < 0.00001f);
XrFrameReceiver receiver; assert(receiver.Start(socketPath));
struct stat status{}; assert(stat(socketPath.c_str(), &status) == 0 && (status.st_mode & 0777) == 0600);
XrFrameReceiver other; assert(!other.Start(socketPath));