Fix issue with multiple item pickup events playing

This was causing horrible audio, as multiple item pickup events were all playing at the same time. This was because the predict player state was being called once per eye, and by the time it came to the right eye it had cleared the buffer and it would just allow server events to get played again. The actual fix is in cg_view.c, line 994, where we only predict if the eye being rendered is the left.
This commit is contained in:
Simon 2022-03-16 23:03:37 +00:00
parent b6896417cf
commit 0772bc8c0b
5 changed files with 28 additions and 21 deletions

View file

@ -40,7 +40,6 @@ int sortedTeamPlayers[TEAM_MAXOVERLAY];
int numSortedTeamPlayers;
extern vr_clientinfo_t* vr;
extern stereoFrame_t hudStereoView;
char systemChat[256];
char teamChat1[256];
@ -983,7 +982,7 @@ CG_DrawUpperRight
=====================
*/
static void CG_DrawUpperRight(stereoFrame_t stereoFrame)
static void CG_DrawUpperRight()
{
float y;
@ -995,7 +994,7 @@ static void CG_DrawUpperRight(stereoFrame_t stereoFrame)
if ( cg_drawSnapshot.integer ) {
y = CG_DrawSnapshot( y );
}
if (cg_drawFPS.integer && (stereoFrame == STEREO_CENTER || stereoFrame == STEREO_RIGHT)) {
if (cg_drawFPS.integer && (cg.stereoView == STEREO_CENTER || cg.stereoView == STEREO_RIGHT)) {
y = CG_DrawFPS( y );
}
if ( cg_drawTimer.integer ) {
@ -2639,7 +2638,7 @@ static void CG_DrawVignette( void )
CG_Draw2D
=================
*/
static void CG_Draw2D(stereoFrame_t stereoFrame)
static void CG_Draw2D()
{
#ifdef MISSIONPACK
if (cgs.orderPending && cg.time > cgs.orderTime) {
@ -2727,10 +2726,10 @@ static void CG_Draw2D(stereoFrame_t stereoFrame)
#ifdef MISSIONPACK
if (!cg_paused.integer) {
CG_DrawUpperRight(stereoFrame);
CG_DrawUpperRight();
}
#else
CG_DrawUpperRight(stereoFrame);
CG_DrawUpperRight();
#endif
#ifndef MISSIONPACK
@ -2757,7 +2756,7 @@ CG_DrawActive
Perform all drawing needed to completely fill the screen
=====================
*/
void CG_DrawActive( stereoFrame_t stereoView ) {
void CG_DrawActive( void ) {
// optionally draw the info screen instead
if ( !cg.snap ) {
CG_DrawInformation();
@ -2800,7 +2799,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
float ipd = trap_Cvar_VariableValue("r_stereoSeparation") / 1000.0f;
float separation = worldscale * (ipd / 2) * (stereoView == STEREO_LEFT ? -1.0f : 1.0f);
float separation = worldscale * (ipd / 2) * (cg.stereoView == STEREO_LEFT ? -1.0f : 1.0f);
if (cg.snap->ps.pm_flags & PMF_FOLLOW && vr->follow_mode == VRFM_FIRSTPERSON)
{
@ -2847,8 +2846,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
VectorCopy( baseOrg, cg.refdef.vieworg );
// draw status bar and other floating elements
hudStereoView = stereoView;
CG_Draw2D(hudStereoView);
CG_Draw2D();
}

View file

@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../vr/vr_clientinfo.h"
int hudflags = 0;
stereoFrame_t hudStereoView = STEREO_CENTER;
extern vr_clientinfo_t* vr;
void CG_SetHUDFlags(int flags)
@ -63,7 +62,7 @@ void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
const auto depth = (int)trap_Cvar_VariableValue( "vr_hudDepth" );
int xoffset = 120 - (depth * 20);
if (hudStereoView == STEREO_RIGHT) {
if (cg.stereoView == STEREO_RIGHT) {
xoffset *= -1;
}

View file

@ -481,6 +481,8 @@ typedef struct {
float worldscale;
stereoFrame_t stereoView;
int frametime; // cg.time - cg.oldTime
int time; // this is the time value that the client
@ -1317,7 +1319,7 @@ void CG_AddLagometerFrameInfo( void );
void CG_AddLagometerSnapshotInfo( snapshot_t *snap );
void CG_CenterPrint( const char *str, int y, int charWidth );
void CG_DrawHead( float x, float y, float w, float h, int clientNum, vec3_t headAngles );
void CG_DrawActive( stereoFrame_t stereoView );
void CG_DrawActive( void );
void CG_DrawFlagModel( float x, float y, float w, float h, int team, qboolean force2D );
void CG_DrawTeamBackground( int x, int y, int w, int h, float alpha, int team );
void CG_OwnerDraw(float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, float scale, vec4_t color, qhandle_t shader, int textStyle);

View file

@ -297,8 +297,12 @@ static void CG_TouchItem( centity_t *cent ) {
return;
}
// grab it
BG_AddPredictableEventToPlayerstate( EV_ITEM_PICKUP, cent->currentState.modelindex , &cg.predictedPlayerState);
if (cg.stereoView == STEREO_LEFT)
{
// grab it
BG_AddPredictableEventToPlayerstate(EV_ITEM_PICKUP, cent->currentState.modelindex,
&cg.predictedPlayerState);
}
// remove it from the frame so it won't be drawn
cent->currentState.eFlags |= EF_NODRAW;

View file

@ -657,7 +657,7 @@ CG_CalcViewValues
Sets cg.refdef view values
===============
*/
static int CG_CalcViewValues( stereoFrame_t stereoView ) {
static int CG_CalcViewValues( ) {
playerState_t *ps;
memset( &cg.refdef, 0, sizeof( cg.refdef ) );
@ -755,7 +755,7 @@ static int CG_CalcViewValues( stereoFrame_t stereoView ) {
VectorCopy(cg.refdef.vieworg, cg.vr_vieworigin);
}
if (!cgs.localServer && stereoView == STEREO_LEFT)
if (!cgs.localServer && cg.stereoView == STEREO_LEFT)
{
vec3_t weaponorigin, weaponangles;
CG_CalculateVRWeaponPosition(weaponorigin, weaponangles);
@ -954,6 +954,7 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
cg.time = serverTime;
cg.demoPlayback = demoPlayback;
cg.stereoView = stereoView;
cg.worldscale = trap_Cvar_VariableValue("vr_worldscale");
@ -990,8 +991,11 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
// this counter will be bumped for every valid scene we generate
cg.clientFrame++;
// update cg.predictedPlayerState
CG_PredictPlayerState();
if (cg.stereoView == STEREO_LEFT)
{
// update cg.predictedPlayerState - only do this on the first eye render
CG_PredictPlayerState();
}
// decide on third person view
cg.renderingThirdPerson = cg.predictedPlayerState.pm_type == PM_SPECTATOR ||
@ -999,7 +1003,7 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
cg_thirdPerson.integer;
// build cg.refdef
inwater = CG_CalcViewValues( stereoView );
inwater = CG_CalcViewValues( );
// first person blend blobs, done after AnglesToAxis
if ( !cg.renderingThirdPerson ) {
@ -1063,7 +1067,7 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
}
// actually issue the rendering calls
CG_DrawActive( stereoView );
CG_DrawActive();
if ( cg_stats.integer ) {
CG_Printf( "cg.clientFrame:%i\n", cg.clientFrame );