[Bf-blender-cvs] [5f7285d4af8] xr-actions-D9124: XR: Check for valid stage reference space bounds

Peter Kim noreply at git.blender.org
Sun Nov 8 14:56:02 CET 2020


Commit: 5f7285d4af8eb5abd329bc7261cfd2f2c9c86555
Author: Peter Kim
Date:   Sat Nov 7 15:19:38 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rB5f7285d4af8eb5abd329bc7261cfd2f2c9c86555

XR: Check for valid stage reference space bounds

Even if the stage reference space is supported by the XR runtime, the
bounds may be invalid (0, 0) if the user did not define a tracking
space via the runtime's UI. In this case, fall back to the local
tracking space.

===================================================================

M	intern/ghost/intern/GHOST_XrSession.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp
index 17a9794791b..23fd069db31 100644
--- a/intern/ghost/intern/GHOST_XrSession.cpp
+++ b/intern/ghost/intern/GHOST_XrSession.cpp
@@ -179,11 +179,10 @@ static void create_reference_spaces(OpenXRSessionData &oxr, const GHOST_XrPose &
        stage reference space for absolute tracking, if the runtime doesn't support it then just
        fallback to the local space. */
     if (result == XR_ERROR_REFERENCE_SPACE_UNSUPPORTED) {
-      /* TODO_XR: Log to Info editor instead of stdout to warn the user that absolute tracking is
-       * disabled. */
+      /* TODO_XR: Log to Info editor instead of stdout. */
       printf(
-          "XR runtime does not support stage reference space, absolute tracking will be "
-          "disabled\n");
+          "Warning: XR runtime does not support stage reference space, disabling absolute "
+          "tracking.\n");
 
       create_info.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL;
       CHECK_XR(xrCreateReferenceSpace(oxr.session, &create_info, &oxr.reference_space),
@@ -193,6 +192,28 @@ static void create_reference_spaces(OpenXRSessionData &oxr, const GHOST_XrPose &
       throw GHOST_XrException("Failed to create stage reference space.", result);
     }
   }
+  else {
+    /* Check if tracking bounds are valid. Tracking bounds may be invalid if the user did not
+     * define a tracking space via the XR runtime. */
+    XrExtent2Df extents;
+    CHECK_XR(xrGetReferenceSpaceBoundsRect(oxr.session, XR_REFERENCE_SPACE_TYPE_STAGE, &extents),
+             "Failed to get stage reference space bounds.");
+    if (extents.width == 0.0f || extents.height == 0.0f) {
+      /* TODO_XR: Log to Info editor. */
+      printf(
+          "Warning: Invalid stage reference space bounds, disabling absolute tracking. To use "
+          "absolute tracking, please define a tracking space via the XR runtime.\n");
+
+      /* Fallback to local space. */
+      if (oxr.reference_space != XR_NULL_HANDLE) {
+        CHECK_XR(xrDestroySpace(oxr.reference_space), "Failed to destroy stage reference space.");
+      }
+
+      create_info.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL;
+      CHECK_XR(xrCreateReferenceSpace(oxr.session, &create_info, &oxr.reference_space),
+               "Failed to create local reference space.");
+    }
+  }
 
   create_info.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_VIEW;
   CHECK_XR(xrCreateReferenceSpace(oxr.session, &create_info, &oxr.view_space),



More information about the Bf-blender-cvs mailing list