From 5282ae63088493434fcbcd68ec8d762f31665f09 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Wed, 14 Feb 2018 18:35:47 -1000 Subject: [PATCH] Additional CVector2f operators --- include/zeus/CVector2f.hpp | 46 +++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/include/zeus/CVector2f.hpp b/include/zeus/CVector2f.hpp index 8496ed9..7ec8ab3 100644 --- a/include/zeus/CVector2f.hpp +++ b/include/zeus/CVector2f.hpp @@ -212,7 +212,7 @@ public: inline CVector2f operator/(float val) const { #if __SSE__ - TVectorUnion splat = {{val, val, val, 0.0f}}; + TVectorUnion splat = {{val, val, 0.0f, 0.0f}}; return CVector2f(_mm_div_ps(mVec128, splat.mVec128)); #else return CVector2f(x / val, y / val); @@ -255,6 +255,50 @@ public: #else x /= rhs.x; y /= rhs.y; +#endif + return *this; + } + inline const CVector2f& operator+=(float rhs) + { +#if __SSE__ + TVectorUnion splat = {{rhs, rhs, 0.f, 0.0f}}; + mVec128 = _mm_add_ps(mVec128, splat.mVec128); +#else + x += rhs; + y += rhs; +#endif + return *this; + } + inline const CVector2f& operator-=(float rhs) + { +#if __SSE__ + TVectorUnion splat = {{rhs, rhs, 0.f, 0.0f}}; + mVec128 = _mm_sub_ps(mVec128, splat.mVec128); +#else + x -= rhs; + y -= rhs; +#endif + return *this; + } + inline const CVector2f& operator*=(float rhs) + { +#if __SSE__ + TVectorUnion splat = {{rhs, rhs, 0.f, 0.0f}}; + mVec128 = _mm_mul_ps(mVec128, splat.mVec128); +#else + x *= rhs; + y *= rhs; +#endif + return *this; + } + inline const CVector2f& operator/=(float rhs) + { +#if __SSE__ + TVectorUnion splat = {{rhs, rhs, 0.f, 0.0f}}; + mVec128 = _mm_div_ps(mVec128, splat.mVec128); +#else + x /= rhs; + y /= rhs; #endif return *this; }