diff --git a/code/nel/include/nel/misc/vector.h b/code/nel/include/nel/misc/vector.h index 0d3216a18..3be84894d 100644 --- a/code/nel/include/nel/misc/vector.h +++ b/code/nel/include/nel/misc/vector.h @@ -73,10 +73,10 @@ public: // Methods. /// Constructor . CVector(float _x, float _y, float _z) : x(_x), y(_y), z(_z) { /*if (((uintptr_t)(void *)(this) & 0xF) != 0) nlerror("Vector alignment error");*/ } /// Copy Constructor. -#if 0 +#if USE_SSE2 CVector(const CVector &v) : mm(v.mm) { /*if (((uintptr_t)(void *)(this) & 0xF) != 0) nlerror("Vector alignment error");*/ } #else - CVector(const CVector &v) : x(v.x), y(v.y), z(v.z) { if (((uintptr_t)(void *)(this) & 0xF) != 0) nlerror("Vector alignment error"); } + CVector(const CVector &v) : x(v.x), y(v.y), z(v.z) { /*if (((uintptr_t)(void *)(this) & 0xF) != 0) nlerror("Vector alignment error");*/ } #endif //@} diff --git a/code/nel/include/nel/misc/vector_inline.h b/code/nel/include/nel/misc/vector_inline.h index 77d827c35..10351e2c9 100644 --- a/code/nel/include/nel/misc/vector_inline.h +++ b/code/nel/include/nel/misc/vector_inline.h @@ -64,7 +64,12 @@ inline CVector &CVector::operator*=(float f) } inline CVector &CVector::operator/=(float f) { +#ifdef USE_SSE2 + mm = _mm_div_ps(mm, _mm_set1_ps(f)); + return *this; +#else return *this*= (1.0f/f); +#endif } inline CVector CVector::operator+(const CVector &v) const { @@ -101,7 +106,13 @@ inline CVector CVector::operator*(float f) const } inline CVector CVector::operator/(float f) const { +#ifdef USE_SSE2 + CVector res; + res.mm = _mm_div_ps(mm, _mm_set1_ps(f)); + return res; +#else return *this*(1.0f/f); +#endif } inline CVector CVector::operator-() const { @@ -220,19 +231,35 @@ inline CVector CVector::normed() const // Misc. inline void CVector::set(float _x, float _y, float _z) { +#ifdef USE_SSE2 + mm = _mm_setr_ps(_x, _y, _z, 0.0f); +#else x=_x; y=_y; z=_z; +#endif } inline bool CVector::operator==(const CVector &v) const { +#ifdef USE_SSE2 + return (_mm_movemask_ps(_mm_cmpeq_ps(mm, v.mm)) & 0x07) == 0x07; +#else return x==v.x && y==v.y && z==v.z; +#endif } inline bool CVector::operator!=(const CVector &v) const { +#ifdef USE_SSE2 + return (_mm_movemask_ps(_mm_cmpneq_ps(mm, v.mm)) & 0x07) != 0; +#else return !(*this==v); +#endif } inline bool CVector::isNull() const { +#ifdef USE_SSE2 + return (_mm_movemask_ps(_mm_cmpeq_ps(mm, _mm_setzero_ps())) & 0x07) == 0x07; +#else return *this==CVector::Null; +#endif } inline bool CVector::operator<(const CVector &v) const {