mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-16 17:11:03 +00:00
Merge pull request #193 from xorw/master
Add partial doppler shift support for 3D audio sources.
This commit is contained in:
commit
e6d46eb452
3 changed files with 26 additions and 0 deletions
|
@ -915,3 +915,21 @@ CL_GetEntitySoundOrigin(int ent, vec3_t org)
|
||||||
VectorCopy(old->lerp_origin, org);
|
VectorCopy(old->lerp_origin, org);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called to get the sound spatialization
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
CL_GetEntitySoundVelocity(int ent, vec3_t vel)
|
||||||
|
{
|
||||||
|
centity_t *old;
|
||||||
|
|
||||||
|
if ((ent < 0) || (ent >= MAX_EDICTS))
|
||||||
|
{
|
||||||
|
Com_Error(ERR_DROP, "CL_GetEntitySoundVelocity: bad ent");
|
||||||
|
}
|
||||||
|
|
||||||
|
old = &cl_entities[ent];
|
||||||
|
|
||||||
|
VectorSubtract(old->current.origin, old->prev.origin, vel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,5 +54,6 @@ struct sfx_s *S_FindName(char *name, qboolean create);
|
||||||
entitiy position information, so entities can be
|
entitiy position information, so entities can be
|
||||||
dynamically re-spatialized */
|
dynamically re-spatialized */
|
||||||
void CL_GetEntitySoundOrigin(int ent, vec3_t org);
|
void CL_GetEntitySoundOrigin(int ent, vec3_t org);
|
||||||
|
void CL_GetEntitySoundVelocity(int ent, vec3_t vel);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -199,6 +199,7 @@ static void
|
||||||
AL_Spatialize(channel_t *ch)
|
AL_Spatialize(channel_t *ch)
|
||||||
{
|
{
|
||||||
vec3_t origin;
|
vec3_t origin;
|
||||||
|
vec3_t velocity;
|
||||||
|
|
||||||
if ((ch->entnum == -1) || (ch->entnum == cl.playernum + 1) || !ch->dist_mult)
|
if ((ch->entnum == -1) || (ch->entnum == cl.playernum + 1) || !ch->dist_mult)
|
||||||
{
|
{
|
||||||
|
@ -218,6 +219,9 @@ AL_Spatialize(channel_t *ch)
|
||||||
{
|
{
|
||||||
CL_GetEntitySoundOrigin(ch->entnum, origin);
|
CL_GetEntitySoundOrigin(ch->entnum, origin);
|
||||||
qalSource3f(ch->srcnum, AL_POSITION, AL_UnpackVector(origin));
|
qalSource3f(ch->srcnum, AL_POSITION, AL_UnpackVector(origin));
|
||||||
|
|
||||||
|
CL_GetEntitySoundVelocity(ch->entnum, velocity);
|
||||||
|
qalSource3f(ch->srcnum, AL_VELOCITY, AL_UnpackVector(velocity));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,6 +617,9 @@ AL_Update(void)
|
||||||
qalListener3f(AL_POSITION, AL_UnpackVector(listener_origin));
|
qalListener3f(AL_POSITION, AL_UnpackVector(listener_origin));
|
||||||
qalListenerfv(AL_ORIENTATION, orientation);
|
qalListenerfv(AL_ORIENTATION, orientation);
|
||||||
|
|
||||||
|
// TODO(xorw): add current listener's velocity update
|
||||||
|
// qalListener3f(AL_VELOCITY, AL_UnpackVector(listener_velocity));
|
||||||
|
|
||||||
/* update spatialization for dynamic sounds */
|
/* update spatialization for dynamic sounds */
|
||||||
ch = channels;
|
ch = channels;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue