mirror of
https://github.com/DrBeef/RTCWQuest.git
synced 2025-04-22 23:11:02 +00:00
Several changes
fixed menu mouse control fixed skybox wobble fixed player height
This commit is contained in:
parent
1684e5f9c2
commit
f92f75e136
8 changed files with 78 additions and 72 deletions
|
@ -827,22 +827,26 @@ void QuatToYawPitchRoll(ovrQuatf q, vec3_t rotation, vec3_t out) {
|
|||
return;
|
||||
}
|
||||
|
||||
void setWorldPosition( float x, float y, float z )
|
||||
void updateHMDOrientation()
|
||||
{
|
||||
vr.positionDeltaThisFrame[0] = (vr.worldPosition[0] - x);
|
||||
vr.positionDeltaThisFrame[1] = (vr.worldPosition[1] - y);
|
||||
vr.positionDeltaThisFrame[2] = (vr.worldPosition[2] - z);
|
||||
//Position
|
||||
VectorSubtract(vr.hmdposition_last, vr.hmdposition, vr.hmdposition_delta);
|
||||
|
||||
vr.worldPosition[0] = x;
|
||||
vr.worldPosition[1] = y;
|
||||
vr.worldPosition[2] = z;
|
||||
//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);
|
||||
}
|
||||
|
||||
void setHMDPosition( float x, float y, float z, float yaw )
|
||||
void setHMDPosition( float x, float y, float z )
|
||||
{
|
||||
static qboolean s_useScreen = qfalse;
|
||||
|
||||
VectorSet(vr.hmdPosition, x, y, z);
|
||||
VectorSet(vr.hmdposition, x, y, z);
|
||||
|
||||
if (s_useScreen != RTCWVR_useScreenLayer())
|
||||
{
|
||||
|
@ -854,7 +858,7 @@ void setHMDPosition( float x, float y, float z, float yaw )
|
|||
|
||||
if (!RTCWVR_useScreenLayer())
|
||||
{
|
||||
playerYaw = yaw;
|
||||
playerYaw = vr.hmdorientation[YAW];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1573,10 +1577,9 @@ void RTCWVR_getHMDOrientation() {//Get orientation
|
|||
const ovrVector3f positionHmd = tracking.HeadPose.Pose.Position;
|
||||
vec3_t rotation = {0};
|
||||
QuatToYawPitchRoll(quatHmd, rotation, vr.hmdorientation);
|
||||
setHMDPosition(positionHmd.x, positionHmd.y, positionHmd.z, vr.hmdorientation[YAW]);
|
||||
setHMDPosition(positionHmd.x, positionHmd.y, positionHmd.z);
|
||||
|
||||
//TODO: fix - set to use HMD position for world position
|
||||
setWorldPosition(positionHmd.x, positionHmd.y, positionHmd.z);
|
||||
updateHMDOrientation();
|
||||
|
||||
ALOGV(" HMD-Position: %f, %f, %f", positionHmd.x, positionHmd.y, positionHmd.z);
|
||||
}
|
||||
|
@ -1588,6 +1591,11 @@ void shutdownVR() {
|
|||
vrapi_Shutdown();
|
||||
}
|
||||
|
||||
long long RTCWVR_getFrameIndex()
|
||||
{
|
||||
return gAppState.FrameIndex;
|
||||
}
|
||||
|
||||
void RTCWVR_incrementFrameIndex()
|
||||
{
|
||||
// This is the only place the frame index is incremented, right before
|
||||
|
|
|
@ -5,13 +5,18 @@ typedef struct {
|
|||
float fov;
|
||||
qboolean weapon_stabilised;
|
||||
|
||||
vec3_t worldPosition;
|
||||
vec3_t hmdposition;
|
||||
vec3_t hmdposition_last; // Don't use this, it is just for calculating delta!
|
||||
vec3_t hmdposition_delta;
|
||||
|
||||
vec3_t hmdPosition;
|
||||
vec3_t hmdorientation;
|
||||
vec3_t positionDeltaThisFrame;
|
||||
vec3_t hmdorientation_last; // Don't use this, it is just for calculating delta!
|
||||
vec3_t hmdorientation_delta;
|
||||
|
||||
vec3_t weaponangles;
|
||||
vec3_t weaponangles_last; // Don't use this, it is just for calculating delta!
|
||||
vec3_t weaponangles_delta;
|
||||
|
||||
vec3_t weaponoffset;
|
||||
|
||||
vec3_t flashlightangles;
|
||||
|
|
|
@ -54,7 +54,7 @@ qboolean between(float min, float val, float max);
|
|||
void rotateAboutOrigin(float v1, float v2, float rotation, vec2_t out);
|
||||
void QuatToYawPitchRoll(ovrQuatf q, vec3_t rotation, vec3_t out);
|
||||
void handleTrackedControllerButton(ovrInputStateTrackedRemote * trackedRemoteState, ovrInputStateTrackedRemote * prevTrackedRemoteState, uint32_t button, int key);
|
||||
void interactWithTouchScreen(ovrTracking *tracking, ovrInputStateTrackedRemote *newState, ovrInputStateTrackedRemote *oldState);
|
||||
void interactWithTouchScreen(ovrInputStateTrackedRemote *newState, ovrInputStateTrackedRemote *oldState);
|
||||
|
||||
|
||||
//Called from engine code
|
||||
|
|
|
@ -145,25 +145,19 @@ void acquireTrackedRemotesData(const ovrMobile *Ovr, double displayTime) {//The
|
|||
|
||||
float initialTouchX, initialTouchY;
|
||||
void PortableMouseAbs(float x,float y);
|
||||
inline float clamp(float _min, float _val, float _max)
|
||||
{
|
||||
return max(min(_val, _max), _min);
|
||||
}
|
||||
|
||||
void interactWithTouchScreen(ovrTracking *tracking, ovrInputStateTrackedRemote *newState, ovrInputStateTrackedRemote *oldState) {
|
||||
float remoteAngles[3];
|
||||
vec3_t rotation = {0};
|
||||
QuatToYawPitchRoll(tracking->HeadPose.Pose.Orientation, rotation, remoteAngles);
|
||||
float yaw = remoteAngles[YAW] - playerYaw;
|
||||
void interactWithTouchScreen(ovrInputStateTrackedRemote *newState, ovrInputStateTrackedRemote *oldState) {
|
||||
static float cursorX = 0.25f;
|
||||
static float cursorY = 0.125f;
|
||||
|
||||
//Adjust for maximum yaw values
|
||||
if (yaw >= 180.0f) yaw -= 180.0f;
|
||||
if (yaw <= -180.0f) yaw += 180.0f;
|
||||
cursorX += (float)(vr.weaponangles_delta[YAW] / 220.0);
|
||||
cursorX = clamp(0.0, cursorX, 0.5);
|
||||
cursorY += (float)(-vr.weaponangles_delta[PITCH] / 220.0);
|
||||
cursorY = clamp(0.0, cursorY, 0.5);
|
||||
|
||||
if (yaw > -45.0f && yaw < 45.0f &&
|
||||
remoteAngles[PITCH] > -15.0f && remoteAngles[PITCH] < 75.0f) {
|
||||
|
||||
int newRemoteTrigState = (newState->Buttons & ovrButton_Trigger) != 0;
|
||||
int prevRemoteTrigState = (oldState->Buttons & ovrButton_Trigger) != 0;
|
||||
|
||||
float touchX = (-yaw + 45.0f) / 90.0f;
|
||||
float touchY = (remoteAngles[PITCH] + 15.0f) / 90.0f;
|
||||
PortableMouseAbs(touchX, touchY);
|
||||
}
|
||||
PortableMouseAbs(cursorX, cursorY);
|
||||
}
|
|
@ -45,13 +45,29 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
showingScreenLayer = !showingScreenLayer;
|
||||
}
|
||||
|
||||
//Need this for the touch screen
|
||||
{
|
||||
//Set gun angles - We need to calculate all those we might need (including adjustments) for the client to then take its pick
|
||||
vec3_t rotation = {0};
|
||||
rotation[PITCH] = vr_weapon_pitchadjust->value;
|
||||
QuatToYawPitchRoll(pDominantTracking->HeadPose.Pose.Orientation, rotation, vr.weaponangles);
|
||||
vr.weaponangles[ROLL] *= -1.0f;
|
||||
|
||||
VectorSubtract(vr.weaponangles_last, vr.weaponangles, vr.weaponangles_delta);
|
||||
VectorCopy(vr.weaponangles, vr.weaponangles_last);
|
||||
|
||||
ALOGV(" weaponangles_last: %f, %f, %f",
|
||||
vr.weaponangles_last[0], vr.weaponangles_last[1], vr.weaponangles_last[2]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Menu button
|
||||
handleTrackedControllerButton(&leftTrackedRemoteState_new, &leftTrackedRemoteState_old, ovrButton_Enter, K_ESCAPE);
|
||||
|
||||
if ( RTCWVR_useScreenLayer() )
|
||||
{
|
||||
interactWithTouchScreen(pDominantTracking, pDominantTrackedRemoteNew, pDominantTrackedRemoteOld);
|
||||
interactWithTouchScreen(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld);
|
||||
|
||||
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, domButton1, K_MOUSE1);
|
||||
handleTrackedControllerButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, ovrButton_Trigger, K_MOUSE1);
|
||||
|
@ -111,9 +127,9 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
//dominant hand stuff first
|
||||
{
|
||||
///Weapon location relative to view
|
||||
vr.weaponoffset[0] = pDominantTracking->HeadPose.Pose.Position.x - vr.hmdPosition[0];
|
||||
vr.weaponoffset[1] = pDominantTracking->HeadPose.Pose.Position.y - vr.hmdPosition[1];
|
||||
vr.weaponoffset[2] = pDominantTracking->HeadPose.Pose.Position.z - vr.hmdPosition[2];
|
||||
vr.weaponoffset[0] = pDominantTracking->HeadPose.Pose.Position.x - vr.hmdposition[0];
|
||||
vr.weaponoffset[1] = pDominantTracking->HeadPose.Pose.Position.y - vr.hmdposition[1];
|
||||
vr.weaponoffset[2] = pDominantTracking->HeadPose.Pose.Position.z - vr.hmdposition[2];
|
||||
|
||||
{
|
||||
vec2_t v;
|
||||
|
@ -122,14 +138,6 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
vr.weaponoffset[2] = v[1];
|
||||
}
|
||||
|
||||
//Set gun angles - We need to calculate all those we might need (including adjustments) for the client to then take its pick
|
||||
vec3_t rotation = {0};
|
||||
rotation[PITCH] = vr_weapon_pitchadjust->value;
|
||||
QuatToYawPitchRoll(pDominantTracking->HeadPose.Pose.Orientation, rotation, vr.weaponangles);
|
||||
vr.weaponangles[YAW] += (cl.viewangles[YAW] - vr.hmdorientation[YAW]);
|
||||
vr.weaponangles[ROLL] *= -1.0f;
|
||||
|
||||
|
||||
if (vr.weapon_stabilised)
|
||||
{
|
||||
float z = pOffTracking->HeadPose.Pose.Position.z - pDominantTracking->HeadPose.Pose.Position.z;
|
||||
|
@ -199,9 +207,9 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
float controllerYawHeading = 0.0f;
|
||||
//off-hand stuff
|
||||
{
|
||||
vr.flashlightoffset[0] = pOffTracking->HeadPose.Pose.Position.x - vr.hmdPosition[0];
|
||||
vr.flashlightoffset[1] = pOffTracking->HeadPose.Pose.Position.y - vr.hmdPosition[1];
|
||||
vr.flashlightoffset[2] = pOffTracking->HeadPose.Pose.Position.z - vr.hmdPosition[2];
|
||||
vr.flashlightoffset[0] = pOffTracking->HeadPose.Pose.Position.x - vr.hmdposition[0];
|
||||
vr.flashlightoffset[1] = pOffTracking->HeadPose.Pose.Position.y - vr.hmdposition[1];
|
||||
vr.flashlightoffset[2] = pOffTracking->HeadPose.Pose.Position.z - vr.hmdposition[2];
|
||||
|
||||
vec2_t v;
|
||||
rotateAboutOrigin(-vr.flashlightoffset[0], vr.flashlightoffset[2], (cl.viewangles[YAW] - vr.hmdorientation[YAW]), v);
|
||||
|
@ -232,8 +240,8 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
//This section corrects for the fact that the controller actually controls direction of movement, but we want to move relative to the direction the
|
||||
//player is facing for positional tracking
|
||||
vec2_t v;
|
||||
rotateAboutOrigin(-vr.positionDeltaThisFrame[0] * vr_positional_factor->value,
|
||||
vr.positionDeltaThisFrame[2] * vr_positional_factor->value, - vr.hmdorientation[YAW], v);
|
||||
rotateAboutOrigin(-vr.hmdposition_delta[0] * vr_positional_factor->value,
|
||||
vr.hmdposition_delta[2] * vr_positional_factor->value, - vr.hmdorientation[YAW], v);
|
||||
positional_movementSideways = v[0];
|
||||
positional_movementForward = v[1];
|
||||
|
||||
|
|
|
@ -348,8 +348,7 @@ void CG_Draw3DModel( float x, float y, float w, float h, qhandle_t model, qhandl
|
|||
refdef.rdflags &= ~RDF_DRAWSKYBOX;
|
||||
}
|
||||
|
||||
//Indicate to renderer it should be trying any view angle adjustments
|
||||
refdef.viewangles[YAW] = -1001;
|
||||
VectorCopy(cg.refdefViewAngles, cg.refdef.viewangles);
|
||||
|
||||
trap_R_ClearScene();
|
||||
trap_R_AddRefEntityToScene( &ent );
|
||||
|
@ -3573,7 +3572,7 @@ void CG_DrawActive( int stereoView ) {
|
|||
|
||||
|
||||
cg.refdef.worldscale = cg_worldScale.value;
|
||||
cg.refdef.viewangles[YAW] = -1001;
|
||||
VectorCopy(cg.refdefViewAngles, cg.refdef.viewangles);
|
||||
|
||||
// clear around the rendered view if sized down
|
||||
// CG_TileClear(); // (SA) moved down
|
||||
|
@ -3586,8 +3585,8 @@ void CG_DrawActive( int stereoView ) {
|
|||
|
||||
//Vertical Positional Movement
|
||||
if (!cg.cameraMode) {
|
||||
cg.refdef.vieworg[2] -= DEFAULT_VIEWHEIGHT;
|
||||
cg.refdef.vieworg[2] += (cgVR->hmdPosition[1] /*+ vr_height_adjust->value*/) * cg_worldScale.value;
|
||||
cg.refdef.vieworg[2] -= 64;
|
||||
cg.refdef.vieworg[2] += (cgVR->hmdposition[1] /*+ vr_height_adjust->value*/) * cg_worldScale.value;
|
||||
}
|
||||
|
||||
cg.refdef.glfog.registered = 0; // make sure it doesn't use fog from another scene
|
||||
|
|
|
@ -311,7 +311,7 @@ cvarTable_t cvarTable[] = {
|
|||
{ &cg_viewsize, "cg_viewsize", "100", CVAR_ARCHIVE },
|
||||
{ &cg_letterbox, "cg_letterbox", "0", CVAR_TEMP }, //----(SA) added
|
||||
{ &cg_stereoSeparation, "cg_stereoSeparation", "0.065", CVAR_ARCHIVE },
|
||||
{ &cg_worldScale, "cg_worldScale", "40.0", CVAR_ARCHIVE },
|
||||
{ &cg_worldScale, "cg_worldScale", "35.0", CVAR_ARCHIVE },
|
||||
{ &cg_shadows, "cg_shadows", "1", CVAR_ARCHIVE },
|
||||
{ &cg_gibs, "cg_gibs", "1", CVAR_ARCHIVE },
|
||||
{ &cg_draw2D, "cg_draw2D", "1", CVAR_ARCHIVE },
|
||||
|
|
|
@ -411,6 +411,7 @@ to handle mirrors,
|
|||
*/
|
||||
qboolean RTCWVR_useScreenLayer();
|
||||
extern int resyncClientYawWithGameYaw;
|
||||
long long RTCWVR_getFrameIndex();
|
||||
void RE_RenderScene( const refdef_t *fd ) {
|
||||
viewParms_t parms;
|
||||
int startTime;
|
||||
|
@ -533,7 +534,8 @@ void RE_RenderScene( const refdef_t *fd ) {
|
|||
|
||||
//This is just madness, but it makes for smooth head tracking
|
||||
static float yaw = 0;
|
||||
static float last_hmd_yaw = 0;
|
||||
static long long lastFrameIndex = 0;
|
||||
long long frameIndex = RTCWVR_getFrameIndex();
|
||||
if ((RTCWVR_useScreenLayer() || resyncClientYawWithGameYaw > 0))
|
||||
{
|
||||
//Resyncing with known game yaw
|
||||
|
@ -543,15 +545,6 @@ void RE_RenderScene( const refdef_t *fd ) {
|
|||
VectorCopy( fd->viewaxis[2], parms.or.axis[2] );
|
||||
if (fd->stereoView == 1 && resyncClientYawWithGameYaw > 0) resyncClientYawWithGameYaw--;
|
||||
}
|
||||
else if (fd->viewangles[YAW] == -1001) // MAGIC NUMBER!
|
||||
{
|
||||
//Normal "in-game" behaviour, use pitch and roll from HMD but use
|
||||
//a yaw that we believe is the same as the game server's yaw, adjusted by our last HMD movement
|
||||
vec3_t viewAngles;
|
||||
VectorCopy(vr.hmdorientation, viewAngles);
|
||||
viewAngles[YAW] = yaw;
|
||||
AnglesToAxis(viewAngles, parms.or.axis);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Normal "in-game" behaviour, use pitch and roll from HMD but use
|
||||
|
@ -560,15 +553,14 @@ void RE_RenderScene( const refdef_t *fd ) {
|
|||
VectorCopy(vr.hmdorientation, viewAngles);
|
||||
|
||||
//Only update this for once per stereo pair
|
||||
if (fd->stereoView == 1)
|
||||
if (frameIndex != lastFrameIndex)
|
||||
{
|
||||
float yawDelta = (vr.hmdorientation[YAW] - last_hmd_yaw);
|
||||
yaw += yawDelta;
|
||||
last_hmd_yaw = vr.hmdorientation[YAW];
|
||||
yaw -= vr.hmdorientation_delta[YAW];
|
||||
}
|
||||
|
||||
viewAngles[YAW] = yaw;
|
||||
AnglesToAxis(viewAngles, parms.or.axis);
|
||||
lastFrameIndex = frameIndex;
|
||||
}
|
||||
|
||||
VectorCopy( fd->vieworg, parms.pvsOrigin );
|
||||
|
|
Loading…
Reference in a new issue