Browse Source

Use channel's 3D level to handle sounds from the view entity. Fixes player sounds still panning left and right, and simplifies attenuation code.

console
Nico de Poel 5 years ago
parent
commit
dedad3b4e4
  1. 10
      engine/Quake/snd_fmod.c

10
engine/Quake/snd_fmod.c

@ -133,12 +133,6 @@ static float SND_FMOD_Attenuation(FMOD_CHANNELCONTROL *channelcontrol, float dis
return 1.0f; return 1.0f;
} }
// Anything coming from the view entity will always be full volume
if (userdata->entnum == cl.viewentity)
{
return 1.0f;
}
scale = 1.0f - (distance * userdata->dist_mult); scale = 1.0f - (distance * userdata->dist_mult);
if (scale < 0.0f) if (scale < 0.0f)
scale = 0.0f; scale = 0.0f;
@ -234,7 +228,9 @@ void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float f
FMOD_Channel_Set3DAttributes(channel, &position, NULL); FMOD_Channel_Set3DAttributes(channel, &position, NULL);
FMOD_Channel_SetMode(channel, FMOD_LOOP_OFF); // TODO: some entity sounds do need to loop, e.g. moving elevators. How is this done? FMOD_Channel_SetMode(channel, FMOD_LOOP_OFF); // TODO: some entity sounds do need to loop, e.g. moving elevators. How is this done?
FMOD_Channel_SetVolume(channel, fvol); FMOD_Channel_SetVolume(channel, fvol);
FMOD_Channel_Set3DLevel(channel, entchannel < 0 ? 0.0f : 1.0f); // entchannel -1 is used for local sounds
// Anything coming from the view entity will always be full volume, and entchannel -1 is used for local sounds (e.g. menu sounds)
FMOD_Channel_Set3DLevel(channel, entchannel < 0 || entnum == cl.viewentity ? 0.0f : 1.0f);
// TODO: attenuation (this is just a quick hack to test) // TODO: attenuation (this is just a quick hack to test)
entchannel_t *userdata = (entchannel_t*)malloc(sizeof(entchannel_t)); // TODO: we REALLY need to allocate this properly, this is now a memory leak!! entchannel_t *userdata = (entchannel_t*)malloc(sizeof(entchannel_t)); // TODO: we REALLY need to allocate this properly, this is now a memory leak!!

Loading…
Cancel
Save