|
|
@ -182,7 +182,7 @@ inline float CVector::sqrnorm() const
|
|
|
|
inline float CVector::norm() const
|
|
|
|
inline float CVector::norm() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef USE_SSE2
|
|
|
|
#ifdef USE_SSE2
|
|
|
|
return sqrt(_mm_cvtss_f32(dotsplat(mm, mm)));
|
|
|
|
return sqrt(sqrnorm());
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
return (float)sqrt(x*x + y*y + z*z);
|
|
|
|
return (float)sqrt(x*x + y*y + z*z);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -191,6 +191,7 @@ inline void CVector::normalize()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef USE_SSE2
|
|
|
|
#ifdef USE_SSE2
|
|
|
|
__m128 normsplat = _mm_sqrt_ps(dotsplat(mm, mm));
|
|
|
|
__m128 normsplat = _mm_sqrt_ps(dotsplat(mm, mm));
|
|
|
|
|
|
|
|
if (_mm_cvtss_f32(normsplat))
|
|
|
|
mm = _mm_div_ps(mm, normsplat);
|
|
|
|
mm = _mm_div_ps(mm, normsplat);
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
float n=norm();
|
|
|
|
float n=norm();
|
|
|
@ -203,6 +204,7 @@ inline CVector CVector::normed() const
|
|
|
|
#ifdef USE_SSE2
|
|
|
|
#ifdef USE_SSE2
|
|
|
|
CVector res;
|
|
|
|
CVector res;
|
|
|
|
__m128 normsplat = _mm_sqrt_ps(dotsplat(mm, mm));
|
|
|
|
__m128 normsplat = _mm_sqrt_ps(dotsplat(mm, mm));
|
|
|
|
|
|
|
|
if (_mm_cvtss_f32(normsplat))
|
|
|
|
res.mm = _mm_div_ps(mm, normsplat);
|
|
|
|
res.mm = _mm_div_ps(mm, normsplat);
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|