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

Set up WebXR Room Scale sizes #3065

Merged
merged 1 commit into from
Mar 27, 2020
Merged
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: 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 SetStageSize(const float aWidth, const float aDepth) = 0;
virtual void SetSittingToStandingTransform(const vrb::Matrix& aTransform) = 0;
virtual void CompleteEnumeration() = 0;
};
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/cpp/ExternalVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ ExternalVR::SetEyeResolution(const int32_t aWidth, const int32_t aHeight) {
m.system.displayState.eyeResolution.height = aHeight;
}

void
ExternalVR::SetStageSize(const float aWidth, const float aDepth) {
m.system.displayState.stageSize.width = aWidth;
m.system.displayState.stageSize.height = aDepth;
}

void
ExternalVR::SetSittingToStandingTransform(const vrb::Matrix& aTransform) {
memcpy(&(m.system.displayState.sittingToStandingTransform), aTransform.Data(), sizeof(m.system.displayState.sittingToStandingTransform));
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 @@ -45,6 +45,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 SetStageSize(const float aWidth, const float aDepth) override;
void SetSittingToStandingTransform(const vrb::Matrix& aTransform) override;
void CompleteEnumeration() override;
// ExternalVR interface
Expand Down
18 changes: 16 additions & 2 deletions app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,18 @@ struct DeviceDelegateOculusVR::State {
}
}

void UpdateBoundary() {
if (!ovr || !Is6DOF()) {
return;
}
ovrPosef pose;
ovrVector3f size;
vrapi_GetBoundaryOrientedBoundingBox(ovr, &pose, &size);
if (immersiveDisplay) {
immersiveDisplay->SetStageSize(size.x * 2.0f, size.z * 2.0f);
}
}

void AddUILayer(const OculusLayerPtr& aLayer, VRLayerSurface::SurfaceType aSurfaceType) {
if (ovr) {
vrb::RenderContextPtr ctx = context.lock();
Expand Down Expand Up @@ -669,9 +681,10 @@ DeviceDelegateOculusVR::RegisterImmersiveDisplay(ImmersiveDisplayPtr aDisplay) {
m.GetImmersiveRenderSize(width, height);
m.immersiveDisplay->SetEyeResolution(width, height);
m.immersiveDisplay->SetSittingToStandingTransform(vrb::Matrix::Translation(kAverageOculusHeight));
m.immersiveDisplay->CompleteEnumeration();

m.UpdateBoundary();
m.UpdatePerspective();

m.immersiveDisplay->CompleteEnumeration();
}

void
Expand Down Expand Up @@ -1199,6 +1212,7 @@ DeviceDelegateOculusVR::EnterVR(const crow::BrowserEGLContext& aEGLContext) {
m.UpdateDisplayRefreshRate();
m.UpdateClockLevels();
m.UpdateTrackingMode();
m.UpdateBoundary();
}

// Reset reorientation after Enter VR
Expand Down
21 changes: 20 additions & 1 deletion app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <wvr/wvr_overlay.h>
#include <wvr/wvr_system.h>
#include <wvr/wvr_events.h>
#include <wvr/wvr_arena.h>

namespace crow {

Expand Down Expand Up @@ -331,6 +332,22 @@ struct DeviceDelegateWaveVR::State {
}
}

void UpdateBoundary() {
if (!immersiveDisplay) {
return;
}
WVR_Arena_t arena = WVR_GetArena();
if (arena.shape == WVR_ArenaShape_Rectangle &&
arena.area.rectangle.width > 0 &&
arena.area.rectangle.length > 0) {
immersiveDisplay->SetStageSize(arena.area.rectangle.width, arena.area.rectangle.length);
} else if (arena.shape == WVR_ArenaShape_Round && arena.area.round.diameter > 0) {
immersiveDisplay->SetStageSize(arena.area.round.diameter, arena.area.round.diameter);
} else {
immersiveDisplay->SetStageSize(0.0f, 0.0f);
}
}

void UpdateHaptics(Controller& controller) {
vrb::RenderContextPtr renderContext = context.lock();
if (!renderContext) {
Expand Down Expand Up @@ -442,8 +459,9 @@ DeviceDelegateWaveVR::RegisterImmersiveDisplay(ImmersiveDisplayPtr aDisplay) {
m.immersiveDisplay->SetCapabilityFlags(flags);
m.immersiveDisplay->SetEyeResolution(m.renderWidth, m.renderHeight);
m.immersiveDisplay->SetSittingToStandingTransform(vrb::Matrix::Translation(kAverageHeight));
m.immersiveDisplay->CompleteEnumeration();
m.UpdateBoundary();
m.InitializeCameras();
m.immersiveDisplay->CompleteEnumeration();
}

void
Expand Down Expand Up @@ -590,6 +608,7 @@ DeviceDelegateWaveVR::ProcessEvents() {
case WVR_EventType_DeviceResume: {
VRB_WAVE_EVENT_LOG("WVR_EventType_DeviceResume");
m.reorientMatrix = vrb::Matrix::Identity();
m.UpdateBoundary();
}
break;
case WVR_EventType_DeviceRoleChanged: {
Expand Down