summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-12-16 07:20:27 -0800
committerChris Robinson <[email protected]>2014-12-16 07:20:27 -0800
commit3b8f54d572b586cd60e6b0c8d839c71edeabbdae (patch)
tree18ceb20f443075707db5a56db4dcc5e40c5b72f3
parent97f6d302fe61529ca590d67af9c32bb42e75cdf5 (diff)
Use aluVector in some more places
-rw-r--r--Alc/ALc.c8
-rw-r--r--Alc/ALu.c67
-rw-r--r--OpenAL32/Include/alListener.h4
-rw-r--r--OpenAL32/Include/alSource.h6
-rw-r--r--OpenAL32/alListener.c32
-rw-r--r--OpenAL32/alSource.c42
6 files changed, 66 insertions, 93 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 4c030478..2f174744 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -2259,12 +2259,8 @@ static ALvoid InitContext(ALCcontext *Context)
//Initialise listener
Context->Listener->Gain = 1.0f;
Context->Listener->MetersPerUnit = 1.0f;
- Context->Listener->Position[0] = 0.0f;
- Context->Listener->Position[1] = 0.0f;
- Context->Listener->Position[2] = 0.0f;
- Context->Listener->Velocity[0] = 0.0f;
- Context->Listener->Velocity[1] = 0.0f;
- Context->Listener->Velocity[2] = 0.0f;
+ aluVectorSet(&Context->Listener->Position, 0.0f, 0.0f, 0.0f, 1.0f);
+ aluVectorSet(&Context->Listener->Velocity, 0.0f, 0.0f, 0.0f, 0.0f);
Context->Listener->Forward[0] = 0.0f;
Context->Listener->Forward[1] = 0.0f;
Context->Listener->Forward[2] = -1.0f;
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 4b3626ff..c10c18a6 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -260,9 +260,9 @@ static ALvoid CalcListenerParams(ALlistener *Listener)
aluCrossproduct(N, V, U);
aluNormalize(U);
- P[0] = Listener->Position[0];
- P[1] = Listener->Position[1];
- P[2] = Listener->Position[2];
+ P[0] = Listener->Position.v[0];
+ P[1] = Listener->Position.v[1];
+ P[2] = Listener->Position.v[2];
aluMatrixSet(&Listener->Params.Matrix,
U[0], V[0], -N[0], 0.0f,
@@ -273,9 +273,7 @@ static ALvoid CalcListenerParams(ALlistener *Listener)
aluMatrixVector(P, 1.0f, &Listener->Params.Matrix);
aluMatrixSetRow(&Listener->Params.Matrix, 3, -P[0], -P[1], -P[2], 1.0f);
- aluVectorSet(&Listener->Params.Velocity,
- Listener->Velocity[0], Listener->Velocity[1], Listener->Velocity[2], 0.0f
- );
+ Listener->Params.Velocity = Listener->Velocity;
aluMatrixVector(Listener->Params.Velocity.v, 0.0f, &Listener->Params.Matrix);
}
@@ -669,7 +667,7 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A
ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCcontext *ALContext)
{
ALCdevice *Device = ALContext->Device;
- ALfloat Velocity[3],Direction[3],Position[3],SourceToListener[3];
+ aluVector Position, Velocity, Direction, SourceToListener;
ALfloat InnerAngle,OuterAngle,Angle,Distance,ClampedDist;
ALfloat MinVolume,MaxVolume,MinDist,MaxDist,Rolloff;
ALfloat ConeVolume,ConeHF,SourceVolume,ListenerGain;
@@ -720,15 +718,9 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte
MinVolume = ALSource->MinGain;
MaxVolume = ALSource->MaxGain;
Pitch = ALSource->Pitch;
- Position[0] = ALSource->Position[0];
- Position[1] = ALSource->Position[1];
- Position[2] = ALSource->Position[2];
- Direction[0] = ALSource->Direction[0];
- Direction[1] = ALSource->Direction[1];
- Direction[2] = ALSource->Direction[2];
- Velocity[0] = ALSource->Velocity[0];
- Velocity[1] = ALSource->Velocity[1];
- Velocity[2] = ALSource->Velocity[2];
+ Position = ALSource->Position;
+ Direction = ALSource->Direction;
+ Velocity = ALSource->Velocity;
MinDist = ALSource->RefDistance;
MaxDist = ALSource->MaxDistance;
Rolloff = ALSource->RollOffFactor;
@@ -791,27 +783,28 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte
{
const aluMatrix *Matrix = &ALContext->Listener->Params.Matrix;
/* Transform source vectors */
- aluMatrixVector(Position, 1.0f, Matrix);
- aluMatrixVector(Direction, 0.0f, Matrix);
- aluMatrixVector(Velocity, 0.0f, Matrix);
+ aluMatrixVector(Position.v, 1.0f, Matrix);
+ aluMatrixVector(Direction.v, 0.0f, Matrix);
+ aluMatrixVector(Velocity.v, 0.0f, Matrix);
}
else
{
const aluVector *lvelocity = &ALContext->Listener->Params.Velocity;
/* Offset the source velocity to be relative of the listener velocity */
- Velocity[0] += lvelocity->v[0];
- Velocity[1] += lvelocity->v[1];
- Velocity[2] += lvelocity->v[2];
+ Velocity.v[0] += lvelocity->v[0];
+ Velocity.v[1] += lvelocity->v[1];
+ Velocity.v[2] += lvelocity->v[2];
}
- SourceToListener[0] = -Position[0];
- SourceToListener[1] = -Position[1];
- SourceToListener[2] = -Position[2];
- aluNormalize(SourceToListener);
- aluNormalize(Direction);
+ SourceToListener.v[0] = -Position.v[0];
+ SourceToListener.v[1] = -Position.v[1];
+ SourceToListener.v[2] = -Position.v[2];
+ SourceToListener.v[2] = 0.0f;
+ aluNormalize(SourceToListener.v);
+ aluNormalize(Direction.v);
/* Calculate distance attenuation */
- Distance = sqrtf(aluDotproduct(Position, Position));
+ Distance = sqrtf(aluDotproduct(Position.v, Position.v));
ClampedDist = Distance;
Attenuation = 1.0f;
@@ -908,7 +901,7 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte
}
/* Calculate directional soundcones */
- Angle = RAD2DEG(acosf(aluDotproduct(Direction,SourceToListener)) * ConeScale) * 2.0f;
+ Angle = RAD2DEG(acosf(aluDotproduct(Direction.v,SourceToListener.v)) * ConeScale) * 2.0f;
if(Angle > InnerAngle && Angle <= OuterAngle)
{
ALfloat scale = (Angle-InnerAngle) / (OuterAngle-InnerAngle);
@@ -968,8 +961,8 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte
SpeedOfSound = 1.0f;
}
- VSS = aluDotproduct(Velocity, SourceToListener) * DopplerFactor;
- VLS = aluDotproduct(lvelocity->v, SourceToListener) * DopplerFactor;
+ VSS = aluDotproduct(Velocity.v, SourceToListener.v) * DopplerFactor;
+ VLS = aluDotproduct(lvelocity->v, SourceToListener.v) * DopplerFactor;
Pitch *= clampf(SpeedOfSound-VLS, 1.0f, SpeedOfSound*2.0f - 1.0f) /
clampf(SpeedOfSound-VSS, 1.0f, SpeedOfSound*2.0f - 1.0f);
@@ -1012,9 +1005,9 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte
if(Distance > FLT_EPSILON)
{
ALfloat invlen = 1.0f/Distance;
- dir[0] = Position[0] * invlen;
- dir[1] = Position[1] * invlen;
- dir[2] = Position[2] * invlen * ZScale;
+ dir[0] = Position.v[0] * invlen;
+ dir[1] = Position.v[1] * invlen;
+ dir[2] = Position.v[2] * invlen * ZScale;
/* Calculate elevation and azimuth only when the source is not at
* the listener. This prevents +0 and -0 Z from producing
@@ -1075,9 +1068,9 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte
if(Distance > FLT_EPSILON || radius > FLT_EPSILON)
{
ALfloat invlen = 1.0f/maxf(Distance, radius);
- dir[0] = Position[0] * invlen;
- dir[1] = Position[1] * invlen;
- dir[2] = Position[2] * invlen * ZScale;
+ dir[0] = Position.v[0] * invlen;
+ dir[1] = Position.v[1] * invlen;
+ dir[2] = Position.v[2] * invlen * ZScale;
}
ComputeDirectionalGains(Device, dir, DryGain, Target);
diff --git a/OpenAL32/Include/alListener.h b/OpenAL32/Include/alListener.h
index d7e495fe..42b5a11f 100644
--- a/OpenAL32/Include/alListener.h
+++ b/OpenAL32/Include/alListener.h
@@ -9,8 +9,8 @@ extern "C" {
#endif
typedef struct ALlistener {
- volatile ALfloat Position[3];
- volatile ALfloat Velocity[3];
+ aluVector Position;
+ aluVector Velocity;
volatile ALfloat Forward[3];
volatile ALfloat Up[3];
volatile ALfloat Gain;
diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h
index 96216b87..fe2867b1 100644
--- a/OpenAL32/Include/alSource.h
+++ b/OpenAL32/Include/alSource.h
@@ -57,9 +57,9 @@ typedef struct ALsource {
volatile ALfloat RefDistance;
volatile ALfloat MaxDistance;
volatile ALfloat RollOffFactor;
- volatile ALfloat Position[3];
- volatile ALfloat Velocity[3];
- volatile ALfloat Direction[3];
+ aluVector Position;
+ aluVector Velocity;
+ aluVector Direction;
volatile ALfloat Orientation[2][3];
volatile ALboolean HeadRelative;
volatile ALboolean Looping;
diff --git a/OpenAL32/alListener.c b/OpenAL32/alListener.c
index c30d6f84..66865473 100644
--- a/OpenAL32/alListener.c
+++ b/OpenAL32/alListener.c
@@ -74,9 +74,7 @@ AL_API ALvoid AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat val
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
LockContext(context);
- context->Listener->Position[0] = value1;
- context->Listener->Position[1] = value2;
- context->Listener->Position[2] = value3;
+ aluVectorSet(&context->Listener->Position, value1, value2, value3, 1.0f);
ATOMIC_STORE(&context->UpdateSources, AL_TRUE);
UnlockContext(context);
break;
@@ -86,9 +84,7 @@ AL_API ALvoid AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat val
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
LockContext(context);
- context->Listener->Velocity[0] = value1;
- context->Listener->Velocity[1] = value2;
- context->Listener->Velocity[2] = value3;
+ aluVectorSet(&context->Listener->Velocity, value1, value2, value3, 0.0f);
ATOMIC_STORE(&context->UpdateSources, AL_TRUE);
UnlockContext(context);
break;
@@ -282,17 +278,17 @@ AL_API ALvoid AL_APIENTRY alGetListener3f(ALenum param, ALfloat *value1, ALfloat
{
case AL_POSITION:
LockContext(context);
- *value1 = context->Listener->Position[0];
- *value2 = context->Listener->Position[1];
- *value3 = context->Listener->Position[2];
+ *value1 = context->Listener->Position.v[0];
+ *value2 = context->Listener->Position.v[1];
+ *value3 = context->Listener->Position.v[2];
UnlockContext(context);
break;
case AL_VELOCITY:
LockContext(context);
- *value1 = context->Listener->Velocity[0];
- *value2 = context->Listener->Velocity[1];
- *value3 = context->Listener->Velocity[2];
+ *value1 = context->Listener->Velocity.v[0];
+ *value2 = context->Listener->Velocity.v[1];
+ *value3 = context->Listener->Velocity.v[2];
UnlockContext(context);
break;
@@ -383,17 +379,17 @@ AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *valu
{
case AL_POSITION:
LockContext(context);
- *value1 = (ALint)context->Listener->Position[0];
- *value2 = (ALint)context->Listener->Position[1];
- *value3 = (ALint)context->Listener->Position[2];
+ *value1 = (ALint)context->Listener->Position.v[0];
+ *value2 = (ALint)context->Listener->Position.v[1];
+ *value3 = (ALint)context->Listener->Position.v[2];
UnlockContext(context);
break;
case AL_VELOCITY:
LockContext(context);
- *value1 = (ALint)context->Listener->Velocity[0];
- *value2 = (ALint)context->Listener->Velocity[1];
- *value3 = (ALint)context->Listener->Velocity[2];
+ *value1 = (ALint)context->Listener->Velocity.v[0];
+ *value2 = (ALint)context->Listener->Velocity.v[1];
+ *value3 = (ALint)context->Listener->Velocity.v[2];
UnlockContext(context);
break;
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index be3768f3..b05b85c5 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -519,9 +519,7 @@ static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SrcFloatProp
CHECKVAL(isfinite(values[0]) && isfinite(values[1]) && isfinite(values[2]));
LockContext(Context);
- Source->Position[0] = values[0];
- Source->Position[1] = values[1];
- Source->Position[2] = values[2];
+ aluVectorSet(&Source->Position, values[0], values[1], values[2], 1.0f);
UnlockContext(Context);
ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE);
return AL_TRUE;
@@ -530,9 +528,7 @@ static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SrcFloatProp
CHECKVAL(isfinite(values[0]) && isfinite(values[1]) && isfinite(values[2]));
LockContext(Context);
- Source->Velocity[0] = values[0];
- Source->Velocity[1] = values[1];
- Source->Velocity[2] = values[2];
+ aluVectorSet(&Source->Velocity, values[0], values[1], values[2], 0.0f);
UnlockContext(Context);
ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE);
return AL_TRUE;
@@ -541,9 +537,7 @@ static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SrcFloatProp
CHECKVAL(isfinite(values[0]) && isfinite(values[1]) && isfinite(values[2]));
LockContext(Context);
- Source->Direction[0] = values[0];
- Source->Direction[1] = values[1];
- Source->Direction[2] = values[2];
+ aluVectorSet(&Source->Direction, values[0], values[1], values[2], 0.0f);
UnlockContext(Context);
ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE);
return AL_TRUE;
@@ -1054,25 +1048,25 @@ static ALboolean GetSourcedv(ALsource *Source, ALCcontext *Context, SrcFloatProp
case AL_POSITION:
LockContext(Context);
- values[0] = Source->Position[0];
- values[1] = Source->Position[1];
- values[2] = Source->Position[2];
+ values[0] = Source->Position.v[0];
+ values[1] = Source->Position.v[1];
+ values[2] = Source->Position.v[2];
UnlockContext(Context);
return AL_TRUE;
case AL_VELOCITY:
LockContext(Context);
- values[0] = Source->Velocity[0];
- values[1] = Source->Velocity[1];
- values[2] = Source->Velocity[2];
+ values[0] = Source->Velocity.v[0];
+ values[1] = Source->Velocity.v[1];
+ values[2] = Source->Velocity.v[2];
UnlockContext(Context);
return AL_TRUE;
case AL_DIRECTION:
LockContext(Context);
- values[0] = Source->Direction[0];
- values[1] = Source->Direction[1];
- values[2] = Source->Direction[2];
+ values[0] = Source->Direction.v[0];
+ values[1] = Source->Direction.v[1];
+ values[2] = Source->Direction.v[2];
UnlockContext(Context);
return AL_TRUE;
@@ -2464,15 +2458,9 @@ static ALvoid InitSourceParams(ALsource *Source)
Source->InnerAngle = 360.0f;
Source->OuterAngle = 360.0f;
Source->Pitch = 1.0f;
- Source->Position[0] = 0.0f;
- Source->Position[1] = 0.0f;
- Source->Position[2] = 0.0f;
- Source->Velocity[0] = 0.0f;
- Source->Velocity[1] = 0.0f;
- Source->Velocity[2] = 0.0f;
- Source->Direction[0] = 0.0f;
- Source->Direction[1] = 0.0f;
- Source->Direction[2] = 0.0f;
+ aluVectorSet(&Source->Position, 0.0f, 0.0f, 0.0f, 1.0f);
+ aluVectorSet(&Source->Velocity, 0.0f, 0.0f, 0.0f, 0.0f);
+ aluVectorSet(&Source->Direction, 0.0f, 0.0f, 0.0f, 0.0f);
Source->Orientation[0][0] = 0.0f;
Source->Orientation[0][1] = 0.0f;
Source->Orientation[0][2] = -1.0f;