From 6bc3ef2ba6df4c09d257da71be63fc86eea8019a Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 3 Jun 2012 15:56:47 +0200 Subject: [PATCH] Changed: Also handle distMax with negative alpha in new manual rolloff function --HG-- branch : sound_dev --- code/nel/src/sound/driver/source.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/code/nel/src/sound/driver/source.cpp b/code/nel/src/sound/driver/source.cpp index a35698d1c..6ef5e420c 100644 --- a/code/nel/src/sound/driver/source.cpp +++ b/code/nel/src/sound/driver/source.cpp @@ -89,9 +89,17 @@ float ISource::computeManualRolloff(double alpha, float sqrdist, float distMin, float rolloff = distMin / dist; if (alpha <= -1.0f) return rolloff; - double mb = mbMin * (dist - distMin) / (distMax - distMin); - float mbrolloff = (float)pow(10.0, (double)mb / 2000.0); - return ((1.0 + alpha) * mbrolloff - alpha * rolloff); + if (dist > distMax) + { + // full attenuation of mbrolloff + return (-alpha * rolloff); + } + else + { + double mb = mbMin * (dist - distMin) / (distMax - distMin); + float mbrolloff = (float)pow(10.0, (double)mb / 2000.0); + return ((1.0 + alpha) * mbrolloff - alpha * rolloff); + } } else {