void DotProduct2( float *velocities, float *distances, float *results, int count )
{
register float vX1, vY1, vZ1; //velocity 1
register float vX2, vY2, vZ2; //velocity 2
register float vX3, vY3, vZ3; //velocity 3
register float dX1, dY1, dZ1; //distance 1
register float dX2, dY2, dZ2; //distance 2
register float dX3, dY3, dZ3; //distance 3
register float DV1, DV2, DV3;
register float one = 1.0;
register float oneHalf = 0.5;
register float *vel = (float*) velocities;
register float *pos = (float*) distances;
//Process three sounds per loop
for( ; count >= 3; count -= 3 )
{
//Load X, Y and Z velocity components for three
//input distances from the listener
dX1 = pos[0];
dY1 = pos[1];
dZ1 = pos[2];
dX2 = pos[3];
dY2 = pos[4];
dZ2 = pos[5];
dX3 = pos[6];
dY3 = pos[7];
dZ3 = pos[8];
pos += 9;
//Load X, Y and Z velocity components for
//three input velocities
vX1 = vel[0];
vY1 = vel[1];
vZ1 = vel[2];
vX2 = vel[3];
vY2 = vel[4];
vZ2 = vel[5];
vX3 = vel[6];
vY3 = vel[7];
vZ3 = vel[8];
vel += 9;
//Calculate D dot V, and store in DV#
DV1 = vX1 * dX1 + vY1 * dY1 + vZ1 * dZ1;
DV2 = vX2 * dX2 + vY2 * dY2 + vZ2 * dZ2;
DV3 = vX3 * dX3 + vY3 * dY3 + vZ3 * dZ3;
//store out the result
//result = (D dot V) * 1.0 / sqrt( D dot D)
(results++)[0] = DV1;
(results++)[0] = DV2;
(results++)[0] = DV3;
}
//Process the remaining sounds
//This is the same algorithm as is used above
for( ; count > 0; count-- )
{
//Load X, Y and Z velocity components for three
//input distances from the listener
dX1 = pos[0];
dY1 = pos[1];
dZ1 = pos[2];
pos += 3;
//Load X, Y and Z velocity components for
//three input velocities
vX1 = vel[0];
vY1 = vel[1];
vZ1 = vel[2];
vel += 3;
//Calculate D dot V, and store in DV#
DV1 = vX1 * dX1 + vY1 * dY1 + vZ1 * dZ1;
//store out the result
//result = (D dot V) * 1.0 / sqrt( D dot D)
(results++)[0] = DV1;
}
}