equal
deleted
inserted
replaced
189 }; |
189 }; |
190 }; |
190 }; |
191 |
191 |
192 typedef Vector3 Colour; |
192 typedef Vector3 Colour; |
193 |
193 |
194 |
|
195 static const __m128 zeros = _mm_set_ps1(0.); |
|
196 static const __m128 ones = _mm_set_ps1(1.); |
|
197 static const __m128 mEps = _mm_set_ps1(Eps); |
|
198 |
|
199 class VectorPacket |
194 class VectorPacket |
200 { |
195 { |
201 public: |
196 public: |
202 union { |
197 union { |
203 __m128 ma[3]; |
198 __m128 ma[3]; |
229 y = _mm_mul_ps(my, my); // y*y |
224 y = _mm_mul_ps(my, my); // y*y |
230 z = _mm_mul_ps(mz, mz); // z*z |
225 z = _mm_mul_ps(mz, mz); // z*z |
231 m = _mm_add_ps(x, y); |
226 m = _mm_add_ps(x, y); |
232 m = _mm_add_ps(m, z); // x*x + y*y + z*z |
227 m = _mm_add_ps(m, z); // x*x + y*y + z*z |
233 m = _mm_sqrt_ps(m); |
228 m = _mm_sqrt_ps(m); |
234 m = _mm_div_ps(ones, m); // m = 1/sqrt(m) |
229 m = _mm_div_ps(mOne, m); // m = 1/sqrt(m) |
235 mx = _mm_mul_ps(mx, m); |
230 mx = _mm_mul_ps(mx, m); |
236 my = _mm_mul_ps(my, m); |
231 my = _mm_mul_ps(my, m); |
237 mz = _mm_mul_ps(mz, m); |
232 mz = _mm_mul_ps(mz, m); |
238 }; |
233 }; |
239 |
234 |
270 }; |
265 }; |
271 |
266 |
272 // write to character stream |
267 // write to character stream |
273 friend ostream & operator<<(ostream &st, const VectorPacket &v) |
268 friend ostream & operator<<(ostream &st, const VectorPacket &v) |
274 { |
269 { |
275 return st << "[" << v.getVector(0) << "," << v.getVector(1) |
270 return st << "[" << v.getVector(0) << "," << v.getVector(1) |
276 << "," << v.getVector(2) << "," << v.getVector(3) << ")"; |
271 << "," << v.getVector(2) << "," << v.getVector(3) << ")"; |
277 }; |
272 }; |
278 |
273 |
279 }; |
274 }; |
280 |
275 |