mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-22 20:51:31 +00:00
Merge pull request #196 from xorw/master
Finished doppler shift support (added listener's velocity update)
This commit is contained in:
commit
8af427b0c9
3 changed files with 16 additions and 2 deletions
|
@ -933,3 +933,13 @@ CL_GetEntitySoundVelocity(int ent, vec3_t vel)
|
|||
VectorSubtract(old->current.origin, old->prev.origin, vel);
|
||||
}
|
||||
|
||||
void
|
||||
CL_GetViewVelocity(vec3_t vel)
|
||||
{
|
||||
// restore value from 12.3 fixed point
|
||||
const float scale_factor = 1.0f / 8.0f;
|
||||
|
||||
vel[0] = (float)cl.frame.playerstate.pmove.velocity[0] * scale_factor;
|
||||
vel[1] = (float)cl.frame.playerstate.pmove.velocity[1] * scale_factor;
|
||||
vel[2] = (float)cl.frame.playerstate.pmove.velocity[2] * scale_factor;
|
||||
}
|
||||
|
|
|
@ -55,5 +55,6 @@ struct sfx_s *S_FindName(char *name, qboolean create);
|
|||
dynamically re-spatialized */
|
||||
void CL_GetEntitySoundOrigin(int ent, vec3_t org);
|
||||
void CL_GetEntitySoundVelocity(int ent, vec3_t vel);
|
||||
void CL_GetViewVelocity(vec3_t vel);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -607,6 +607,7 @@ AL_Update(void)
|
|||
int i;
|
||||
channel_t *ch;
|
||||
vec_t orientation[6];
|
||||
vec3_t listener_velocity;
|
||||
|
||||
paintedtime = cls.realtime;
|
||||
|
||||
|
@ -617,8 +618,10 @@ AL_Update(void)
|
|||
qalListener3f(AL_POSITION, AL_UnpackVector(listener_origin));
|
||||
qalListenerfv(AL_ORIENTATION, orientation);
|
||||
|
||||
// TODO(xorw): add current listener's velocity update
|
||||
// qalListener3f(AL_VELOCITY, AL_UnpackVector(listener_velocity));
|
||||
CL_GetViewVelocity(listener_velocity);
|
||||
// xorw: sounds funky if not scaled down a lot
|
||||
VectorScale(listener_velocity, 0.05f, listener_velocity);
|
||||
qalListener3f(AL_VELOCITY, AL_UnpackVector(listener_velocity));
|
||||
|
||||
/* update spatialization for dynamic sounds */
|
||||
ch = channels;
|
||||
|
|
Loading…
Reference in a new issue