Bugfix #4081: support for OpenBSD platform for scons. Big thanks to Nathan Houghton...
[blender-staging.git] / extern / bullet / LinearMath / SimdQuadWord.h
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 SIMD_QUADWORD_H
17 #define SIMD_QUADWORD_H
18
19 #include "SimdScalar.h"
20
21
22
23
24
25 class   SimdQuadWord
26 {
27         protected:
28                 ATTRIBUTE_ALIGNED16     (SimdScalar     m_x);
29                 SimdScalar      m_y;
30                 SimdScalar      m_z;
31                 SimdScalar      m_unusedW;
32
33         public:
34         
35                 SIMD_FORCE_INLINE SimdScalar&       operator[](int i)       { return (&m_x)[i]; }      
36                 SIMD_FORCE_INLINE const SimdScalar& operator[](int i) const { return (&m_x)[i]; }
37
38                 SIMD_FORCE_INLINE const SimdScalar& getX() const { return m_x; }
39
40                 SIMD_FORCE_INLINE const SimdScalar& getY() const { return m_y; }
41
42                 SIMD_FORCE_INLINE const SimdScalar& getZ() const { return m_z; }
43
44                 SIMD_FORCE_INLINE void  setX(float x) { m_x = x;};
45
46                 SIMD_FORCE_INLINE void  setY(float y) { m_y = y;};
47
48                 SIMD_FORCE_INLINE void  setZ(float z) { m_z = z;};
49
50                 SIMD_FORCE_INLINE const SimdScalar& x() const { return m_x; }
51
52                 SIMD_FORCE_INLINE const SimdScalar& y() const { return m_y; }
53
54                 SIMD_FORCE_INLINE const SimdScalar& z() const { return m_z; }
55
56
57                 operator       SimdScalar *()       { return &m_x; }
58                 operator const SimdScalar *() const { return &m_x; }
59
60                 SIMD_FORCE_INLINE void  setValue(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z)
61                 {
62                         m_x=x;
63                         m_y=y;
64                         m_z=z;
65                 }
66
67 /*              void getValue(SimdScalar *m) const 
68                 {
69                         m[0] = m_x;
70                         m[1] = m_y;
71                         m[2] = m_z;
72                 }
73 */
74                 SIMD_FORCE_INLINE void  setValue(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z,const SimdScalar& w)
75                 {
76                         m_x=x;
77                         m_y=y;
78                         m_z=z;
79                         m_unusedW=w;
80                 }
81
82                 SIMD_FORCE_INLINE SimdQuadWord() :
83                 m_x(0.f),m_y(0.f),m_z(0.f),m_unusedW(0.f)
84                 {
85                 }
86
87                 SIMD_FORCE_INLINE SimdQuadWord(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z) 
88                 :m_x(x),m_y(y),m_z(z)
89                 //todo, remove this in release/simd ?
90                 ,m_unusedW(0.f)
91                 {
92                 }
93
94                 SIMD_FORCE_INLINE SimdQuadWord(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z,const SimdScalar& w) 
95                         :m_x(x),m_y(y),m_z(z),m_unusedW(w)
96                 {
97                 }
98
99
100                 SIMD_FORCE_INLINE void  setMax(const SimdQuadWord& other)
101                 {
102                         if (other.m_x > m_x)
103                                 m_x = other.m_x;
104
105                         if (other.m_y > m_y)
106                                 m_y = other.m_y;
107
108                         if (other.m_z > m_z)
109                                 m_z = other.m_z;
110
111                         if (other.m_unusedW > m_unusedW)
112                                 m_unusedW = other.m_unusedW;
113                 }
114
115                 SIMD_FORCE_INLINE void  setMin(const SimdQuadWord& other)
116                 {
117                         if (other.m_x < m_x)
118                                 m_x = other.m_x;
119
120                         if (other.m_y < m_y)
121                                 m_y = other.m_y;
122
123                         if (other.m_z < m_z)
124                                 m_z = other.m_z;
125
126                         if (other.m_unusedW < m_unusedW)
127                                 m_unusedW = other.m_unusedW;
128                 }
129
130
131
132 };
133
134 #endif //SIMD_QUADWORD_H