tf2  master
tf2 maintains the relationship between coordinate frames in a tree structure buffered in time, and lets the user transform points, vectors, etc between any two coordinate frames at any desired point in time.
QuadWord.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/
3 
4 This software is provided 'as-is', without any express or implied warranty.
5 In no event will the authors be held liable for any damages arising from the use of this software.
6 Permission is granted to anyone to use this software for any purpose,
7 including commercial applications, and to alter it and redistribute it freely,
8 subject to the following restrictions:
9 
10 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.
11 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
12 3. This notice may not be removed or altered from any source distribution.
13 */
14 
15 
16 #ifndef TF2SIMD_QUADWORD_H
17 #define TF2SIMD_QUADWORD_H
18 
19 #include "Scalar.h"
20 #include "MinMax.h"
21 #include "tf2/visibility_control.h"
22 
23 
24 #if defined (__CELLOS_LV2) && defined (__SPU__)
25 #include <altivec.h>
26 #endif
27 
28 namespace tf2
29 {
33 #ifndef USE_LIBSPE2
34 ATTRIBUTE_ALIGNED16(class) QuadWord
35 #else
36 class QuadWord
37 #endif
38 {
39 protected:
40 
41 #if defined (__SPU__) && defined (__CELLOS_LV2__)
42  union {
43  vec_float4 mVec128;
44  tf2Scalar m_floats[4];
45  };
46 public:
48  vec_float4 get128() const
49  {
50  return mVec128;
51  }
52 protected:
53 #else //__CELLOS_LV2__ __SPU__
54  tf2Scalar m_floats[4];
55 #endif //__CELLOS_LV2__ __SPU__
56 
57  public:
58 
59 
61  TF2SIMD_FORCE_INLINE const tf2Scalar& getX() const { return m_floats[0]; }
63  TF2SIMD_FORCE_INLINE const tf2Scalar& getY() const { return m_floats[1]; }
65  TF2SIMD_FORCE_INLINE const tf2Scalar& getZ() const { return m_floats[2]; }
67  TF2SIMD_FORCE_INLINE void setX(tf2Scalar x) { m_floats[0] = x;};
69  TF2SIMD_FORCE_INLINE void setY(tf2Scalar y) { m_floats[1] = y;};
71  TF2SIMD_FORCE_INLINE void setZ(tf2Scalar z) { m_floats[2] = z;};
73  TF2SIMD_FORCE_INLINE void setW(tf2Scalar w) { m_floats[3] = w;};
75  TF2SIMD_FORCE_INLINE const tf2Scalar& x() const { return m_floats[0]; }
77  TF2SIMD_FORCE_INLINE const tf2Scalar& y() const { return m_floats[1]; }
79  TF2SIMD_FORCE_INLINE const tf2Scalar& z() const { return m_floats[2]; }
81  TF2SIMD_FORCE_INLINE const tf2Scalar& w() const { return m_floats[3]; }
82 
83  //TF2SIMD_FORCE_INLINE tf2Scalar& operator[](int i) { return (&m_floats[0])[i]; }
84  //TF2SIMD_FORCE_INLINE const tf2Scalar& operator[](int i) const { return (&m_floats[0])[i]; }
86  TF2SIMD_FORCE_INLINE operator tf2Scalar *() { return &m_floats[0]; }
87  TF2SIMD_FORCE_INLINE operator const tf2Scalar *() const { return &m_floats[0]; }
88 
89  TF2SIMD_FORCE_INLINE bool operator==(const QuadWord& other) const
90  {
91  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]));
92  }
93 
94  TF2SIMD_FORCE_INLINE bool operator!=(const QuadWord& other) const
95  {
96  return !(*this == other);
97  }
98 
104  TF2SIMD_FORCE_INLINE void setValue(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z)
105  {
106  m_floats[0]=x;
107  m_floats[1]=y;
108  m_floats[2]=z;
109  m_floats[3] = 0.f;
110  }
111 
112 /* void getValue(tf2Scalar *m) const
113  {
114  m[0] = m_floats[0];
115  m[1] = m_floats[1];
116  m[2] = m_floats[2];
117  }
118 */
125  TF2SIMD_FORCE_INLINE void setValue(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z,const tf2Scalar& w)
126  {
127  m_floats[0]=x;
128  m_floats[1]=y;
129  m_floats[2]=z;
130  m_floats[3]=w;
131  }
133  TF2SIMD_FORCE_INLINE QuadWord()
134  // :m_floats[0](tf2Scalar(0.)),m_floats[1](tf2Scalar(0.)),m_floats[2](tf2Scalar(0.)),m_floats[3](tf2Scalar(0.))
135  {
136  }
137 
143  TF2SIMD_FORCE_INLINE QuadWord(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z)
144  {
145  m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = 0.0f;
146  }
147 
154  TF2SIMD_FORCE_INLINE QuadWord(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z,const tf2Scalar& w)
155  {
156  m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = w;
157  }
158 
162  TF2SIMD_FORCE_INLINE void setMax(const QuadWord& other)
163  {
164  tf2SetMax(m_floats[0], other.m_floats[0]);
165  tf2SetMax(m_floats[1], other.m_floats[1]);
166  tf2SetMax(m_floats[2], other.m_floats[2]);
167  tf2SetMax(m_floats[3], other.m_floats[3]);
168  }
172  TF2SIMD_FORCE_INLINE void setMin(const QuadWord& other)
173  {
174  tf2SetMin(m_floats[0], other.m_floats[0]);
175  tf2SetMin(m_floats[1], other.m_floats[1]);
176  tf2SetMin(m_floats[2], other.m_floats[2]);
177  tf2SetMin(m_floats[3], other.m_floats[3]);
178  }
179 
180 
181 
182 };
183 
184 }
185 #endif //TF2SIMD_QUADWORD_H
Scalar.h
MinMax.h
tf2::ATTRIBUTE_ALIGNED16
ATTRIBUTE_ALIGNED16(class) QuadWord
The QuadWord class is base class for Vector3 and Quaternion. Some issues under PS3 Linux with IBM 2....
Definition: QuadWord.h:34
tf2::operator==
TF2SIMD_FORCE_INLINE bool operator==(const Matrix3x3 &m1, const Matrix3x3 &m2)
Equality operator between two matrices It will test all elements are equal.
Definition: Matrix3x3.h:649
TF2SIMD_FORCE_INLINE
#define TF2SIMD_FORCE_INLINE
Definition: Scalar.h:129
tf2SetMin
TF2SIMD_FORCE_INLINE void tf2SetMin(T &a, const T &b)
Definition: MinMax.h:39
visibility_control.h
tf2
Definition: buffer_core.h:55
TF2_PUBLIC
#define TF2_PUBLIC
Definition: visibility_control.h:58
tf2Scalar
double tf2Scalar
The tf2Scalar type abstracts floating point numbers, to easily switch between double and single float...
Definition: Scalar.h:159
tf2SetMax
TF2SIMD_FORCE_INLINE void tf2SetMax(T &a, const T &b)
Definition: MinMax.h:48