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 TF_QUADWORD_H
17 #define TF_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 
28 namespace tf
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  tfScalar m_floats[4];
45  };
46 public:
47  vec_float4 get128() const
48  {
49  return mVec128;
50  }
51 protected:
52 #else //__CELLOS_LV2__ __SPU__
53  tfScalar m_floats[4];
54 #endif //__CELLOS_LV2__ __SPU__
55 
56  public:
57 
58 
60  TFSIMD_FORCE_INLINE const tfScalar& getX() const { return m_floats[0]; }
62  TFSIMD_FORCE_INLINE const tfScalar& getY() const { return m_floats[1]; }
64  TFSIMD_FORCE_INLINE const tfScalar& getZ() const { return m_floats[2]; }
66  TFSIMD_FORCE_INLINE void setX(tfScalar x) { m_floats[0] = x;};
68  TFSIMD_FORCE_INLINE void setY(tfScalar y) { m_floats[1] = y;};
70  TFSIMD_FORCE_INLINE void setZ(tfScalar z) { m_floats[2] = z;};
72  TFSIMD_FORCE_INLINE void setW(tfScalar w) { m_floats[3] = w;};
74  TFSIMD_FORCE_INLINE const tfScalar& x() const { return m_floats[0]; }
76  TFSIMD_FORCE_INLINE const tfScalar& y() const { return m_floats[1]; }
78  TFSIMD_FORCE_INLINE const tfScalar& z() const { return m_floats[2]; }
80  TFSIMD_FORCE_INLINE const tfScalar& w() const { return m_floats[3]; }
81 
82  //TFSIMD_FORCE_INLINE tfScalar& operator[](int i) { return (&m_floats[0])[i]; }
83  //TFSIMD_FORCE_INLINE const tfScalar& operator[](int i) const { return (&m_floats[0])[i]; }
85  TFSIMD_FORCE_INLINE operator tfScalar *() { return &m_floats[0]; }
86  TFSIMD_FORCE_INLINE operator const tfScalar *() const { return &m_floats[0]; }
87 
88  TFSIMD_FORCE_INLINE bool operator==(const QuadWord& other) const
89  {
90  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]));
91  }
92 
93  TFSIMD_FORCE_INLINE bool operator!=(const QuadWord& other) const
94  {
95  return !(*this == other);
96  }
97 
103  TFSIMD_FORCE_INLINE void setValue(const tfScalar& x, const tfScalar& y, const tfScalar& z)
104  {
105  m_floats[0]=x;
106  m_floats[1]=y;
107  m_floats[2]=z;
108  m_floats[3] = 0.f;
109  }
110 
111 /* void getValue(tfScalar *m) const
112  {
113  m[0] = m_floats[0];
114  m[1] = m_floats[1];
115  m[2] = m_floats[2];
116  }
117 */
124  TFSIMD_FORCE_INLINE void setValue(const tfScalar& x, const tfScalar& y, const tfScalar& z,const tfScalar& w)
125  {
126  m_floats[0]=x;
127  m_floats[1]=y;
128  m_floats[2]=z;
129  m_floats[3]=w;
130  }
132  TFSIMD_FORCE_INLINE QuadWord()
133  // :m_floats[0](tfScalar(0.)),m_floats[1](tfScalar(0.)),m_floats[2](tfScalar(0.)),m_floats[3](tfScalar(0.))
134  {
135  }
136 
142  TFSIMD_FORCE_INLINE QuadWord(const tfScalar& x, const tfScalar& y, const tfScalar& z)
143  {
144  m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = 0.0f;
145  }
146 
153  TFSIMD_FORCE_INLINE QuadWord(const tfScalar& x, const tfScalar& y, const tfScalar& z,const tfScalar& w)
154  {
155  m_floats[0] = x, m_floats[1] = y, m_floats[2] = z, m_floats[3] = w;
156  }
157 
161  TFSIMD_FORCE_INLINE void setMax(const QuadWord& other)
162  {
163  tfSetMax(m_floats[0], other.m_floats[0]);
164  tfSetMax(m_floats[1], other.m_floats[1]);
165  tfSetMax(m_floats[2], other.m_floats[2]);
166  tfSetMax(m_floats[3], other.m_floats[3]);
167  }
171  TFSIMD_FORCE_INLINE void setMin(const QuadWord& other)
172  {
173  tfSetMin(m_floats[0], other.m_floats[0]);
174  tfSetMin(m_floats[1], other.m_floats[1]);
175  tfSetMin(m_floats[2], other.m_floats[2]);
176  tfSetMin(m_floats[3], other.m_floats[3]);
177  }
178 
179 
180 
181 };
182 
183 }
184 
185 #endif //TFSIMD_QUADWORD_H
double tfScalar
The tfScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: Scalar.h:160
TFSIMD_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:642
Definition: exceptions.h:38
TFSIMD_FORCE_INLINE void tfSetMin(T &a, const T &b)
Definition: MinMax.h:34
#define TFSIMD_FORCE_INLINE
Definition: Scalar.h:130
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
TFSIMD_FORCE_INLINE void tfSetMax(T &a, const T &b)
Definition: MinMax.h:43


tf
Author(s): Tully Foote, Eitan Marder-Eppstein, Wim Meeussen
autogenerated on Mon Feb 28 2022 22:26:19