mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2025-04-08 09:20:56 +00:00
OpenXR delayed controller pose fixed
This commit is contained in:
parent
325641f90e
commit
92941b3547
3 changed files with 24 additions and 18 deletions
|
@ -1341,24 +1341,6 @@ void IN_VRInputFrame( void )
|
|||
rightControllerAimSpace = CreateActionSpace(handPoseRightAction, rightHandPath);
|
||||
}
|
||||
|
||||
// update input information
|
||||
XrAction controller[] = {handPoseLeftAction, handPoseRightAction};
|
||||
XrPath subactionPath[] = {leftHandPath, rightHandPath};
|
||||
XrSpace controllerSpace[] = {leftControllerAimSpace, rightControllerAimSpace};
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (ActionPoseIsActive(controller[i], subactionPath[i])) {
|
||||
LocVel lv = GetSpaceLocVel(controllerSpace[i], VR_GetEngine()->predictedDisplayTime);
|
||||
VR_GetEngine()->appState.TrackedController[i].Active = (lv.loc.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) != 0;
|
||||
VR_GetEngine()->appState.TrackedController[i].Pose = lv.loc.pose;
|
||||
for (int j = 0; j < 3; j++) {
|
||||
float dt = 0.01f; // use 0.2f for for testing velocity vectors
|
||||
(&VR_GetEngine()->appState.TrackedController[i].Pose.position.x)[j] += (&lv.vel.linearVelocity.x)[j] * dt;
|
||||
}
|
||||
} else {
|
||||
ovrTrackedController_Clear(&VR_GetEngine()->appState.TrackedController[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// OpenXR input
|
||||
{
|
||||
// Attach to session
|
||||
|
@ -1427,4 +1409,24 @@ void IN_VRInputFrame( void )
|
|||
in_vrEventTime = Sys_Milliseconds( );
|
||||
}
|
||||
|
||||
void IN_VRUpdateControllers( float predictedDisplayTime )
|
||||
{
|
||||
XrAction controller[] = {handPoseLeftAction, handPoseRightAction};
|
||||
XrPath subactionPath[] = {leftHandPath, rightHandPath};
|
||||
XrSpace controllerSpace[] = {leftControllerAimSpace, rightControllerAimSpace};
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (ActionPoseIsActive(controller[i], subactionPath[i])) {
|
||||
LocVel lv = GetSpaceLocVel(controllerSpace[i], predictedDisplayTime);
|
||||
VR_GetEngine()->appState.TrackedController[i].Active = (lv.loc.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) != 0;
|
||||
VR_GetEngine()->appState.TrackedController[i].Pose = lv.loc.pose;
|
||||
for (int j = 0; j < 3; j++) {
|
||||
float dt = 0.01f; // use 0.2f for for testing velocity vectors
|
||||
(&VR_GetEngine()->appState.TrackedController[i].Pose.position.x)[j] += (&lv.vel.linearVelocity.x)[j] * dt;
|
||||
}
|
||||
} else {
|
||||
ovrTrackedController_Clear(&VR_GetEngine()->appState.TrackedController[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#endif
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
void IN_VRInputFrame( void );
|
||||
void IN_VRInit( void );
|
||||
void IN_VRUpdateControllers( float predictedDisplayTime );
|
||||
|
||||
void QuatToYawPitchRoll(XrQuaternionf q, vec3_t rotation, vec3_t out);
|
||||
|
||||
|
|
|
@ -413,6 +413,9 @@ void VR_DrawFrame( engine_t* engine ) {
|
|||
vr.clientview_yaw_delta = vr.clientview_yaw_last - clientview_yaw;
|
||||
vr.clientview_yaw_last = clientview_yaw;
|
||||
|
||||
// Update controllers
|
||||
IN_VRUpdateControllers( frameState.predictedDisplayTime );
|
||||
|
||||
XrViewLocateInfo projectionInfo = {};
|
||||
projectionInfo.type = XR_TYPE_VIEW_LOCATE_INFO;
|
||||
projectionInfo.viewConfigurationType = engine->appState.ViewportConfig.viewConfigurationType;
|
||||
|
|
Loading…
Reference in a new issue