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.
This commit is contained in:
parent
f1cb3dfbaa
commit
2e5c877056
|
@ -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;
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue