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 
22 
23 #if defined (__CELLOS_LV2) && defined (__SPU__)
24 #include <altivec.h>
25 #endif
26 
27 namespace tf2
28 {
32 #ifndef USE_LIBSPE2
33 ATTRIBUTE_ALIGNED16(class) QuadWord
34 #else
35 class QuadWord
36 #endif
37 {
38 protected:
39 
40 #if defined (__SPU__) && defined (__CELLOS_LV2__)
41  union {
42  vec_float4 mVec128;
43  tf2Scalar m_floats[4];
44  };
45 public:
46  vec_float4 get128() const
47  {
48  return mVec128;
49  }
50 protected:
51 #else //__CELLOS_LV2__ __SPU__
52  tf2Scalar m_floats[4];
53 #endif //__CELLOS_LV2__ __SPU__
54 
55  public:
56 
57 
59  TF2SIMD_FORCE_INLINE const tf2Scalar& getX() const { return m_floats[0]; }
61  TF2SIMD_FORCE_INLINE const tf2Scalar& getY() const { return m_floats[1]; }
63  TF2SIMD_FORCE_INLINE const tf2Scalar& getZ() const { return m_floats[2]; }
65  TF2SIMD_FORCE_INLINE void setX(tf2Scalar x) { m_floats[0] = x;};
67  TF2SIMD_FORCE_INLINE void setY(tf2Scalar y) { m_floats[1] = y;};
69  TF2SIMD_FORCE_INLINE void setZ(tf2Scalar z) { m_floats[2] = z;};
71  TF2SIMD_FORCE_INLINE void setW(tf2Scalar w) { m_floats[3] = w;};
73  TF2SIMD_FORCE_INLINE const tf2Scalar& x() const { return m_floats[0]; }
75  TF2SIMD_FORCE_INLINE const tf2Scalar& y() const { return m_floats[1]; }
77  TF2SIMD_FORCE_INLINE const tf2Scalar& z() const { return m_floats[2]; }
79  TF2SIMD_FORCE_INLINE const tf2Scalar& w() const { return m_floats[3]; }
80 
81  //TF2SIMD_FORCE_INLINE tf2Scalar& operator[](int i) { return (&m_floats[0])[i]; }
82  //TF2SIMD_FORCE_INLINE const tf2Scalar& operator[](int i) const { return (&m_floats[0])[i]; }
84  TF2SIMD_FORCE_INLINE operator tf2Scalar *() { return &m_floats[0]; }
85  TF2SIMD_FORCE_INLINE operator const tf2Scalar *() const { return &m_floats[0]; }
86 
87  TF2SIMD_FORCE_INLINE bool operator==(const QuadWord& other) const
88  {
89  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]));
90  }
91 
92  TF2SIMD_FORCE_INLINE bool operator!=(const QuadWord& other) const
93  {
94  return !(*this == other);
95  }
96 
102  TF2SIMD_FORCE_INLINE void setValue(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z)
103  {
104  m_floats[0]=x;
105  m_floats[1]=y;
106  m_floats[2]=z;
107  m_floats[3] = 0.f;
108  }
109 
110 /* void getValue(tf2Scalar *m) const
111  {
112  m[0] = m_floats[0];
113  m[1] = m_floats[1];
114  m[2] = m_floats[2];
115  }
116 */
123  TF2SIMD_FORCE_INLINE void setValue(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z,const tf2Scalar& w)
124  {
125  m_floats[0]=x;
126  m_floats[1]=y;
127  m_floats[2]=z;
128  m_floats[3]=w;
129  }
131  TF2SIMD_FORCE_INLINE QuadWord()
132  // :m_floats[0](tf2Scalar(0.)),m_floats[1](tf2Scalar(0.)),m_floats[2](tf2Scalar(0.)),m_floats[3](tf2Scalar(0.))
133  {
134  }
135 
141  TF2SIMD_FORCE_INLINE QuadWord(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z)
142  {
143  m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = 0.0f;
144  }
145 
152  TF2SIMD_FORCE_INLINE QuadWord(const tf2Scalar& x, const tf2Scalar& y, const tf2Scalar& z,const tf2Scalar& w)
153  {
154  m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = w;
155  }
156 
160  TF2SIMD_FORCE_INLINE void setMax(const QuadWord& other)
161  {
162  tf2SetMax(m_floats[0], other.m_floats[0]);
163  tf2SetMax(m_floats[1], other.m_floats[1]);
164  tf2SetMax(m_floats[2], other.m_floats[2]);
165  tf2SetMax(m_floats[3], other.m_floats[3]);
166  }
170  TF2SIMD_FORCE_INLINE void setMin(const QuadWord& other)
171  {
172  tf2SetMin(m_floats[0], other.m_floats[0]);
173  tf2SetMin(m_floats[1], other.m_floats[1]);
174  tf2SetMin(m_floats[2], other.m_floats[2]);
175  tf2SetMin(m_floats[3], other.m_floats[3]);
176  }
177 
178 
179 
180 };
181 
182 }
183 #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:33
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:641
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
tf2
Definition: buffer_core.h:54
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


tf2
Author(s): Tully Foote, Eitan Marder-Eppstein, Wim Meeussen
autogenerated on Sun Feb 4 2024 03:18:11