.. _program_listing_file_include_tf2_LinearMath_QuadWord.h: Program Listing for File QuadWord.h =================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/tf2/LinearMath/QuadWord.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /* Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef TF2SIMD_QUADWORD_H #define TF2SIMD_QUADWORD_H #include "Scalar.h" #include "MinMax.h" #include "tf2/visibility_control.h" #if defined (__CELLOS_LV2) && defined (__SPU__) #include #endif namespace tf2 { #ifndef USE_LIBSPE2 ATTRIBUTE_ALIGNED16(class) QuadWord #else class QuadWord #endif { protected: #if defined (__SPU__) && defined (__CELLOS_LV2__) union { vec_float4 mVec128; tf2Scalar m_floats[4]; }; public: TF2_PUBLIC vec_float4 get128() const { return mVec128; } protected: #else //__CELLOS_LV2__ __SPU__ tf2Scalar m_floats[4]; #endif //__CELLOS_LV2__ __SPU__ public: TF2SIMD_FORCE_INLINE const tf2Scalar& getX() const { return m_floats[0]; } TF2SIMD_FORCE_INLINE const tf2Scalar& getY() const { return m_floats[1]; } TF2SIMD_FORCE_INLINE const tf2Scalar& getZ() const { return m_floats[2]; } TF2SIMD_FORCE_INLINE void setX(tf2Scalar x) { m_floats[0] = x;}; TF2SIMD_FORCE_INLINE void setY(tf2Scalar y) { m_floats[1] = y;}; TF2SIMD_FORCE_INLINE void setZ(tf2Scalar z) { m_floats[2] = z;}; TF2SIMD_FORCE_INLINE void setW(tf2Scalar w) { m_floats[3] = w;}; TF2SIMD_FORCE_INLINE const tf2Scalar& x() const { return m_floats[0]; } TF2SIMD_FORCE_INLINE const tf2Scalar& y() const { return m_floats[1]; } TF2SIMD_FORCE_INLINE const tf2Scalar& z() const { return m_floats[2]; } TF2SIMD_FORCE_INLINE const tf2Scalar& w() const { return m_floats[3]; } //TF2SIMD_FORCE_INLINE tf2Scalar& operator[](int i) { return (&m_floats[0])[i]; } //TF2SIMD_FORCE_INLINE const tf2Scalar& operator[](int i) const { return (&m_floats[0])[i]; } TF2SIMD_FORCE_INLINE operator tf2Scalar *() { return &m_floats[0]; } TF2SIMD_FORCE_INLINE operator const tf2Scalar *() const { return &m_floats[0]; } TF2SIMD_FORCE_INLINE bool operator==(const QuadWord& other) const { return ((m_floats[3]==other.m_floats[3]) && (m_floats[2]==other.m_floats[2]) && (m_floats[1]==other.m_floats[1]) && (m_floats[0]==other.m_floats[0])); } TF2SIMD_FORCE_INLINE bool operator!=(const QuadWord& other) const { return !(*this == other); } TF2SIMD_FORCE_INLINE void setValue(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z) { m_floats[0]=x; m_floats[1]=y; m_floats[2]=z; m_floats[3] = 0.f; } /* void getValue(tf2Scalar *m) const { m[0] = m_floats[0]; m[1] = m_floats[1]; m[2] = m_floats[2]; } */ TF2SIMD_FORCE_INLINE void setValue(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z,const tf2Scalar& w) { m_floats[0]=x; m_floats[1]=y; m_floats[2]=z; m_floats[3]=w; } TF2SIMD_FORCE_INLINE QuadWord() // :m_floats[0](tf2Scalar(0.)),m_floats[1](tf2Scalar(0.)),m_floats[2](tf2Scalar(0.)),m_floats[3](tf2Scalar(0.)) { } TF2SIMD_FORCE_INLINE QuadWord(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z) { m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = 0.0f; } TF2SIMD_FORCE_INLINE QuadWord(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z,const tf2Scalar& w) { m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = w; } TF2SIMD_FORCE_INLINE void setMax(const QuadWord& other) { tf2SetMax(m_floats[0], other.m_floats[0]); tf2SetMax(m_floats[1], other.m_floats[1]); tf2SetMax(m_floats[2], other.m_floats[2]); tf2SetMax(m_floats[3], other.m_floats[3]); } TF2SIMD_FORCE_INLINE void setMin(const QuadWord& other) { tf2SetMin(m_floats[0], other.m_floats[0]); tf2SetMin(m_floats[1], other.m_floats[1]); tf2SetMin(m_floats[2], other.m_floats[2]); tf2SetMin(m_floats[3], other.m_floats[3]); } }; } #endif //TF2SIMD_QUADWORD_H