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

Revert "Use eye transform instead of translation in external_vr" #211

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion app/src/main/cpp/DeviceDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class ImmersiveDisplay {
const double aTopDegrees,
const double aBottomDegrees) = 0;
virtual void SetEyeOffset(const device::Eye aEye, const float aX, const float aY, const float aZ) = 0;
virtual void SetEyeTransform(const device::Eye aEye, const vrb::Matrix& aTransform) = 0;
virtual void SetEyeResolution(const int32_t aWidth, const int32_t aHeight) = 0;
virtual void SetNativeFramebufferScaleFactor(const float aScale) = 0;
virtual void SetStageSize(const float aWidth, const float aDepth) = 0;
Expand Down
17 changes: 7 additions & 10 deletions app/src/main/cpp/ExternalVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ struct ExternalVR::State {
mozilla::gfx::VRSystemState system = {};
mozilla::gfx::VRBrowserState browser = {};
// device::CapabilityFlags deviceCapabilities = 0;
vrb::Matrix eyeTransforms[device::EyeCount];
vrb::Vector eyeOffsets[device::EyeCount];
uint64_t lastFrameId = 0;
bool firstPresentingFrame = false;
bool compositorEnabled = true;
Expand Down Expand Up @@ -325,16 +325,13 @@ ExternalVR::SetFieldOfView(const device::Eye aEye, const double aLeftDegrees,

void
ExternalVR::SetEyeOffset(const device::Eye aEye, const float aX, const float aY, const float aZ) {
SetEyeTransform(aEye, vrb::Matrix::Translation(vrb::Vector(aX, aY, aZ)));
}

void
ExternalVR::SetEyeTransform(const device::Eye aEye, const vrb::Matrix& aTransform) {
mozilla::gfx::VRDisplayState::Eye which = (aEye == device::Eye::Right
? mozilla::gfx::VRDisplayState::Eye_Right
: mozilla::gfx::VRDisplayState::Eye_Left);
memcpy(&(m.system.displayState.eyeTransform[which]), aTransform.Data(), sizeof(m.system.displayState.eyeTransform[which]));
m.eyeTransforms[device::EyeIndex(aEye)] = aTransform;
m.system.displayState.eyeTranslation[which].x = aX;
m.system.displayState.eyeTranslation[which].y = aY;
m.system.displayState.eyeTranslation[which].z = aZ;
m.eyeOffsets[device::EyeIndex(aEye)].Set(aX, aY, aZ);
}

void
Expand Down Expand Up @@ -469,8 +466,8 @@ ExternalVR::PushFramePoses(const vrb::Matrix& aHeadTransform, const std::vector<
m.system.sensorState.inputFrameID++;
m.system.displayState.lastSubmittedFrameId = m.lastFrameId;

vrb::Matrix leftView = m.eyeTransforms[device::EyeIndex(device::Eye::Left)].Inverse().PostMultiply(inverseHeadTransform);
vrb::Matrix rightView = m.eyeTransforms[device::EyeIndex(device::Eye::Right)].Inverse().PostMultiply(inverseHeadTransform);
vrb::Matrix leftView = vrb::Matrix::Position(-m.eyeOffsets[device::EyeIndex(device::Eye::Left)]).PostMultiply(inverseHeadTransform);
vrb::Matrix rightView = vrb::Matrix::Position(-m.eyeOffsets[device::EyeIndex(device::Eye::Right)]).PostMultiply(inverseHeadTransform);
memcpy(&(m.system.sensorState.leftViewMatrix), leftView.Data(),
sizeof(m.system.sensorState.leftViewMatrix));
memcpy(&(m.system.sensorState.rightViewMatrix), rightView.Data(),
Expand Down
1 change: 0 additions & 1 deletion app/src/main/cpp/ExternalVR.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class ExternalVR : public ImmersiveDisplay {
const double aBottomDegrees) override;
void SetEyeOffset(const device::Eye aEye, const float aX, const float aY, const float aZ) override;
void SetEyeResolution(const int32_t aX, const int32_t aY) override;
void SetEyeTransform(const device::Eye aEye, const vrb::Matrix& aTransform) override;
void SetNativeFramebufferScaleFactor(const float aScale) override;
void SetStageSize(const float aWidth, const float aDepth) override;
void SetSittingToStandingTransform(const vrb::Matrix& aTransform) override;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/cpp/moz_external_vr.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace gfx {
// running at the same time? Or...what if we have multiple
// release builds running on same machine? (Bug 1563232)
#define SHMEM_VERSION "0.0.11"
static const int32_t kVRExternalVersion = 19;
static const int32_t kVRExternalVersion = 18;

// We assign VR presentations to groups with a bitmask.
// Currently, we will only display either content or chrome.
Expand Down Expand Up @@ -344,7 +344,7 @@ struct VRDisplayState {
VRDisplayCapabilityFlags capabilityFlags;
VRDisplayBlendMode blendMode;
VRFieldOfView eyeFOV[VRDisplayState::NumEyes];
float eyeTransform[VRDisplayState::NumEyes][16];
Point3D_POD eyeTranslation[VRDisplayState::NumEyes];
IntSize_POD eyeResolution;
float nativeFramebufferScaleFactor;
bool suppressFrames;
Expand Down
7 changes: 3 additions & 4 deletions app/src/openxr/cpp/DeviceDelegateOpenXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ DeviceDelegateOpenXR::StartFrame(const FramePrediction aPrediction) {
}
}

// Query eyeTransform and perspective for each view
// Query eyeTransform ans perspective for each view
XrViewState viewState{XR_TYPE_VIEW_STATE};
uint32_t viewCapacityInput = (uint32_t) m.views.size();
uint32_t viewCountOutput = 0;
Expand All @@ -744,10 +744,9 @@ DeviceDelegateOpenXR::StartFrame(const FramePrediction aPrediction) {
for (int i = 0; i < m.views.size(); ++i) {
const XrView &view = m.views[i];
const device::Eye eye = i == 0 ? device::Eye::Left : device::Eye::Right;
vrb::Matrix eyeTransform = XrPoseToMatrix(view.pose);
m.cameras[i]->SetEyeTransform(eyeTransform);
m.cameras[i]->SetEyeTransform(XrPoseToMatrix(view.pose));
if (m.immersiveDisplay) {
m.immersiveDisplay->SetEyeTransform(eye, eyeTransform);
m.immersiveDisplay->SetEyeOffset(eye, view.pose.position.x, view.pose.position.y, view.pose.position.z);
}
}
}
Expand Down