Use a proper enum for the distance model

This commit is contained in:
Chris Robinson 2011-07-03 19:39:19 -07:00
parent 5ba864b6da
commit 202f57552a
4 changed files with 20 additions and 10 deletions

View File

@ -471,13 +471,13 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
switch(ALContext->SourceDistanceModel ? ALSource->DistanceModel :
ALContext->DistanceModel)
{
case AL_INVERSE_DISTANCE_CLAMPED:
case InverseDistanceClamped:
ClampedDist=__max(ClampedDist,MinDist);
ClampedDist=__min(ClampedDist,MaxDist);
if(MaxDist < MinDist)
break;
//fall-through
case AL_INVERSE_DISTANCE:
case InverseDistance:
if(MinDist > 0.0f)
{
if((MinDist + (Rolloff * (ClampedDist - MinDist))) > 0.0f)
@ -490,13 +490,13 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
}
break;
case AL_LINEAR_DISTANCE_CLAMPED:
case LinearDistanceClamped:
ClampedDist=__max(ClampedDist,MinDist);
ClampedDist=__min(ClampedDist,MaxDist);
if(MaxDist < MinDist)
break;
//fall-through
case AL_LINEAR_DISTANCE:
case LinearDistance:
if(MaxDist != MinDist)
{
Attenuation = 1.0f - (Rolloff*(ClampedDist-MinDist)/(MaxDist - MinDist));
@ -509,13 +509,13 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
}
break;
case AL_EXPONENT_DISTANCE_CLAMPED:
case ExponentDistanceClamped:
ClampedDist=__max(ClampedDist,MinDist);
ClampedDist=__min(ClampedDist,MaxDist);
if(MaxDist < MinDist)
break;
//fall-through
case AL_EXPONENT_DISTANCE:
case ExponentDistance:
if(ClampedDist > 0.0f && MinDist > 0.0f)
{
Attenuation = aluPow(ClampedDist/MinDist, -Rolloff);
@ -524,7 +524,7 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
}
break;
case AL_NONE:
case DisableDistance:
break;
}

View File

@ -464,8 +464,8 @@ struct ALCcontext_struct
ALboolean Suspended;
ALenum DistanceModel;
ALboolean SourceDistanceModel;
enum DistanceModel DistanceModel;
ALboolean SourceDistanceModel;
ALfloat DopplerFactor;
ALfloat DopplerVelocity;

View File

@ -45,7 +45,7 @@ typedef struct ALsource
ALfloat vOrientation[3];
ALboolean bHeadRelative;
ALboolean bLooping;
ALenum DistanceModel;
enum DistanceModel DistanceModel;
ALboolean VirtualChannels;
enum Resampler Resampler;

View File

@ -94,6 +94,16 @@ enum Channel {
MAXCHANNELS
};
enum DistanceModel {
InverseDistanceClamped = AL_INVERSE_DISTANCE_CLAMPED,
LinearDistanceClamped = AL_LINEAR_DISTANCE_CLAMPED,
ExponentDistanceClamped = AL_EXPONENT_DISTANCE_CLAMPED,
InverseDistance = AL_INVERSE_DISTANCE,
LinearDistance = AL_LINEAR_DISTANCE,
ExponentDistance = AL_EXPONENT_DISTANCE,
DisableDistance = AL_NONE
};
#define BUFFERSIZE 4096
#define FRACTIONBITS (14)