summaryrefslogtreecommitdiff
path: root/indra/llmath/m4math.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmath/m4math.h')
-rw-r--r--indra/llmath/m4math.h30
1 files changed, 27 insertions, 3 deletions
diff --git a/indra/llmath/m4math.h b/indra/llmath/m4math.h
index 58c9c09d7f..e74b7afe9b 100644
--- a/indra/llmath/m4math.h
+++ b/indra/llmath/m4math.h
@@ -230,7 +230,7 @@ public:
// friend inline LLMatrix4 operator*(const LLMatrix4 &a, const LLMatrix4 &b); // Return a * b
friend LLVector4 operator*(const LLVector4 &a, const LLMatrix4 &b); // Return transform of vector a by matrix b
- friend LLVector3 operator*(const LLVector3 &a, const LLMatrix4 &b); // Return full transform of a by matrix b
+ friend const LLVector3 operator*(const LLVector3 &a, const LLMatrix4 &b); // Return full transform of a by matrix b
friend LLVector4 rotate_vector(const LLVector4 &a, const LLMatrix4 &b); // Rotates a but does not translate
friend LLVector3 rotate_vector(const LLVector3 &a, const LLMatrix4 &b); // Rotates a but does not translate
@@ -353,7 +353,31 @@ inline const LLMatrix4& operator-=(LLMatrix4 &a, const LLMatrix4 &b)
return a;
}
-#endif
-
+// Operates "to the left" on row-vector a
+//
+// When avatar vertex programs are off, this function is a hot spot in profiles
+// due to software skinning in LLViewerJointMesh::updateGeometry(). JC
+inline const 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]);
+}
+#endif