mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-28 20:00:54 +00:00
Changed: Avoid some more sqrt calculations
This commit is contained in:
parent
971f753706
commit
a3616abd5c
1 changed files with 4 additions and 3 deletions
|
@ -82,13 +82,13 @@ float ISource::computeManualRolloff(double alpha, float sqrdist, float distMin,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double dist = (double)sqrt(sqrdist);
|
|
||||||
if (alpha < 0.0f)
|
if (alpha < 0.0f)
|
||||||
{
|
{
|
||||||
|
double dist = (double)sqrt(sqrdist);
|
||||||
// inverse distance rolloff
|
// inverse distance rolloff
|
||||||
float rolloff = distMin / dist;
|
float rolloff = distMin / dist;
|
||||||
if (alpha <= -1.0f) return rolloff;
|
if (alpha <= -1.0f) return rolloff;
|
||||||
|
|
||||||
double mb = mbMin * (dist - distMin) / (distMax - distMin);
|
double mb = mbMin * (dist - distMin) / (distMax - distMin);
|
||||||
float mbrolloff = (float)pow(10.0, (double)mb / 2000.0);
|
float mbrolloff = (float)pow(10.0, (double)mb / 2000.0);
|
||||||
return ((1.0 + alpha) * mbrolloff - alpha * rolloff);
|
return ((1.0 + alpha) * mbrolloff - alpha * rolloff);
|
||||||
|
@ -100,6 +100,7 @@ float ISource::computeManualRolloff(double alpha, float sqrdist, float distMin,
|
||||||
// full attenuation
|
// full attenuation
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
double dist = (double)sqrt(sqrdist);
|
||||||
if (alpha == 0.0f)
|
if (alpha == 0.0f)
|
||||||
{
|
{
|
||||||
// linearly descending volume on a dB scale
|
// linearly descending volume on a dB scale
|
||||||
|
@ -111,7 +112,7 @@ float ISource::computeManualRolloff(double alpha, float sqrdist, float distMin,
|
||||||
// linear distance rolloff
|
// linear distance rolloff
|
||||||
float rolloff = (distMax - dist) / (distMax - distMin);
|
float rolloff = (distMax - dist) / (distMax - distMin);
|
||||||
if (alpha >= 1.0f) return rolloff;
|
if (alpha >= 1.0f) return rolloff;
|
||||||
|
|
||||||
double mb = mbMin * (dist - distMin) / (distMax - distMin);
|
double mb = mbMin * (dist - distMin) / (distMax - distMin);
|
||||||
float mbrolloff = (float)pow(10.0, (double)mb / 2000.0);
|
float mbrolloff = (float)pow(10.0, (double)mb / 2000.0);
|
||||||
return ((1.0 - alpha) * mbrolloff + alpha * rolloff);
|
return ((1.0 - alpha) * mbrolloff + alpha * rolloff);
|
||||||
|
|
Loading…
Reference in a new issue