diff --git a/include/CMatrix3f.hpp b/include/CMatrix3f.hpp index f0b3b84..33c3f8e 100644 --- a/include/CMatrix3f.hpp +++ b/include/CMatrix3f.hpp @@ -62,7 +62,17 @@ public: #endif CMatrix3f(const CVector3f& axis, float angle); CMatrix3f(const CQuaternion& quat); - + CMatrix3f(const TVectorUnion& r0, const TVectorUnion& r1, const TVectorUnion& r2) + { +#if __SSE__ + vec[0].mVec128 = r0.mVec128; vec[1].mVec128 = r1.mVec128; vec[2].mVec128 = r2.mVec128; +#else + vec[0].x = r0.vec[0]; vec[0].y = r0.vec[1]; vec[0].z = r0.vec[2]; + vec[1].x = r1.vec[0]; vec[1].y = r1.vec[1]; vec[1].z = r1.vec[2]; + vec[2].x = r2.vec[0]; vec[2].y = r2.vec[1]; vec[2].z = r2.vec[2]; +#endif + } + inline CMatrix3f& operator=(const CMatrix3f& other) { vec[0] = other.vec[0]; diff --git a/include/CTransform.hpp b/include/CTransform.hpp index 9503b39..544192a 100644 --- a/include/CTransform.hpp +++ b/include/CTransform.hpp @@ -71,27 +71,27 @@ public: { float sinT = sinf(theta); float cosT = cosf(theta); - return CTransform(CMatrix3f(CVector4f{1.f, 0.f, 0.f, 0.f}, - CVector4f{0.f, cosT, sinT, 0.f}, - CVector4f{0.f, -sinT, cosT, 0.f})); + return CTransform(CMatrix3f(TVectorUnion{1.f, 0.f, 0.f, 0.f}, + TVectorUnion{0.f, cosT, sinT, 0.f}, + TVectorUnion{0.f, -sinT, cosT, 0.f})); } static inline CTransform RotateY(float theta) { float sinT = sinf(theta); float cosT = cosf(theta); - return CTransform(CMatrix3f(CVector4f{cosT, 0.f, -sinT, 0.f}, - CVector4f{0.f, 1.f, 0.f, 0.f}, - CVector4f{sinT, 0.f, cosT, 0.f})); + return CTransform(CMatrix3f(TVectorUnion{cosT, 0.f, -sinT, 0.f}, + TVectorUnion{0.f, 1.f, 0.f, 0.f}, + TVectorUnion{sinT, 0.f, cosT, 0.f})); } static inline CTransform RotateZ(float theta) { float sinT = sinf(theta); float cosT = cosf(theta); - return CTransform(CMatrix3f(CVector4f{cosT, sinT, 0.f, 0.f}, - CVector4f{-sinT, cosT, 0.f, 0.f}, - CVector4f{0.f, 0.f, 1.f, 0.f})); + return CTransform(CMatrix3f(TVectorUnion{cosT, sinT, 0.f, 0.f}, + TVectorUnion{-sinT, cosT, 0.f, 0.f}, + TVectorUnion{0.f, 0.f, 1.f, 0.f})); } inline void rotateLocalX(float theta) @@ -152,23 +152,23 @@ public: static inline CTransform Scale(const CVector3f& factor) { - return CTransform(CMatrix3f(CVector4f{factor.x, 0.f, 0.f, 0.f}, - CVector4f{0.f, factor.y, 0.f, 0.f}, - CVector4f{0.f, 0.f, factor.z, 0.f})); + return CTransform(CMatrix3f(TVectorUnion{factor.x, 0.f, 0.f, 0.f}, + TVectorUnion{0.f, factor.y, 0.f, 0.f}, + TVectorUnion{0.f, 0.f, factor.z, 0.f})); } static inline CTransform Scale(float x, float y, float z) { - return CTransform(CMatrix3f(CVector4f{x, 0.f, 0.f, 0.f}, - CVector4f{0.f, y, 0.f, 0.f}, - CVector4f{0.f, 0.f, z, 0.f})); + return CTransform(CMatrix3f(TVectorUnion{x, 0.f, 0.f, 0.f}, + TVectorUnion{0.f, y, 0.f, 0.f}, + TVectorUnion{0.f, 0.f, z, 0.f})); } static inline CTransform Scale(float factor) { - return CTransform(CMatrix3f(CVector4f{factor, 0.f, 0.f, 0.f}, - CVector4f{0.f, factor, 0.f, 0.f}, - CVector4f{0.f, 0.f, factor, 0.f})); + return CTransform(CMatrix3f(TVectorUnion{factor, 0.f, 0.f, 0.f}, + TVectorUnion{0.f, factor, 0.f, 0.f}, + TVectorUnion{0.f, 0.f, factor, 0.f})); } inline void multiplyIgnoreTranslation(const CTransform& xfrm) { m_basis = m_basis*xfrm.m_basis; }