mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-10 06:41:58 +00:00
OpenXR change the way of getting the head position
This commit is contained in:
parent
859cecb424
commit
d354212c5d
3 changed files with 9 additions and 17 deletions
|
@ -1425,16 +1425,10 @@ void IN_VRUpdateControllers( float predictedDisplayTime )
|
|||
IN_VRController(qtrue, engine->appState.TrackedController[1].Pose);
|
||||
}
|
||||
|
||||
XrPosef IN_VRUpdateHMD( float predictedDisplayTime )
|
||||
void IN_VRUpdateHMD( XrPosef xfStageFromHead )
|
||||
{
|
||||
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};
|
||||
|
@ -1457,8 +1451,6 @@ XrPosef IN_VRUpdateHMD( float predictedDisplayTime )
|
|||
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;
|
||||
|
||||
return xfStageFromHead;
|
||||
}
|
||||
|
||||
//#endif
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
void IN_VRInputFrame( void );
|
||||
void IN_VRInit( void );
|
||||
void IN_VRSyncActions( void );
|
||||
XrPosef IN_VRUpdateHMD( float predictedDisplayTime );
|
||||
void IN_VRUpdateHMD( XrPosef xfStageFromHead );
|
||||
void IN_VRUpdateControllers( float predictedDisplayTime );
|
||||
|
||||
void QuatToYawPitchRoll(XrQuaternionf q, vec3_t rotation, vec3_t out);
|
||||
|
|
|
@ -384,11 +384,6 @@ void VR_DrawFrame( engine_t* engine ) {
|
|||
beginFrameDesc.next = NULL;
|
||||
OXR(xrBeginFrame(engine->appState.Session, &beginFrameDesc));
|
||||
|
||||
// Update HMD and controllers
|
||||
XrPosef xfStageFromHead = IN_VRUpdateHMD( frameState.predictedDisplayTime );
|
||||
IN_VRSyncActions();
|
||||
IN_VRUpdateControllers( frameState.predictedDisplayTime );
|
||||
|
||||
XrViewLocateInfo projectionInfo = {};
|
||||
projectionInfo.type = XR_TYPE_VIEW_LOCATE_INFO;
|
||||
projectionInfo.viewConfigurationType = engine->appState.ViewportConfig.viewConfigurationType;
|
||||
|
@ -422,6 +417,11 @@ void VR_DrawFrame( engine_t* engine ) {
|
|||
vr.fov_x = (fabs(fov.angleLeft) + fabs(fov.angleRight)) * 180.0f / M_PI;
|
||||
vr.fov_y = (fabs(fov.angleUp) + fabs(fov.angleDown)) * 180.0f / M_PI;
|
||||
|
||||
// Update HMD and controllers
|
||||
IN_VRUpdateHMD( invViewTransform[0] );
|
||||
IN_VRSyncActions();
|
||||
IN_VRUpdateControllers( frameState.predictedDisplayTime );
|
||||
|
||||
//Projection used for drawing HUD models etc
|
||||
float hudScale = M_PI * 15.0f / 180.0f;
|
||||
const ovrMatrix4f monoVRMatrix = ovrMatrix4f_CreateProjectionFov(
|
||||
|
@ -505,9 +505,9 @@ void VR_DrawFrame( engine_t* engine ) {
|
|||
cylinder_layer.subImage.imageArrayIndex = 0;
|
||||
const XrVector3f axis = {0.0f, 1.0f, 0.0f};
|
||||
XrVector3f pos = {
|
||||
xfStageFromHead.position.x - sin(radians(vr.menuYaw)) * 4.0f,
|
||||
invViewTransform[0].position.x - sin(radians(vr.menuYaw)) * 4.0f,
|
||||
-0.25f,
|
||||
xfStageFromHead.position.z - cos(radians(vr.menuYaw)) * 4.0f
|
||||
invViewTransform[0].position.z - cos(radians(vr.menuYaw)) * 4.0f
|
||||
};
|
||||
cylinder_layer.pose.orientation = XrQuaternionf_CreateFromVectorAngle(axis, radians(vr.menuYaw));
|
||||
cylinder_layer.pose.position = pos;
|
||||
|
|
Loading…
Reference in a new issue