OpenXR controllers coordinates relative to head space

This commit is contained in:
Lubos 2022-05-11 16:51:07 +02:00
parent 5068ce7199
commit f2dbc90823
3 changed files with 5 additions and 5 deletions

View file

@ -1394,7 +1394,7 @@ void IN_VRSyncActions( void )
getInfo.subactionPath = XR_NULL_PATH;
}
void IN_VRUpdateControllers( float predictedDisplayTime )
void IN_VRUpdateControllers( XrPosef xfStageFromHead, float predictedDisplayTime )
{
engine_t* engine = VR_GetEngine();
@ -1406,10 +1406,10 @@ void IN_VRUpdateControllers( float predictedDisplayTime )
if (ActionPoseIsActive(controller[i], subactionPath[i])) {
XrSpaceLocation loc = {};
loc.type = XR_TYPE_SPACE_LOCATION;
OXR(xrLocateSpace(controllerSpace[i], engine->appState.CurrentSpace, predictedDisplayTime, &loc));
OXR(xrLocateSpace(controllerSpace[i], engine->appState.HeadSpace, predictedDisplayTime, &loc));
engine->appState.TrackedController[i].Active = (loc.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) != 0;
engine->appState.TrackedController[i].Pose = loc.pose;
engine->appState.TrackedController[i].Pose = XrPosef_Multiply(xfStageFromHead, loc.pose);
} else {
ovrTrackedController_Clear(&engine->appState.TrackedController[i]);
}

View file

@ -10,7 +10,7 @@ void IN_VRInputFrame( void );
void IN_VRInit( void );
void IN_VRSyncActions( void );
void IN_VRUpdateHMD( XrPosef xfStageFromHead );
void IN_VRUpdateControllers( float predictedDisplayTime );
void IN_VRUpdateControllers( XrPosef xfStageFromHead, float predictedDisplayTime );
void QuatToYawPitchRoll(XrQuaternionf q, vec3_t rotation, vec3_t out);

View file

@ -421,8 +421,8 @@ void VR_DrawFrame( engine_t* engine ) {
// Update HMD and controllers
IN_VRUpdateHMD( invViewTransform[0] );
IN_VRUpdateControllers( invViewTransform[0], frameState.predictedDisplayTime );
IN_VRSyncActions();
IN_VRUpdateControllers( frameState.predictedDisplayTime );
//Projection used for drawing HUD models etc
float hudScale = M_PI * 15.0f / 180.0f;