From 28d8d4e7664bcd6c8369cc18832e42096af7cad2 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:45:01 -0500 Subject: Second Life viewer sources 1.17.3.0 --- linden/indra/llmath/llmath.vcproj | 12 ++ linden/indra/llmath/llmath_vc8.vcproj | 16 +++ linden/indra/llmath/lluuid.h | 2 + linden/indra/llmath/llv4math.h | 121 ++++++++++++++++ linden/indra/llmath/llv4matrix3.h | 222 ++++++++++++++++++++++++++++++ linden/indra/llmath/llv4matrix4.h | 251 ++++++++++++++++++++++++++++++++++ linden/indra/llmath/llv4vector3.h | 82 +++++++++++ linden/indra/llmath/llvolume.h | 2 +- linden/indra/llmath/v4color.h | 2 +- 9 files changed, 708 insertions(+), 2 deletions(-) create mode 100644 linden/indra/llmath/llv4math.h create mode 100644 linden/indra/llmath/llv4matrix3.h create mode 100644 linden/indra/llmath/llv4matrix4.h create mode 100644 linden/indra/llmath/llv4vector3.h (limited to 'linden/indra/llmath') diff --git a/linden/indra/llmath/llmath.vcproj b/linden/indra/llmath/llmath.vcproj index 4876065..bdc8ded 100644 --- a/linden/indra/llmath/llmath.vcproj +++ b/linden/indra/llmath/llmath.vcproj @@ -272,6 +272,18 @@ RelativePath=".\lluuid.h"> + + + + + + + + + + + + + + + + diff --git a/linden/indra/llmath/lluuid.h b/linden/indra/llmath/lluuid.h index 99cd585..6334ea4 100644 --- a/linden/indra/llmath/lluuid.h +++ b/linden/indra/llmath/lluuid.h @@ -317,6 +317,8 @@ typedef LLUUID LLAssetID; class LLTransactionID : public LLUUID { public: + LLTransactionID() : LLUUID() { } + static const LLTransactionID tnull; LLAssetID makeAssetID(const LLUUID& session) const; }; diff --git a/linden/indra/llmath/llv4math.h b/linden/indra/llmath/llv4math.h new file mode 100644 index 0000000..d0b956b --- /dev/null +++ b/linden/indra/llmath/llv4math.h @@ -0,0 +1,121 @@ +/** + * @file llviewerjointmesh.cpp + * @brief LLV4* class header file - vector processor enabled math + * + * Copyright (c) 2007-2007, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlife.com/developers/opensource/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlife.com/developers/opensource/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + */ + +#ifndef LL_LLV4MATH_H +#define LL_LLV4MATH_H + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// LLV4MATH - GNUC +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +#if LL_GNUC && __GNUC__ >= 4 && __SSE__ + +#define LL_VECTORIZE 1 + +#if LL_DARWIN + +#include +#include +typedef vFloat V4F32; + +#else + +#include +typedef float V4F32 __attribute__((vector_size(16))); + +#endif + +#endif +#if LL_GNUC + +#define LL_LLV4MATH_ALIGN_PREFIX +#define LL_LLV4MATH_ALIGN_POSTFIX __attribute__((aligned(16))) + +#endif + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// LLV4MATH - MSVC +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +#if LL_MSVC && _M_IX86_FP + +#define LL_VECTORIZE 1 + +#include + +typedef __m128 V4F32; + +#endif +#if LL_MSVC + +#define LL_LLV4MATH_ALIGN_PREFIX __declspec(align(16)) +#define LL_LLV4MATH_ALIGN_POSTFIX + +#endif + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// LLV4MATH - default - no vectorization +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +#if !LL_VECTORIZE + +#define LL_VECTORIZE 0 + +struct V4F32 { F32 __pad__[4]; }; + +inline F32 llv4lerp(F32 a, F32 b, F32 w) { return ( b - a ) * w + a; } + +#endif + +#ifndef LL_LLV4MATH_ALIGN_PREFIX +# define LL_LLV4MATH_ALIGN_PREFIX +#endif +#ifndef LL_LLV4MATH_ALIGN_POSTFIX +# define LL_LLV4MATH_ALIGN_POSTFIX +#endif + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// LLV4MATH +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + + +#define LLV4_NUM_AXIS 4 + +class LLV4Vector3; +class LLV4Matrix3; +class LLV4Matrix4; + +#endif diff --git a/linden/indra/llmath/llv4matrix3.h b/linden/indra/llmath/llv4matrix3.h new file mode 100644 index 0000000..0811338 --- /dev/null +++ b/linden/indra/llmath/llv4matrix3.h @@ -0,0 +1,222 @@ +/** + * @file llviewerjointmesh.cpp + * @brief LLV4* class header file - vector processor enabled math + * + * Copyright (c) 2007-2007, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlife.com/developers/opensource/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlife.com/developers/opensource/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + */ + +#ifndef LL_LLV4MATRIX3_H +#define LL_LLV4MATRIX3_H + +#include "llv4math.h" +#include "llv4vector3.h" +#include "m3math.h" // for operator LLMatrix3() + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// LLV4Matrix3 +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +LL_LLV4MATH_ALIGN_PREFIX + +class LLV4Matrix3 +{ +public: + union { + F32 mMatrix[LLV4_NUM_AXIS][LLV4_NUM_AXIS]; + V4F32 mV[LLV4_NUM_AXIS]; + }; + + void lerp(const LLV4Matrix3 &a, const LLV4Matrix3 &b, const F32 &w); + void multiply(const LLVector3 &a, LLVector3& out) const; + void multiply(const LLVector4 &a, LLV4Vector3& out) const; + void multiply(const LLVector3 &a, LLV4Vector3& out) const; + + const LLV4Matrix3& transpose(); + const LLV4Matrix3& operator=(const LLMatrix3& a); + + operator LLMatrix3() const { return (reinterpret_cast(const_cast(&mMatrix[0][0])))->getMat3(); } + + friend LLVector3 operator*(const LLVector3& a, const LLV4Matrix3& b); +} + +LL_LLV4MATH_ALIGN_POSTFIX; + + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// LLV4Matrix3 - SSE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +#if LL_VECTORIZE + +inline void LLV4Matrix3::lerp(const LLV4Matrix3 &a, const LLV4Matrix3 &b, const F32 &w) +{ + __m128 vw = _mm_set1_ps(w); + 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 + mV[VY] = _mm_add_ps(_mm_mul_ps(_mm_sub_ps(b.mV[VY], a.mV[VY]), vw), a.mV[VY]); + mV[VZ] = _mm_add_ps(_mm_mul_ps(_mm_sub_ps(b.mV[VZ], a.mV[VZ]), vw), a.mV[VZ]); +} + +inline void LLV4Matrix3::multiply(const LLVector3 &a, LLVector3& o) const +{ + LLV4Vector3 j; + j.v = _mm_mul_ps(_mm_set1_ps(a.mV[VX]), mV[VX]); // ( ax * vx ) + ... + j.v = _mm_add_ps(j.v , _mm_mul_ps(_mm_set1_ps(a.mV[VY]), mV[VY])); + j.v = _mm_add_ps(j.v , _mm_mul_ps(_mm_set1_ps(a.mV[VZ]), mV[VZ])); + o.setVec(j.mV); +} + +inline void LLV4Matrix3::multiply(const LLVector4 &a, LLV4Vector3& o) const +{ + o.v = _mm_mul_ps(_mm_set1_ps(a.mV[VX]), mV[VX]); // ( ax * vx ) + ... + o.v = _mm_add_ps(o.v , _mm_mul_ps(_mm_set1_ps(a.mV[VY]), mV[VY])); + o.v = _mm_add_ps(o.v , _mm_mul_ps(_mm_set1_ps(a.mV[VZ]), mV[VZ])); +} + +inline void LLV4Matrix3::multiply(const LLVector3 &a, LLV4Vector3& o) const +{ + o.v = _mm_mul_ps(_mm_set1_ps(a.mV[VX]), mV[VX]); // ( ax * vx ) + ... + o.v = _mm_add_ps(o.v , _mm_mul_ps(_mm_set1_ps(a.mV[VY]), mV[VY])); + o.v = _mm_add_ps(o.v , _mm_mul_ps(_mm_set1_ps(a.mV[VZ]), mV[VZ])); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// LLV4Matrix3 +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +#else + +inline void LLV4Matrix3::lerp(const LLV4Matrix3 &a, const LLV4Matrix3 &b, const F32 &w) +{ + mMatrix[VX][VX] = llv4lerp(a.mMatrix[VX][VX], b.mMatrix[VX][VX], w); + mMatrix[VX][VY] = llv4lerp(a.mMatrix[VX][VY], b.mMatrix[VX][VY], w); + mMatrix[VX][VZ] = llv4lerp(a.mMatrix[VX][VZ], b.mMatrix[VX][VZ], w); + + mMatrix[VY][VX] = llv4lerp(a.mMatrix[VY][VX], b.mMatrix[VY][VX], w); + mMatrix[VY][VY] = llv4lerp(a.mMatrix[VY][VY], b.mMatrix[VY][VY], w); + mMatrix[VY][VZ] = llv4lerp(a.mMatrix[VY][VZ], b.mMatrix[VY][VZ], w); + + mMatrix[VZ][VX] = llv4lerp(a.mMatrix[VZ][VX], b.mMatrix[VZ][VX], w); + mMatrix[VZ][VY] = llv4lerp(a.mMatrix[VZ][VY], b.mMatrix[VZ][VY], w); + mMatrix[VZ][VZ] = llv4lerp(a.mMatrix[VZ][VZ], b.mMatrix[VZ][VZ], w); +} + +inline void LLV4Matrix3::multiply(const LLVector3 &a, LLVector3& o) const +{ + o.setVec( a.mV[VX] * mMatrix[VX][VX] + + a.mV[VY] * mMatrix[VY][VX] + + a.mV[VZ] * mMatrix[VZ][VX], + + a.mV[VX] * mMatrix[VX][VY] + + a.mV[VY] * mMatrix[VY][VY] + + a.mV[VZ] * mMatrix[VZ][VY], + + a.mV[VX] * mMatrix[VX][VZ] + + a.mV[VY] * mMatrix[VY][VZ] + + a.mV[VZ] * mMatrix[VZ][VZ]); +} + +inline void LLV4Matrix3::multiply(const LLVector4 &a, LLV4Vector3& o) const +{ + o.setVec( a.mV[VX] * mMatrix[VX][VX] + + a.mV[VY] * mMatrix[VY][VX] + + a.mV[VZ] * mMatrix[VZ][VX], + + a.mV[VX] * mMatrix[VX][VY] + + a.mV[VY] * mMatrix[VY][VY] + + a.mV[VZ] * mMatrix[VZ][VY], + + a.mV[VX] * mMatrix[VX][VZ] + + a.mV[VY] * mMatrix[VY][VZ] + + a.mV[VZ] * mMatrix[VZ][VZ]); +} + +inline void LLV4Matrix3::multiply(const LLVector3 &a, LLV4Vector3& o) const +{ + o.setVec( a.mV[VX] * mMatrix[VX][VX] + + a.mV[VY] * mMatrix[VY][VX] + + a.mV[VZ] * mMatrix[VZ][VX], + + a.mV[VX] * mMatrix[VX][VY] + + a.mV[VY] * mMatrix[VY][VY] + + a.mV[VZ] * mMatrix[VZ][VY], + + a.mV[VX] * mMatrix[VX][VZ] + + a.mV[VY] * mMatrix[VY][VZ] + + a.mV[VZ] * mMatrix[VZ][VZ]); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// LLV4Matrix3 +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +#endif + +inline const LLV4Matrix3& LLV4Matrix3::transpose() +{ +#if LL_VECTORIZE && defined(_MM_TRANSPOSE4_PS) + _MM_TRANSPOSE4_PS(mV[VX], mV[VY], mV[VZ], mV[VW]); + return *this; +#else + F32 temp; + temp = mMatrix[VX][VY]; mMatrix[VX][VY] = mMatrix[VY][VX]; mMatrix[VY][VX] = temp; + temp = mMatrix[VX][VZ]; mMatrix[VX][VZ] = mMatrix[VZ][VX]; mMatrix[VZ][VX] = temp; + temp = mMatrix[VY][VZ]; mMatrix[VY][VZ] = mMatrix[VZ][VY]; mMatrix[VZ][VY] = temp; +#endif + return *this; +} + +inline const LLV4Matrix3& LLV4Matrix3::operator=(const LLMatrix3& a) +{ + memcpy(mMatrix[VX], a.mMatrix[VX], sizeof(F32) * 3 ); + memcpy(mMatrix[VY], a.mMatrix[VY], sizeof(F32) * 3 ); + memcpy(mMatrix[VZ], a.mMatrix[VZ], sizeof(F32) * 3 ); + return *this; +} + +inline LLVector3 operator*(const LLVector3& a, const LLV4Matrix3& b) +{ + return LLVector3( + a.mV[VX] * b.mMatrix[VX][VX] + + a.mV[VY] * b.mMatrix[VY][VX] + + a.mV[VZ] * b.mMatrix[VZ][VX], + + a.mV[VX] * b.mMatrix[VX][VY] + + a.mV[VY] * b.mMatrix[VY][VY] + + a.mV[VZ] * b.mMatrix[VZ][VY], + + a.mV[VX] * b.mMatrix[VX][VZ] + + a.mV[VY] * b.mMatrix[VY][VZ] + + a.mV[VZ] * b.mMatrix[VZ][VZ] ); +} + +#endif diff --git a/linden/indra/llmath/llv4matrix4.h b/linden/indra/llmath/llv4matrix4.h new file mode 100644 index 0000000..38280a2 --- /dev/null +++ b/linden/indra/llmath/llv4matrix4.h @@ -0,0 +1,251 @@ +/** + * @file llviewerjointmesh.cpp + * @brief LLV4* class header file - vector processor enabled math + * + * Copyright (c) 2007-2007, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlife.com/developers/opensource/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlife.com/developers/opensource/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + */ + +#ifndef LL_LLV4MATRIX4_H +#define LL_LLV4MATRIX4_H + +#include "llv4math.h" +#include "llv4matrix3.h" // just for operator LLV4Matrix3() +#include "llv4vector3.h" + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// LLV4Matrix4 +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +LL_LLV4MATH_ALIGN_PREFIX + +class LLV4Matrix4 +{ +public: + union { + F32 mMatrix[LLV4_NUM_AXIS][LLV4_NUM_AXIS]; + V4F32 mV[LLV4_NUM_AXIS]; + }; + + void lerp(const LLV4Matrix4 &a, const LLV4Matrix4 &b, const F32 &w); + void multiply(const LLVector3 &a, LLVector3& o) const; + void multiply(const LLVector3 &a, LLV4Vector3& o) const; + + const LLV4Matrix4& transpose(); + const LLV4Matrix4& translate(const LLVector3 &vec); + const LLV4Matrix4& translate(const LLV4Vector3 &vec); + const LLV4Matrix4& operator=(const LLMatrix4& a); + + operator LLMatrix4() const { return *(reinterpret_cast(const_cast(&mMatrix[0][0]))); } + operator LLV4Matrix3() const { return *(reinterpret_cast(const_cast(&mMatrix[0][0]))); } + + friend LLVector3 operator*(const LLVector3 &a, const LLV4Matrix4 &b); +} + +LL_LLV4MATH_ALIGN_POSTFIX; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// LLV4Matrix4 - SSE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +#if LL_VECTORIZE + +inline void LLV4Matrix4::lerp(const LLV4Matrix4 &a, const LLV4Matrix4 &b, const F32 &w) +{ + __m128 vw = _mm_set1_ps(w); + 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 + mV[VY] = _mm_add_ps(_mm_mul_ps(_mm_sub_ps(b.mV[VY], a.mV[VY]), vw), a.mV[VY]); + mV[VZ] = _mm_add_ps(_mm_mul_ps(_mm_sub_ps(b.mV[VZ], a.mV[VZ]), vw), a.mV[VZ]); + mV[VW] = _mm_add_ps(_mm_mul_ps(_mm_sub_ps(b.mV[VW], a.mV[VW]), vw), a.mV[VW]); +} + +inline void LLV4Matrix4::multiply(const LLVector3 &a, LLVector3& o) const +{ + LLV4Vector3 j; + j.v = _mm_add_ps(mV[VW], _mm_mul_ps(_mm_set1_ps(a.mV[VX]), mV[VX])); // ( ax * vx ) + vw + j.v = _mm_add_ps(j.v , _mm_mul_ps(_mm_set1_ps(a.mV[VY]), mV[VY])); + j.v = _mm_add_ps(j.v , _mm_mul_ps(_mm_set1_ps(a.mV[VZ]), mV[VZ])); + o.setVec(j.mV); +} + +inline void LLV4Matrix4::multiply(const LLVector3 &a, LLV4Vector3& o) const +{ + o.v = _mm_add_ps(mV[VW], _mm_mul_ps(_mm_set1_ps(a.mV[VX]), mV[VX])); // ( ax * vx ) + vw + o.v = _mm_add_ps(o.v , _mm_mul_ps(_mm_set1_ps(a.mV[VY]), mV[VY])); + o.v = _mm_add_ps(o.v , _mm_mul_ps(_mm_set1_ps(a.mV[VZ]), mV[VZ])); +} + +inline const LLV4Matrix4& LLV4Matrix4::translate(const LLV4Vector3 &vec) +{ + mV[VW] = _mm_add_ps(mV[VW], vec.v); + return (*this); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// LLV4Matrix4 +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +#else + +inline void LLV4Matrix4::lerp(const LLV4Matrix4 &a, const LLV4Matrix4 &b, const F32 &w) +{ + mMatrix[VX][VX] = llv4lerp(a.mMatrix[VX][VX], b.mMatrix[VX][VX], w); + mMatrix[VX][VY] = llv4lerp(a.mMatrix[VX][VY], b.mMatrix[VX][VY], w); + mMatrix[VX][VZ] = llv4lerp(a.mMatrix[VX][VZ], b.mMatrix[VX][VZ], w); + + mMatrix[VY][VX] = llv4lerp(a.mMatrix[VY][VX], b.mMatrix[VY][VX], w); + mMatrix[VY][VY] = llv4lerp(a.mMatrix[VY][VY], b.mMatrix[VY][VY], w); + mMatrix[VY][VZ] = llv4lerp(a.mMatrix[VY][VZ], b.mMatrix[VY][VZ], w); + + mMatrix[VZ][VX] = llv4lerp(a.mMatrix[VZ][VX], b.mMatrix[VZ][VX], w); + mMatrix[VZ][VY] = llv4lerp(a.mMatrix[VZ][VY], b.mMatrix[VZ][VY], w); + mMatrix[VZ][VZ] = llv4lerp(a.mMatrix[VZ][VZ], b.mMatrix[VZ][VZ], w); + + mMatrix[VW][VX] = llv4lerp(a.mMatrix[VW][VX], b.mMatrix[VW][VX], w); + mMatrix[VW][VY] = llv4lerp(a.mMatrix[VW][VY], b.mMatrix[VW][VY], w); + mMatrix[VW][VZ] = llv4lerp(a.mMatrix[VW][VZ], b.mMatrix[VW][VZ], w); +} + +inline void LLV4Matrix4::multiply(const LLVector3 &a, LLVector3& o) const +{ + o.setVec( a.mV[VX] * mMatrix[VX][VX] + + a.mV[VY] * mMatrix[VY][VX] + + a.mV[VZ] * mMatrix[VZ][VX] + + mMatrix[VW][VX], + + a.mV[VX] * mMatrix[VX][VY] + + a.mV[VY] * mMatrix[VY][VY] + + a.mV[VZ] * mMatrix[VZ][VY] + + mMatrix[VW][VY], + + a.mV[VX] * mMatrix[VX][VZ] + + a.mV[VY] * mMatrix[VY][VZ] + + a.mV[VZ] * mMatrix[VZ][VZ] + + mMatrix[VW][VZ]); +} + +inline void LLV4Matrix4::multiply(const LLVector3 &a, LLV4Vector3& o) const +{ + o.setVec( a.mV[VX] * mMatrix[VX][VX] + + a.mV[VY] * mMatrix[VY][VX] + + a.mV[VZ] * mMatrix[VZ][VX] + + mMatrix[VW][VX], + + a.mV[VX] * mMatrix[VX][VY] + + a.mV[VY] * mMatrix[VY][VY] + + a.mV[VZ] * mMatrix[VZ][VY] + + mMatrix[VW][VY], + + a.mV[VX] * mMatrix[VX][VZ] + + a.mV[VY] * mMatrix[VY][VZ] + + a.mV[VZ] * mMatrix[VZ][VZ] + + mMatrix[VW][VZ]); +} + +inline const LLV4Matrix4& LLV4Matrix4::translate(const LLV4Vector3 &vec) +{ + mMatrix[3][0] += vec.mV[0]; + mMatrix[3][1] += vec.mV[1]; + mMatrix[3][2] += vec.mV[2]; + return (*this); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// LLV4Matrix4 +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +#endif + +inline const LLV4Matrix4& LLV4Matrix4::operator=(const LLMatrix4& a) +{ + memcpy(mMatrix, a.mMatrix, sizeof(F32) * 16 ); + return *this; +} + +inline const LLV4Matrix4& LLV4Matrix4::transpose() +{ +#if LL_VECTORIZE && defined(_MM_TRANSPOSE4_PS) + _MM_TRANSPOSE4_PS(mV[VX], mV[VY], mV[VZ], mV[VW]); +#else + LLV4Matrix4 mat; + mat.mMatrix[0][0] = mMatrix[0][0]; + mat.mMatrix[1][0] = mMatrix[0][1]; + mat.mMatrix[2][0] = mMatrix[0][2]; + mat.mMatrix[3][0] = mMatrix[0][3]; + + mat.mMatrix[0][1] = mMatrix[1][0]; + mat.mMatrix[1][1] = mMatrix[1][1]; + mat.mMatrix[2][1] = mMatrix[1][2]; + mat.mMatrix[3][1] = mMatrix[1][3]; + + mat.mMatrix[0][2] = mMatrix[2][0]; + mat.mMatrix[1][2] = mMatrix[2][1]; + mat.mMatrix[2][2] = mMatrix[2][2]; + mat.mMatrix[3][2] = mMatrix[2][3]; + + mat.mMatrix[0][3] = mMatrix[3][0]; + mat.mMatrix[1][3] = mMatrix[3][1]; + mat.mMatrix[2][3] = mMatrix[3][2]; + mat.mMatrix[3][3] = mMatrix[3][3]; + + *this = mat; +#endif + return *this; +} + +inline const LLV4Matrix4& LLV4Matrix4::translate(const LLVector3 &vec) +{ + mMatrix[3][0] += vec.mV[0]; + mMatrix[3][1] += vec.mV[1]; + mMatrix[3][2] += vec.mV[2]; + return (*this); +} + +inline LLVector3 operator*(const LLVector3 &a, const LLV4Matrix4 &b) +{ + 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 diff --git a/linden/indra/llmath/llv4vector3.h b/linden/indra/llmath/llv4vector3.h new file mode 100644 index 0000000..994e7f5 --- /dev/null +++ b/linden/indra/llmath/llv4vector3.h @@ -0,0 +1,82 @@ +/** + * @file llviewerjointmesh.cpp + * @brief LLV4* class header file - vector processor enabled math + * + * Copyright (c) 2007-2007, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlife.com/developers/opensource/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlife.com/developers/opensource/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + */ + +#ifndef LL_LLV4VECTOR3_H +#define LL_LLV4VECTOR3_H + +#include "llv4math.h" + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// LLV4Vector3 +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +LL_LLV4MATH_ALIGN_PREFIX + +class LLV4Vector3 +{ +public: + union { + F32 mV[LLV4_NUM_AXIS]; + V4F32 v; + }; + + enum { + ALIGNMENT = 16 + }; + + void setVec(F32 x, F32 y, F32 z); + void setVec(F32 a); +} + +LL_LLV4MATH_ALIGN_POSTFIX; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// LLV4Vector3 +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +inline void LLV4Vector3::setVec(F32 x, F32 y, F32 z) +{ + mV[VX] = x; + mV[VY] = y; + mV[VZ] = z; +} + +inline void LLV4Vector3::setVec(F32 a) +{ +#if LL_VECTORIZE + v = _mm_set1_ps(a); +#else + setVec(a, a, a); +#endif +} + +#endif diff --git a/linden/indra/llmath/llvolume.h b/linden/indra/llmath/llvolume.h index 3973f70..8292d0c 100644 --- a/linden/indra/llmath/llvolume.h +++ b/linden/indra/llmath/llvolume.h @@ -842,7 +842,7 @@ public: U8 getPathType() const { return mPathp->mParams.getCurveType(); } S32 getNumFaces() const { return (S32)mProfilep->mFaces.size(); } S32 getNumVolumeFaces() const { return mNumVolumeFaces; } - const F32 getDetail() const { return mDetail; } + F32 getDetail() const { return mDetail; } const LLVolumeParams & getParams() const { return mParams; } LLVolumeParams getCopyOfParams() const { return mParams; } const LLProfile& getProfile() const { return *mProfilep; } diff --git a/linden/indra/llmath/v4color.h b/linden/indra/llmath/v4color.h index d79b6c8..2e9d13f 100644 --- a/linden/indra/llmath/v4color.h +++ b/linden/indra/llmath/v4color.h @@ -93,7 +93,7 @@ class LLColor4 F32 magVec() const; // Returns magnitude of LLColor4 F32 magVecSquared() const; // Returns magnitude squared of LLColor4 F32 normVec(); // Normalizes and returns the magnitude of LLColor4 - const BOOL isOpaque() { return mV[VALPHA] == 1.f; } + BOOL isOpaque() { return mV[VALPHA] == 1.f; } F32 operator[](int idx) const { return mV[idx]; } F32 &operator[](int idx) { return mV[idx]; } -- cgit v1.1