|
|
|
@ -47,6 +47,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|
|
|
|
#include "hsStream.h" |
|
|
|
|
#include <math.h> |
|
|
|
|
|
|
|
|
|
#ifdef HAVE_SSE |
|
|
|
|
# include <smmintrin.h> |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
static hsMatrix44 myIdent = hsMatrix44().Reset(); |
|
|
|
|
const hsMatrix44& hsMatrix44::IdentityMatrix() { return myIdent; } |
|
|
|
|
|
|
|
|
@ -92,6 +96,18 @@ void hsMatrix44::DecompRigid(hsScalarTriple &translate, hsQuat &rotate) const
|
|
|
|
|
rotate.QuatFromMatrix44(*this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef HAVE_SSE |
|
|
|
|
# define MULTBEGIN(i) \ |
|
|
|
|
xmm[0] = _mm_loadu_ps(fMap[i]); |
|
|
|
|
# define MULTCELL(i, j) \ |
|
|
|
|
xmm[1] = _mm_set_ps(b.fMap[3][j], b.fMap[2][j], b.fMap[1][j], b.fMap[0][j]); \
|
|
|
|
|
xmm[j+2] = _mm_mul_ps(xmm[0], xmm[1]); |
|
|
|
|
# define MULTFINISH(i) \ |
|
|
|
|
xmm[6] = _mm_hadd_ps(xmm[2], xmm[3]); \
|
|
|
|
|
xmm[7] = _mm_hadd_ps(xmm[4], xmm[5]); \
|
|
|
|
|
xmm[1] = _mm_hadd_ps(xmm[6], xmm[7]); \
|
|
|
|
|
_mm_storeu_ps(c.fMap[i], xmm[1]); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
hsMatrix44 hsMatrix44::operator*(const hsMatrix44& b) const |
|
|
|
|
{ |
|
|
|
@ -108,6 +124,37 @@ hsMatrix44 hsMatrix44::operator*(const hsMatrix44& b) const
|
|
|
|
|
if( b.fFlags & hsMatrix44::kIsIdent ) |
|
|
|
|
return *this; |
|
|
|
|
|
|
|
|
|
#ifdef HAVE_SSE |
|
|
|
|
__m128 xmm[8]; |
|
|
|
|
|
|
|
|
|
MULTBEGIN(0); |
|
|
|
|
MULTCELL(0, 0); |
|
|
|
|
MULTCELL(0, 1); |
|
|
|
|
MULTCELL(0, 2); |
|
|
|
|
MULTCELL(0, 3); |
|
|
|
|
MULTFINISH(0); |
|
|
|
|
|
|
|
|
|
MULTBEGIN(1); |
|
|
|
|
MULTCELL(1, 0); |
|
|
|
|
MULTCELL(1, 1); |
|
|
|
|
MULTCELL(1, 2); |
|
|
|
|
MULTCELL(1, 3); |
|
|
|
|
MULTFINISH(1); |
|
|
|
|
|
|
|
|
|
MULTBEGIN(2); |
|
|
|
|
MULTCELL(2, 0); |
|
|
|
|
MULTCELL(2, 1); |
|
|
|
|
MULTCELL(2, 2); |
|
|
|
|
MULTCELL(2, 3); |
|
|
|
|
MULTFINISH(2); |
|
|
|
|
|
|
|
|
|
MULTBEGIN(3); |
|
|
|
|
MULTCELL(3, 0); |
|
|
|
|
MULTCELL(3, 1); |
|
|
|
|
MULTCELL(3, 2); |
|
|
|
|
MULTCELL(3, 3); |
|
|
|
|
MULTFINISH(3); |
|
|
|
|
#else |
|
|
|
|
c.fMap[0][0] = (fMap[0][0] * b.fMap[0][0]) + (fMap[0][1] * b.fMap[1][0]) + (fMap[0][2] * b.fMap[2][0]) + (fMap[0][3] * b.fMap[3][0]); |
|
|
|
|
c.fMap[0][1] = (fMap[0][0] * b.fMap[0][1]) + (fMap[0][1] * b.fMap[1][1]) + (fMap[0][2] * b.fMap[2][1]) + (fMap[0][3] * b.fMap[3][1]); |
|
|
|
|
c.fMap[0][2] = (fMap[0][0] * b.fMap[0][2]) + (fMap[0][1] * b.fMap[1][2]) + (fMap[0][2] * b.fMap[2][2]) + (fMap[0][3] * b.fMap[3][2]); |
|
|
|
@ -127,6 +174,7 @@ hsMatrix44 hsMatrix44::operator*(const hsMatrix44& b) const
|
|
|
|
|
c.fMap[3][1] = (fMap[3][0] * b.fMap[0][1]) + (fMap[3][1] * b.fMap[1][1]) + (fMap[3][2] * b.fMap[2][1]) + (fMap[3][3] * b.fMap[3][1]); |
|
|
|
|
c.fMap[3][2] = (fMap[3][0] * b.fMap[0][2]) + (fMap[3][1] * b.fMap[1][2]) + (fMap[3][2] * b.fMap[2][2]) + (fMap[3][3] * b.fMap[3][2]); |
|
|
|
|
c.fMap[3][3] = (fMap[3][0] * b.fMap[0][3]) + (fMap[3][1] * b.fMap[1][3]) + (fMap[3][2] * b.fMap[2][3]) + (fMap[3][3] * b.fMap[3][3]); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
return c; |
|
|
|
|
} |
|
|
|
|