From af495e03a0c720b705b58f74275012ecab86f7c2 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 7 Mar 2022 20:42:26 +0000 Subject: [PATCH] Tweaks to weapon selector and make damage roll cvar apply to pitch too --- android/app/src/main/cpp/code/cgame/cg_view.c | 4 ++-- .../app/src/main/cpp/code/cgame/cg_weapons.c | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) 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 a6f7f728..36c70201 100644 --- a/android/app/src/main/cpp/code/cgame/cg_view.c +++ b/android/app/src/main/cpp/code/cgame/cg_view.c @@ -381,12 +381,12 @@ static void CG_OffsetFirstPersonView( void ) { ratio = cg.time - cg.damageTime; if ( ratio < DAMAGE_DEFLECT_TIME ) { ratio /= DAMAGE_DEFLECT_TIME; - angles[PITCH] += ratio * cg.v_dmg_pitch; + angles[PITCH] += ratio * cg.v_dmg_pitch * hitRollCoeff; angles[ROLL] += ratio * cg.v_dmg_roll * hitRollCoeff; } else { ratio = 1.0 - ( ratio - DAMAGE_DEFLECT_TIME ) / DAMAGE_RETURN_TIME; if ( ratio > 0 ) { - angles[PITCH] += ratio * cg.v_dmg_pitch; + angles[PITCH] += ratio * cg.v_dmg_pitch * hitRollCoeff; angles[ROLL] += ratio * cg.v_dmg_roll * hitRollCoeff; } } 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 8ef19056..83509be1 100644 --- a/android/app/src/main/cpp/code/cgame/cg_weapons.c +++ b/android/app/src/main/cpp/code/cgame/cg_weapons.c @@ -2083,7 +2083,7 @@ void CG_DrawHolsteredWeapons( void ) { if ( cg_weapons[ weapons[w] ].item ) { //first calculate holster slot position - vec3_t angles, iconOrigin; + vec3_t angles, iconOrigin,iconBackground; VectorClear(angles); angles[YAW] = startingPositionYaw - (w * SEP) - 4; // add a few degrees as models aren't central vec3_t forward; @@ -2092,10 +2092,13 @@ void CG_DrawHolsteredWeapons( void ) int dist = (cg.time - cg.weaponHolsterTime) / 10; if (dist > DIST) dist = DIST; VectorMA(vieworg, dist, forward, iconOrigin); + VectorMA(vieworg, dist+0.01f, forward, iconBackground); float worldscale = trap_Cvar_VariableValue("vr_worldscale"); iconOrigin[2] -= PLAYER_HEIGHT; iconOrigin[2] += (vr->hmdposition[1] * 0.85f) * worldscale; + iconBackground[2] -= PLAYER_HEIGHT; + iconBackground[2] += (vr->hmdposition[1] * 0.85f) * worldscale; //Float sprite above selected weapon qboolean selected = qfalse; @@ -2109,7 +2112,7 @@ void CG_DrawHolsteredWeapons( void ) refEntity_t sprite; memset( &sprite, 0, sizeof( sprite ) ); VectorCopy( iconOrigin, sprite.origin ); - sprite.origin[2] += 2.5f + (0.5f * sinf(DEG2RAD(AngleNormalize360(cg.time/6)))); + sprite.origin[2] += 2.5f + (0.5f * sinf(DEG2RAD(AngleNormalize360((cg.time - cg.weaponHolsterTime)/4)))); sprite.reType = RT_SPRITE; sprite.customShader = cgs.media.friendShader; sprite.radius = 0.5f; @@ -2164,7 +2167,7 @@ void CG_DrawHolsteredWeapons( void ) barrel.hModel = cg_weapons[weapons[w]].barrelModel; vec3_t barrelAngles; VectorClear(barrelAngles); - barrelAngles[ROLL] = AngleNormalize360(cg.time * 0.9f); + barrelAngles[ROLL] = AngleNormalize360((cg.time - cg.weaponHolsterTime) * 0.9f); AnglesToAxis(barrelAngles, barrel.axis); CG_PositionRotatedEntityOnTag(&barrel, &ent, cg_weapons[weapons[w]].weaponModel, "tag_barrel"); @@ -2185,6 +2188,16 @@ void CG_DrawHolsteredWeapons( void ) sprite.shaderRGBA[2] = 255; sprite.shaderRGBA[3] = 255; trap_R_AddRefEntityToScene( &sprite ); + + //And now the selection background + VectorCopy( iconBackground, sprite.origin ); + sprite.customShader = cgs.media.selectShader; + sprite.radius = 0.7f + (selected ? 0.1f : 0); + sprite.shaderRGBA[0] = 255; + sprite.shaderRGBA[1] = 255; + sprite.shaderRGBA[2] = 255; + sprite.shaderRGBA[3] = 255; + trap_R_AddRefEntityToScene( &sprite ); } } }