Fixed several bugs: python refcounting related and Bullet related (basic add/remove...
[blender.git] / extern / bullet / LinearMath / SimdQuadWord.h
1 /*
2
3 Copyright (c) 2005 Gino van den Bergen / Erwin Coumans http://continuousphysics.com
4
5 Permission is hereby granted, free of charge, to any person or organization
6 obtaining a copy of the software and accompanying documentation covered by
7 this license (the "Software") to use, reproduce, display, distribute,
8 execute, and transmit the Software, and to prepare derivative works of the
9 Software, and to permit third-parties to whom the Software is furnished to
10 do so, all subject to the following:
11
12 The copyright notices in the Software and this entire statement, including
13 the above license grant, this restriction and the following disclaimer,
14 must be included in all copies of the Software, in whole or in part, and
15 all derivative works of the Software, unless such copies or derivative
16 works are solely in the form of machine-executable object code generated by
17 a source language processor.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26 */
27
28 #ifndef SIMD_QUADWORD_H
29 #define SIMD_QUADWORD_H
30
31 #include "SimdScalar.h"
32
33
34
35
36
37 class   SimdQuadWord
38 {
39         protected:
40                 ATTRIBUTE_ALIGNED16     (SimdScalar     m_x);
41                 SimdScalar      m_y;
42                 SimdScalar      m_z;
43                 SimdScalar      m_unusedW;
44
45         public:
46         
47                 SIMD_FORCE_INLINE SimdScalar&       operator[](int i)       { return (&m_x)[i]; }      
48                 SIMD_FORCE_INLINE const SimdScalar& operator[](int i) const { return (&m_x)[i]; }
49
50                 SIMD_FORCE_INLINE const SimdScalar& getX() const { return m_x; }
51
52                 SIMD_FORCE_INLINE const SimdScalar& getY() const { return m_y; }
53
54                 SIMD_FORCE_INLINE const SimdScalar& getZ() const { return m_z; }
55
56                 SIMD_FORCE_INLINE void  setX(float x) { m_x = x;};
57
58                 SIMD_FORCE_INLINE void  setY(float y) { m_y = y;};
59
60                 SIMD_FORCE_INLINE void  setZ(float z) { m_z = z;};
61
62                 SIMD_FORCE_INLINE const SimdScalar& x() const { return m_x; }
63
64                 SIMD_FORCE_INLINE const SimdScalar& y() const { return m_y; }
65
66                 SIMD_FORCE_INLINE const SimdScalar& z() const { return m_z; }
67
68
69                 operator       SimdScalar *()       { return &m_x; }
70                 operator const SimdScalar *() const { return &m_x; }
71
72                 SIMD_FORCE_INLINE void  setValue(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z)
73                 {
74                         m_x=x;
75                         m_y=y;
76                         m_z=z;
77                 }
78
79 /*              void getValue(SimdScalar *m) const 
80                 {
81                         m[0] = m_x;
82                         m[1] = m_y;
83                         m[2] = m_z;
84                 }
85 */
86                 SIMD_FORCE_INLINE void  setValue(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z,const SimdScalar& w)
87                 {
88                         m_x=x;
89                         m_y=y;
90                         m_z=z;
91                         m_unusedW=w;
92                 }
93
94                 SIMD_FORCE_INLINE SimdQuadWord() :
95                 m_x(0.f),m_y(0.f),m_z(0.f),m_unusedW(0.f)
96                 {
97                 }
98
99                 SIMD_FORCE_INLINE SimdQuadWord(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z) 
100                 :m_x(x),m_y(y),m_z(z)
101                 //todo, remove this in release/simd ?
102                 ,m_unusedW(0.f)
103                 {
104                 }
105
106                 SIMD_FORCE_INLINE SimdQuadWord(const SimdScalar& x, const SimdScalar& y, const SimdScalar& z,const SimdScalar& w) 
107                         :m_x(x),m_y(y),m_z(z),m_unusedW(w)
108                 {
109                 }
110
111
112                 SIMD_FORCE_INLINE void  setMax(const SimdQuadWord& other)
113                 {
114                         if (other.m_x > m_x)
115                                 m_x = other.m_x;
116
117                         if (other.m_y > m_y)
118                                 m_y = other.m_y;
119
120                         if (other.m_z > m_z)
121                                 m_z = other.m_z;
122
123                         if (other.m_unusedW > m_unusedW)
124                                 m_unusedW = other.m_unusedW;
125                 }
126
127                 SIMD_FORCE_INLINE void  setMin(const SimdQuadWord& other)
128                 {
129                         if (other.m_x < m_x)
130                                 m_x = other.m_x;
131
132                         if (other.m_y < m_y)
133                                 m_y = other.m_y;
134
135                         if (other.m_z < m_z)
136                                 m_z = other.m_z;
137
138                         if (other.m_unusedW < m_unusedW)
139                                 m_unusedW = other.m_unusedW;
140                 }
141
142
143
144 };
145
146 #endif //SIMD_QUADWORD_H