summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
authorJosh Bell <josh@lindenlab.com>2007-04-11 17:54:18 +0000
committerJosh Bell <josh@lindenlab.com>2007-04-11 17:54:18 +0000
commit0277259455c4354f81ea8a24c8ab93f27567bc6f (patch)
treef1411dab563dcf697f794e9e8a592a6d3e5c4d2d /indra/llmath
parent568397bbcc4fca307ebc010ec7f815422b9ba80a (diff)
svn merge -r 59968:60342 svn+ssh://svn.lindenlab.com/svn/linden/branches/maintenance --> release
Diffstat (limited to 'indra/llmath')
-rw-r--r--indra/llmath/m4math.cpp66
-rw-r--r--indra/llmath/m4math.h21
-rw-r--r--indra/llmath/v4math.h11
3 files changed, 55 insertions, 43 deletions
diff --git a/indra/llmath/m4math.cpp b/indra/llmath/m4math.cpp
index 969c3663e6..8d5fc27776 100644
--- a/indra/llmath/m4math.cpp
+++ b/indra/llmath/m4math.cpp
@@ -654,31 +654,55 @@ LLVector4 operator*(const LLMatrix4 &a, const LLVector4 &b)
}
*/
+// Operates "to the left" on row-vector a
+//
+// This used to be in the header file but was not actually inlined in practice.
+// When avatar vertex programs are off, this function is a hot spot in profiles
+// due to software skinning in LLViewerJointMesh::updateGeometry(). JC
+LLVector3 operator*(const LLVector3 &a, const LLMatrix4 &b)
+{
+ // This is better than making a temporary LLVector3. This eliminates an
+ // unnecessary LLVector3() constructor and also helps the compiler to
+ // realize that the output floats do not alias the input floats, hence
+ // eliminating redundant loads of a.mV[0], etc. JC
+ return LLVector3(a.mV[VX] * b.mMatrix[VX][VX] +
+ a.mV[VY] * b.mMatrix[VY][VX] +
+ a.mV[VZ] * b.mMatrix[VZ][VX] +
+ b.mMatrix[VW][VX],
+
+ a.mV[VX] * b.mMatrix[VX][VY] +
+ a.mV[VY] * b.mMatrix[VY][VY] +
+ a.mV[VZ] * b.mMatrix[VZ][VY] +
+ b.mMatrix[VW][VY],
+
+ a.mV[VX] * b.mMatrix[VX][VZ] +
+ a.mV[VY] * b.mMatrix[VY][VZ] +
+ a.mV[VZ] * b.mMatrix[VZ][VZ] +
+ b.mMatrix[VW][VZ]);
+}
LLVector4 operator*(const LLVector4 &a, const LLMatrix4 &b)
{
// Operate "to the left" on row-vector a
- LLVector4 vec;
- vec.mV[VX] = a.mV[VX] * b.mMatrix[VX][VX] +
- a.mV[VY] * b.mMatrix[VY][VX] +
- a.mV[VZ] * b.mMatrix[VZ][VX] +
- a.mV[VW] * b.mMatrix[VW][VX];
-
- vec.mV[VY] = a.mV[VX] * b.mMatrix[VX][VY] +
- a.mV[VY] * b.mMatrix[VY][VY] +
- a.mV[VZ] * b.mMatrix[VZ][VY] +
- a.mV[VW] * b.mMatrix[VW][VY];
-
- vec.mV[VZ] = a.mV[VX] * b.mMatrix[VX][VZ] +
- a.mV[VY] * b.mMatrix[VY][VZ] +
- a.mV[VZ] * b.mMatrix[VZ][VZ] +
- a.mV[VW] * b.mMatrix[VW][VZ];
-
- vec.mV[VW] = a.mV[VX] * b.mMatrix[VX][VW] +
- a.mV[VY] * b.mMatrix[VY][VW] +
- a.mV[VZ] * b.mMatrix[VZ][VW] +
- a.mV[VW] * b.mMatrix[VW][VW];
- return vec;
+ return LLVector4(a.mV[VX] * b.mMatrix[VX][VX] +
+ a.mV[VY] * b.mMatrix[VY][VX] +
+ a.mV[VZ] * b.mMatrix[VZ][VX] +
+ a.mV[VW] * b.mMatrix[VW][VX],
+
+ a.mV[VX] * b.mMatrix[VX][VY] +
+ a.mV[VY] * b.mMatrix[VY][VY] +
+ a.mV[VZ] * b.mMatrix[VZ][VY] +
+ a.mV[VW] * b.mMatrix[VW][VY],
+
+ a.mV[VX] * b.mMatrix[VX][VZ] +
+ a.mV[VY] * b.mMatrix[VY][VZ] +
+ a.mV[VZ] * b.mMatrix[VZ][VZ] +
+ a.mV[VW] * b.mMatrix[VW][VZ],
+
+ a.mV[VX] * b.mMatrix[VX][VW] +
+ a.mV[VY] * b.mMatrix[VY][VW] +
+ a.mV[VZ] * b.mMatrix[VZ][VW] +
+ a.mV[VW] * b.mMatrix[VW][VW]);
}
LLVector4 rotate_vector(const LLVector4 &a, const LLMatrix4 &b)
diff --git a/indra/llmath/m4math.h b/indra/llmath/m4math.h
index 69463d7718..e95a40af16 100644
--- a/indra/llmath/m4math.h
+++ b/indra/llmath/m4math.h
@@ -247,27 +247,6 @@ inline const LLMatrix4& LLMatrix4::identity()
return (*this);
}
-inline LLVector3 operator*(const LLVector3 &a, const LLMatrix4 &b)
-{
- // Converts a to LLVector4 and applies full transformation
- // Operates "to the left" on row-vector a
- LLVector3 vec;
- vec.mV[VX] = a.mV[VX] * b.mMatrix[VX][VX] +
- a.mV[VY] * b.mMatrix[VY][VX] +
- a.mV[VZ] * b.mMatrix[VZ][VX] +
- b.mMatrix[VW][VX];
-
- vec.mV[VY] = a.mV[VX] * b.mMatrix[VX][VY] +
- a.mV[VY] * b.mMatrix[VY][VY] +
- a.mV[VZ] * b.mMatrix[VZ][VY] +
- b.mMatrix[VW][VY];
-
- vec.mV[VZ] = a.mV[VX] * b.mMatrix[VX][VZ] +
- a.mV[VY] * b.mMatrix[VY][VZ] +
- a.mV[VZ] * b.mMatrix[VZ][VZ] +
- b.mMatrix[VW][VZ];
- return vec;
-}
/*
inline LLMatrix4 operator*(const LLMatrix4 &a, const LLMatrix4 &b)
diff --git a/indra/llmath/v4math.h b/indra/llmath/v4math.h
index e9b8d5b71f..ced7ef131a 100644
--- a/indra/llmath/v4math.h
+++ b/indra/llmath/v4math.h
@@ -26,7 +26,8 @@ class LLVector4
public:
F32 mV[LENGTHOFVECTOR4];
LLVector4(); // Initializes LLVector4 to (0, 0, 0, 1)
- explicit LLVector4(const F32 *vec); // Initializes LLVector4 to (vec[0]. vec[1], vec[2], 1)
+ explicit LLVector4(const F32 *vec); // Initializes LLVector4 to (vec[0]. vec[1], vec[2], vec[3])
+ explicit LLVector4(const F64 *vec); // Initialized LLVector4 to ((F32) vec[0], (F32) vec[1], (F32) vec[3], (F32) vec[4]);
explicit LLVector4(const LLVector3 &vec); // Initializes LLVector4 to (vec, 1)
explicit LLVector4(const LLVector3 &vec, F32 w); // Initializes LLVector4 to (vec, w)
LLVector4(F32 x, F32 y, F32 z); // Initializes LLVector4 to (x. y, z, 1)
@@ -136,6 +137,14 @@ inline LLVector4::LLVector4(const F32 *vec)
mV[VW] = vec[VW];
}
+inline LLVector4::LLVector4(const F64 *vec)
+{
+ mV[VX] = (F32) vec[VX];
+ mV[VY] = (F32) vec[VY];
+ mV[VZ] = (F32) vec[VZ];
+ mV[VW] = (F32) vec[VW];
+}
+
inline LLVector4::LLVector4(const LLVector3 &vec)
{
mV[VX] = vec.mV[VX];