mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-16 17:11:03 +00:00
Make sure not all OpenAL sources are relative, fix #100
OpenAL sources are reused in Quake2, so if a source has once been used for a sound coming from the view entity, it'd stay relative, unless told not to. So now I set source's AL_SOURCE_RELATIVE to AL_TRUE or AL_FALSE in AL_PlayChannel(), depending on the source coming from the player or not. Thanks a lot to Tommi Teistelä for identifying the problem and pushing me in the right direction!
This commit is contained in:
parent
87ed67fd3d
commit
1977570b17
1 changed files with 19 additions and 6 deletions
|
@ -198,13 +198,12 @@ AL_Spatialize(channel_t *ch)
|
|||
{
|
||||
vec3_t origin;
|
||||
|
||||
/* anything coming from the view entity
|
||||
will always be full volume. no
|
||||
attenuation = no spatialization */
|
||||
if ((ch->entnum == -1) || (ch->entnum == cl.playernum + 1) || !ch->dist_mult)
|
||||
{
|
||||
qalSource3f(ch->srcnum, AL_POSITION, 0,0,0);
|
||||
qalSourcei(ch->srcnum, AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
/* from view entity (player) => nothing to do,
|
||||
* position is still (0,0,0) and relative,
|
||||
* as set in AL_PlayChannel() */
|
||||
|
||||
return;
|
||||
}
|
||||
else if (ch->fixed_origin)
|
||||
|
@ -247,7 +246,7 @@ AL_PlayChannel(channel_t *ch)
|
|||
vol = 1.0f;
|
||||
}
|
||||
|
||||
sc = ch->sfx->cache;
|
||||
sc = ch->sfx->cache;
|
||||
ch->srcnum = s_srcnums[ch - channels];
|
||||
|
||||
qalGetError();
|
||||
|
@ -258,6 +257,20 @@ AL_PlayChannel(channel_t *ch)
|
|||
qalSourcei(ch->srcnum, AL_BUFFER, sc->bufnum);
|
||||
qalSourcei(ch->srcnum, AL_LOOPING, ch->autosound ? AL_TRUE : AL_FALSE);
|
||||
|
||||
if ((ch->entnum == -1) || (ch->entnum == cl.playernum + 1) || !ch->dist_mult)
|
||||
{
|
||||
/* anything coming from the view entity will always
|
||||
* be full volume and at the listeners position */
|
||||
qalSource3f(ch->srcnum, AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
qalSourcei(ch->srcnum, AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* all other sources are *not* relative */
|
||||
qalSourcei(ch->srcnum, AL_SOURCE_RELATIVE, AL_FALSE);
|
||||
}
|
||||
|
||||
|
||||
/* Spatialize it */
|
||||
AL_Spatialize(ch);
|
||||
|
||||
|
|
Loading…
Reference in a new issue