From 2fc601c556cc907fdaa8a45f8aa742b2e36935aa Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 3 Jun 2012 02:00:32 +0200 Subject: [PATCH] Changed: Avoid some more sqrt calculations --HG-- branch : sound_dev --- code/nel/src/sound/driver/source.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/nel/src/sound/driver/source.cpp b/code/nel/src/sound/driver/source.cpp index 3ef9aa279..a35698d1c 100644 --- a/code/nel/src/sound/driver/source.cpp +++ b/code/nel/src/sound/driver/source.cpp @@ -82,13 +82,13 @@ float ISource::computeManualRolloff(double alpha, float sqrdist, float distMin, } else { - double dist = (double)sqrt(sqrdist); if (alpha < 0.0f) { + double dist = (double)sqrt(sqrdist); // inverse distance rolloff 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); @@ -100,6 +100,7 @@ float ISource::computeManualRolloff(double alpha, float sqrdist, float distMin, // full attenuation return 0.0f; } + double dist = (double)sqrt(sqrdist); if (alpha == 0.0f) { // linearly descending volume on a dB scale @@ -111,7 +112,7 @@ float ISource::computeManualRolloff(double alpha, float sqrdist, float distMin, // linear distance rolloff float rolloff = (distMax - dist) / (distMax - distMin); 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);