From f8987d408df18fc599ba2b6f774dd1a282a91326 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 7 Apr 2022 22:31:22 +0100 Subject: [PATCH] Use HUD depth for HMD weapon selector depth Also, ensure TA draws flags when picked up and ensure flag model is 1/10th size (so as not to obscure view) --- android/app/src/main/cpp/code/cgame/cg_draw.c | 4 +-- .../app/src/main/cpp/code/cgame/cg_players.c | 8 +++--- .../app/src/main/cpp/code/cgame/cg_weapons.c | 28 ++++++++++--------- 3 files changed, 21 insertions(+), 19 deletions(-) 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 696945e0..adfd7474 100644 --- a/android/app/src/main/cpp/code/cgame/cg_draw.c +++ b/android/app/src/main/cpp/code/cgame/cg_draw.c @@ -479,7 +479,7 @@ static void CG_DrawStatusBarHead( float x ) { } #endif // MISSIONPACK -/* +/*c ================ CG_DrawStatusBarFlag @@ -2901,7 +2901,7 @@ void CG_DrawActive( void ) { vec3_t forward, right, up; float scale = trap_Cvar_VariableValue("vr_worldscaleScaler"); - float dist = (trap_Cvar_VariableValue("vr_hudDepth")+2) * 6 * scale; + float dist = (trap_Cvar_VariableValue("vr_hudDepth")+2) * 5 * scale; float radius = dist / 3.0f; if (cg.snap->ps.stats[STAT_HEALTH] > 0 && diff --git a/android/app/src/main/cpp/code/cgame/cg_players.c b/android/app/src/main/cpp/code/cgame/cg_players.c index b41acd13..84d1ab2f 100644 --- a/android/app/src/main/cpp/code/cgame/cg_players.c +++ b/android/app/src/main/cpp/code/cgame/cg_players.c @@ -1692,7 +1692,7 @@ static void CG_PlayerFlag( centity_t *cent, qhandle_t hSkin, refEntity_t *torso int legsAnim, flagAnim, updateangles; float angle, d; - // show the flag pole model + // show the flag pole model memset( &pole, 0, sizeof(pole) ); pole.hModel = cgs.media.flagPoleModel; VectorCopy( torso->lightingOrigin, pole.lightingOrigin ); @@ -1908,7 +1908,7 @@ static void CG_PlayerPowerups( centity_t *cent, refEntity_t *torso ) { ci = &cgs.clientinfo[ cent->currentState.clientNum ]; // redflag if ( powerups & ( 1 << PW_REDFLAG ) ) { - if (ci->newAnims) { + if (ci->newAnims && cent->currentState.clientNum != vr->clientNum) { CG_PlayerFlag( cent, cgs.media.redFlagFlapSkin, torso ); } else { @@ -1921,7 +1921,7 @@ static void CG_PlayerPowerups( centity_t *cent, refEntity_t *torso ) { // blueflag if ( powerups & ( 1 << PW_BLUEFLAG ) ) { - if (ci->newAnims){ + if (ci->newAnims && cent->currentState.clientNum != vr->clientNum){ CG_PlayerFlag( cent, cgs.media.blueFlagFlapSkin, torso ); } else { @@ -1934,7 +1934,7 @@ static void CG_PlayerPowerups( centity_t *cent, refEntity_t *torso ) { // neutralflag if ( powerups & ( 1 << PW_NEUTRALFLAG ) ) { - if (ci->newAnims) { + if (ci->newAnims && cent->currentState.clientNum != vr->clientNum) { CG_PlayerFlag( cent, cgs.media.neutralFlagFlapSkin, torso ); } else { 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 cdb46a4c..ba8f8ac9 100644 --- a/android/app/src/main/cpp/code/cgame/cg_weapons.c +++ b/android/app/src/main/cpp/code/cgame/cg_weapons.c @@ -2068,19 +2068,21 @@ void CG_DrawWeaponSelector( void ) } const int selectorMode = (int)trap_Cvar_VariableValue("vr_weaponSelectorMode"); - float DEPTH = 5.0f; - float RAD = 4.0f; - float SCALE = 0.05f; + float dist = 10.0f; + float radius = 4.0f; + float scale = 0.05f; if (selectorMode == WS_HMD) // HMD locked { VectorCopy(vr->hmdorientation, cg.weaponSelectorAngles); VectorCopy(vr->hmdposition, cg.weaponSelectorOrigin); VectorClear(cg.weaponSelectorOffset); - DEPTH = 7.5f; // push a bit further away from the HMD origin + dist = (trap_Cvar_VariableValue("vr_hudDepth")+2) * 5; + radius = dist / 3.0f; + scale = 0.04f + 0.02f * (trap_Cvar_VariableValue("vr_hudDepth")+1); } - float frac = (cg.time - cg.weaponSelectorTime) / (20 * DEPTH); + float frac = (cg.time - cg.weaponSelectorTime) / 100.0f; if (frac > 1.0f) frac = 1.0f; vec3_t controllerOrigin, controllerAngles, controllerOffset, selectorOrigin; @@ -2103,7 +2105,7 @@ void CG_DrawWeaponSelector( void ) } VectorCopy(wheelOrigin, beamOrigin); - VectorMA(wheelOrigin, ((DEPTH*2.0f)*((selectorMode == WS_CONTROLLER) ? frac : 1.0f)), wheelForward, wheelOrigin); + VectorMA(wheelOrigin, (dist * ((selectorMode == WS_CONTROLLER) ? frac : 1.0f)), wheelForward, wheelOrigin); VectorCopy(wheelOrigin, selectorOrigin); const int switchThumbsticks = (int)trap_Cvar_VariableValue("vr_switchThumbsticks"); @@ -2138,17 +2140,17 @@ void CG_DrawWeaponSelector( void ) y = thumbstickAxisY; } - VectorMA(selectorOrigin, RAD * x, wheelRight, selectorOrigin); - VectorMA(selectorOrigin, RAD * y, wheelUp, selectorOrigin); + VectorMA(selectorOrigin, radius * x, wheelRight, selectorOrigin); + VectorMA(selectorOrigin, radius * y, wheelUp, selectorOrigin); { refEntity_t blob; memset( &blob, 0, sizeof( blob ) ); VectorCopy( selectorOrigin, blob.origin ); AnglesToAxis(vec3_origin, blob.axis); - VectorScale( blob.axis[0], SCALE - 0.01f, blob.axis[0] ); - VectorScale( blob.axis[1], SCALE - 0.01f, blob.axis[1] ); - VectorScale( blob.axis[2], SCALE - 0.01f, blob.axis[2] ); + VectorScale( blob.axis[0], scale - 0.01f, blob.axis[0] ); + VectorScale( blob.axis[1], scale - 0.01f, blob.axis[1] ); + VectorScale( blob.axis[2], scale - 0.01f, blob.axis[2] ); blob.nonNormalizedAxes = qtrue; blob.hModel = cgs.media.smallSphereModel; trap_R_AddRefEntityToScene( &blob ); @@ -2197,7 +2199,7 @@ void CG_DrawWeaponSelector( void ) vec3_t forward, up; AngleVectors(angles, forward, NULL, up); - VectorMA(wheelOrigin, (RAD*frac), up, iconOrigin); + VectorMA(wheelOrigin, (radius*frac), up, iconOrigin); VectorMA(iconOrigin, 0.2f, forward, iconBackground); VectorMA(iconOrigin, -0.2f, forward, iconForeground); @@ -2280,7 +2282,7 @@ void CG_DrawWeaponSelector( void ) iconAngles[ROLL] -= 90.0f; } - float weaponScale = ((SCALE+0.02f)*frac) + + float weaponScale = ((scale+0.02f)*frac) + (cg.weaponSelectorSelection == weaponId ? 0.04f : 0); AnglesToAxis(iconAngles, ent.axis);