- another #include fix for Linux.

- Added a 'logarithmic' parameter to S_GetRolloff.


SVN r1235 (trunk)
This commit is contained in:
Christoph Oelckers 2008-09-18 21:00:12 +00:00
parent 4ecb892df3
commit 71dd0d0269
4 changed files with 24 additions and 7 deletions

View File

@ -1778,7 +1778,7 @@ static void S_SetListener(SoundListener &listener, AActor *listenactor)
//
//==========================================================================
float S_GetRolloff(FRolloffInfo *rolloff, float distance)
float S_GetRolloff(FRolloffInfo *rolloff, float distance, bool logarithmic)
{
if (rolloff == NULL)
{
@ -1803,13 +1803,27 @@ float S_GetRolloff(FRolloffInfo *rolloff, float distance)
{
volume = S_SoundCurve[int(S_SoundCurveSize * (1 - volume))] / 127.f;
}
if (logarithmic)
{
if (rolloff->RolloffType == ROLLOFF_Linear)
{
return volume;
}
else
{
return (powf(10.f, volume) - 1.f) / 9.f;
return float((pow(10.f, volume) - 1.) / 9.);
}
}
else
{
if (rolloff->RolloffType == ROLLOFF_Linear)
{
return float(log10(9. * volume + 1.));
}
else
{
return volume;
}
}
}

View File

@ -54,6 +54,9 @@
#include "errors.h"
#include "version.h"
#include "w_wad.h"
#include "g_level.h"
#include "r_state.h"
#include "cmdlib.h"
// MACROS ------------------------------------------------------------------

View File

@ -2040,11 +2040,11 @@ float F_CALLBACK FMODSoundRenderer::RolloffCallback(FMOD_CHANNEL *channel, float
if (GRolloff != NULL)
{
return S_GetRolloff(GRolloff, distance * GDistScale);
return S_GetRolloff(GRolloff, distance * GDistScale, true);
}
else if (chan->getUserData((void **)&schan) == FMOD_OK && schan != NULL)
{
return S_GetRolloff(&schan->Rolloff, distance * schan->DistanceScale);
return S_GetRolloff(&schan->Rolloff, distance * schan->DistanceScale, true);
}
else
{

View File

@ -141,7 +141,7 @@ void I_InitSound ();
void I_ShutdownSound ();
void S_ChannelEnded(FISoundChannel *schan);
float S_GetRolloff(FRolloffInfo *rolloff, float distance);
float S_GetRolloff(FRolloffInfo *rolloff, float distance, bool logarithmic);
FISoundChannel *S_GetChannel(void *syschan);
extern ReverbContainer *DefaultEnvironments[26];