Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine field-of-vision and projection matrix, to fix Oculus distortions #134

Merged
merged 1 commit into from
May 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,13 @@ struct DeviceDelegateOculusVR::State {
float fovX = vrapi_GetSystemPropertyFloat(&java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_X);
float fovY = vrapi_GetSystemPropertyFloat(&java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_Y);

ovrMatrix4f projection = ovrMatrix4f_CreateProjectionFov(fovX, fovY, 0.0, 0.0, near, far);
auto matrix = vrb::Matrix::FromRowMajor(projection.M);
ovrMatrix4f fov = ovrMatrix4f_CreateProjectionFov(fovX, fovY, 0.0, 0.0, near, far);
auto fovMatrix = vrb::Matrix::FromRowMajor(fov.M);
for (int i = 0; i < VRAPI_EYE_COUNT; ++i) {
cameras[i]->SetPerspective(matrix);
ovrMatrix4f projection = predictedTracking.Eye[i].ProjectionMatrix;
auto projectionMatrix = vrb::Matrix::FromRowMajor(projection.M);
auto perspectiveMatrix = projectionMatrix.PostMultiply(fovMatrix);
cameras[i]->SetPerspective(perspectiveMatrix);
}

if (immersiveDisplay) {
Expand Down Expand Up @@ -1032,6 +1035,8 @@ DeviceDelegateOculusVR::StartFrame(const FramePrediction aPrediction) {
m.immersiveDisplay->SetCapabilityFlags(caps);
}

m.UpdatePerspective();

int lastReorientCount = m.reorientCount;
m.UpdateControllers(head);
bool reoriented = lastReorientCount != m.reorientCount && lastReorientCount > 0 && m.reorientCount > 0;
Expand Down