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.
  • Loading branch information
MortimerGoro committed Mar 21, 2019
1 parent dc3efee commit c425a70
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
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 PositionNeckModel = 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::PositionNeckModel & aFlags) {
result |= static_cast<uint16_t>(mozilla::gfx::VRDisplayCapabilityFlags::Cap_PositionNeckModel);
}
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_PositionNeckModel is set if the VRDisplay is capable of setting a
* neck model in position even if still doesn't support 6DOF tracking.
*/
Cap_PositionNeckModel = 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
6 changes: 5 additions & 1 deletion app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1116,9 +1116,13 @@ 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;
m.immersiveDisplay->SetSittingToStandingTransform(vrb::Matrix::Identity());
} else {
caps |= device::Position;
m.immersiveDisplay->SetSittingToStandingTransform(vrb::Matrix::Translation(vrb::Vector(0.0f, 1.65f, 0.0f)));
}
m.immersiveDisplay->SetCapabilityFlags(caps);
}
Expand Down

0 comments on commit c425a70

Please sign in to comment.