Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Set WebVR sittingToStanding transform. Enabled WebVR neck model for 3…
Browse files Browse the repository at this point in the history
…DOF devices. (#1036)
  • Loading branch information
MortimerGoro authored Mar 22, 2019
1 parent 220fbb4 commit 4d5fb75
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 21 deletions.
5 changes: 3 additions & 2 deletions app/src/googlevr/cpp/DeviceDelegateGoogleVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

namespace {

static const vrb::Vector kAverageHeight(0.0f, 1.7f, 0.0f);
static const int32_t kMaxControllerCount = 2;

struct Controller {
Expand Down Expand Up @@ -391,7 +392,8 @@ DeviceDelegateGoogleVR::RegisterImmersiveDisplay(ImmersiveDisplayPtr aDisplay) {
}

m.immersiveDisplay->SetDeviceName("Daydream");
m.immersiveDisplay->SetCapabilityFlags(device::Position | device::Orientation | device::Present);
m.immersiveDisplay->SetCapabilityFlags(device::Position | device::Orientation | device::Present | device::StageParameters);
m.immersiveDisplay->SetSittingToStandingTransform(vrb::Matrix::Translation(kAverageHeight));
gvr_sizei size = m.GetImmersiveModeSize();
m.immersiveDisplay->SetEyeResolution(size.width / 2, size.height);
m.immersiveDisplay->CompleteEnumeration();
Expand Down Expand Up @@ -469,7 +471,6 @@ DeviceDelegateGoogleVR::ProcessEvents() {

void
DeviceDelegateGoogleVR::StartFrame() {
static const vrb::Vector kAverageHeight(0.0f, 1.7f, 0.0f);
gvr_clock_time_point when = GVR_CHECK(gvr_get_time_point_now());
// 50ms into the future is what GVR docs recommends using for head rotation prediction.
when.monotonic_system_time_nanos += 50000000;
Expand Down
1 change: 1 addition & 0 deletions app/src/main/cpp/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const CapabilityFlags AngularAcceleration = 1 << 5;
const CapabilityFlags LinearAcceleration = 1 << 6;
const CapabilityFlags StageParameters = 1 << 7;
const CapabilityFlags MountDetection = 1 << 8;
const CapabilityFlags PositionEmulated = 1 << 9;
enum class Eye { Left, Right };
enum class RenderMode { StandAlone, Immersive };
const int32_t EyeCount = 2;
Expand Down
1 change: 1 addition & 0 deletions app/src/main/cpp/DeviceDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ImmersiveDisplay {
const double aBottomDegrees) = 0;
virtual void SetEyeOffset(const device::Eye aEye, const float aX, const float aY, const float aZ) = 0;
virtual void SetEyeResolution(const int32_t aWidth, const int32_t aHeight) = 0;
virtual void SetSittingToStandingTransform(const vrb::Matrix& aTransform) = 0;
virtual void CompleteEnumeration() = 0;
};

Expand Down
8 changes: 8 additions & 0 deletions app/src/main/cpp/ExternalVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ ExternalVR::SetCapabilityFlags(const device::CapabilityFlags aFlags) {
if (device::MountDetection & aFlags) {
result |= static_cast<uint16_t>(mozilla::gfx::VRDisplayCapabilityFlags::Cap_MountDetection);
}
if (device::PositionEmulated & aFlags) {
result |= static_cast<uint16_t>(mozilla::gfx::VRDisplayCapabilityFlags::Cap_PositionEmulated);
}
m.deviceCapabilities = aFlags;
m.system.displayState.capabilityFlags = static_cast<mozilla::gfx::VRDisplayCapabilityFlags>(result);
m.system.sensorState.flags = m.system.displayState.capabilityFlags;
Expand Down Expand Up @@ -292,6 +295,11 @@ ExternalVR::SetEyeResolution(const int32_t aWidth, const int32_t aHeight) {
m.system.displayState.eyeResolution.height = aHeight;
}

void
ExternalVR::SetSittingToStandingTransform(const vrb::Matrix& aTransform) {
memcpy(&(m.system.displayState.sittingToStandingTransform), aTransform.Data(), sizeof(m.system.displayState.sittingToStandingTransform));
}

void
ExternalVR::PushSystemState() {
Lock lock(m.data.systemMutex);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/cpp/ExternalVR.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ 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 SetSittingToStandingTransform(const vrb::Matrix& aTransform) override;
void CompleteEnumeration() override;
// ExternalVR interface
void PushSystemState();
Expand Down
35 changes: 20 additions & 15 deletions app/src/main/cpp/moz_external_vr.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enum class GamepadCapabilityFlags : uint16_t;
#endif // MOZILLA_INTERNAL_API
namespace gfx {

static const int32_t kVRExternalVersion = 6;
static const int32_t kVRExternalVersion = 7;

// We assign VR presentations to groups with a bitmask.
// Currently, we will only display either content or chrome.
Expand Down Expand Up @@ -88,26 +88,26 @@ enum class ControllerCapabilityFlags : uint16_t {
/**
* Cap_Position is set if the Gamepad is capable of tracking its position.
*/
Cap_Position = 1 << 1,
Cap_Position = 1 << 1,
/**
* Cap_Orientation is set if the Gamepad is capable of tracking its
* orientation.
*/
Cap_Orientation = 1 << 2,
Cap_Orientation = 1 << 2,
/**
* Cap_AngularAcceleration is set if the Gamepad is capable of tracking its
* angular acceleration.
*/
Cap_AngularAcceleration = 1 << 3,
Cap_AngularAcceleration = 1 << 3,
/**
* Cap_LinearAcceleration is set if the Gamepad is capable of tracking its
* linear acceleration.
*/
Cap_LinearAcceleration = 1 << 4,
Cap_LinearAcceleration = 1 << 4,
/**
* Cap_All used for validity checking during IPC serialization
*/
Cap_All = (1 << 5) - 1
Cap_All = (1 << 5) - 1
};

#endif // ifndef MOZILLA_INTERNAL_API
Expand All @@ -117,52 +117,57 @@ enum class VRDisplayCapabilityFlags : uint16_t {
/**
* Cap_Position is set if the VRDisplay is capable of tracking its position.
*/
Cap_Position = 1 << 1,
Cap_Position = 1 << 1,
/**
* Cap_Orientation is set if the VRDisplay is capable of tracking its
* orientation.
*/
Cap_Orientation = 1 << 2,
Cap_Orientation = 1 << 2,
/**
* Cap_Present is set if the VRDisplay is capable of presenting content to an
* HMD or similar device. Can be used to indicate "magic window" devices that
* are capable of 6DoF tracking but for which requestPresent is not
* meaningful. If false then calls to requestPresent should always fail, and
* getEyeParameters should return null.
*/
Cap_Present = 1 << 3,
Cap_Present = 1 << 3,
/**
* Cap_External is set if the VRDisplay is separate from the device's
* primary display. If presenting VR content will obscure
* other content on the device, this should be un-set. When
* un-set, the application should not attempt to mirror VR content
* or update non-VR UI because that content will not be visible.
*/
Cap_External = 1 << 4,
Cap_External = 1 << 4,
/**
* Cap_AngularAcceleration is set if the VRDisplay is capable of tracking its
* angular acceleration.
*/
Cap_AngularAcceleration = 1 << 5,
Cap_AngularAcceleration = 1 << 5,
/**
* Cap_LinearAcceleration is set if the VRDisplay is capable of tracking its
* linear acceleration.
*/
Cap_LinearAcceleration = 1 << 6,
Cap_LinearAcceleration = 1 << 6,
/**
* Cap_StageParameters is set if the VRDisplay is capable of room scale VR
* and can report the StageParameters to describe the space.
*/
Cap_StageParameters = 1 << 7,
Cap_StageParameters = 1 << 7,
/**
* Cap_MountDetection is set if the VRDisplay is capable of sensing when the
* user is wearing the device.
*/
Cap_MountDetection = 1 << 8,
Cap_MountDetection = 1 << 8,
/**
* Cap_PositionEmulated is set if the VRDisplay is capable of setting a
* neck model in position even if still doesn't support 6DOF tracking.
*/
Cap_PositionEmulated = 1 << 9,
/**
* Cap_All used for validity checking during IPC serialization
*/
Cap_All = (1 << 9) - 1
Cap_All = (1 << 9) - 1
};

#ifdef MOZILLA_INTERNAL_API
Expand Down
7 changes: 6 additions & 1 deletion app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,8 @@ class OculusLayerEquirect: public OculusLayerBase<VRLayerEquirectPtr, ovrLayerEq
};

const vrb::Vector kAverageHeight(0.0f, 1.7f, 0.0f);
// Height used to match Oculus default in WebVR
const vrb::Vector kAverageOculusHeight(0.0f, 1.65f, 0.0f);

struct DeviceDelegateOculusVR::State {
struct ControllerState {
Expand Down Expand Up @@ -996,6 +998,7 @@ DeviceDelegateOculusVR::RegisterImmersiveDisplay(ImmersiveDisplayPtr aDisplay) {
uint32_t width, height;
m.GetImmersiveRenderSize(width, height);
m.immersiveDisplay->SetEyeResolution(width, height);
m.immersiveDisplay->SetSittingToStandingTransform(vrb::Matrix::Translation(kAverageOculusHeight));
m.immersiveDisplay->CompleteEnumeration();

m.UpdatePerspective();
Expand Down Expand Up @@ -1116,9 +1119,11 @@ DeviceDelegateOculusVR::StartFrame() {
if (m.immersiveDisplay) {
m.immersiveDisplay->SetEyeOffset(device::Eye::Left, -ipd * 0.5f, 0.f, 0.f);
m.immersiveDisplay->SetEyeOffset(device::Eye::Right, ipd * 0.5f, 0.f, 0.f);
device::CapabilityFlags caps = device::Orientation | device::Present;
device::CapabilityFlags caps = device::Orientation | device::Present | device::StageParameters;
if (m.predictedTracking.Status & VRAPI_TRACKING_STATUS_POSITION_TRACKED) {
caps |= device::Position;
} else {
caps |= device::PositionEmulated;
}
m.immersiveDisplay->SetCapabilityFlags(caps);
}
Expand Down
13 changes: 11 additions & 2 deletions app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

namespace crow {

static const vrb::Vector kAverageHeight(0.0f, 1.7f, 0.0f);
static const int32_t kMaxControllerCount = 2;

struct Controller {
Expand Down Expand Up @@ -249,8 +250,17 @@ DeviceDelegateWaveVR::RegisterImmersiveDisplay(ImmersiveDisplayPtr aDisplay) {
}

m.immersiveDisplay->SetDeviceName("Wave");
m.immersiveDisplay->SetCapabilityFlags(device::Position | device::Orientation | device::Present);
device::CapabilityFlags flags = device::Orientation | device::Present | device::StageParameters;

if (WVR_GetDegreeOfFreedom(WVR_DeviceType_HMD) == WVR_NumDoF_6DoF) {
flags |= device::Position;
} else {
flags |= device::PositionEmulated;
}

m.immersiveDisplay->SetCapabilityFlags(flags);
m.immersiveDisplay->SetEyeResolution(m.renderWidth, m.renderHeight);
m.immersiveDisplay->SetSittingToStandingTransform(vrb::Matrix::Translation(kAverageHeight));
m.immersiveDisplay->CompleteEnumeration();
m.InitializeCameras();
}
Expand Down Expand Up @@ -462,7 +472,6 @@ DeviceDelegateWaveVR::ProcessEvents() {
void
DeviceDelegateWaveVR::StartFrame() {
VRB_GL_CHECK(glClearColor(m.clearColor.Red(), m.clearColor.Green(), m.clearColor.Blue(), m.clearColor.Alpha()));
static const vrb::Vector kAverageHeight(0.0f, 1.7f, 0.0f);
if (!m.lastSubmitDiscarded) {
m.leftFBOIndex = WVR_GetAvailableTextureIndex(m.leftTextureQueue);
m.rightFBOIndex = WVR_GetAvailableTextureIndex(m.rightTextureQueue);
Expand Down
2 changes: 1 addition & 1 deletion versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ext.deps = [:]
def versions = [:]
// GeckoView versions can be found here:
// https://maven.mozilla.org/?prefix=maven2/org/mozilla/geckoview/
versions.gecko_view = "67.0.20190311102806"
versions.gecko_view = "68.0.20190322101035"

This comment has been minimized.

Copy link
@cvan

cvan Mar 22, 2019

Contributor

this is a major-version change in GeckoView. in the future, should we do these in separate PRs? doing some web-compat testing now, just in case.

This comment has been minimized.

Copy link
@cvan

cvan Mar 22, 2019

Contributor

ah, I see this needed bug 1537899 to land in Gecko first. it looks like you did thorough testing. nevermind me, my bad.

versions.android_components = "0.31.0"
versions.mozilla_speech = "1.0.6"
versions.google_vr = "1.190.0"
Expand Down

0 comments on commit 4d5fb75

Please sign in to comment.