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

Commit 28b0362

Browse files
authored
Set up WebXR Room Scale sizes (#3065)
1 parent 9f5c1d7 commit 28b0362

File tree

5 files changed

+44
-3
lines changed

5 files changed

+44
-3
lines changed

app/src/main/cpp/DeviceDelegate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class ImmersiveDisplay {
3939
const double aBottomDegrees) = 0;
4040
virtual void SetEyeOffset(const device::Eye aEye, const float aX, const float aY, const float aZ) = 0;
4141
virtual void SetEyeResolution(const int32_t aWidth, const int32_t aHeight) = 0;
42+
virtual void SetStageSize(const float aWidth, const float aDepth) = 0;
4243
virtual void SetSittingToStandingTransform(const vrb::Matrix& aTransform) = 0;
4344
virtual void CompleteEnumeration() = 0;
4445
};

app/src/main/cpp/ExternalVR.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ ExternalVR::SetEyeResolution(const int32_t aWidth, const int32_t aHeight) {
299299
m.system.displayState.eyeResolution.height = aHeight;
300300
}
301301

302+
void
303+
ExternalVR::SetStageSize(const float aWidth, const float aDepth) {
304+
m.system.displayState.stageSize.width = aWidth;
305+
m.system.displayState.stageSize.height = aDepth;
306+
}
307+
302308
void
303309
ExternalVR::SetSittingToStandingTransform(const vrb::Matrix& aTransform) {
304310
memcpy(&(m.system.displayState.sittingToStandingTransform), aTransform.Data(), sizeof(m.system.displayState.sittingToStandingTransform));

app/src/main/cpp/ExternalVR.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class ExternalVR : public ImmersiveDisplay {
4545
const double aBottomDegrees) override;
4646
void SetEyeOffset(const device::Eye aEye, const float aX, const float aY, const float aZ) override;
4747
void SetEyeResolution(const int32_t aX, const int32_t aY) override;
48+
void SetStageSize(const float aWidth, const float aDepth) override;
4849
void SetSittingToStandingTransform(const vrb::Matrix& aTransform) override;
4950
void CompleteEnumeration() override;
5051
// ExternalVR interface

app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,18 @@ struct DeviceDelegateOculusVR::State {
227227
}
228228
}
229229

230+
void UpdateBoundary() {
231+
if (!ovr || !Is6DOF()) {
232+
return;
233+
}
234+
ovrPosef pose;
235+
ovrVector3f size;
236+
vrapi_GetBoundaryOrientedBoundingBox(ovr, &pose, &size);
237+
if (immersiveDisplay) {
238+
immersiveDisplay->SetStageSize(size.x * 2.0f, size.z * 2.0f);
239+
}
240+
}
241+
230242
void AddUILayer(const OculusLayerPtr& aLayer, VRLayerSurface::SurfaceType aSurfaceType) {
231243
if (ovr) {
232244
vrb::RenderContextPtr ctx = context.lock();
@@ -669,9 +681,10 @@ DeviceDelegateOculusVR::RegisterImmersiveDisplay(ImmersiveDisplayPtr aDisplay) {
669681
m.GetImmersiveRenderSize(width, height);
670682
m.immersiveDisplay->SetEyeResolution(width, height);
671683
m.immersiveDisplay->SetSittingToStandingTransform(vrb::Matrix::Translation(kAverageOculusHeight));
672-
m.immersiveDisplay->CompleteEnumeration();
673-
684+
m.UpdateBoundary();
674685
m.UpdatePerspective();
686+
687+
m.immersiveDisplay->CompleteEnumeration();
675688
}
676689

677690
void
@@ -1199,6 +1212,7 @@ DeviceDelegateOculusVR::EnterVR(const crow::BrowserEGLContext& aEGLContext) {
11991212
m.UpdateDisplayRefreshRate();
12001213
m.UpdateClockLevels();
12011214
m.UpdateTrackingMode();
1215+
m.UpdateBoundary();
12021216
}
12031217

12041218
// Reset reorientation after Enter VR

app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <wvr/wvr_overlay.h>
2929
#include <wvr/wvr_system.h>
3030
#include <wvr/wvr_events.h>
31+
#include <wvr/wvr_arena.h>
3132

3233
namespace crow {
3334

@@ -331,6 +332,22 @@ struct DeviceDelegateWaveVR::State {
331332
}
332333
}
333334

335+
void UpdateBoundary() {
336+
if (!immersiveDisplay) {
337+
return;
338+
}
339+
WVR_Arena_t arena = WVR_GetArena();
340+
if (arena.shape == WVR_ArenaShape_Rectangle &&
341+
arena.area.rectangle.width > 0 &&
342+
arena.area.rectangle.length > 0) {
343+
immersiveDisplay->SetStageSize(arena.area.rectangle.width, arena.area.rectangle.length);
344+
} else if (arena.shape == WVR_ArenaShape_Round && arena.area.round.diameter > 0) {
345+
immersiveDisplay->SetStageSize(arena.area.round.diameter, arena.area.round.diameter);
346+
} else {
347+
immersiveDisplay->SetStageSize(0.0f, 0.0f);
348+
}
349+
}
350+
334351
void UpdateHaptics(Controller& controller) {
335352
vrb::RenderContextPtr renderContext = context.lock();
336353
if (!renderContext) {
@@ -442,8 +459,9 @@ DeviceDelegateWaveVR::RegisterImmersiveDisplay(ImmersiveDisplayPtr aDisplay) {
442459
m.immersiveDisplay->SetCapabilityFlags(flags);
443460
m.immersiveDisplay->SetEyeResolution(m.renderWidth, m.renderHeight);
444461
m.immersiveDisplay->SetSittingToStandingTransform(vrb::Matrix::Translation(kAverageHeight));
445-
m.immersiveDisplay->CompleteEnumeration();
462+
m.UpdateBoundary();
446463
m.InitializeCameras();
464+
m.immersiveDisplay->CompleteEnumeration();
447465
}
448466

449467
void
@@ -590,6 +608,7 @@ DeviceDelegateWaveVR::ProcessEvents() {
590608
case WVR_EventType_DeviceResume: {
591609
VRB_WAVE_EVENT_LOG("WVR_EventType_DeviceResume");
592610
m.reorientMatrix = vrb::Matrix::Identity();
611+
m.UpdateBoundary();
593612
}
594613
break;
595614
case WVR_EventType_DeviceRoleChanged: {

0 commit comments

Comments
 (0)