mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-10 14:52:00 +00:00
OpenXR input cleanup
This commit is contained in:
parent
be158b4ad9
commit
ab1e853554
3 changed files with 38 additions and 31 deletions
|
@ -1418,4 +1418,38 @@ void IN_VRUpdateControllers( float predictedDisplayTime )
|
||||||
IN_VRController(qtrue, engine->appState.TrackedController[1].Pose);
|
IN_VRController(qtrue, engine->appState.TrackedController[1].Pose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IN_VRUpdateHMD( float predictedDisplayTime )
|
||||||
|
{
|
||||||
|
engine_t* engine = VR_GetEngine();
|
||||||
|
|
||||||
|
// We extract Yaw, Pitch, Roll instead of directly using the orientation
|
||||||
|
// to allow "additional" yaw manipulation with mouse/controller.
|
||||||
|
XrSpaceLocation loc = {};
|
||||||
|
loc.type = XR_TYPE_SPACE_LOCATION;
|
||||||
|
OXR(xrLocateSpace(engine->appState.HeadSpace, engine->appState.CurrentSpace, predictedDisplayTime, &loc));
|
||||||
|
XrPosef xfStageFromHead = loc.pose;
|
||||||
|
const XrQuaternionf quatHmd = xfStageFromHead.orientation;
|
||||||
|
const XrVector3f positionHmd = xfStageFromHead.position;
|
||||||
|
vec3_t rotation = {0, 0, 0};
|
||||||
|
QuatToYawPitchRoll(quatHmd, rotation, vr.hmdorientation);
|
||||||
|
VectorSet(vr.hmdposition, positionHmd.x, positionHmd.y + vr_heightAdjust->value, positionHmd.z);
|
||||||
|
|
||||||
|
//Position
|
||||||
|
VectorSubtract(vr.hmdposition_last, vr.hmdposition, vr.hmdposition_delta);
|
||||||
|
|
||||||
|
//Keep this for our records
|
||||||
|
VectorCopy(vr.hmdposition, vr.hmdposition_last);
|
||||||
|
|
||||||
|
//Orientation
|
||||||
|
VectorSubtract(vr.hmdorientation_last, vr.hmdorientation, vr.hmdorientation_delta);
|
||||||
|
|
||||||
|
//Keep this for our records
|
||||||
|
VectorCopy(vr.hmdorientation, vr.hmdorientation_last);
|
||||||
|
|
||||||
|
// View yaw delta
|
||||||
|
const float clientview_yaw = vr.clientviewangles[YAW] - vr.hmdorientation[YAW];
|
||||||
|
vr.clientview_yaw_delta = vr.clientview_yaw_last - clientview_yaw;
|
||||||
|
vr.clientview_yaw_last = clientview_yaw;
|
||||||
|
}
|
||||||
|
|
||||||
//#endif
|
//#endif
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
void IN_VRInputFrame( void );
|
void IN_VRInputFrame( void );
|
||||||
void IN_VRInit( void );
|
void IN_VRInit( void );
|
||||||
void IN_VRSyncActions( void );
|
void IN_VRSyncActions( void );
|
||||||
|
void IN_VRUpdateHMD( float predictedDisplayTime );
|
||||||
void IN_VRUpdateControllers( float predictedDisplayTime );
|
void IN_VRUpdateControllers( float predictedDisplayTime );
|
||||||
|
|
||||||
void QuatToYawPitchRoll(XrQuaternionf q, vec3_t rotation, vec3_t out);
|
void QuatToYawPitchRoll(XrQuaternionf q, vec3_t rotation, vec3_t out);
|
||||||
|
|
|
@ -384,38 +384,10 @@ void VR_DrawFrame( engine_t* engine ) {
|
||||||
beginFrameDesc.next = NULL;
|
beginFrameDesc.next = NULL;
|
||||||
OXR(xrBeginFrame(engine->appState.Session, &beginFrameDesc));
|
OXR(xrBeginFrame(engine->appState.Session, &beginFrameDesc));
|
||||||
|
|
||||||
// We extract Yaw, Pitch, Roll instead of directly using the orientation
|
// Update HMD and controllers
|
||||||
// to allow "additional" yaw manipulation with mouse/controller.
|
IN_VRUpdateHMD( frameState.predictedDisplayTime );
|
||||||
XrSpaceLocation loc = {};
|
|
||||||
loc.type = XR_TYPE_SPACE_LOCATION;
|
|
||||||
OXR(xrLocateSpace(engine->appState.HeadSpace, engine->appState.CurrentSpace, frameState.predictedDisplayTime, &loc));
|
|
||||||
XrPosef xfStageFromHead = loc.pose;
|
|
||||||
const XrQuaternionf quatHmd = xfStageFromHead.orientation;
|
|
||||||
const XrVector3f positionHmd = xfStageFromHead.position;
|
|
||||||
vec3_t rotation = {0, 0, 0};
|
|
||||||
QuatToYawPitchRoll(quatHmd, rotation, vr.hmdorientation);
|
|
||||||
VectorSet(vr.hmdposition, positionHmd.x, positionHmd.y + vr_heightAdjust->value, positionHmd.z);
|
|
||||||
|
|
||||||
//Position
|
|
||||||
VectorSubtract(vr.hmdposition_last, vr.hmdposition, vr.hmdposition_delta);
|
|
||||||
|
|
||||||
//Keep this for our records
|
|
||||||
VectorCopy(vr.hmdposition, vr.hmdposition_last);
|
|
||||||
|
|
||||||
//Orientation
|
|
||||||
VectorSubtract(vr.hmdorientation_last, vr.hmdorientation, vr.hmdorientation_delta);
|
|
||||||
|
|
||||||
//Keep this for our records
|
|
||||||
VectorCopy(vr.hmdorientation, vr.hmdorientation_last);
|
|
||||||
|
|
||||||
// View yaw delta
|
|
||||||
const float clientview_yaw = vr.clientviewangles[YAW] - vr.hmdorientation[YAW];
|
|
||||||
vr.clientview_yaw_delta = vr.clientview_yaw_last - clientview_yaw;
|
|
||||||
vr.clientview_yaw_last = clientview_yaw;
|
|
||||||
|
|
||||||
// Update controllers
|
|
||||||
IN_VRSyncActions();
|
|
||||||
IN_VRUpdateControllers( frameState.predictedDisplayTime );
|
IN_VRUpdateControllers( frameState.predictedDisplayTime );
|
||||||
|
IN_VRSyncActions();
|
||||||
|
|
||||||
XrViewLocateInfo projectionInfo = {};
|
XrViewLocateInfo projectionInfo = {};
|
||||||
projectionInfo.type = XR_TYPE_VIEW_LOCATE_INFO;
|
projectionInfo.type = XR_TYPE_VIEW_LOCATE_INFO;
|
||||||
|
|
Loading…
Reference in a new issue