Commit: 2e5c877056926a1f3713d90f5a8920d1b121d823
Author: Julian Eisel
Date:   Mon Aug 10 13:47:00 2020 +0200
Branches: blender-v2.90-release
https://developer.blender.org/rB2e5c877056926a1f3713d90f5a8920d1b121d823

Fix pose offset on VR session start for some OpenXR runtimes

We want the session to start exactly at the landmark position, with
no additional offset. Some runtimes (e.g. Windows Mixed Reality) may
give an initial non-[0,0,0] position at session start though.

Also add a comment explaining the purpose of the eye offset variable.

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

M       source/blender/windowmanager/xr/intern/wm_xr_intern.h
M       source/blender/windowmanager/xr/intern/wm_xr_session.c

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

diff --git a/source/blender/windowmanager/xr/intern/wm_xr_intern.h 
b/source/blender/windowmanager/xr/intern/wm_xr_intern.h
index 9b7b81f769a..c49e9e534b6 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_intern.h
+++ b/source/blender/windowmanager/xr/intern/wm_xr_intern.h
@@ -70,6 +70,8 @@ typedef struct wmXrDrawData {
    * space). With positional tracking enabled, it should be the same as the 
base pose, when
    * disabled it also contains a location delta from the moment the option was 
toggled. */
   GHOST_XrPose base_pose;
+  /** Offset to _substract_ from the OpenXR eye and viewer pose to get the 
wanted effective pose
+   * (e.g. a pose exactly at the landmark position). */
   float eye_position_ofs[3]; /* Local/view space. */
 } wmXrDrawData;
 
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.c 
b/source/blender/windowmanager/xr/intern/wm_xr_session.c
index ab419bac6ac..4b991f69355 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_session.c
+++ b/source/blender/windowmanager/xr/intern/wm_xr_session.c
@@ -208,8 +208,9 @@ void wm_xr_session_draw_data_update(const wmXrSessionState 
*state,
 
   switch (event) {
     case SESSION_STATE_EVENT_START:
-      /* Always use the exact base pose with no offset when starting the 
session. */
-      copy_v3_fl(draw_data->eye_position_ofs, 0.0f);
+      /* We want to start the session exactly at landmark position. Runtimes 
may have a non-[0,0,0]
+       * starting position that we have to substract for that. */
+      copy_v3_v3(draw_data->eye_position_ofs, draw_view->local_pose.position);
       break;
       /* This should be triggered by the VR add-on if a landmark changes. */
     case SESSION_STATE_EVENT_RESET_TO_BASE_POSE:

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to