Avoid divide-by-0 when the area sound radius is less than the max distance

This commit is contained in:
Chris Robinson 2016-05-03 21:05:13 -07:00 committed by Christoph Oelckers
parent 66c61a7c8b
commit e298f8389b
1 changed files with 2 additions and 1 deletions

View File

@ -1431,7 +1431,8 @@ FISoundChannel *OpenALSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener
/* Since the OpenAL distance is decoupled from the sound's distance, get the OpenAL
* distance that corresponds to the area radius. */
alSourcef(source, AL_SOURCE_RADIUS, (chanflags&SNDF_AREA) ?
1.f / GetRolloff(rolloff, AREA_SOUND_RADIUS) : 0.f
// Clamp in case the max distance is <= the area radius
1.f/MAX<float>(GetRolloff(rolloff, AREA_SOUND_RADIUS), 0.00001f) : 0.f
);
}
else if((chanflags&SNDF_AREA) && dist_sqr < AREA_SOUND_RADIUS*AREA_SOUND_RADIUS)