aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmath/llv4matrix3.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:02 -0500
committerJacek Antonelli2008-08-15 23:45:02 -0500
commitd644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd (patch)
tree7ed0c2c27d717801238a2e6b5749cd5bf88c3059 /linden/indra/llmath/llv4matrix3.h
parentSecond Life viewer sources 1.17.3.0 (diff)
downloadmeta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.zip
meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.tar.gz
meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.tar.bz2
meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.tar.xz
Second Life viewer sources 1.18.0.6
Diffstat (limited to 'linden/indra/llmath/llv4matrix3.h')
-rw-r--r--linden/indra/llmath/llv4matrix3.h222
1 files changed, 0 insertions, 222 deletions
diff --git a/linden/indra/llmath/llv4matrix3.h b/linden/indra/llmath/llv4matrix3.h
deleted file mode 100644
index 0811338..0000000
--- a/linden/indra/llmath/llv4matrix3.h
+++ /dev/null
@@ -1,222 +0,0 @@
1/**
2 * @file llviewerjointmesh.cpp
3 * @brief LLV4* class header file - vector processor enabled math
4 *
5 * Copyright (c) 2007-2007, Linden Research, Inc.
6 *
7 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27 */
28
29#ifndef LL_LLV4MATRIX3_H
30#define LL_LLV4MATRIX3_H
31
32#include "llv4math.h"
33#include "llv4vector3.h"
34#include "m3math.h" // for operator LLMatrix3()
35
36//-----------------------------------------------------------------------------
37//-----------------------------------------------------------------------------
38// LLV4Matrix3
39//-----------------------------------------------------------------------------
40//-----------------------------------------------------------------------------
41
42LL_LLV4MATH_ALIGN_PREFIX
43
44class LLV4Matrix3
45{
46public:
47 union {
48 F32 mMatrix[LLV4_NUM_AXIS][LLV4_NUM_AXIS];
49 V4F32 mV[LLV4_NUM_AXIS];
50 };
51
52 void lerp(const LLV4Matrix3 &a, const LLV4Matrix3 &b, const F32 &w);
53 void multiply(const LLVector3 &a, LLVector3& out) const;
54 void multiply(const LLVector4 &a, LLV4Vector3& out) const;
55 void multiply(const LLVector3 &a, LLV4Vector3& out) const;
56
57 const LLV4Matrix3& transpose();
58 const LLV4Matrix3& operator=(const LLMatrix3& a);
59
60 operator LLMatrix3() const { return (reinterpret_cast<const LLMatrix4*>(const_cast<const F32*>(&mMatrix[0][0])))->getMat3(); }
61
62 friend LLVector3 operator*(const LLVector3& a, const LLV4Matrix3& b);
63}
64
65LL_LLV4MATH_ALIGN_POSTFIX;
66
67
68
69//-----------------------------------------------------------------------------
70//-----------------------------------------------------------------------------
71// LLV4Matrix3 - SSE
72//-----------------------------------------------------------------------------
73//-----------------------------------------------------------------------------
74
75#if LL_VECTORIZE
76
77inline void LLV4Matrix3::lerp(const LLV4Matrix3 &a, const LLV4Matrix3 &b, const F32 &w)
78{
79 __m128 vw = _mm_set1_ps(w);
80 mV[VX] = _mm_add_ps(_mm_mul_ps(_mm_sub_ps(b.mV[VX], a.mV[VX]), vw), a.mV[VX]); // ( b - a ) * w + a
81 mV[VY] = _mm_add_ps(_mm_mul_ps(_mm_sub_ps(b.mV[VY], a.mV[VY]), vw), a.mV[VY]);
82 mV[VZ] = _mm_add_ps(_mm_mul_ps(_mm_sub_ps(b.mV[VZ], a.mV[VZ]), vw), a.mV[VZ]);
83}
84
85inline void LLV4Matrix3::multiply(const LLVector3 &a, LLVector3& o) const
86{
87 LLV4Vector3 j;
88 j.v = _mm_mul_ps(_mm_set1_ps(a.mV[VX]), mV[VX]); // ( ax * vx ) + ...
89 j.v = _mm_add_ps(j.v , _mm_mul_ps(_mm_set1_ps(a.mV[VY]), mV[VY]));
90 j.v = _mm_add_ps(j.v , _mm_mul_ps(_mm_set1_ps(a.mV[VZ]), mV[VZ]));
91 o.setVec(j.mV);
92}
93
94inline void LLV4Matrix3::multiply(const LLVector4 &a, LLV4Vector3& o) const
95{
96 o.v = _mm_mul_ps(_mm_set1_ps(a.mV[VX]), mV[VX]); // ( ax * vx ) + ...
97 o.v = _mm_add_ps(o.v , _mm_mul_ps(_mm_set1_ps(a.mV[VY]), mV[VY]));
98 o.v = _mm_add_ps(o.v , _mm_mul_ps(_mm_set1_ps(a.mV[VZ]), mV[VZ]));
99}
100
101inline void LLV4Matrix3::multiply(const LLVector3 &a, LLV4Vector3& o) const
102{
103 o.v = _mm_mul_ps(_mm_set1_ps(a.mV[VX]), mV[VX]); // ( ax * vx ) + ...
104 o.v = _mm_add_ps(o.v , _mm_mul_ps(_mm_set1_ps(a.mV[VY]), mV[VY]));
105 o.v = _mm_add_ps(o.v , _mm_mul_ps(_mm_set1_ps(a.mV[VZ]), mV[VZ]));
106}
107
108//-----------------------------------------------------------------------------
109//-----------------------------------------------------------------------------
110// LLV4Matrix3
111//-----------------------------------------------------------------------------
112//-----------------------------------------------------------------------------
113
114#else
115
116inline void LLV4Matrix3::lerp(const LLV4Matrix3 &a, const LLV4Matrix3 &b, const F32 &w)
117{
118 mMatrix[VX][VX] = llv4lerp(a.mMatrix[VX][VX], b.mMatrix[VX][VX], w);
119 mMatrix[VX][VY] = llv4lerp(a.mMatrix[VX][VY], b.mMatrix[VX][VY], w);
120 mMatrix[VX][VZ] = llv4lerp(a.mMatrix[VX][VZ], b.mMatrix[VX][VZ], w);
121
122 mMatrix[VY][VX] = llv4lerp(a.mMatrix[VY][VX], b.mMatrix[VY][VX], w);
123 mMatrix[VY][VY] = llv4lerp(a.mMatrix[VY][VY], b.mMatrix[VY][VY], w);
124 mMatrix[VY][VZ] = llv4lerp(a.mMatrix[VY][VZ], b.mMatrix[VY][VZ], w);
125
126 mMatrix[VZ][VX] = llv4lerp(a.mMatrix[VZ][VX], b.mMatrix[VZ][VX], w);
127 mMatrix[VZ][VY] = llv4lerp(a.mMatrix[VZ][VY], b.mMatrix[VZ][VY], w);
128 mMatrix[VZ][VZ] = llv4lerp(a.mMatrix[VZ][VZ], b.mMatrix[VZ][VZ], w);
129}
130
131inline void LLV4Matrix3::multiply(const LLVector3 &a, LLVector3& o) const
132{
133 o.setVec( a.mV[VX] * mMatrix[VX][VX] +
134 a.mV[VY] * mMatrix[VY][VX] +
135 a.mV[VZ] * mMatrix[VZ][VX],
136
137 a.mV[VX] * mMatrix[VX][VY] +
138 a.mV[VY] * mMatrix[VY][VY] +
139 a.mV[VZ] * mMatrix[VZ][VY],
140
141 a.mV[VX] * mMatrix[VX][VZ] +
142 a.mV[VY] * mMatrix[VY][VZ] +
143 a.mV[VZ] * mMatrix[VZ][VZ]);
144}
145
146inline void LLV4Matrix3::multiply(const LLVector4 &a, LLV4Vector3& o) const
147{
148 o.setVec( a.mV[VX] * mMatrix[VX][VX] +
149 a.mV[VY] * mMatrix[VY][VX] +
150 a.mV[VZ] * mMatrix[VZ][VX],
151
152 a.mV[VX] * mMatrix[VX][VY] +
153 a.mV[VY] * mMatrix[VY][VY] +
154 a.mV[VZ] * mMatrix[VZ][VY],
155
156 a.mV[VX] * mMatrix[VX][VZ] +
157 a.mV[VY] * mMatrix[VY][VZ] +
158 a.mV[VZ] * mMatrix[VZ][VZ]);
159}
160
161inline void LLV4Matrix3::multiply(const LLVector3 &a, LLV4Vector3& o) const
162{
163 o.setVec( a.mV[VX] * mMatrix[VX][VX] +
164 a.mV[VY] * mMatrix[VY][VX] +
165 a.mV[VZ] * mMatrix[VZ][VX],
166
167 a.mV[VX] * mMatrix[VX][VY] +
168 a.mV[VY] * mMatrix[VY][VY] +
169 a.mV[VZ] * mMatrix[VZ][VY],
170
171 a.mV[VX] * mMatrix[VX][VZ] +
172 a.mV[VY] * mMatrix[VY][VZ] +
173 a.mV[VZ] * mMatrix[VZ][VZ]);
174}
175
176//-----------------------------------------------------------------------------
177//-----------------------------------------------------------------------------
178// LLV4Matrix3
179//-----------------------------------------------------------------------------
180//-----------------------------------------------------------------------------
181
182#endif
183
184inline const LLV4Matrix3& LLV4Matrix3::transpose()
185{
186#if LL_VECTORIZE && defined(_MM_TRANSPOSE4_PS)
187 _MM_TRANSPOSE4_PS(mV[VX], mV[VY], mV[VZ], mV[VW]);
188 return *this;
189#else
190 F32 temp;
191 temp = mMatrix[VX][VY]; mMatrix[VX][VY] = mMatrix[VY][VX]; mMatrix[VY][VX] = temp;
192 temp = mMatrix[VX][VZ]; mMatrix[VX][VZ] = mMatrix[VZ][VX]; mMatrix[VZ][VX] = temp;
193 temp = mMatrix[VY][VZ]; mMatrix[VY][VZ] = mMatrix[VZ][VY]; mMatrix[VZ][VY] = temp;
194#endif
195 return *this;
196}
197
198inline const LLV4Matrix3& LLV4Matrix3::operator=(const LLMatrix3& a)
199{
200 memcpy(mMatrix[VX], a.mMatrix[VX], sizeof(F32) * 3 );
201 memcpy(mMatrix[VY], a.mMatrix[VY], sizeof(F32) * 3 );
202 memcpy(mMatrix[VZ], a.mMatrix[VZ], sizeof(F32) * 3 );
203 return *this;
204}
205
206inline LLVector3 operator*(const LLVector3& a, const LLV4Matrix3& b)
207{
208 return LLVector3(
209 a.mV[VX] * b.mMatrix[VX][VX] +
210 a.mV[VY] * b.mMatrix[VY][VX] +
211 a.mV[VZ] * b.mMatrix[VZ][VX],
212
213 a.mV[VX] * b.mMatrix[VX][VY] +
214 a.mV[VY] * b.mMatrix[VY][VY] +
215 a.mV[VZ] * b.mMatrix[VZ][VY],
216
217 a.mV[VX] * b.mMatrix[VX][VZ] +
218 a.mV[VY] * b.mMatrix[VY][VZ] +
219 a.mV[VZ] * b.mMatrix[VZ][VZ] );
220}
221
222#endif