00001 #include "MercuryMath.h"
00002
00003 #if !defined( _MSC_VER ) || defined( SLOW_CODE )
00004
00005
00006
00007 void Mul4f(const float* first, const float* second, float* out)
00008 {
00009 out[0] = first[0] * second[0];
00010 out[1] = first[1] * second[1];
00011 out[2] = first[2] * second[2];
00012 out[3] = first[3] * second[3];
00013 }
00014
00015 void Div4f(const float* first, const float* second, float* out)
00016 {
00017 out[0] = first[0] / second[0];
00018 out[1] = first[1] / second[1];
00019 out[2] = first[2] / second[2];
00020 out[3] = first[3] / second[3];
00021 }
00022
00023 void Add4f(const float* first, const float* second, float* out)
00024 {
00025 out[0] = first[0] + second[0];
00026 out[1] = first[1] + second[1];
00027 out[2] = first[2] + second[2];
00028 out[3] = first[3] + second[3];
00029 }
00030
00031 void Sub4f(const float* first, const float* second, float* out)
00032 {
00033 out[0] = first[0] - second[0];
00034 out[1] = first[1] - second[1];
00035 out[2] = first[2] - second[2];
00036 out[3] = first[3] - second[3];
00037 }
00038
00039 void Copy4f( void * dest, const void * source )
00040 {
00041 ((float*)dest)[0] = ((float*)source)[0];
00042 ((float*)dest)[1] = ((float*)source)[1];
00043 ((float*)dest)[2] = ((float*)source)[2];
00044 ((float*)dest)[3] = ((float*)source)[3];
00045 }
00046
00047 void Copy8f( void * dest, const void * source )
00048 {
00049 ((float*)dest)[0] = ((float*)source)[0];
00050 ((float*)dest)[1] = ((float*)source)[1];
00051 ((float*)dest)[2] = ((float*)source)[2];
00052 ((float*)dest)[3] = ((float*)source)[3];
00053
00054 ((float*)dest)[4] = ((float*)source)[4];
00055 ((float*)dest)[5] = ((float*)source)[5];
00056 ((float*)dest)[6] = ((float*)source)[6];
00057 ((float*)dest)[7] = ((float*)source)[7];
00058 }
00059
00060 void Copy16f( void * dest, const void * source )
00061 {
00062 ((float*)dest)[0] = ((float*)source)[0];
00063 ((float*)dest)[1] = ((float*)source)[1];
00064 ((float*)dest)[2] = ((float*)source)[2];
00065 ((float*)dest)[3] = ((float*)source)[3];
00066
00067 ((float*)dest)[4] = ((float*)source)[4];
00068 ((float*)dest)[5] = ((float*)source)[5];
00069 ((float*)dest)[6] = ((float*)source)[6];
00070 ((float*)dest)[7] = ((float*)source)[7];
00071
00072 ((float*)dest)[8] = ((float*)source)[8];
00073 ((float*)dest)[9] = ((float*)source)[9];
00074 ((float*)dest)[10] = ((float*)source)[10];
00075 ((float*)dest)[11] = ((float*)source)[11];
00076
00077 ((float*)dest)[12] = ((float*)source)[12];
00078 ((float*)dest)[13] = ((float*)source)[13];
00079 ((float*)dest)[14] = ((float*)source)[14];
00080 ((float*)dest)[15] = ((float*)source)[15];
00081 }
00082
00083 void R_ConcatTransforms4 ( const float* in1, const float* in2, float* out)
00084 {
00085 out[0] = in1[0] * in2[0] + in1[1] * in2[4] +
00086 in1[2] * in2[8] + in1[3] * in2[12];
00087 out[1] = in1[0] * in2[1] + in1[1] * in2[5] +
00088 in1[2] * in2[9] + in1[3] * in2[13];
00089 out[2] = in1[0] * in2[2] + in1[1] * in2[6] +
00090 in1[2] * in2[10] + in1[3] * in2[14];
00091 out[3] = in1[0] * in2[3] + in1[1] * in2[7] +
00092 in1[2] * in2[11] + in1[3] * in2[15];
00093
00094 out[4] = in1[4] * in2[0] + in1[5] * in2[4] +
00095 in1[6] * in2[8] + in1[7] * in2[12];
00096 out[5] = in1[4] * in2[1] + in1[5] * in2[5] +
00097 in1[6] * in2[9] + in1[7] * in2[13];
00098 out[6] = in1[4] * in2[2] + in1[5] * in2[6] +
00099 in1[6] * in2[10] + in1[7] * in2[14];
00100 out[7] = in1[4] * in2[3] + in1[5] * in2[7] +
00101 in1[6] * in2[11] + in1[7] * in2[15];
00102
00103 out[8] = in1[8] * in2[0] + in1[9] * in2[4] +
00104 in1[10] * in2[8] + in1[11] * in2[12];
00105 out[9] = in1[8] * in2[1] + in1[9] * in2[5] +
00106 in1[10] * in2[9] + in1[11] * in2[13];
00107 out[10] = in1[8] * in2[2] + in1[9] * in2[6] +
00108 in1[10] * in2[10] + in1[11] * in2[14];
00109 out[11] = in1[8] * in2[3] + in1[9] * in2[7] +
00110 in1[10] * in2[11] + in1[11] * in2[15];
00111
00112 out[12] = in1[12] * in2[0] + in1[13] * in2[4] +
00113 in1[14] * in2[8] + in1[15] * in2[12];
00114 out[13] = in1[12] * in2[1] + in1[13] * in2[5] +
00115 in1[14] * in2[9] + in1[15] * in2[13];
00116 out[14] = in1[12] * in2[2] + in1[13] * in2[6] +
00117 in1[14] * in2[10] + in1[15] * in2[14];
00118 out[15] = in1[12] * in2[3] + in1[13] * in2[7] +
00119 in1[14] * in2[11] + in1[15] * in2[15];
00120 }
00121
00122 #endif
00123
00124 void VectorMultiply4f( const float * m, float *p, float *out )
00125 {
00126 out[0] = p[0] * m[0] + p[1] * m[1] + p[2] * m[2] + p[3] * m[3];
00127 out[1] = p[0] * m[4] + p[1] * m[5] + p[2] * m[6] + p[3] * m[7];
00128 out[2] = p[0] * m[8] + p[1] * m[9] + p[2] * m[10] + p[3] * m[11];
00129 out[3] = p[0] * m[12] + p[1] * m[13] + p[2] * m[14] + p[3] * m[15];
00130 }
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155