From 60c10333aaf98a65fc0556b283c68df606b7ec7d Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 7 Jun 2021 02:21:46 +0300 Subject: [PATCH] engine: client: fix sound not spatialized correctly, remove unused field from rawchan --- engine/client/cl_frame.c | 22 ++++++++-------------- engine/client/sound.h | 1 - 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/engine/client/cl_frame.c b/engine/client/cl_frame.c index 2bb6a9c2..5b550ac1 100644 --- a/engine/client/cl_frame.c +++ b/engine/client/cl_frame.c @@ -1378,17 +1378,13 @@ qboolean CL_GetEntitySpatialization( channel_t *ch ) ent = CL_GetEntityByIndex( ch->entnum ); // entity is not present on the client but has valid origin - if( !ent || !ent->index || ent->curstate.messagenum == 0 ) + if( !ent || !ent->model || ent->curstate.messagenum != cl.parsecount ) return valid_origin; -#if 0 - // uncomment this if you want enable additional check by PVS - if( ent->curstate.messagenum != cl.parsecount ) - return valid_origin; -#endif - // setup origin - VectorAverage( ent->curstate.mins, ent->curstate.maxs, ch->origin ); - VectorAdd( ch->origin, ent->curstate.origin, ch->origin ); + VectorCopy( ent->origin, ch->origin ); + + if( ent->model->type == mod_brush ) + VectorAverage( ent->curstate.mins, ent->curstate.maxs, ch->origin ); return true; } @@ -1406,12 +1402,10 @@ qboolean CL_GetMovieSpatialization( rawchan_t *ch ) return valid_origin; // setup origin - VectorAverage( ent->curstate.mins, ent->curstate.maxs, ch->origin ); - VectorAdd( ch->origin, ent->curstate.origin, ch->origin ); + VectorCopy( ent->origin, ch->origin ); - // setup radius - if( ent->model != NULL && ent->model->radius ) ch->radius = ent->model->radius; - else ch->radius = RadiusFromBounds( ent->curstate.mins, ent->curstate.maxs ); + if( ent->model->type == mod_brush ) + VectorAverage( ent->curstate.mins, ent->curstate.maxs, ch->origin ); return true; } diff --git a/engine/client/sound.h b/engine/client/sound.h index 791820db..7be57049 100644 --- a/engine/client/sound.h +++ b/engine/client/sound.h @@ -138,7 +138,6 @@ typedef struct rawchan_s int rightvol; // 0-255 right volume float dist_mult; // distance multiplier (attenuation/clipK) vec3_t origin; // only use if fixed_origin is set - float radius; // radius of this sound effect volatile uint s_rawend; wavdata_t sound_info; // advance play position float oldtime; // catch time jumps