diff --git a/android/app/src/main/cpp/code/cgame/cg_draw.c b/android/app/src/main/cpp/code/cgame/cg_draw.c index 8b8000ba..0eecd3c3 100644 --- a/android/app/src/main/cpp/code/cgame/cg_draw.c +++ b/android/app/src/main/cpp/code/cgame/cg_draw.c @@ -2821,9 +2821,9 @@ void CG_DrawActive( void ) { cg.refdef.vieworg[2] += (vr->hmdposition[1] + heightOffset) * worldscale; } - if (!cgs.localServer) + if (vr->use_fake_6dof) { - //If connected to a remote server, allow some amount of faked positional tracking + //If running multiplayer, allow some amount of faked positional tracking if (cg.snap->ps.stats[STAT_HEALTH] > 0 && //Don't use fake positional if following another player - this is handled in the //VR third person code diff --git a/android/app/src/main/cpp/code/cgame/cg_main.c b/android/app/src/main/cpp/code/cgame/cg_main.c index b43ebc4b..acced5b3 100644 --- a/android/app/src/main/cpp/code/cgame/cg_main.c +++ b/android/app/src/main/cpp/code/cgame/cg_main.c @@ -1974,6 +1974,13 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) { const char *serverinfo = CG_ConfigString( CS_SERVERINFO ); vr->no_crosshair = (strcasestr(serverinfo, "nocrosshair") != NULL || strcasestr(serverinfo, "no crosshair") != NULL); + vr->local_server = cgs.localServer; +#ifdef MISSIONPACK + vr->single_player = trap_Cvar_VariableValue("ui_singlePlayerActive"); +#else + vr->single_player = trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER; +#endif + vr->use_fake_6dof = !vr->single_player; } /* diff --git a/android/app/src/main/cpp/code/cgame/cg_view.c b/android/app/src/main/cpp/code/cgame/cg_view.c index c9d39c7a..ca5e1453 100644 --- a/android/app/src/main/cpp/code/cgame/cg_view.c +++ b/android/app/src/main/cpp/code/cgame/cg_view.c @@ -745,7 +745,7 @@ static int CG_CalcViewValues( ) { VectorCopy(cg.refdef.vieworg, cg.vr_vieworigin); } - if (!cgs.localServer && cg.stereoView == STEREO_LEFT) + if (vr->use_fake_6dof && cg.stereoView == STEREO_LEFT) { vec3_t weaponorigin, weaponangles; CG_CalculateVRWeaponPosition(weaponorigin, weaponangles); @@ -807,7 +807,7 @@ static int CG_CalcViewValues( ) { } // position eye relative to origin - if (!cgs.localServer) + if (vr->use_fake_6dof) { if (vr->weapon_zoomed) { //If we are zoomed, then we use the refdefViewANgles (which are the weapon angles) diff --git a/android/app/src/main/cpp/code/cgame/cg_weapons.c b/android/app/src/main/cpp/code/cgame/cg_weapons.c index 68eaf649..212ff966 100644 --- a/android/app/src/main/cpp/code/cgame/cg_weapons.c +++ b/android/app/src/main/cpp/code/cgame/cg_weapons.c @@ -231,9 +231,9 @@ void CG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out) VectorSet(vrSpace, in[2], in[0], in[1] ); vec2_t r; - if (!cgs.localServer) + if (vr->use_fake_6dof) { - //We are connected to a multiplayer server, so make the appropriate adjustment to the view + //We are running multiplayer, so make the appropriate adjustment to the view //angles as we send orientation to the server that includes the weapon angles float deltaYaw = SHORT2ANGLE(cg.predictedPlayerState.delta_angles[YAW]); if (cg.snap->ps.pm_flags & PMF_FOLLOW) @@ -262,7 +262,7 @@ void CG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out) static void CG_CalculateVRPositionInWorld( vec3_t in_position, vec3_t in_offset, vec3_t in_orientation, vec3_t origin, vec3_t angles ) { - if (!cgs.localServer) + if (vr->use_fake_6dof) { //Use absolute position for the faked 6DoF for multiplayer vec3_t offset; @@ -274,7 +274,7 @@ static void CG_CalculateVRPositionInWorld( vec3_t in_position, vec3_t in_offset } else { - //Local server - true 6DoF offset from HMD + //Singleplayer - true 6DoF offset from HMD vec3_t offset; VectorCopy(in_offset, offset); offset[1] = 0; // up/down is index 1 in this case @@ -284,7 +284,7 @@ static void CG_CalculateVRPositionInWorld( vec3_t in_position, vec3_t in_offset } VectorCopy(in_orientation, angles); - if ( !cgs.localServer ) + if ( vr->use_fake_6dof ) { //Calculate the offhand angles from "first principles" float deltaYaw = SHORT2ANGLE(cg.predictedPlayerState.delta_angles[YAW]); diff --git a/android/app/src/main/cpp/code/client/cl_input.c b/android/app/src/main/cpp/code/client/cl_input.c index 019a0a0a..5103b70f 100644 --- a/android/app/src/main/cpp/code/client/cl_input.c +++ b/android/app/src/main/cpp/code/client/cl_input.c @@ -599,12 +599,10 @@ void CL_FinishMove( usercmd_t *cmd ) { vr.clientNum = cl.snap.ps.clientNum; - //If we are running with a remote non-vr server, then the best we can do is pass the angles from the weapon - //and adjust the move values accordingly, to "fake" a 3DoF weapon but keeping the movement correct - if ( !com_sv_running || !com_sv_running->integer ) + //If we are running multiplayer, pass the angles from the weapon and adjust the move values accordingly, + // to "fake" a 3DoF weapon but keeping the movement correct (necessary with a remote non-vr server) + if ( vr.use_fake_6dof ) { - vr.local_server = qfalse; - //Realign in playspace if (--vr.realign == 0) { @@ -633,10 +631,6 @@ void CL_FinishMove( usercmd_t *cmd ) { cmd->forwardmove = out[1]; } else { - //Record client number - local server uses this to know we can use absolute angles - //rather than deltas - vr.local_server = qtrue; - for (i = 0; i < 3; i++) { cmd->angles[i] = ANGLE2SHORT(cl.viewangles[i]); } diff --git a/android/app/src/main/cpp/code/game/bg_pmove.c b/android/app/src/main/cpp/code/game/bg_pmove.c index 35cded43..88f59ad3 100644 --- a/android/app/src/main/cpp/code/game/bg_pmove.c +++ b/android/app/src/main/cpp/code/game/bg_pmove.c @@ -50,7 +50,7 @@ extern vr_clientinfo_t *vr; float PM_GetFrictionCoefficient( void ) { - if (vr != NULL && vr->clientNum == pm->ps->clientNum && vr->local_server) { + if (vr != NULL && vr->clientNum == pm->ps->clientNum && !vr->use_fake_6dof) { return 10.0f; } else { return 6.0f; @@ -58,7 +58,7 @@ float PM_GetFrictionCoefficient( void ) { } float PM_GetAccelerationCoefficient( void ) { - if (vr != NULL && vr->clientNum == pm->ps->clientNum && vr->local_server) { + if (vr != NULL && vr->clientNum == pm->ps->clientNum && !vr->use_fake_6dof) { return 1000.0f; } else { return 10.0f; @@ -1828,14 +1828,14 @@ void PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd ) { // circularly clamp the angles with deltas for (i=0 ; i<3 ; i++) { - if (vr != NULL && vr->clientNum == ps->clientNum && vr->local_server) + if (vr != NULL && vr->clientNum == ps->clientNum && !vr->use_fake_6dof) { - //Client is the VR player on the "local" server + //Client is the VR player in the singleplayer game temp = cmd->angles[i] + (i == YAW ? ps->delta_angles[i] : 0); } else { - //Client is either a BOT or a remote/connected player, or + //Client is either a BOT or we are running multiplayer, or //the vr player playing on a remote server (since this is shared code by game and cgame) temp = cmd->angles[i] + ps->delta_angles[i]; } diff --git a/android/app/src/main/cpp/code/game/g_main.c b/android/app/src/main/cpp/code/game/g_main.c index e350eef3..499b8580 100644 --- a/android/app/src/main/cpp/code/game/g_main.c +++ b/android/app/src/main/cpp/code/game/g_main.c @@ -519,6 +519,13 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) { char serverinfo[MAX_INFO_STRING]; trap_GetServerinfo( serverinfo, sizeof( serverinfo ) ); vr->no_crosshair = (strcasestr(serverinfo, "nocrosshair") != NULL || strcasestr(serverinfo, "no crosshair") != NULL); + vr->local_server = qtrue; +#ifdef MISSIONPACK + vr->single_player = trap_Cvar_VariableValue("ui_singlePlayerActive"); +#else + vr->single_player = trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER; +#endif + vr->use_fake_6dof = !vr->single_player; } diff --git a/android/app/src/main/cpp/code/game/g_weapon.c b/android/app/src/main/cpp/code/game/g_weapon.c index 35f5ed20..a74ff579 100644 --- a/android/app/src/main/cpp/code/game/g_weapon.c +++ b/android/app/src/main/cpp/code/game/g_weapon.c @@ -109,7 +109,8 @@ qboolean CheckGauntletAttack( gentity_t *ent ) { vec3_t angles; if ( !( ent->r.svFlags & SVF_BOT ) && vr != NULL && - (ent->client->ps.clientNum == vr->clientNum)) + (ent->client->ps.clientNum == vr->clientNum) && + !vr->use_fake_6dof) { VectorCopy(vr->weaponangles, angles); angles[YAW] += ent->client->ps.viewangles[YAW] - vr->hmdorientation[YAW]; @@ -817,7 +818,8 @@ set muzzle location relative to pivoting eye void CalcMuzzlePoint ( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint ) { if ( ( ent->r.svFlags & SVF_BOT ) || //Can't use the vr_clientinfo if this isn't the vr client - vr == NULL || (ent->client->ps.clientNum != vr->clientNum)) + vr == NULL || (ent->client->ps.clientNum != vr->clientNum) || + vr->use_fake_6dof) { VectorCopy( ent->s.pos.trBase, muzzlePoint ); muzzlePoint[2] += ent->client->ps.viewheight; @@ -881,7 +883,8 @@ void FireWeapon( gentity_t *ent ) { vec3_t viewang; if ( !( ent->r.svFlags & SVF_BOT ) && vr != NULL && - (ent->client->ps.clientNum == vr->clientNum)) + (ent->client->ps.clientNum == vr->clientNum) && + !vr->use_fake_6dof) { VectorCopy(vr->weaponangles, viewang); viewang[YAW] += ent->client->ps.viewangles[YAW] - vr->hmdorientation[YAW]; diff --git a/android/app/src/main/cpp/code/vr/vr_clientinfo.h b/android/app/src/main/cpp/code/vr/vr_clientinfo.h index 7d3759f7..51a2aa4e 100644 --- a/android/app/src/main/cpp/code/vr/vr_clientinfo.h +++ b/android/app/src/main/cpp/code/vr/vr_clientinfo.h @@ -18,7 +18,9 @@ typedef struct { float weapon_zoomLevel; qboolean right_handed; qboolean virtual_screen; - qboolean local_server; // used in bg_pmove.c + qboolean local_server; + qboolean single_player; + qboolean use_fake_6dof; vrFollowMode_t follow_mode; qboolean weapon_select; qboolean weapon_select_autoclose; diff --git a/android/app/src/main/cpp/code/vr/vr_input.c b/android/app/src/main/cpp/code/vr/vr_input.c index adfeb3cc..5c342827 100644 --- a/android/app/src/main/cpp/code/vr/vr_input.c +++ b/android/app/src/main/cpp/code/vr/vr_input.c @@ -531,9 +531,9 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo VectorClear(positional); vec2_t joystick; - if ( !com_sv_running || !com_sv_running->integer ) + if ( vr.use_fake_6dof ) { - //multiplayer server + //multiplayer game if (!vr_directionMode->integer) { //HMD Based rotateAboutOrigin(joystickX, joystickY, vr.hmdorientation[YAW], joystick);