41 #ifndef __FIXEDPOINT_HEADERFILE__ 42 #define __FIXEDPOINT_HEADERFILE__ 48 #define FIXED_Float_To_Fixed_n(x, n) ((I32)(x * (float)(1 << n) + 0.5f)) 49 #define FIXED_Fixed_n_To_Float(x, n) ((float)x / (float)(1 << n)) 55 # define _USE_GPP_ARITHMETIC_ 56 # define _USE_GPP_TRIGONOMETRIC_ 57 # define _USE_GPP_VECTOR_ 58 # define _FIXEDPOINT_MATH_ACTIVATED_ 62 # pragma comment( lib, "gpp_WMMX40_d.lib" ) 64 # pragma comment( lib, "gpp_WMMX40_r.lib" ) 70 # if defined(_WIN32) || defined(WIN32) 71 typedef unsigned __int64
U64;
73 typedef unsigned int U32;
76 # define _USE_GENERIC_ARITHMETIC_ 77 # define _USE_GENERIC_TRIGONOMETRIC_ 78 # define _USE_GENERIC_VECTOR_ 79 # define _FIXEDPOINT_MATH_ACTIVATED_ 83 #ifdef _USE_GPP_ARITHMETIC_ 85 #define FIXED_MUL2(a,b, res, bits) \ 86 gppMul_n_32s((a), (b), &res, bits); 88 #define FIXED_MUL3(a,b,c, res, bits) \ 89 gppMul_n_32s((a), (b), &_tmp1, bits); \ 90 gppMul_n_32s(_tmp1, (c), &res, bits); 92 #define FIXED_MUL4(a,b,c,d, res, bits) \ 93 gppMul_n_32s((a), (b), &_tmp1, bits); \ 94 gppMul_n_32s(_tmp1, (c), &_tmp2, bits); \ 95 gppMul_n_32s(_tmp2, (d), &res, bits); 97 #define FIXED_DIV2(a,b, res, bits) \ 98 gppDiv_n_32s((a), (b), &res, bits); 100 #endif //_USE_GPP_ARITHMETIC_ 103 #ifdef _USE_GPP_TRIGONOMETRIC_ 105 #define FIXED_SIN(theta, sin_theta, n) \ 106 gppSinHP_n_32s((theta), sin_theta, n); 108 #define FIXED_COS(theta, cos_theta, n) \ 109 gppCosHP_n_32s((theta), cos_theta, n); 111 #define FIXED_SINCOS(theta, sin_theta, cos_theta, n) \ 112 gppSinCosHP_n_32s((theta), sin_theta, cos_theta, n); 114 #endif // _USE_GPP_TRIGONOMETRIC_ 117 #ifdef _USE_GPP_VECTOR_ 119 typedef GPP_VEC3D FIXED_VEC3D;
121 #define FIXED_VEC3_DOT(vec1, vec2, res, n) \ 122 gppVec3DDot_n_32s((vec1), (vec2), (res), (n)); 124 #define FIXED_VEC3_SUB(vec1, vec2, res) \ 125 gppVec3DSub_n_32s((vec1), (vec2), (res)); 127 #define FIXED_VEC3_LENGTH_SQ(vec, res, n) \ 128 gppVec3DLengthSq_n_32s((vec), (res), (n)); 130 #endif // _USE_GPP_VECTOR_ 134 #ifdef _USE_GENERIC_ARITHMETIC_ 136 # define FIXED_MUL2(a,b, res, bits) \ 137 res = ((I32) (((I64)a * (I64)b) >> bits)); 139 # define FIXED_MUL3(a,b,c, res, bits) \ 140 FIXED_MUL2((a), (b), (res), bits); \ 141 FIXED_MUL2((res), (c), (res), bits); 143 # define FIXED_MUL4(a,b,c,d, res, bits) \ 144 FIXED_MUL2((a), (b), (res), bits); \ 145 FIXED_MUL2((res), (c), (res), bits); \ 146 FIXED_MUL2((res), (d), (res), bits); 148 # define FIXED_DIV2(a,b, res, bits) \ 149 res = (I32) ((((I64)a)<<bits)/(I64)b); 151 #endif //_USE_GENERIC_ARITHMETIC_ 154 #ifdef _USE_GENERIC_TRIGONOMETRIC_ 157 void Fixed28_Deinit();
159 inline void Fixed28_SinCos(I32 phi, I32 &sin, I32 &cos);
161 #define FIXED_SINCOS(theta, sin_theta, cos_theta, n) \ 162 Fixed28_SinCos((theta), *(sin_theta), *(cos_theta)); 164 #endif //_USE_GENERIC_TRIGONOMETRIC_ 167 #ifdef _USE_GENERIC_VECTOR_ 173 inline void FIXED_VEC3_DOT(FIXED_VEC3D* vec1, FIXED_VEC3D* vec2, I32* res, I32 n)
176 FIXED_MUL2(vec1->x, vec2->x, x, n);
177 FIXED_MUL2(vec1->y, vec2->y, y, n);
178 FIXED_MUL2(vec1->z, vec2->z, z, n);
183 inline void FIXED_VEC3_SUB(FIXED_VEC3D* vec1, FIXED_VEC3D* vec2, FIXED_VEC3D* res)
185 res->x = vec1->x - vec2->x;
186 res->y = vec1->y - vec2->y;
187 res->z = vec1->z - vec2->z;
190 inline void FIXED_VEC3_LENGTH_SQ(FIXED_VEC3D* vec, U32* res, I32 n)
193 FIXED_MUL2(vec->x, vec->x, x, n);
194 FIXED_MUL2(vec->y, vec->y, y, n);
195 FIXED_MUL2(vec->z, vec->z, z, n);
200 #endif //_USE_GENERIC_VECTOR_ 206 #endif //__FIXEDPOINT_HEADERFILE__ TFSIMD_FORCE_INLINE const tfScalar & y() const
TFSIMD_FORCE_INLINE const tfScalar & x() const
TFSIMD_FORCE_INLINE const tfScalar & z() const