Migrated gl matrix stack to LLMatrix4a
This commit is contained in:
@@ -260,7 +260,7 @@ void LLAvatarJointCollisionVolume::renderCollision()
|
||||
updateWorldMatrix();
|
||||
|
||||
gGL.pushMatrix();
|
||||
gGL.multMatrix( &mXform.getWorldMatrix().mMatrix[0][0] );
|
||||
gGL.multMatrix( mXform.getWorldMatrix() );
|
||||
|
||||
gGL.diffuseColor3f( 0.f, 0.f, 1.f );
|
||||
|
||||
|
||||
@@ -146,10 +146,10 @@ public:
|
||||
class LLJointRenderData
|
||||
{
|
||||
public:
|
||||
LLJointRenderData(const LLMatrix4* world_matrix, LLSkinJoint* skin_joint) : mWorldMatrix(world_matrix), mSkinJoint(skin_joint) {}
|
||||
LLJointRenderData(const LLMatrix4a* world_matrix, LLSkinJoint* skin_joint) : mWorldMatrix(world_matrix), mSkinJoint(skin_joint) {}
|
||||
~LLJointRenderData(){}
|
||||
|
||||
const LLMatrix4* mWorldMatrix;
|
||||
const LLMatrix4a* mWorldMatrix;
|
||||
LLSkinJoint* mSkinJoint;
|
||||
};
|
||||
|
||||
|
||||
@@ -312,19 +312,15 @@ void LLJoint::setWorldPosition( const LLVector3& pos )
|
||||
return;
|
||||
}
|
||||
|
||||
LLMatrix4 temp_matrix = getWorldMatrix();
|
||||
temp_matrix.mMatrix[VW][VX] = pos.mV[VX];
|
||||
temp_matrix.mMatrix[VW][VY] = pos.mV[VY];
|
||||
temp_matrix.mMatrix[VW][VZ] = pos.mV[VZ];
|
||||
LLMatrix4a temp_matrix = getWorldMatrix();
|
||||
temp_matrix.setTranslate_affine(pos);
|
||||
|
||||
LLMatrix4 parentWorldMatrix = mParent->getWorldMatrix();
|
||||
LLMatrix4 invParentWorldMatrix = parentWorldMatrix.invert();
|
||||
LLMatrix4a invParentWorldMatrix = mParent->getWorldMatrix();
|
||||
invParentWorldMatrix.invert();
|
||||
|
||||
temp_matrix *= invParentWorldMatrix;
|
||||
invParentWorldMatrix.mul(temp_matrix);
|
||||
|
||||
LLVector3 localPos( temp_matrix.mMatrix[VW][VX],
|
||||
temp_matrix.mMatrix[VW][VY],
|
||||
temp_matrix.mMatrix[VW][VZ] );
|
||||
LLVector3 localPos( invParentWorldMatrix.getRow<LLMatrix4a::ROW_TRANS>().getF32ptr() );
|
||||
|
||||
setPosition( localPos );
|
||||
}
|
||||
@@ -383,19 +379,19 @@ void LLJoint::setWorldRotation( const LLQuaternion& rot )
|
||||
this->setRotation( rot );
|
||||
return;
|
||||
}
|
||||
|
||||
LLMatrix4a parentWorldMatrix = mParent->getWorldMatrix();
|
||||
LLQuaternion2 rota(rot);
|
||||
LLMatrix4a temp_mat(rota);
|
||||
|
||||
LLMatrix4 temp_mat(rot);
|
||||
LLMatrix4a invParentWorldMatrix = mParent->getWorldMatrix();
|
||||
invParentWorldMatrix.setTranslate_affine(LLVector3(0.f));
|
||||
|
||||
LLMatrix4 parentWorldMatrix = mParent->getWorldMatrix();
|
||||
parentWorldMatrix.mMatrix[VW][VX] = 0;
|
||||
parentWorldMatrix.mMatrix[VW][VY] = 0;
|
||||
parentWorldMatrix.mMatrix[VW][VZ] = 0;
|
||||
invParentWorldMatrix.invert();
|
||||
|
||||
LLMatrix4 invParentWorldMatrix = parentWorldMatrix.invert();
|
||||
invParentWorldMatrix.mul(temp_mat);
|
||||
|
||||
temp_mat *= invParentWorldMatrix;
|
||||
|
||||
setRotation(LLQuaternion(temp_mat));
|
||||
setRotation(LLQuaternion(LLMatrix4(invParentWorldMatrix.getF32ptr())));
|
||||
}
|
||||
|
||||
|
||||
@@ -425,7 +421,7 @@ void LLJoint::setScale( const LLVector3& scale )
|
||||
//--------------------------------------------------------------------
|
||||
// getWorldMatrix()
|
||||
//--------------------------------------------------------------------
|
||||
const LLMatrix4 &LLJoint::getWorldMatrix()
|
||||
const LLMatrix4a &LLJoint::getWorldMatrix()
|
||||
{
|
||||
updateWorldMatrixParent();
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ public:
|
||||
void setScale( const LLVector3& scale );
|
||||
|
||||
// get/set world matrix
|
||||
const LLMatrix4 &getWorldMatrix();
|
||||
const LLMatrix4a &getWorldMatrix();
|
||||
void setWorldMatrix( const LLMatrix4& mat );
|
||||
|
||||
void updateWorldMatrixChildren();
|
||||
|
||||
@@ -171,12 +171,14 @@ void LLJointSolverRP3::solve()
|
||||
//-------------------------------------------------------------------------
|
||||
// get the poleVector in world space
|
||||
//-------------------------------------------------------------------------
|
||||
LLMatrix4 worldJointAParentMat;
|
||||
LLVector3 poleVec = mPoleVector;
|
||||
if ( mJointA->getParent() )
|
||||
{
|
||||
worldJointAParentMat = mJointA->getParent()->getWorldMatrix();
|
||||
LLVector4a pole_veca;
|
||||
pole_veca.load3(mPoleVector.mV);
|
||||
mJointA->getParent()->getWorldMatrix().rotate(pole_veca,pole_veca);
|
||||
poleVec.set(pole_veca.getF32ptr());
|
||||
}
|
||||
LLVector3 poleVec = rotate_vector( mPoleVector, worldJointAParentMat );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// compute the following:
|
||||
|
||||
@@ -286,40 +286,38 @@ BOOL LLKeyframeStandMotion::onUpdate(F32 time, U8* joint_mask)
|
||||
//-------------------------------------------------------------------------
|
||||
if ( mTrackAnkles )
|
||||
{
|
||||
LLVector4 dirLeft4 = mAnkleLeftJoint.getWorldMatrix().getFwdRow4();
|
||||
LLVector4 dirRight4 = mAnkleRightJoint.getWorldMatrix().getFwdRow4();
|
||||
LLVector3 dirLeft = vec4to3( dirLeft4 );
|
||||
LLVector3 dirRight = vec4to3( dirRight4 );
|
||||
const LLVector4a& dirLeft4 = mAnkleLeftJoint.getWorldMatrix().getRow<LLMatrix4a::ROW_FWD>();
|
||||
const LLVector4a& dirRight4 = mAnkleRightJoint.getWorldMatrix().getRow<LLMatrix4a::ROW_FWD>();
|
||||
|
||||
LLVector3 up;
|
||||
LLVector3 dir;
|
||||
LLVector3 left;
|
||||
LLVector4a up;
|
||||
LLVector4a dir;
|
||||
LLVector4a left;
|
||||
|
||||
up = mNormalLeft;
|
||||
up.normVec();
|
||||
up.load3(mNormalLeft.mV);
|
||||
up.normalize3fast();
|
||||
if (mFlipFeet)
|
||||
{
|
||||
up *= -1.0f;
|
||||
up.negate();
|
||||
}
|
||||
dir = dirLeft;
|
||||
dir.normVec();
|
||||
left = up % dir;
|
||||
left.normVec();
|
||||
dir = left % up;
|
||||
mRotationLeft = LLQuaternion( dir, left, up );
|
||||
dir = dirLeft4;
|
||||
dir.normalize3fast();
|
||||
left.setCross3(up,dir);
|
||||
left.normalize3fast();
|
||||
dir.setCross3(left,up);
|
||||
mRotationLeft = LLQuaternion( LLVector3(dir.getF32ptr()), LLVector3(left.getF32ptr()), LLVector3(up.getF32ptr()));
|
||||
|
||||
up = mNormalRight;
|
||||
up.normVec();
|
||||
up.load3(mNormalRight.mV);
|
||||
up.normalize3fast();
|
||||
if (mFlipFeet)
|
||||
{
|
||||
up *= -1.0f;
|
||||
up.negate();
|
||||
}
|
||||
dir = dirRight;
|
||||
dir.normVec();
|
||||
left = up % dir;
|
||||
left.normVec();
|
||||
dir = left % up;
|
||||
mRotationRight = LLQuaternion( dir, left, up );
|
||||
dir = dirRight4;
|
||||
dir.normalize3fast();
|
||||
left.setCross3(up,dir);
|
||||
left.normalize3fast();
|
||||
dir.setCross3(left,up);
|
||||
mRotationRight = LLQuaternion( LLVector3(dir.getF32ptr()), LLVector3(left.getF32ptr()), LLVector3(up.getF32ptr()));
|
||||
}
|
||||
mAnkleLeftJoint.setWorldRotation( mRotationLeft );
|
||||
mAnkleRightJoint.setWorldRotation( mRotationRight );
|
||||
|
||||
@@ -31,15 +31,72 @@
|
||||
#include "m4math.h"
|
||||
#include "m3math.h"
|
||||
|
||||
LL_ALIGN_PREFIX(16)
|
||||
class LLMatrix4a
|
||||
{
|
||||
public:
|
||||
private:
|
||||
LL_ALIGN_16(LLVector4a mMatrix[4]);
|
||||
public:
|
||||
enum
|
||||
{
|
||||
ROW_FWD = 0,
|
||||
ROW_LEFT,
|
||||
ROW_UP,
|
||||
ROW_TRANS
|
||||
};
|
||||
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
return ll_aligned_malloc_16(size);
|
||||
}
|
||||
|
||||
void operator delete(void* ptr)
|
||||
{
|
||||
ll_aligned_free_16(ptr);
|
||||
}
|
||||
|
||||
LLMatrix4a()
|
||||
{}
|
||||
LLMatrix4a(const LLQuad& q1,const LLQuad& q2,const LLQuad& q3,const LLQuad& q4)
|
||||
{
|
||||
mMatrix[0] = q1;
|
||||
mMatrix[1] = q2;
|
||||
mMatrix[2] = q3;
|
||||
mMatrix[3] = q4;
|
||||
}
|
||||
LLMatrix4a(const LLQuaternion2& quat)
|
||||
{
|
||||
const LLVector4a& xyzw = quat.getVector4a();
|
||||
LLVector4a nyxwz = _mm_shuffle_ps(xyzw, xyzw, _MM_SHUFFLE(2,3,0,1));
|
||||
nyxwz.negate();
|
||||
|
||||
const LLVector4a xnyynx = _mm_unpacklo_ps(xyzw,nyxwz);
|
||||
const LLVector4a znwwnz = _mm_unpackhi_ps(xyzw,nyxwz);
|
||||
|
||||
LLMatrix4a mata;
|
||||
mata.setRow<0>(_mm_shuffle_ps(xyzw, xnyynx, _MM_SHUFFLE(0,1,2,3)));
|
||||
mata.setRow<1>(_mm_shuffle_ps(znwwnz, xyzw, _MM_SHUFFLE(1,0,2,3)));
|
||||
mata.setRow<2>(_mm_shuffle_ps(xnyynx, xyzw, _MM_SHUFFLE(2,3,3,2)));
|
||||
mata.setRow<3>(_mm_shuffle_ps(xnyynx, znwwnz, _MM_SHUFFLE(2,3,1,3)));
|
||||
|
||||
LLMatrix4a matb;
|
||||
matb.setRow<0>(_mm_shuffle_ps(xyzw, xnyynx, _MM_SHUFFLE(3,1,2,3)));
|
||||
matb.setRow<1>(_mm_shuffle_ps(znwwnz, xnyynx, _MM_SHUFFLE(1,0,2,3)));
|
||||
matb.setRow<2>(_mm_shuffle_ps(xnyynx, znwwnz, _MM_SHUFFLE(3,2,3,2)));
|
||||
matb.setRow<3>(xyzw);
|
||||
|
||||
setMul(matb,mata);
|
||||
}
|
||||
|
||||
inline F32* getF32ptr()
|
||||
{
|
||||
return mMatrix[0].getF32ptr();
|
||||
}
|
||||
|
||||
inline const F32* getF32ptr() const
|
||||
{
|
||||
return mMatrix[0].getF32ptr();
|
||||
}
|
||||
|
||||
inline void clear()
|
||||
{
|
||||
@@ -60,10 +117,10 @@ public:
|
||||
|
||||
inline void loadu(const LLMatrix4& src)
|
||||
{
|
||||
mMatrix[0] = _mm_loadu_ps(src.mMatrix[0]);
|
||||
mMatrix[1] = _mm_loadu_ps(src.mMatrix[1]);
|
||||
mMatrix[2] = _mm_loadu_ps(src.mMatrix[2]);
|
||||
mMatrix[3] = _mm_loadu_ps(src.mMatrix[3]);
|
||||
mMatrix[0].loadua(src.mMatrix[0]);
|
||||
mMatrix[1].loadua(src.mMatrix[1]);
|
||||
mMatrix[2].loadua(src.mMatrix[2]);
|
||||
mMatrix[3].loadua(src.mMatrix[3]);
|
||||
}
|
||||
|
||||
inline void loadu(const LLMatrix3& src)
|
||||
@@ -76,10 +133,10 @@ public:
|
||||
|
||||
inline void loadu(const F32* src)
|
||||
{
|
||||
mMatrix[0] = _mm_loadu_ps(src+0);
|
||||
mMatrix[1] = _mm_loadu_ps(src+4);
|
||||
mMatrix[2] = _mm_loadu_ps(src+8);
|
||||
mMatrix[3] = _mm_loadu_ps(src+12);
|
||||
mMatrix[0].loadua(src+0);
|
||||
mMatrix[1].loadua(src+4);
|
||||
mMatrix[2].loadua(src+8);
|
||||
mMatrix[3].loadua(src+12);
|
||||
}
|
||||
|
||||
inline void add(const LLMatrix4a& rhs)
|
||||
@@ -90,6 +147,75 @@ public:
|
||||
mMatrix[3].add(rhs.mMatrix[3]);
|
||||
}
|
||||
|
||||
inline void mul(const LLMatrix4a& rhs)
|
||||
{
|
||||
//Not using rotate4 to avoid extra copy of *this.
|
||||
LLVector4a x0,y0,z0,w0;
|
||||
LLVector4a x1,y1,z1,w1;
|
||||
LLVector4a x2,y2,z2,w2;
|
||||
LLVector4a x3,y3,z3,w3;
|
||||
|
||||
//16 shuffles
|
||||
x0.splat<0>(rhs.mMatrix[0]);
|
||||
x1.splat<0>(rhs.mMatrix[1]);
|
||||
x2.splat<0>(rhs.mMatrix[2]);
|
||||
x3.splat<0>(rhs.mMatrix[3]);
|
||||
|
||||
y0.splat<1>(rhs.mMatrix[0]);
|
||||
y1.splat<1>(rhs.mMatrix[1]);
|
||||
y2.splat<1>(rhs.mMatrix[2]);
|
||||
y3.splat<1>(rhs.mMatrix[3]);
|
||||
|
||||
z0.splat<2>(rhs.mMatrix[0]);
|
||||
z1.splat<2>(rhs.mMatrix[1]);
|
||||
z2.splat<2>(rhs.mMatrix[2]);
|
||||
z3.splat<2>(rhs.mMatrix[3]);
|
||||
|
||||
w0.splat<3>(rhs.mMatrix[0]);
|
||||
w1.splat<3>(rhs.mMatrix[1]);
|
||||
w2.splat<3>(rhs.mMatrix[2]);
|
||||
w3.splat<3>(rhs.mMatrix[3]);
|
||||
|
||||
//16 muls
|
||||
x0.mul(mMatrix[0]);
|
||||
x1.mul(mMatrix[0]);
|
||||
x2.mul(mMatrix[0]);
|
||||
x3.mul(mMatrix[0]);
|
||||
|
||||
y0.mul(mMatrix[1]);
|
||||
y1.mul(mMatrix[1]);
|
||||
y2.mul(mMatrix[1]);
|
||||
y3.mul(mMatrix[1]);
|
||||
|
||||
z0.mul(mMatrix[2]);
|
||||
z1.mul(mMatrix[2]);
|
||||
z2.mul(mMatrix[2]);
|
||||
z3.mul(mMatrix[2]);
|
||||
|
||||
w0.mul(mMatrix[3]);
|
||||
w1.mul(mMatrix[3]);
|
||||
w2.mul(mMatrix[3]);
|
||||
w3.mul(mMatrix[3]);
|
||||
|
||||
//12 adds
|
||||
x0.add(y0);
|
||||
z0.add(w0);
|
||||
|
||||
x1.add(y1);
|
||||
z1.add(w1);
|
||||
|
||||
x2.add(y2);
|
||||
z2.add(w2);
|
||||
|
||||
x3.add(y3);
|
||||
z3.add(w3);
|
||||
|
||||
mMatrix[0].setAdd(x0,z0);
|
||||
mMatrix[1].setAdd(x1,z1);
|
||||
mMatrix[2].setAdd(x2,z2);
|
||||
mMatrix[3].setAdd(x3,z3);
|
||||
}
|
||||
|
||||
inline void setRows(const LLVector4a& r0, const LLVector4a& r1, const LLVector4a& r2)
|
||||
{
|
||||
mMatrix[0] = r0;
|
||||
@@ -97,6 +223,44 @@ public:
|
||||
mMatrix[2] = r2;
|
||||
}
|
||||
|
||||
template<int N>
|
||||
inline void setRow(const LLVector4a& row)
|
||||
{
|
||||
mMatrix[N] = row;
|
||||
}
|
||||
|
||||
template<int N>
|
||||
inline const LLVector4a& getRow() const
|
||||
{
|
||||
return mMatrix[N];
|
||||
}
|
||||
|
||||
template<int N>
|
||||
inline LLVector4a& getRow()
|
||||
{
|
||||
return mMatrix[N];
|
||||
}
|
||||
|
||||
template<int N>
|
||||
inline void setColumn(const LLVector4a& col)
|
||||
{
|
||||
mMatrix[0].copyComponent<N>(col.getScalarAt<0>());
|
||||
mMatrix[1].copyComponent<N>(col.getScalarAt<1>());
|
||||
mMatrix[2].copyComponent<N>(col.getScalarAt<2>());
|
||||
mMatrix[3].copyComponent<N>(col.getScalarAt<3>());
|
||||
}
|
||||
|
||||
template<int N>
|
||||
inline LLVector4a getColumn()
|
||||
{
|
||||
LLVector4a v;
|
||||
v.copyComponent<0>(mMatrix[0].getScalarAt<N>());
|
||||
v.copyComponent<1>(mMatrix[1].getScalarAt<N>());
|
||||
v.copyComponent<2>(mMatrix[2].getScalarAt<N>());
|
||||
v.copyComponent<3>(mMatrix[3].getScalarAt<N>());
|
||||
return v;
|
||||
}
|
||||
|
||||
inline void setMul(const LLMatrix4a& m, const F32 s)
|
||||
{
|
||||
mMatrix[0].setMul(m.mMatrix[0], s);
|
||||
@@ -136,13 +300,14 @@ public:
|
||||
|
||||
//Singu Note: Don't mess with this. It's intentionally different from LL's.
|
||||
// Note how res isn't manipulated until the very end.
|
||||
//Fast(er). Treats v[VW] as 0.f
|
||||
inline void rotate(const LLVector4a& v, LLVector4a& res) const
|
||||
{
|
||||
LLVector4a x,y,z;
|
||||
|
||||
x = _mm_shuffle_ps(v, v, _MM_SHUFFLE(0, 0, 0, 0));
|
||||
y = _mm_shuffle_ps(v, v, _MM_SHUFFLE(1, 1, 1, 1));
|
||||
z = _mm_shuffle_ps(v, v, _MM_SHUFFLE(2, 2, 2, 2));
|
||||
x.splat<0>(v);
|
||||
y.splat<1>(v);
|
||||
z.splat<2>(v);
|
||||
|
||||
x.mul(mMatrix[0]);
|
||||
y.mul(mMatrix[1]);
|
||||
@@ -152,14 +317,15 @@ public:
|
||||
res.setAdd(x,z);
|
||||
}
|
||||
|
||||
//Proper. v[VW] as v[VW]
|
||||
inline void rotate4(const LLVector4a& v, LLVector4a& res) const
|
||||
{
|
||||
LLVector4a x,y,z,w;
|
||||
|
||||
x = _mm_shuffle_ps(v, v, _MM_SHUFFLE(0, 0, 0, 0));
|
||||
y = _mm_shuffle_ps(v, v, _MM_SHUFFLE(1, 1, 1, 1));
|
||||
z = _mm_shuffle_ps(v, v, _MM_SHUFFLE(2, 2, 2, 2));
|
||||
w = _mm_shuffle_ps(v, v, _MM_SHUFFLE(3, 3, 3, 3));
|
||||
x.splat<0>(v);
|
||||
y.splat<1>(v);
|
||||
z.splat<2>(v);
|
||||
w.splat<3>(v);
|
||||
|
||||
x.mul(mMatrix[0]);
|
||||
y.mul(mMatrix[1]);
|
||||
@@ -171,14 +337,15 @@ public:
|
||||
res.setAdd(x,z);
|
||||
}
|
||||
|
||||
//Fast(er). Treats v[VW] as 1.f
|
||||
inline void affineTransform(const LLVector4a& v, LLVector4a& res) const
|
||||
{
|
||||
LLVector4a x,y,z;
|
||||
|
||||
x = _mm_shuffle_ps(v, v, _MM_SHUFFLE(0, 0, 0, 0));
|
||||
y = _mm_shuffle_ps(v, v, _MM_SHUFFLE(1, 1, 1, 1));
|
||||
z = _mm_shuffle_ps(v, v, _MM_SHUFFLE(2, 2, 2, 2));
|
||||
|
||||
x.splat<0>(v);
|
||||
y.splat<1>(v);
|
||||
z.splat<2>(v);
|
||||
|
||||
x.mul(mMatrix[0]);
|
||||
y.mul(mMatrix[1]);
|
||||
z.mul(mMatrix[2]);
|
||||
@@ -188,6 +355,36 @@ public:
|
||||
res.setAdd(x,z);
|
||||
}
|
||||
|
||||
inline void perspectiveTransform(const LLVector4a& v, LLVector4a& res) const
|
||||
{
|
||||
LLVector4a x,y,z,s,t,p,q;
|
||||
|
||||
x.splat<0>(v);
|
||||
y.splat<1>(v);
|
||||
z.splat<2>(v);
|
||||
|
||||
s.splat<3>(mMatrix[0]);
|
||||
t.splat<3>(mMatrix[1]);
|
||||
p.splat<3>(mMatrix[2]);
|
||||
q.splat<3>(mMatrix[3]);
|
||||
|
||||
s.mul(x);
|
||||
t.mul(y);
|
||||
p.mul(z);
|
||||
q.add(s);
|
||||
t.add(p);
|
||||
q.add(t);
|
||||
|
||||
x.mul(mMatrix[0]);
|
||||
y.mul(mMatrix[1]);
|
||||
z.mul(mMatrix[2]);
|
||||
|
||||
x.add(y);
|
||||
z.add(mMatrix[3]);
|
||||
res.setAdd(x,z);
|
||||
res.div(q);
|
||||
}
|
||||
|
||||
inline void transpose()
|
||||
{
|
||||
__m128 q1 = _mm_unpackhi_ps(mMatrix[0],mMatrix[1]);
|
||||
@@ -313,9 +510,186 @@ public:
|
||||
mMatrix[1] = _mm_shuffle_ps(iA,iB,0x22);
|
||||
mMatrix[2] = _mm_shuffle_ps(iC,iD,0x77);
|
||||
mMatrix[3] = _mm_shuffle_ps(iC,iD,0x22);
|
||||
|
||||
return *(float*)&det;
|
||||
|
||||
F32 ret;
|
||||
_mm_store_ss(&ret,det);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
//=============Affine transformation matrix only=========================
|
||||
|
||||
//Multiply matrix with a pure translation matrix.
|
||||
inline void applyTranslation_affine(const F32& x, const F32& y, const F32& z)
|
||||
{
|
||||
const LLVector4a xyz0(x,y,z,0); //load
|
||||
LLVector4a xxxx;
|
||||
xxxx.splat<0>(xyz0);
|
||||
LLVector4a yyyy;
|
||||
yyyy.splat<1>(xyz0);
|
||||
LLVector4a zzzz;
|
||||
zzzz.splat<2>(xyz0);
|
||||
|
||||
LLVector4a sum1;
|
||||
LLVector4a sum2;
|
||||
LLVector4a sum3;
|
||||
|
||||
sum1.setMul(xxxx,mMatrix[0]);
|
||||
sum2.setMul(yyyy,mMatrix[1]);
|
||||
sum3.setMul(zzzz,mMatrix[2]);
|
||||
|
||||
mMatrix[3].add(sum1);
|
||||
mMatrix[3].add(sum2);
|
||||
mMatrix[3].add(sum3);
|
||||
}
|
||||
|
||||
//Multiply matrix with a pure translation matrix.
|
||||
inline void applyTranslation_affine(const LLVector3& trans)
|
||||
{
|
||||
applyTranslation_affine(trans.mV[VX],trans.mV[VY],trans.mV[VZ]);
|
||||
}
|
||||
|
||||
//Multiply matrix with a pure scale matrix.
|
||||
inline void applyScale_affine(const F32& x, const F32& y, const F32& z)
|
||||
{
|
||||
const LLVector4a xyz0(x,y,z,0); //load
|
||||
LLVector4a xxxx;
|
||||
xxxx.splat<0>(xyz0);
|
||||
LLVector4a yyyy;
|
||||
yyyy.splat<1>(xyz0);
|
||||
LLVector4a zzzz;
|
||||
zzzz.splat<2>(xyz0);
|
||||
|
||||
mMatrix[0].mul(xxxx);
|
||||
mMatrix[1].mul(yyyy);
|
||||
mMatrix[2].mul(zzzz);
|
||||
}
|
||||
|
||||
//Multiply matrix with a pure scale matrix.
|
||||
inline void applyScale_affine(const LLVector3& scale)
|
||||
{
|
||||
applyScale_affine(scale.mV[VX],scale.mV[VY],scale.mV[VZ]);
|
||||
}
|
||||
|
||||
//Multiply matrix with a pure scale matrix.
|
||||
inline void applyScale_affine(const F32& s)
|
||||
{
|
||||
const LLVector4a scale(s); //load
|
||||
mMatrix[0].mul(scale);
|
||||
mMatrix[1].mul(scale);
|
||||
mMatrix[2].mul(scale);
|
||||
}
|
||||
|
||||
//Direct addition to row3.
|
||||
inline void translate_affine(const LLVector3& trans)
|
||||
{
|
||||
LLVector4a translation;
|
||||
translation.load3(trans.mV);
|
||||
mMatrix[3].add(translation);
|
||||
}
|
||||
|
||||
//Direct assignment of row3.
|
||||
inline void setTranslate_affine(const LLVector3& trans)
|
||||
{
|
||||
static const LLVector4Logical mask = _mm_load_ps((F32*)&S_V4LOGICAL_MASK_TABLE[3*4]);
|
||||
|
||||
LLVector4a translation;
|
||||
translation.load3(trans.mV);
|
||||
|
||||
mMatrix[3].setSelectWithMask(mask,mMatrix[3],translation);
|
||||
}
|
||||
|
||||
inline void mul_affine(const LLMatrix4a& rhs)
|
||||
{
|
||||
LLVector4a x0,y0,z0;
|
||||
LLVector4a x1,y1,z1;
|
||||
LLVector4a x2,y2,z2;
|
||||
LLVector4a x3,y3,z3;
|
||||
|
||||
//12 shuffles
|
||||
x0.splat<0>(rhs.mMatrix[0]);
|
||||
x1.splat<0>(rhs.mMatrix[1]);
|
||||
x2.splat<0>(rhs.mMatrix[2]);
|
||||
x3.splat<0>(rhs.mMatrix[3]);
|
||||
|
||||
y0.splat<1>(rhs.mMatrix[0]);
|
||||
y1.splat<1>(rhs.mMatrix[1]);
|
||||
y2.splat<1>(rhs.mMatrix[2]);
|
||||
y3.splat<1>(rhs.mMatrix[3]);
|
||||
|
||||
z0.splat<2>(rhs.mMatrix[0]);
|
||||
z1.splat<2>(rhs.mMatrix[1]);
|
||||
z2.splat<2>(rhs.mMatrix[2]);
|
||||
z3.splat<2>(rhs.mMatrix[3]);
|
||||
|
||||
//12 muls
|
||||
x0.mul(mMatrix[0]);
|
||||
x1.mul(mMatrix[0]);
|
||||
x2.mul(mMatrix[0]);
|
||||
x3.mul(mMatrix[0]);
|
||||
|
||||
y0.mul(mMatrix[1]);
|
||||
y1.mul(mMatrix[1]);
|
||||
y2.mul(mMatrix[1]);
|
||||
y3.mul(mMatrix[1]);
|
||||
|
||||
z0.mul(mMatrix[2]);
|
||||
z1.mul(mMatrix[2]);
|
||||
z2.mul(mMatrix[2]);
|
||||
z3.mul(mMatrix[2]);
|
||||
|
||||
//9 adds
|
||||
x0.add(y0);
|
||||
|
||||
x1.add(y1);
|
||||
|
||||
x2.add(y2);
|
||||
|
||||
x3.add(y3);
|
||||
z3.add(mMatrix[3]);
|
||||
|
||||
mMatrix[0].setAdd(x0,z0);
|
||||
mMatrix[1].setAdd(x1,z1);
|
||||
mMatrix[2].setAdd(x2,z2);
|
||||
mMatrix[3].setAdd(x3,z3);
|
||||
}
|
||||
|
||||
inline void extractRotation_affine()
|
||||
{
|
||||
static const LLVector4Logical mask = _mm_load_ps((F32*)&S_V4LOGICAL_MASK_TABLE[3*4]);
|
||||
mMatrix[0].setSelectWithMask(mask,_mm_setzero_ps(),mMatrix[0]);
|
||||
mMatrix[1].setSelectWithMask(mask,_mm_setzero_ps(),mMatrix[1]);
|
||||
mMatrix[2].setSelectWithMask(mask,_mm_setzero_ps(),mMatrix[2]);
|
||||
mMatrix[3].setSelectWithMask(mask,LLVector4a(1.f),_mm_setzero_ps());
|
||||
}
|
||||
|
||||
//======================Logic====================
|
||||
inline bool isIdentity() const
|
||||
{
|
||||
static LLMatrix4a mins;
|
||||
static LLMatrix4a maxs;
|
||||
static LLVector4a delta(0.0001f);
|
||||
|
||||
static bool init_mins = ( mins.setIdentity(),
|
||||
mins.getRow<0>().sub(delta),
|
||||
mins.getRow<1>().sub(delta),
|
||||
mins.getRow<2>().sub(delta),
|
||||
mins.getRow<3>().sub(delta), true );
|
||||
static bool init_maxs = ( maxs.setIdentity(),
|
||||
maxs.getRow<0>().add(delta),
|
||||
maxs.getRow<1>().add(delta),
|
||||
maxs.getRow<2>().add(delta),
|
||||
maxs.getRow<3>().add(delta), true );
|
||||
|
||||
LLVector4a mask1 = _mm_and_ps(_mm_cmpgt_ps(mMatrix[0],mins.getRow<0>()), _mm_cmplt_ps(mMatrix[0],maxs.getRow<0>()));
|
||||
LLVector4a mask2 = _mm_and_ps(_mm_cmpgt_ps(mMatrix[1],mins.getRow<1>()), _mm_cmplt_ps(mMatrix[1],maxs.getRow<1>()));
|
||||
LLVector4a mask3 = _mm_and_ps(_mm_cmpgt_ps(mMatrix[2],mins.getRow<2>()), _mm_cmplt_ps(mMatrix[2],maxs.getRow<2>()));
|
||||
LLVector4a mask4 = _mm_and_ps(_mm_cmpgt_ps(mMatrix[3],mins.getRow<3>()), _mm_cmplt_ps(mMatrix[3],maxs.getRow<3>()));
|
||||
|
||||
mask1 = _mm_and_ps(mask1,mask2);
|
||||
mask2 = _mm_and_ps(mask3,mask4);
|
||||
|
||||
return _mm_movemask_epi8(_mm_castps_si128(_mm_and_ps(mask1, mask2))) == 0xFFFF;
|
||||
}
|
||||
} LL_ALIGN_POSTFIX(16);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -84,6 +84,8 @@ public:
|
||||
// Quantize this quaternion to 16 bit precision
|
||||
inline void quantize16();
|
||||
|
||||
inline void mul(const LLQuaternion2& b);
|
||||
|
||||
/////////////////////////
|
||||
// Quaternion inspection
|
||||
/////////////////////////
|
||||
|
||||
@@ -50,6 +50,39 @@ inline LLVector4a& LLQuaternion2::getVector4aRw()
|
||||
return mQ;
|
||||
}
|
||||
|
||||
inline void LLQuaternion2::mul(const LLQuaternion2& b)
|
||||
{
|
||||
static LL_ALIGN_16(const unsigned int signMask[4]) = { 0x0, 0x0, 0x0, 0x80000000 };
|
||||
|
||||
LLVector4a sum1, sum2, prod1, prod2, prod3, prod4;
|
||||
const LLVector4a& va = mQ;
|
||||
const LLVector4a& vb = b.getVector4a();
|
||||
|
||||
// [VX] [VY] [VZ] [VW]
|
||||
//prod1: +wx +wy +wz +ww Bwwww*Axyzw
|
||||
//prod2: +xw +yw +zw -xx Bxyzx*Awwwx [VW] sign flip
|
||||
//prod3: +yz +zx +xy -yy Byzxy*Azxyy [VW] sign flip
|
||||
//prod4: -zy -xz -yx -zz Bzxyz*Ayzzz
|
||||
|
||||
const LLVector4a Bwwww = _mm_shuffle_ps(vb,vb,_MM_SHUFFLE(3,3,3,3));
|
||||
const LLVector4a Bxyzx = _mm_shuffle_ps(vb,vb,_MM_SHUFFLE(0,2,1,0));
|
||||
const LLVector4a Awwwx = _mm_shuffle_ps(va,va,_MM_SHUFFLE(0,3,3,3));
|
||||
const LLVector4a Byzxy = _mm_shuffle_ps(vb,vb,_MM_SHUFFLE(1,0,2,1));
|
||||
const LLVector4a Azxyy = _mm_shuffle_ps(va,va,_MM_SHUFFLE(1,1,0,2));
|
||||
const LLVector4a Bzxyz = _mm_shuffle_ps(vb,vb,_MM_SHUFFLE(2,1,0,2));
|
||||
const LLVector4a Ayzxz = _mm_shuffle_ps(va,va,_MM_SHUFFLE(2,0,2,1));
|
||||
|
||||
prod1.setMul(Bwwww,va);
|
||||
prod2.setMul(Bxyzx,Awwwx);
|
||||
prod3.setMul(Byzxy,Azxyy);
|
||||
prod4.setMul(Bzxyz,Ayzxz);
|
||||
|
||||
sum1.setAdd(prod2,prod3);
|
||||
sum1 = _mm_xor_ps(sum1, _mm_load_ps((const float*)signMask));
|
||||
sum2.setSub(prod1,prod4);
|
||||
mQ.setAdd(sum1,sum2);
|
||||
}
|
||||
|
||||
/////////////////////////
|
||||
// Quaternion modification
|
||||
/////////////////////////
|
||||
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
inline void loadua(const F32* src);
|
||||
|
||||
// Load only three floats beginning at address 'src'. Slowest method.
|
||||
inline void load3(const F32* src);
|
||||
inline void load3(const F32* src, const F32 w=0.f);
|
||||
|
||||
// Store to a 16-byte aligned memory address
|
||||
inline void store4a(F32* dst) const;
|
||||
@@ -169,6 +169,9 @@ public:
|
||||
|
||||
// Set all 4 elements to element i of v, with i NOT known at compile time
|
||||
inline void splat(const LLVector4a& v, U32 i);
|
||||
|
||||
// Sets element N to that of src's element N. Much cleaner than.. {LLVector4Logical mask; mask.clear(); mask.setElement<N>(); target.setSelectWithMask(mask,src,target);}
|
||||
template <int N> inline void copyComponent(const LLVector4a& src);
|
||||
|
||||
// Select bits from sourceIfTrue and sourceIfFalse according to bits in mask
|
||||
inline void setSelectWithMask( const LLVector4Logical& mask, const LLVector4a& sourceIfTrue, const LLVector4a& sourceIfFalse );
|
||||
@@ -281,6 +284,8 @@ public:
|
||||
void quantize8( const LLVector4a& low, const LLVector4a& high );
|
||||
void quantize16( const LLVector4a& low, const LLVector4a& high );
|
||||
|
||||
void negate();
|
||||
|
||||
////////////////////////////////////
|
||||
// LOGICAL
|
||||
////////////////////////////////////
|
||||
|
||||
@@ -41,11 +41,11 @@ inline void LLVector4a::loadua(const F32* src)
|
||||
}
|
||||
|
||||
// Load only three floats beginning at address 'src'. Slowest method.
|
||||
inline void LLVector4a::load3(const F32* src)
|
||||
inline void LLVector4a::load3(const F32* src, const F32 w)
|
||||
{
|
||||
// mQ = { 0.f, src[2], src[1], src[0] } = { W, Z, Y, X }
|
||||
// NB: This differs from the convention of { Z, Y, X, W }
|
||||
mQ = _mm_set_ps(0.f, src[2], src[1], src[0]);
|
||||
mQ = _mm_set_ps(w, src[2], src[1], src[0]);
|
||||
}
|
||||
|
||||
// Store to a 16-byte aligned memory address
|
||||
@@ -154,6 +154,13 @@ inline void LLVector4a::splat(const LLVector4a& v, U32 i)
|
||||
}
|
||||
}
|
||||
|
||||
// Sets element N to that of src's element N
|
||||
template <int N> inline void LLVector4a::copyComponent(const LLVector4a& src)
|
||||
{
|
||||
static const LLVector4Logical mask = _mm_load_ps((F32*)&S_V4LOGICAL_MASK_TABLE[N*4]);
|
||||
setSelectWithMask(mask,src,mQ);
|
||||
}
|
||||
|
||||
// Select bits from sourceIfTrue and sourceIfFalse according to bits in mask
|
||||
inline void LLVector4a::setSelectWithMask( const LLVector4Logical& mask, const LLVector4a& sourceIfTrue, const LLVector4a& sourceIfFalse )
|
||||
{
|
||||
@@ -529,6 +536,11 @@ inline void LLVector4a::clamp( const LLVector4a& low, const LLVector4a& high )
|
||||
setSelectWithMask( lowMask, low, *this );
|
||||
}
|
||||
|
||||
inline void LLVector4a::negate()
|
||||
{
|
||||
static LL_ALIGN_16(const U32 signMask[4]) = {0x80000000, 0x80000000, 0x80000000, 0x80000000 };
|
||||
mQ = _mm_xor_ps(*reinterpret_cast<const LLQuad*>(signMask), mQ);
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// LOGICAL
|
||||
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
{
|
||||
static const LL_ALIGN_16(U32 allOnes[4]) = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
|
||||
ll_assert_aligned(allOnes,16);
|
||||
mQ = _mm_andnot_ps( mQ, *(LLQuad*)(allOnes) );
|
||||
mQ = _mm_andnot_ps( mQ, _mm_load_ps((F32*)(allOnes)));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
|
||||
template<int N> void setElement()
|
||||
{
|
||||
mQ = _mm_or_ps( mQ, *reinterpret_cast<const LLQuad*>(S_V4LOGICAL_MASK_TABLE + 4*N) );
|
||||
mQ = _mm_or_ps( mQ, _mm_load_ps( (F32*)&S_V4LOGICAL_MASK_TABLE[4*N] ) );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -96,30 +96,29 @@ void LLXformMatrix::updateMatrix(BOOL update_bounds)
|
||||
{
|
||||
update();
|
||||
|
||||
mWorldMatrix.initAll(mScale, mWorldRotation, mWorldPosition);
|
||||
LLMatrix4 world_matrix;
|
||||
world_matrix.initAll(mScale, mWorldRotation, mWorldPosition);
|
||||
mWorldMatrix.loadu(world_matrix);
|
||||
|
||||
if (update_bounds && (mChanged & MOVED))
|
||||
{
|
||||
mMin.mV[0] = mMax.mV[0] = mWorldMatrix.mMatrix[3][0];
|
||||
mMin.mV[1] = mMax.mV[1] = mWorldMatrix.mMatrix[3][1];
|
||||
mMin.mV[2] = mMax.mV[2] = mWorldMatrix.mMatrix[3][2];
|
||||
mMax = mMin = mWorldMatrix.getRow<3>();
|
||||
|
||||
F32 f0 = (fabs(mWorldMatrix.mMatrix[0][0])+fabs(mWorldMatrix.mMatrix[1][0])+fabs(mWorldMatrix.mMatrix[2][0])) * 0.5f;
|
||||
F32 f1 = (fabs(mWorldMatrix.mMatrix[0][1])+fabs(mWorldMatrix.mMatrix[1][1])+fabs(mWorldMatrix.mMatrix[2][1])) * 0.5f;
|
||||
F32 f2 = (fabs(mWorldMatrix.mMatrix[0][2])+fabs(mWorldMatrix.mMatrix[1][2])+fabs(mWorldMatrix.mMatrix[2][2])) * 0.5f;
|
||||
LLVector4a total_sum,sum1,sum2;
|
||||
total_sum.setAbs(mWorldMatrix.getRow<0>());
|
||||
sum1.setAbs(mWorldMatrix.getRow<1>());
|
||||
sum2.setAbs(mWorldMatrix.getRow<2>());
|
||||
sum1.add(sum2);
|
||||
total_sum.add(sum1);
|
||||
total_sum.mul(.5f);
|
||||
|
||||
mMin.mV[0] -= f0;
|
||||
mMin.mV[1] -= f1;
|
||||
mMin.mV[2] -= f2;
|
||||
|
||||
mMax.mV[0] += f0;
|
||||
mMax.mV[1] += f1;
|
||||
mMax.mV[2] += f2;
|
||||
mMax.add(total_sum);
|
||||
mMin.sub(total_sum);
|
||||
}
|
||||
}
|
||||
|
||||
void LLXformMatrix::getMinMax(LLVector3& min, LLVector3& max) const
|
||||
{
|
||||
min = mMin;
|
||||
max = mMax;
|
||||
min.set(mMin.getF32ptr());
|
||||
max.set(mMax.getF32ptr());
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "v3math.h"
|
||||
#include "m4math.h"
|
||||
#include "llmatrix4a.h"
|
||||
#include "llquaternion.h"
|
||||
|
||||
const F32 MAX_OBJECT_Z = 4096.f; // should match REGION_HEIGHT_METERS, Pre-havok4: 768.f
|
||||
@@ -130,20 +131,21 @@ public:
|
||||
const LLVector3& getWorldPosition() const { return mWorldPosition; }
|
||||
};
|
||||
|
||||
LL_ALIGN_PREFIX(16)
|
||||
class LLXformMatrix : public LLXform
|
||||
{
|
||||
public:
|
||||
LLXformMatrix() : LLXform() {};
|
||||
virtual ~LLXformMatrix();
|
||||
|
||||
const LLMatrix4& getWorldMatrix() const { return mWorldMatrix; }
|
||||
void setWorldMatrix (const LLMatrix4& mat) { mWorldMatrix = mat; }
|
||||
const LLMatrix4a& getWorldMatrix() const { return mWorldMatrix; }
|
||||
void setWorldMatrix (const LLMatrix4a& mat) { mWorldMatrix = mat; }
|
||||
|
||||
void init()
|
||||
{
|
||||
mWorldMatrix.setIdentity();
|
||||
mMin.clearVec();
|
||||
mMax.clearVec();
|
||||
mMin.clear();
|
||||
mMax.clear();
|
||||
|
||||
LLXform::init();
|
||||
}
|
||||
@@ -153,11 +155,11 @@ public:
|
||||
void getMinMax(LLVector3& min,LLVector3& max) const;
|
||||
|
||||
protected:
|
||||
LLMatrix4 mWorldMatrix;
|
||||
LLVector3 mMin;
|
||||
LLVector3 mMax;
|
||||
LL_ALIGN_16(LLMatrix4a mWorldMatrix);
|
||||
LL_ALIGN_16(LLVector4a mMin);
|
||||
LL_ALIGN_16(LLVector4a mMax);
|
||||
|
||||
};
|
||||
} LL_ALIGN_POSTFIX(16);
|
||||
|
||||
BOOL LLXform::setParent(LLXform* parent)
|
||||
{
|
||||
|
||||
@@ -278,7 +278,7 @@ void LLCubeMap::setMatrix(S32 stage)
|
||||
|
||||
gGL.matrixMode(LLRender::MM_TEXTURE);
|
||||
gGL.pushMatrix();
|
||||
gGL.loadMatrix(trans.getF32ptr());
|
||||
gGL.loadMatrix(trans);
|
||||
gGL.matrixMode(LLRender::MM_MODELVIEW);
|
||||
|
||||
/*if (stage > 0)
|
||||
|
||||
@@ -1662,10 +1662,6 @@ void LLGLState::checkTextureChannels(const std::string& msg)
|
||||
|
||||
GLint stackDepth = 0;
|
||||
|
||||
glh::matrix4f mat;
|
||||
glh::matrix4f identity;
|
||||
identity.identity();
|
||||
|
||||
for (GLint i = 1; i < gGLManager.mNumTextureUnits; i++)
|
||||
{
|
||||
gGL.getTexUnit(i)->activate();
|
||||
@@ -1685,10 +1681,11 @@ void LLGLState::checkTextureChannels(const std::string& msg)
|
||||
}
|
||||
}
|
||||
|
||||
glGetFloatv(GL_TEXTURE_MATRIX, (GLfloat*) mat.m);
|
||||
LLMatrix4a mat;
|
||||
glGetFloatv(GL_TEXTURE_MATRIX, (GLfloat*) mat.mMatrix);
|
||||
stop_glerror();
|
||||
|
||||
if (mat != identity)
|
||||
if (!mat.isIdentity())
|
||||
{
|
||||
error = TRUE;
|
||||
LL_WARNS("RenderState") << "Texture matrix in channel " << i << " corrupt." << LL_ENDL;
|
||||
@@ -2204,12 +2201,21 @@ void LLGLUserClipPlane::setPlane(F32 a, F32 b, F32 c, F32 d)
|
||||
|
||||
LLVector4a oplane(a,b,c,d);
|
||||
LLVector4a cplane;
|
||||
invtrans_MVP.rotate4(oplane,cplane);
|
||||
LLVector4a cplane_splat;
|
||||
LLVector4a cplane_neg;
|
||||
|
||||
cplane.div(cplane.getScalarAt<2>().getAbs());
|
||||
invtrans_MVP.rotate4(oplane,cplane);
|
||||
|
||||
cplane_splat.splat<2>(cplane);
|
||||
cplane_splat.setAbs(cplane_splat);
|
||||
cplane.div(cplane_splat);
|
||||
cplane.sub(LLVector4a(0.f,0.f,0.f,1.f));
|
||||
|
||||
cplane.setSelectWithMask( LLVector4a(cplane.getScalarAt<2>().getQuad()).lessThan( _mm_setzero_ps() ), -(LLSimdScalar)cplane, cplane );
|
||||
cplane_splat.splat<2>(cplane);
|
||||
cplane_neg = cplane;
|
||||
cplane_neg.negate();
|
||||
|
||||
cplane.setSelectWithMask( cplane_splat.lessThan( _mm_setzero_ps() ), cplane_neg, cplane );
|
||||
|
||||
LLMatrix4a suffix;
|
||||
suffix.setIdentity();
|
||||
@@ -2219,7 +2225,7 @@ void LLGLUserClipPlane::setPlane(F32 a, F32 b, F32 c, F32 d)
|
||||
|
||||
gGL.matrixMode(LLRender::MM_PROJECTION);
|
||||
gGL.pushMatrix();
|
||||
gGL.loadMatrix(newP.getF32ptr());
|
||||
gGL.loadMatrix(newP);
|
||||
//gGLObliqueProjectionInverse = LLMatrix4(newP.inverse().transpose().m);
|
||||
gGL.matrixMode(LLRender::MM_MODELVIEW);
|
||||
}
|
||||
@@ -2409,19 +2415,18 @@ void LLGLDepthTest::checkState()
|
||||
}
|
||||
}
|
||||
|
||||
LLGLSquashToFarClip::LLGLSquashToFarClip(glh::matrix4f P, U32 layer)
|
||||
LLGLSquashToFarClip::LLGLSquashToFarClip(const LLMatrix4a& P_in, U32 layer)
|
||||
{
|
||||
|
||||
LLMatrix4a P = P_in;
|
||||
F32 depth = 0.99999f - 0.0001f * layer;
|
||||
|
||||
for (U32 i = 0; i < 4; i++)
|
||||
{
|
||||
P.element(2, i) = P.element(3, i) * depth;
|
||||
}
|
||||
LLVector4a col = P.getColumn<3>();
|
||||
col.mul(depth);
|
||||
P.setColumn<2>(col);
|
||||
|
||||
gGL.matrixMode(LLRender::MM_PROJECTION);
|
||||
gGL.pushMatrix();
|
||||
gGL.loadMatrix(P.m);
|
||||
gGL.loadMatrix(P);
|
||||
gGL.matrixMode(LLRender::MM_MODELVIEW);
|
||||
}
|
||||
|
||||
|
||||
@@ -349,7 +349,7 @@ private:
|
||||
class LLGLSquashToFarClip
|
||||
{
|
||||
public:
|
||||
LLGLSquashToFarClip(glh::matrix4f projection, U32 layer = 0);
|
||||
LLGLSquashToFarClip(const LLMatrix4a& projection, U32 layer = 0);
|
||||
~LLGLSquashToFarClip();
|
||||
};
|
||||
|
||||
|
||||
@@ -311,14 +311,11 @@ public:
|
||||
/*virtual*/ S32 getDepthChannel() const { return 1; }
|
||||
/*virtual*/ QuadType preDraw()
|
||||
{
|
||||
const LLMatrix4a& M = gGLModelView;
|
||||
const LLMatrix4a& P = gGLProjection;
|
||||
LLMatrix4a inv_proj;
|
||||
inv_proj.setMul(gGLProjection,gGLModelView);
|
||||
inv_proj.invert();
|
||||
const LLMatrix4a& MPrev = gGLPreviousModelView;
|
||||
LLMatrix4a prev_proj;
|
||||
prev_proj.setMul(P,MPrev);
|
||||
prev_proj.setMul(gGLProjection,gGLPreviousModelView);
|
||||
|
||||
LLVector2 screen_rect = LLPostProcess::getInstance()->getDimensions();
|
||||
|
||||
|
||||
@@ -929,12 +929,12 @@ void LLLightState::setPosition(const LLVector4& position)
|
||||
}
|
||||
else
|
||||
{ //transform position by current modelview matrix
|
||||
glh::vec4f pos(position.mV);
|
||||
LLVector4a pos;
|
||||
pos.loadua(position.mV);
|
||||
|
||||
const glh::matrix4f& mat = gGL.getModelviewMatrix();
|
||||
mat.mult_matrix_vec(pos);
|
||||
gGL.getModelviewMatrix().rotate4(pos,pos);
|
||||
|
||||
mPosition.set(pos.v);
|
||||
mPosition.set(pos.getF32ptr());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1015,12 +1015,12 @@ void LLLightState::setSpotDirection(const LLVector3& direction)
|
||||
}
|
||||
else
|
||||
{ //transform direction by current modelview matrix
|
||||
glh::vec3f dir(direction.mV);
|
||||
LLVector4a dir;
|
||||
dir.load3(direction.mV);
|
||||
|
||||
const glh::matrix4f& mat = gGL.getModelviewMatrix();
|
||||
mat.mult_matrix_dir(dir);
|
||||
gGL.getModelviewMatrix().rotate(dir,dir);
|
||||
|
||||
mSpotDirection.set(dir.v);
|
||||
mSpotDirection.set(dir.getF32ptr());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1067,6 +1067,18 @@ LLRender::LLRender()
|
||||
}
|
||||
|
||||
mLightHash = 0;
|
||||
|
||||
//Init base matrix for each mode
|
||||
for(S32 i = 0; i < NUM_MATRIX_MODES; ++i)
|
||||
{
|
||||
mMatrix[i][0].setIdentity();
|
||||
}
|
||||
|
||||
gGLModelView.setIdentity();
|
||||
gGLLastModelView.setIdentity();
|
||||
gGLPreviousModelView.setIdentity();
|
||||
gGLLastProjection.setIdentity();
|
||||
gGLProjection.setIdentity();
|
||||
}
|
||||
|
||||
LLRender::~LLRender()
|
||||
@@ -1189,12 +1201,11 @@ void LLRender::syncMatrices()
|
||||
};
|
||||
|
||||
LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
|
||||
|
||||
static glh::matrix4f cached_mvp;
|
||||
static LLMatrix4a cached_mvp;
|
||||
static U32 cached_mvp_mdv_hash = 0xFFFFFFFF;
|
||||
static U32 cached_mvp_proj_hash = 0xFFFFFFFF;
|
||||
|
||||
static glh::matrix4f cached_normal;
|
||||
static LLMatrix4a cached_normal;
|
||||
static U32 cached_normal_hash = 0xFFFFFFFF;
|
||||
|
||||
if (shader)
|
||||
@@ -1206,9 +1217,9 @@ void LLRender::syncMatrices()
|
||||
U32 i = MM_MODELVIEW;
|
||||
if (mMatHash[i] != shader->mMatHash[i])
|
||||
{ //update modelview, normal, and MVP
|
||||
glh::matrix4f& mat = mMatrix[i][mMatIdx[i]];
|
||||
|
||||
shader->uniformMatrix4fv(name[i], 1, GL_FALSE, mat.m);
|
||||
const LLMatrix4a& mat = mMatrix[i][mMatIdx[i]];
|
||||
|
||||
shader->uniformMatrix4fv(name[i], 1, GL_FALSE, mat.getF32ptr());
|
||||
shader->mMatHash[i] = mMatHash[i];
|
||||
|
||||
//update normal matrix
|
||||
@@ -1217,20 +1228,20 @@ void LLRender::syncMatrices()
|
||||
{
|
||||
if (cached_normal_hash != mMatHash[i])
|
||||
{
|
||||
cached_normal = mat.inverse().transpose();
|
||||
cached_normal = mat;
|
||||
cached_normal.invert();
|
||||
cached_normal.transpose();
|
||||
cached_normal_hash = mMatHash[i];
|
||||
}
|
||||
|
||||
const LLMatrix4a& norm = cached_normal;
|
||||
|
||||
glh::matrix4f& norm = cached_normal;
|
||||
LLVector3 norms[3];
|
||||
norms[0].set(norm.getRow<0>().getF32ptr());
|
||||
norms[1].set(norm.getRow<1>().getF32ptr());
|
||||
norms[2].set(norm.getRow<2>().getF32ptr());
|
||||
|
||||
F32 norm_mat[] =
|
||||
{
|
||||
norm.m[0], norm.m[1], norm.m[2],
|
||||
norm.m[4], norm.m[5], norm.m[6],
|
||||
norm.m[8], norm.m[9], norm.m[10]
|
||||
};
|
||||
|
||||
shader->uniformMatrix3fv(LLShaderMgr::NORMAL_MATRIX, 1, GL_FALSE, norm_mat);
|
||||
shader->uniformMatrix3fv(LLShaderMgr::NORMAL_MATRIX, 1, GL_FALSE, norms[0].mV);
|
||||
}
|
||||
|
||||
//update MVP matrix
|
||||
@@ -1242,13 +1253,12 @@ void LLRender::syncMatrices()
|
||||
|
||||
if (cached_mvp_mdv_hash != mMatHash[i] || cached_mvp_proj_hash != mMatHash[MM_PROJECTION])
|
||||
{
|
||||
cached_mvp = mat;
|
||||
cached_mvp.mult_left(mMatrix[proj][mMatIdx[proj]]);
|
||||
cached_mvp.setMul(mMatrix[proj][mMatIdx[proj]], mat);
|
||||
cached_mvp_mdv_hash = mMatHash[i];
|
||||
cached_mvp_proj_hash = mMatHash[MM_PROJECTION];
|
||||
}
|
||||
|
||||
shader->uniformMatrix4fv(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX, 1, GL_FALSE, cached_mvp.m);
|
||||
shader->uniformMatrix4fv(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX, 1, GL_FALSE, cached_mvp.getF32ptr());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1256,9 +1266,9 @@ void LLRender::syncMatrices()
|
||||
i = MM_PROJECTION;
|
||||
if (mMatHash[i] != shader->mMatHash[i])
|
||||
{ //update projection matrix, normal, and MVP
|
||||
glh::matrix4f& mat = mMatrix[i][mMatIdx[i]];
|
||||
|
||||
shader->uniformMatrix4fv(name[i], 1, GL_FALSE, mat.m);
|
||||
const LLMatrix4a& mat = mMatrix[i][mMatIdx[i]];
|
||||
|
||||
shader->uniformMatrix4fv(name[i], 1, GL_FALSE, mat.getF32ptr());
|
||||
shader->mMatHash[i] = mMatHash[i];
|
||||
|
||||
if (!mvp_done)
|
||||
@@ -1270,13 +1280,12 @@ void LLRender::syncMatrices()
|
||||
if (cached_mvp_mdv_hash != mMatHash[i] || cached_mvp_proj_hash != mMatHash[MM_PROJECTION])
|
||||
{
|
||||
U32 mdv = MM_MODELVIEW;
|
||||
cached_mvp = mat;
|
||||
cached_mvp.mult_right(mMatrix[mdv][mMatIdx[mdv]]);
|
||||
cached_mvp.setMul(mat,mMatrix[mdv][mMatIdx[mdv]]);
|
||||
cached_mvp_mdv_hash = mMatHash[MM_MODELVIEW];
|
||||
cached_mvp_proj_hash = mMatHash[MM_PROJECTION];
|
||||
}
|
||||
|
||||
shader->uniformMatrix4fv(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX, 1, GL_FALSE, cached_mvp.m);
|
||||
|
||||
shader->uniformMatrix4fv(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX, 1, GL_FALSE, cached_mvp.getF32ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1285,7 +1294,7 @@ void LLRender::syncMatrices()
|
||||
{
|
||||
if (mMatHash[i] != shader->mMatHash[i])
|
||||
{
|
||||
shader->uniformMatrix4fv(name[i], 1, GL_FALSE, mMatrix[i][mMatIdx[i]].m);
|
||||
shader->uniformMatrix4fv(name[i], 1, GL_FALSE, mMatrix[i][mMatIdx[i]].getF32ptr());
|
||||
shader->mMatHash[i] = mMatHash[i];
|
||||
}
|
||||
}
|
||||
@@ -1313,7 +1322,7 @@ void LLRender::syncMatrices()
|
||||
if (mMatHash[i] != mCurMatHash[i])
|
||||
{
|
||||
glMatrixMode(mode[i]);
|
||||
glLoadMatrixf(mMatrix[i][mMatIdx[i]].m);
|
||||
glLoadMatrixf(mMatrix[i][mMatIdx[i]].getF32ptr());
|
||||
mCurMatHash[i] = mMatHash[i];
|
||||
}
|
||||
}
|
||||
@@ -1324,7 +1333,7 @@ void LLRender::syncMatrices()
|
||||
{
|
||||
gGL.getTexUnit(i-2)->activate();
|
||||
glMatrixMode(mode[i]);
|
||||
glLoadMatrixf(mMatrix[i][mMatIdx[i]].m);
|
||||
glLoadMatrixf(mMatrix[i][mMatIdx[i]].getF32ptr());
|
||||
mCurMatHash[i] = mMatHash[i];
|
||||
}
|
||||
}
|
||||
@@ -1333,32 +1342,143 @@ void LLRender::syncMatrices()
|
||||
stop_glerror();
|
||||
}
|
||||
|
||||
LLMatrix4a LLRender::genRot(const GLfloat& a, const LLVector4a& axis) const
|
||||
{
|
||||
F32 r = a * DEG_TO_RAD;
|
||||
|
||||
F32 c = cosf(r);
|
||||
F32 s = sinf(r);
|
||||
|
||||
F32 ic = 1.f-c;
|
||||
|
||||
const LLVector4a add1(c,axis[VZ]*s,-axis[VY]*s); //1,z,-y
|
||||
const LLVector4a add2(-axis[VZ]*s,c,axis[VX]*s); //-z,1,x
|
||||
const LLVector4a add3(axis[VY]*s,-axis[VX]*s,c); //y,-x,1
|
||||
|
||||
LLVector4a axis_x;
|
||||
axis_x.splat<0>(axis);
|
||||
LLVector4a axis_y;
|
||||
axis_y.splat<1>(axis);
|
||||
LLVector4a axis_z;
|
||||
axis_z.splat<2>(axis);
|
||||
|
||||
LLVector4a c_axis;
|
||||
c_axis.setMul(axis,ic);
|
||||
|
||||
LLMatrix4a rot_mat;
|
||||
rot_mat.getRow<0>().setMul(c_axis,axis_x);
|
||||
rot_mat.getRow<0>().add(add1);
|
||||
rot_mat.getRow<1>().setMul(c_axis,axis_y);
|
||||
rot_mat.getRow<1>().add(add2);
|
||||
rot_mat.getRow<2>().setMul(c_axis,axis_z);
|
||||
rot_mat.getRow<2>().add(add3);
|
||||
rot_mat.setRow<3>(LLVector4a(0,0,0,1));
|
||||
|
||||
return rot_mat;
|
||||
}
|
||||
LLMatrix4a LLRender::genOrtho(const GLfloat& left, const GLfloat& right, const GLfloat& bottom, const GLfloat& top, const GLfloat& zNear, const GLfloat& zFar) const
|
||||
{
|
||||
LLMatrix4a ortho_mat;
|
||||
ortho_mat.setRow<0>(LLVector4a(2.f/(right-left),0,0));
|
||||
ortho_mat.setRow<1>(LLVector4a(0,2.f/(top-bottom),0));
|
||||
ortho_mat.setRow<2>(LLVector4a(0,0,-2.f/(zFar-zNear)));
|
||||
ortho_mat.setRow<3>(LLVector4a(-(right+left)/(right-left),-(top+bottom)/(top-bottom),-(zFar+zNear)/(zFar-zNear),1));
|
||||
|
||||
return ortho_mat;
|
||||
}
|
||||
|
||||
LLMatrix4a LLRender::genPersp(const GLfloat& fovy, const GLfloat& aspect, const GLfloat& zNear, const GLfloat& zFar) const
|
||||
{
|
||||
GLfloat f = 1.f/tanf(DEG_TO_RAD*fovy/2.f);
|
||||
|
||||
LLMatrix4a persp_mat;
|
||||
persp_mat.setRow<0>(LLVector4a(f/aspect,0,0));
|
||||
persp_mat.setRow<1>(LLVector4a(0,f,0));
|
||||
persp_mat.setRow<2>(LLVector4a(0,0,(zFar+zNear)/(zNear-zFar),-1.f));
|
||||
persp_mat.setRow<3>(LLVector4a(0,0,(2.f*zFar*zNear)/(zNear-zFar),0));
|
||||
|
||||
return persp_mat;
|
||||
}
|
||||
|
||||
LLMatrix4a LLRender::genLook(const LLVector3& pos_in, const LLVector3& dir_in, const LLVector3& up_in) const
|
||||
{
|
||||
const LLVector4a pos(pos_in.mV[VX],pos_in.mV[VY],pos_in.mV[VZ],1.f);
|
||||
LLVector4a dir(dir_in.mV[VX],dir_in.mV[VY],dir_in.mV[VZ]);
|
||||
const LLVector4a up(up_in.mV[VX],up_in.mV[VY],up_in.mV[VZ]);
|
||||
|
||||
LLVector4a left_norm;
|
||||
left_norm.setCross3(dir,up);
|
||||
left_norm.normalize3fast();
|
||||
LLVector4a up_norm;
|
||||
up_norm.setCross3(left_norm,dir);
|
||||
up_norm.normalize3fast();
|
||||
LLVector4a& dir_norm = dir;
|
||||
dir.normalize3fast();
|
||||
|
||||
LLVector4a left_dot;
|
||||
left_dot.setAllDot3(left_norm,pos);
|
||||
left_dot.negate();
|
||||
LLVector4a up_dot;
|
||||
up_dot.setAllDot3(up_norm,pos);
|
||||
up_dot.negate();
|
||||
LLVector4a dir_dot;
|
||||
dir_dot.setAllDot3(dir_norm,pos);
|
||||
|
||||
dir_norm.negate();
|
||||
|
||||
LLMatrix4a lookat_mat;
|
||||
lookat_mat.setRow<0>(left_norm);
|
||||
lookat_mat.setRow<1>(up_norm);
|
||||
lookat_mat.setRow<2>(dir_norm);
|
||||
lookat_mat.setRow<3>(LLVector4a(0,0,0,1));
|
||||
|
||||
lookat_mat.getRow<0>().copyComponent<3>(left_dot);
|
||||
lookat_mat.getRow<1>().copyComponent<3>(up_dot);
|
||||
lookat_mat.getRow<2>().copyComponent<3>(dir_dot);
|
||||
|
||||
lookat_mat.transpose();
|
||||
|
||||
return lookat_mat;
|
||||
}
|
||||
|
||||
const LLMatrix4a& LLRender::genNDCtoWC() const
|
||||
{
|
||||
static LLMatrix4a mat(
|
||||
LLVector4a(.5f,0,0,0),
|
||||
LLVector4a(0,.5f,0,0),
|
||||
LLVector4a(0,0,.5f,0),
|
||||
LLVector4a(.5f,.5f,.5f,1.f));
|
||||
return mat;
|
||||
}
|
||||
|
||||
void LLRender::translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z)
|
||||
{
|
||||
if( llabs(x) < F_APPROXIMATELY_ZERO &&
|
||||
llabs(y) < F_APPROXIMATELY_ZERO &&
|
||||
llabs(z) < F_APPROXIMATELY_ZERO)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
flush();
|
||||
|
||||
{
|
||||
glh::matrix4f trans_mat(1,0,0,x,
|
||||
0,1,0,y,
|
||||
0,0,1,z,
|
||||
0,0,0,1);
|
||||
|
||||
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].mult_right(trans_mat);
|
||||
mMatHash[mMatrixMode]++;
|
||||
}
|
||||
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].applyTranslation_affine(x,y,z);
|
||||
mMatHash[mMatrixMode]++;
|
||||
|
||||
}
|
||||
|
||||
void LLRender::scalef(const GLfloat& x, const GLfloat& y, const GLfloat& z)
|
||||
{
|
||||
if( (llabs(x-1.f)) < F_APPROXIMATELY_ZERO &&
|
||||
(llabs(y-1.f)) < F_APPROXIMATELY_ZERO &&
|
||||
(llabs(z-1.f)) < F_APPROXIMATELY_ZERO)
|
||||
{
|
||||
return;
|
||||
}
|
||||
flush();
|
||||
|
||||
{
|
||||
glh::matrix4f scale_mat(x,0,0,0,
|
||||
0,y,0,0,
|
||||
0,0,z,0,
|
||||
0,0,0,1);
|
||||
|
||||
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].mult_right(scale_mat);
|
||||
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].applyScale_affine(x,y,z);
|
||||
mMatHash[mMatrixMode]++;
|
||||
}
|
||||
}
|
||||
@@ -1367,38 +1487,35 @@ void LLRender::ortho(F32 left, F32 right, F32 bottom, F32 top, F32 zNear, F32 zF
|
||||
{
|
||||
flush();
|
||||
|
||||
{
|
||||
LLMatrix4a ortho_mat;
|
||||
ortho_mat.setRow<0>(LLVector4a(2.f/(right-left),0,0));
|
||||
ortho_mat.setRow<1>(LLVector4a(0,2.f/(top-bottom),0));
|
||||
ortho_mat.setRow<2>(LLVector4a(0,0,-2.f/(zFar-zNear)));
|
||||
ortho_mat.setRow<3>(LLVector4a(-(right+left)/(right-left),-(top+bottom)/(top-bottom),-(zFar+zNear)/(zFar-zNear),1));
|
||||
|
||||
glh::matrix4f ortho_mat(2.f/(right-left),0,0, -(right+left)/(right-left),
|
||||
0,2.f/(top-bottom),0, -(top+bottom)/(top-bottom),
|
||||
0,0,-2.f/(zFar-zNear), -(zFar+zNear)/(zFar-zNear),
|
||||
0,0,0,1);
|
||||
|
||||
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].mult_right(ortho_mat);
|
||||
mMatHash[mMatrixMode]++;
|
||||
}
|
||||
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].mul_affine(ortho_mat);
|
||||
mMatHash[mMatrixMode]++;
|
||||
}
|
||||
|
||||
void LLRender::rotatef(const LLMatrix4a& rot)
|
||||
{
|
||||
flush();
|
||||
|
||||
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].mul_affine(rot);
|
||||
mMatHash[mMatrixMode]++;
|
||||
}
|
||||
|
||||
void LLRender::rotatef(const GLfloat& a, const GLfloat& x, const GLfloat& y, const GLfloat& z)
|
||||
{
|
||||
if( llabs(a) < F_APPROXIMATELY_ZERO ||
|
||||
llabs(a-360.f) < F_APPROXIMATELY_ZERO)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
flush();
|
||||
|
||||
{
|
||||
F32 r = a * DEG_TO_RAD;
|
||||
|
||||
F32 c = cosf(r);
|
||||
F32 s = sinf(r);
|
||||
|
||||
F32 ic = 1.f-c;
|
||||
|
||||
glh::matrix4f rot_mat(x*x*ic+c, x*y*ic-z*s, x*z*ic+y*s, 0,
|
||||
x*y*ic+z*s, y*y*ic+c, y*z*ic-x*s, 0,
|
||||
x*z*ic-y*s, y*z*ic+x*s, z*z*ic+c, 0,
|
||||
0,0,0,1);
|
||||
|
||||
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].mult_right(rot_mat);
|
||||
mMatHash[mMatrixMode]++;
|
||||
}
|
||||
rotatef(genRot(a,x,y,z));
|
||||
}
|
||||
|
||||
//LLRender::projectf & LLRender::unprojectf adapted from gluProject & gluUnproject in Mesa's GLU 9.0 library.
|
||||
@@ -1450,18 +1567,20 @@ bool LLRender::projectf(const LLVector3& object, const LLMatrix4a& modelview, co
|
||||
|
||||
w.splat<3>(temp_vec); //w = temp_vec.wwww
|
||||
|
||||
//If w == 0.f, use 1.f instead. Defer return if temp_vec.w == 0.f until after all SSE intrinsics.
|
||||
__m128 is_zero_mask = _mm_cmpeq_ps(w,LLVector4a::getZero()); //bool is_zero = (w == 0.f);
|
||||
temp_vec.div(_mm_or_ps(_mm_andnot_ps(is_zero_mask, w), _mm_and_ps(is_zero_mask, one))); //temp_vec /= (!iszero ? w : 1.f);
|
||||
//If w == 0.f, use 1.f instead.
|
||||
LLVector4a div;
|
||||
div.setSelectWithMask( w.equal( _mm_setzero_ps() ), one, w ); //float div = (w[N] == 0.f ? 1.f : w[N]);
|
||||
temp_vec.div(div); //temp_vec /= div;
|
||||
|
||||
//Map x, y to range 0-1
|
||||
temp_vec.mul(.5f);
|
||||
temp_vec.add(.5f);
|
||||
|
||||
//End SSE intrinsics
|
||||
LLVector4Logical mask = temp_vec.equal(_mm_setzero_ps());
|
||||
if(mask.areAllSet(LLVector4Logical::MASK_W))
|
||||
return false;
|
||||
|
||||
if(temp_vec[VW]==0.f)
|
||||
return false;
|
||||
//End SSE intrinsics
|
||||
|
||||
//Window coordinates
|
||||
windowCoordinate[0]=temp_vec[VX]*viewport.getWidth()+viewport.mLeft;
|
||||
@@ -1502,12 +1621,17 @@ bool LLRender::unprojectf(const LLVector3& windowCoordinate, const LLMatrix4a& m
|
||||
w.splat<3>(temp_vec); //w = temp_vec.wwww
|
||||
|
||||
//If w == 0.f, use 1.f instead. Defer return if temp_vec.w == 0.f until after all SSE intrinsics.
|
||||
__m128 is_zero_mask = _mm_cmpeq_ps(w,LLVector4a::getZero()); //bool is_zero = (w == 0.f);
|
||||
temp_vec.div(_mm_or_ps(_mm_andnot_ps(is_zero_mask, w), _mm_and_ps(is_zero_mask, one))); //temp_vec /= (!iszero ? w : 1.f);
|
||||
|
||||
LLVector4a div;
|
||||
div.setSelectWithMask( w.equal( _mm_setzero_ps() ), one, w ); //float div = (w[N] == 0.f ? 1.f : w[N]);
|
||||
temp_vec.div(div); //temp_vec /= div;
|
||||
|
||||
LLVector4Logical mask = temp_vec.equal(_mm_setzero_ps());
|
||||
if(mask.areAllSet(LLVector4Logical::MASK_W))
|
||||
return false;
|
||||
|
||||
//End SSE intrinsics
|
||||
|
||||
if(det == 0.f || temp_vec[VW]==0.f)
|
||||
if(det == 0.f)
|
||||
return false;
|
||||
|
||||
object.set(temp_vec.getF32ptr());
|
||||
@@ -1548,24 +1672,21 @@ void LLRender::popMatrix()
|
||||
}
|
||||
}
|
||||
|
||||
void LLRender::loadMatrix(const GLfloat* m)
|
||||
void LLRender::loadMatrix(const LLMatrix4a& mat)
|
||||
{
|
||||
flush();
|
||||
{
|
||||
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].set_value((GLfloat*) m);
|
||||
mMatHash[mMatrixMode]++;
|
||||
}
|
||||
|
||||
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]] = mat;
|
||||
mMatHash[mMatrixMode]++;
|
||||
}
|
||||
|
||||
void LLRender::multMatrix(const GLfloat* m)
|
||||
void LLRender::multMatrix(const LLMatrix4a& mat)
|
||||
{
|
||||
flush();
|
||||
{
|
||||
glh::matrix4f mat((GLfloat*) m);
|
||||
|
||||
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].mul_affine(mat);
|
||||
mMatHash[mMatrixMode]++;
|
||||
|
||||
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].mult_right(mat);
|
||||
mMatHash[mMatrixMode]++;
|
||||
}
|
||||
}
|
||||
|
||||
void LLRender::matrixMode(U32 mode)
|
||||
@@ -1594,20 +1715,16 @@ void LLRender::loadIdentity()
|
||||
{
|
||||
flush();
|
||||
|
||||
{
|
||||
llassert_always(mMatrixMode < NUM_MATRIX_MODES) ;
|
||||
|
||||
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].make_identity();
|
||||
mMatHash[mMatrixMode]++;
|
||||
}
|
||||
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].setIdentity();
|
||||
mMatHash[mMatrixMode]++;
|
||||
}
|
||||
|
||||
const glh::matrix4f& LLRender::getModelviewMatrix()
|
||||
const LLMatrix4a& LLRender::getModelviewMatrix()
|
||||
{
|
||||
return mMatrix[MM_MODELVIEW][mMatIdx[MM_MODELVIEW]];
|
||||
}
|
||||
|
||||
const glh::matrix4f& LLRender::getProjectionMatrix()
|
||||
const LLMatrix4a& LLRender::getProjectionMatrix()
|
||||
{
|
||||
return mMatrix[MM_PROJECTION][mMatIdx[MM_PROJECTION]];
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "v3math.h"
|
||||
#include "v4coloru.h"
|
||||
#include "v4math.h"
|
||||
#include "llmatrix4a.h"
|
||||
#include "llalignedarray.h"
|
||||
#include "llstrider.h"
|
||||
#include "llpointer.h"
|
||||
@@ -258,6 +259,8 @@ protected:
|
||||
F32 mSpotExponent;
|
||||
F32 mSpotCutoff;
|
||||
};
|
||||
|
||||
LL_ALIGN_PREFIX(16)
|
||||
class LLRender
|
||||
{
|
||||
friend class LLTexUnit;
|
||||
@@ -344,8 +347,17 @@ public:
|
||||
// Needed when the render context has changed and invalidated the current state
|
||||
void refreshState(void);
|
||||
|
||||
LLMatrix4a genRot(const GLfloat& a, const LLVector4a& axis) const;
|
||||
LLMatrix4a genRot(const GLfloat& a, const GLfloat& x, const GLfloat& y, const GLfloat& z) const { return genRot(a,LLVector4a(x,y,z)); }
|
||||
LLMatrix4a genOrtho(const GLfloat& left, const GLfloat& right, const GLfloat& bottom, const GLfloat& top, const GLfloat& znear, const GLfloat& zfar) const;
|
||||
LLMatrix4a genPersp(const GLfloat& fovy, const GLfloat& aspect, const GLfloat& znear, const GLfloat& zfar) const;
|
||||
LLMatrix4a genLook(const LLVector3& pos_in, const LLVector3& dir_in, const LLVector3& up_in) const;
|
||||
const LLMatrix4a& genNDCtoWC() const;
|
||||
|
||||
void translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z);
|
||||
void scalef(const GLfloat& x, const GLfloat& y, const GLfloat& z);
|
||||
//rotatef requires generation of a transform matrix involving sine/cosine. If rotating by a constant value, use genRot, store the result in a static variable, and pass that var to rotatef.
|
||||
void rotatef(const LLMatrix4a& rot);
|
||||
void rotatef(const GLfloat& a, const GLfloat& x, const GLfloat& y, const GLfloat& z);
|
||||
void ortho(F32 left, F32 right, F32 bottom, F32 top, F32 zNear, F32 zFar);
|
||||
bool projectf(const LLVector3& object, const LLMatrix4a& modelview, const LLMatrix4a& projection, const LLRect& viewport, LLVector3& windowCoordinate);
|
||||
@@ -353,14 +365,14 @@ public:
|
||||
|
||||
void pushMatrix();
|
||||
void popMatrix();
|
||||
void loadMatrix(const GLfloat* m);
|
||||
void loadMatrix(const LLMatrix4a& mat);
|
||||
void loadIdentity();
|
||||
void multMatrix(const GLfloat* m);
|
||||
void multMatrix(const LLMatrix4a& mat);
|
||||
void matrixMode(U32 mode);
|
||||
U32 getMatrixMode();
|
||||
|
||||
const glh::matrix4f& getModelviewMatrix();
|
||||
const glh::matrix4f& getProjectionMatrix();
|
||||
const LLMatrix4a& getModelviewMatrix();
|
||||
const LLMatrix4a& getProjectionMatrix();
|
||||
|
||||
void syncMatrices();
|
||||
void syncLightState();
|
||||
@@ -450,7 +462,7 @@ private:
|
||||
U32 mMatrixMode;
|
||||
U32 mMatIdx[NUM_MATRIX_MODES];
|
||||
U32 mMatHash[NUM_MATRIX_MODES];
|
||||
glh::matrix4f mMatrix[NUM_MATRIX_MODES][LL_MATRIX_STACK_DEPTH];
|
||||
LL_ALIGN_16(LLMatrix4a mMatrix[NUM_MATRIX_MODES][LL_MATRIX_STACK_DEPTH]);
|
||||
U32 mCurMatHash[NUM_MATRIX_MODES];
|
||||
U32 mLightHash;
|
||||
LLColor4 mAmbientLightColor;
|
||||
@@ -481,7 +493,8 @@ private:
|
||||
|
||||
LLAlignedArray<LLVector4a, 64> mUIOffset;
|
||||
LLAlignedArray<LLVector4a, 64> mUIScale;
|
||||
};
|
||||
} LL_ALIGN_POSTFIX(16);
|
||||
|
||||
|
||||
extern LLMatrix4a gGLModelView;
|
||||
extern LLMatrix4a gGLLastModelView;
|
||||
|
||||
@@ -2044,6 +2044,10 @@ bool LLVertexBuffer::getNormalStrider(LLStrider<LLVector3>& strider, S32 index,
|
||||
{
|
||||
return VertexBufferStrider<LLVector3,TYPE_NORMAL>::get(*this, strider, index, count, map_range);
|
||||
}
|
||||
bool LLVertexBuffer::getNormalStrider(LLStrider<LLVector4a>& strider, S32 index, S32 count, bool map_range)
|
||||
{
|
||||
return VertexBufferStrider<LLVector4a,TYPE_NORMAL>::get(*this, strider, index, count, map_range);
|
||||
}
|
||||
bool LLVertexBuffer::getTangentStrider(LLStrider<LLVector3>& strider, S32 index, S32 count, bool map_range)
|
||||
{
|
||||
return VertexBufferStrider<LLVector3,TYPE_TANGENT>::get(*this, strider, index, count, map_range);
|
||||
|
||||
@@ -250,6 +250,7 @@ public:
|
||||
bool getTexCoord1Strider(LLStrider<LLVector2>& strider, S32 index=0, S32 count = -1, bool map_range = false);
|
||||
bool getTexCoord2Strider(LLStrider<LLVector2>& strider, S32 index=0, S32 count = -1, bool map_range = false);
|
||||
bool getNormalStrider(LLStrider<LLVector3>& strider, S32 index=0, S32 count = -1, bool map_range = false);
|
||||
bool getNormalStrider(LLStrider<LLVector4a>& strider, S32 index=0, S32 count = -1, bool map_range = false);
|
||||
bool getTangentStrider(LLStrider<LLVector3>& strider, S32 index=0, S32 count = -1, bool map_range = false);
|
||||
bool getTangentStrider(LLStrider<LLVector4a>& strider, S32 index=0, S32 count = -1, bool map_range = false);
|
||||
bool getColorStrider(LLStrider<LLColor4U>& strider, S32 index=0, S32 count = -1, bool map_range = false);
|
||||
|
||||
@@ -395,7 +395,7 @@ void LLAgentCamera::slamLookAt(const LLVector3 &look_at)
|
||||
//-----------------------------------------------------------------------------
|
||||
LLVector3 LLAgentCamera::calcFocusOffset(LLViewerObject *object, LLVector3 original_focus_point, S32 x, S32 y)
|
||||
{
|
||||
LLMatrix4 obj_matrix = object->getRenderMatrix();
|
||||
const LLMatrix4a& obj_matrix = object->getRenderMatrix();
|
||||
LLQuaternion obj_rot = object->getRenderRotation();
|
||||
LLVector3 obj_pos = object->getRenderPosition();
|
||||
|
||||
@@ -427,24 +427,24 @@ LLVector3 LLAgentCamera::calcFocusOffset(LLViewerObject *object, LLVector3 origi
|
||||
|
||||
// find the largest ratio stored in obj_to_cam_ray_proportions
|
||||
// this corresponds to the object's local axial plane (XY, YZ, XZ) that is *most* facing the camera
|
||||
LLVector3 longest_object_axis;
|
||||
LLVector4a focus_plane_normal;
|
||||
// is x-axis longest?
|
||||
if (obj_to_cam_ray_proportions.mV[VX] > obj_to_cam_ray_proportions.mV[VY]
|
||||
&& obj_to_cam_ray_proportions.mV[VX] > obj_to_cam_ray_proportions.mV[VZ])
|
||||
{
|
||||
// then grab it
|
||||
longest_object_axis.setVec(obj_matrix.getFwdRow4());
|
||||
focus_plane_normal = obj_matrix.getRow<LLMatrix4a::ROW_FWD>();
|
||||
}
|
||||
// is y-axis longest?
|
||||
else if (obj_to_cam_ray_proportions.mV[VY] > obj_to_cam_ray_proportions.mV[VZ])
|
||||
{
|
||||
// then grab it
|
||||
longest_object_axis.setVec(obj_matrix.getLeftRow4());
|
||||
focus_plane_normal = obj_matrix.getRow<LLMatrix4a::ROW_LEFT>();
|
||||
}
|
||||
// otherwise, use z axis
|
||||
else
|
||||
{
|
||||
longest_object_axis.setVec(obj_matrix.getUpRow4());
|
||||
focus_plane_normal = obj_matrix.getRow<LLMatrix4a::ROW_UP>();
|
||||
}
|
||||
|
||||
// Use this axis as the normal to project mouse click on to plane with that normal, at the object center.
|
||||
@@ -453,11 +453,10 @@ LLVector3 LLAgentCamera::calcFocusOffset(LLViewerObject *object, LLVector3 origi
|
||||
// We do this to allow the camera rotation tool to "tumble" the object by rotating the camera.
|
||||
// If the focus point were the object surface under the mouse, camera rotation would introduce an undesirable
|
||||
// eccentricity to the object orientation
|
||||
LLVector3 focus_plane_normal(longest_object_axis);
|
||||
focus_plane_normal.normalize();
|
||||
focus_plane_normal.normalize3fast();
|
||||
|
||||
LLVector3d focus_pt_global;
|
||||
gViewerWindow->mousePointOnPlaneGlobal(focus_pt_global, x, y, gAgent.getPosGlobalFromAgent(obj_pos), focus_plane_normal);
|
||||
gViewerWindow->mousePointOnPlaneGlobal(focus_pt_global, x, y, gAgent.getPosGlobalFromAgent(obj_pos), LLVector3(focus_plane_normal.getF32ptr()));
|
||||
LLVector3 focus_pt = gAgent.getPosAgentFromGlobal(focus_pt_global);
|
||||
|
||||
// find vector from camera to focus point in object space
|
||||
@@ -1781,7 +1780,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
|
||||
head_offset.mdV[VX] = gAgentAvatarp->mHeadOffset.mV[VX];
|
||||
head_offset.mdV[VY] = gAgentAvatarp->mHeadOffset.mV[VY];
|
||||
head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ] + 0.1f;
|
||||
const LLMatrix4& mat = ((LLViewerObject*) gAgentAvatarp->getParent())->getRenderMatrix();
|
||||
const LLMatrix4 mat(((LLViewerObject*) gAgentAvatarp->getParent())->getRenderMatrix().getF32ptr());
|
||||
camera_position_global = gAgent.getPosGlobalFromAgent
|
||||
((gAgentAvatarp->getPosition()+
|
||||
LLVector3(head_offset)*gAgentAvatarp->getRotation()) * mat);
|
||||
|
||||
@@ -179,7 +179,7 @@ LLVOVolume* LLDrawable::getVOVolume() const
|
||||
}
|
||||
}
|
||||
|
||||
const LLMatrix4& LLDrawable::getRenderMatrix() const
|
||||
const LLMatrix4a& LLDrawable::getRenderMatrix() const
|
||||
{
|
||||
return isRoot() ? getWorldMatrix() : getParent()->getWorldMatrix();
|
||||
}
|
||||
@@ -1211,8 +1211,7 @@ void LLSpatialBridge::updateSpatialExtents()
|
||||
LLVector4a size = root->mBounds[1];
|
||||
|
||||
//VECTORIZE THIS
|
||||
LLMatrix4a mat;
|
||||
mat.loadu(mDrawable->getXform()->getWorldMatrix());
|
||||
const LLMatrix4a& mat = mDrawable->getXform()->getWorldMatrix();
|
||||
|
||||
LLVector4a t;
|
||||
t.splat(0.f);
|
||||
@@ -1279,27 +1278,35 @@ LLCamera LLSpatialBridge::transformCamera(LLCamera& camera)
|
||||
{
|
||||
LLCamera ret = camera;
|
||||
LLXformMatrix* mat = mDrawable->getXform();
|
||||
LLVector3 center = LLVector3(0,0,0) * mat->getWorldMatrix();
|
||||
const LLVector4a& center = mat->getWorldMatrix().getRow<3>();
|
||||
|
||||
LLVector3 delta = ret.getOrigin() - center;
|
||||
LLQuaternion rot = ~mat->getRotation();
|
||||
LLQuaternion2 invRot;
|
||||
invRot.setConjugate( LLQuaternion2(mat->getRotation()) );
|
||||
|
||||
delta *= rot;
|
||||
LLVector3 lookAt = ret.getAtAxis();
|
||||
LLVector3 up_axis = ret.getUpAxis();
|
||||
LLVector3 left_axis = ret.getLeftAxis();
|
||||
LLVector4a delta;
|
||||
delta.load3(ret.getOrigin().mV);
|
||||
delta.sub(center);
|
||||
|
||||
lookAt *= rot;
|
||||
up_axis *= rot;
|
||||
left_axis *= rot;
|
||||
LLVector4a lookAt;
|
||||
lookAt.load3(ret.getAtAxis().mV);
|
||||
LLVector4a up_axis;
|
||||
|
||||
if (!delta.isFinite())
|
||||
up_axis.load3(ret.getUpAxis().mV);
|
||||
LLVector4a left_axis;
|
||||
left_axis.load3(ret.getLeftAxis().mV);
|
||||
|
||||
delta.setRotated(invRot, delta);
|
||||
lookAt.setRotated(invRot, lookAt);
|
||||
up_axis.setRotated(invRot, up_axis);
|
||||
left_axis.setRotated(invRot, left_axis);
|
||||
|
||||
if (!delta.isFinite3())
|
||||
{
|
||||
delta.clearVec();
|
||||
delta.clear();
|
||||
}
|
||||
|
||||
ret.setOrigin(delta);
|
||||
ret.setAxes(lookAt, left_axis, up_axis);
|
||||
ret.setOrigin(LLVector3(delta.getF32ptr()));
|
||||
ret.setAxes(LLVector3(lookAt.getF32ptr()), LLVector3(left_axis.getF32ptr()), LLVector3(up_axis.getF32ptr()));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1591,12 +1598,17 @@ const LLVector3 LLDrawable::getPositionAgent() const
|
||||
{
|
||||
if (isActive())
|
||||
{
|
||||
LLVector3 pos(0,0,0);
|
||||
if (!isRoot())
|
||||
{
|
||||
pos = mVObjp->getPosition();
|
||||
LLVector4a pos;
|
||||
pos.load3(mVObjp->getPosition().mV);
|
||||
getRenderMatrix().affineTransform(pos,pos);
|
||||
return LLVector3(pos.getF32ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
return LLVector3(getRenderMatrix().getRow<3>().getF32ptr());
|
||||
}
|
||||
return pos * getRenderMatrix();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -110,8 +110,8 @@ public:
|
||||
const LLViewerObject *getVObj() const { return mVObjp; }
|
||||
LLVOVolume* getVOVolume() const; // cast mVObjp tp LLVOVolume if OK
|
||||
|
||||
const LLMatrix4& getWorldMatrix() const { return mXform.getWorldMatrix(); }
|
||||
const LLMatrix4& getRenderMatrix() const;
|
||||
const LLMatrix4a& getWorldMatrix() const { return mXform.getWorldMatrix(); }
|
||||
const LLMatrix4a& getRenderMatrix() const;
|
||||
void setPosition(LLVector3 v) const { }
|
||||
const LLVector3& getPosition() const { return mXform.getPosition(); }
|
||||
const LLVector3& getWorldPosition() const { return mXform.getPositionW(); }
|
||||
@@ -305,7 +305,7 @@ private: //aligned members
|
||||
LL_ALIGN_16(LLVector4a mPositionGroup);
|
||||
|
||||
public:
|
||||
LLXformMatrix mXform;
|
||||
LL_ALIGN_16(LLXformMatrix mXform);
|
||||
|
||||
// vis data
|
||||
LLPointer<LLDrawable> mParent;
|
||||
|
||||
@@ -445,11 +445,11 @@ void LLRenderPass::applyModelMatrix(LLDrawInfo& params)
|
||||
if (params.mModelMatrix != gGLLastMatrix)
|
||||
{
|
||||
gGLLastMatrix = params.mModelMatrix;
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
if (params.mModelMatrix)
|
||||
{
|
||||
llassert(gGL.getMatrixMode() == LLRender::MM_MODELVIEW);
|
||||
gGL.multMatrix((GLfloat*) params.mModelMatrix->mMatrix);
|
||||
gGL.multMatrix(*params.mModelMatrix);
|
||||
}
|
||||
gPipeline.mMatrixOpCount++;
|
||||
}
|
||||
@@ -484,7 +484,7 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL ba
|
||||
tex_setup = true;
|
||||
gGL.getTexUnit(0)->activate();
|
||||
gGL.matrixMode(LLRender::MM_TEXTURE);
|
||||
gGL.loadMatrix((GLfloat*) params.mTextureMatrix->mMatrix);
|
||||
gGL.loadMatrix(*params.mTextureMatrix);
|
||||
gPipeline.mTextureMatrixOps++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,7 +515,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass)
|
||||
tex_setup = true;
|
||||
gGL.getTexUnit(0)->activate();
|
||||
gGL.matrixMode(LLRender::MM_TEXTURE);
|
||||
gGL.loadMatrix((GLfloat*) params.mTextureMatrix->mMatrix);
|
||||
gGL.loadMatrix(*params.mTextureMatrix);
|
||||
gPipeline.mTextureMatrixOps++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,13 +155,9 @@ void LLDrawPoolAvatar::prerender()
|
||||
}
|
||||
}
|
||||
|
||||
LLMatrix4& LLDrawPoolAvatar::getModelView()
|
||||
const LLMatrix4a& LLDrawPoolAvatar::getModelView()
|
||||
{
|
||||
static LLMatrix4 ret;
|
||||
|
||||
ret = LLMatrix4(gGLModelView.getF32ptr());
|
||||
|
||||
return ret;
|
||||
return gGLModelView;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1330,7 +1326,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
|
||||
{
|
||||
LLMatrix4 rot_mat;
|
||||
LLViewerCamera::getInstance()->getMatrixToLocal(rot_mat);
|
||||
LLMatrix4 cfr(OGL_TO_CFR_ROTATION);
|
||||
LLMatrix4 cfr(OGL_TO_CFR_ROTATION.getF32ptr());
|
||||
rot_mat *= cfr;
|
||||
|
||||
LLVector4 wind;
|
||||
@@ -1532,8 +1528,10 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
|
||||
}
|
||||
if (joint)
|
||||
{
|
||||
mat[i] = skin->mInvBindMatrix[i];
|
||||
mat[i] *= joint->getWorldMatrix();
|
||||
LLMatrix4a tmp;
|
||||
tmp.loadu((F32*)skin->mInvBindMatrix[i].mMatrix);
|
||||
tmp.setMul(joint->getWorldMatrix(),tmp);
|
||||
mat[i] = LLMatrix4(tmp.getF32ptr());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1657,7 +1655,7 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
|
||||
if (face->mTextureMatrix && vobj->mTexAnimMode)
|
||||
{
|
||||
gGL.matrixMode(LLRender::MM_TEXTURE);
|
||||
gGL.loadMatrix((F32*) face->mTextureMatrix->mMatrix);
|
||||
gGL.loadMatrix(*face->mTextureMatrix);
|
||||
buff->setBuffer(data_mask);
|
||||
buff->drawRange(LLRender::TRIANGLES, start, end, count, offset);
|
||||
gGL.loadIdentity();
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
|
||||
LLDrawPoolAvatar();
|
||||
|
||||
static LLMatrix4& getModelView();
|
||||
static const LLMatrix4a& getModelView();
|
||||
|
||||
/*virtual*/ LLDrawPool *instancePool();
|
||||
|
||||
|
||||
@@ -1489,16 +1489,16 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL
|
||||
{
|
||||
gGL.getTexUnit(1)->activate();
|
||||
gGL.matrixMode(LLRender::MM_TEXTURE);
|
||||
gGL.loadMatrix((GLfloat*) params.mTextureMatrix->mMatrix);
|
||||
gGL.loadMatrix(*params.mTextureMatrix);
|
||||
}
|
||||
|
||||
gGL.getTexUnit(0)->activate();
|
||||
gGL.matrixMode(LLRender::MM_TEXTURE);
|
||||
gGL.loadMatrix((GLfloat*) params.mTextureMatrix->mMatrix);
|
||||
gGL.loadMatrix(*params.mTextureMatrix);
|
||||
gPipeline.mTextureMatrixOps++;
|
||||
}
|
||||
|
||||
gGL.loadMatrix((GLfloat*) params.mTextureMatrix->mMatrix);
|
||||
gGL.loadMatrix(*params.mTextureMatrix);
|
||||
gPipeline.mTextureMatrixOps++;
|
||||
|
||||
tex_setup = true;
|
||||
|
||||
@@ -187,7 +187,7 @@ void LLDrawPoolMaterials::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture,
|
||||
gGL.matrixMode(LLRender::MM_TEXTURE);
|
||||
}
|
||||
|
||||
gGL.loadMatrix((GLfloat*) params.mTextureMatrix->mMatrix);
|
||||
gGL.loadMatrix(*params.mTextureMatrix);
|
||||
gPipeline.mTextureMatrixOps++;
|
||||
|
||||
tex_setup = true;
|
||||
|
||||
@@ -314,16 +314,19 @@ void LLDrawPoolTerrain::drawLoop()
|
||||
{
|
||||
LLFace *facep = *iter;
|
||||
|
||||
LLMatrix4* model_matrix = &(facep->getDrawable()->getRegion()->mRenderMatrix);
|
||||
|
||||
LLMatrix4a* model_matrix = &(facep->getDrawable()->getRegion()->mRenderMatrix);
|
||||
if(model_matrix && model_matrix->isIdentity())
|
||||
{
|
||||
model_matrix = NULL;
|
||||
}
|
||||
if (model_matrix != gGLLastMatrix)
|
||||
{
|
||||
llassert(gGL.getMatrixMode() == LLRender::MM_MODELVIEW);
|
||||
gGLLastMatrix = model_matrix;
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
if (model_matrix)
|
||||
{
|
||||
gGL.multMatrix((GLfloat*) model_matrix->mMatrix);
|
||||
gGL.multMatrix(*model_matrix);
|
||||
}
|
||||
gPipeline.mMatrixOpCount++;
|
||||
}
|
||||
|
||||
@@ -120,16 +120,19 @@ void LLDrawPoolTree::render(S32 pass)
|
||||
|
||||
if(buff)
|
||||
{
|
||||
LLMatrix4* model_matrix = &(face->getDrawable()->getRegion()->mRenderMatrix);
|
||||
|
||||
LLMatrix4a* model_matrix = &(face->getDrawable()->getRegion()->mRenderMatrix);
|
||||
if(model_matrix && model_matrix->isIdentity())
|
||||
{
|
||||
model_matrix = NULL;
|
||||
}
|
||||
if (model_matrix != gGLLastMatrix)
|
||||
{
|
||||
gGLLastMatrix = model_matrix;
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
if (model_matrix)
|
||||
{
|
||||
llassert(gGL.getMatrixMode() == LLRender::MM_MODELVIEW);
|
||||
gGL.multMatrix((GLfloat*) model_matrix->mMatrix);
|
||||
gGL.multMatrix(*model_matrix);
|
||||
}
|
||||
gPipeline.mMatrixOpCount++;
|
||||
}
|
||||
@@ -250,17 +253,16 @@ void LLDrawPoolTree::renderTree(BOOL selecting)
|
||||
}
|
||||
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
//gGL.pushMatrix();
|
||||
|
||||
LLMatrix4 matrix(gGLModelView.getF32ptr());
|
||||
LLMatrix4a matrix(gGLModelView);
|
||||
|
||||
// Translate to tree base HACK - adjustment in Z plants tree underground
|
||||
const LLVector3 &pos_agent = treep->getPositionAgent();
|
||||
//gGL.translatef(pos_agent.mV[VX], pos_agent.mV[VY], pos_agent.mV[VZ] - 0.1f);
|
||||
LLMatrix4 trans_mat;
|
||||
trans_mat.setTranslation(pos_agent.mV[VX], pos_agent.mV[VY], pos_agent.mV[VZ] - 0.1f);
|
||||
trans_mat *= matrix;
|
||||
LLMatrix4a trans_mat = matrix;
|
||||
trans_mat.applyTranslation_affine(pos_agent - LLVector3(0.f,0.f,1.f));
|
||||
|
||||
// Rotate to tree position and bend for current trunk/wind
|
||||
// Note that trunk stiffness controls the amount of bend at the trunk as
|
||||
@@ -273,16 +275,12 @@ void LLDrawPoolTree::renderTree(BOOL selecting)
|
||||
LLQuaternion(90.f*DEG_TO_RAD, LLVector4(0,0,1)) *
|
||||
treep->getRotation();
|
||||
|
||||
LLMatrix4 rot_mat(rot);
|
||||
rot_mat *= trans_mat;
|
||||
LLMatrix4a rot_mat = trans_mat;
|
||||
rot_mat.mul(LLQuaternion2(rot));
|
||||
|
||||
F32 radius = treep->getScale().magVec()*0.05f;
|
||||
LLMatrix4 scale_mat;
|
||||
scale_mat.mMatrix[0][0] =
|
||||
scale_mat.mMatrix[1][1] =
|
||||
scale_mat.mMatrix[2][2] = radius;
|
||||
|
||||
scale_mat *= rot_mat;
|
||||
LLMatrix4a scale_mat = rot_mat;
|
||||
scale_mat.applyScale_affine(radius);
|
||||
|
||||
//TO-DO: Make these set-able?
|
||||
const F32 THRESH_ANGLE_FOR_BILLBOARD = 7.5f; //Made LoD now a little less aggressive here -Shyotl
|
||||
|
||||
@@ -293,11 +293,10 @@ void LLDrawPoolWater::render(S32 pass)
|
||||
|
||||
gGL.matrixMode(LLRender::MM_TEXTURE);
|
||||
gGL.loadIdentity();
|
||||
LLMatrix4 camera_mat = LLViewerCamera::getInstance()->getModelview();
|
||||
LLMatrix4 camera_rot(camera_mat.getMat3());
|
||||
LLMatrix4a camera_rot = LLViewerCamera::getInstance()->getModelview();
|
||||
camera_rot.extractRotation_affine();
|
||||
camera_rot.invert();
|
||||
|
||||
gGL.loadMatrix((F32 *)camera_rot.mMatrix);
|
||||
gGL.loadMatrix(camera_rot);
|
||||
|
||||
gGL.matrixMode(LLRender::MM_MODELVIEW);
|
||||
LLOverrideFaceColor overrid(this, 1.f, 1.f, 1.f, 0.5f*up_dot);
|
||||
@@ -727,7 +726,7 @@ void LLDrawPoolWater::shade()
|
||||
gGL.getTexUnit(diffTex)->bind(face->getTexture());
|
||||
|
||||
sNeedsReflectionUpdate = TRUE;
|
||||
|
||||
|
||||
if (water->getUseTexture() || !water->getIsEdgePatch())
|
||||
{
|
||||
sNeedsDistortionUpdate = TRUE;
|
||||
|
||||
@@ -154,7 +154,8 @@ void LLDrawPoolWLSky::renderDome(F32 camHeightLocal, LLGLSLShader * shader) cons
|
||||
|
||||
// the windlight sky dome works most conveniently in a coordinate system
|
||||
// where Y is up, so permute our basis vectors accordingly.
|
||||
gGL.rotatef(120.f, 1.f / F_SQRT3, 1.f / F_SQRT3, 1.f / F_SQRT3);
|
||||
static const LLMatrix4a rot = gGL.genRot(120.f, 1.f / F_SQRT3, 1.f / F_SQRT3, 1.f / F_SQRT3);
|
||||
gGL.rotatef(rot);
|
||||
|
||||
gGL.scalef(0.333f, 0.333f, 0.333f);
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ void LLFace::destroy()
|
||||
|
||||
if (mTextureMatrix)
|
||||
{
|
||||
delete mTextureMatrix;
|
||||
ll_aligned_free_16(mTextureMatrix);
|
||||
mTextureMatrix = NULL;
|
||||
|
||||
if (mDrawablep.notNull())
|
||||
@@ -493,7 +493,11 @@ void LLFace::updateCenterAgent()
|
||||
{
|
||||
if (mDrawablep->isActive())
|
||||
{
|
||||
mCenterAgent = mCenterLocal * getRenderMatrix();
|
||||
LLVector4a local_pos;
|
||||
local_pos.load3(mCenterLocal.mV);
|
||||
|
||||
getRenderMatrix().affineTransform(local_pos,local_pos);
|
||||
mCenterAgent.set(local_pos.getF32ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -521,15 +525,21 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color)
|
||||
gGL.getTexUnit(0)->bind(imagep);
|
||||
|
||||
gGL.pushMatrix();
|
||||
|
||||
const LLMatrix4a* model_matrix = NULL;
|
||||
if (mDrawablep->isActive())
|
||||
{
|
||||
gGL.multMatrix((GLfloat*)mDrawablep->getRenderMatrix().mMatrix);
|
||||
model_matrix = &(mDrawablep->getRenderMatrix());
|
||||
}
|
||||
else
|
||||
{
|
||||
gGL.multMatrix((GLfloat*)mDrawablep->getRegion()->mRenderMatrix.mMatrix);
|
||||
model_matrix = &mDrawablep->getRegion()->mRenderMatrix;
|
||||
}
|
||||
|
||||
if(model_matrix && !model_matrix->isIdentity())
|
||||
{
|
||||
gGL.multMatrix(*model_matrix);
|
||||
}
|
||||
|
||||
if (mDrawablep->isState(LLDrawable::RIGGED))
|
||||
{
|
||||
LLVOVolume* volume = mDrawablep->getVOVolume();
|
||||
@@ -540,7 +550,7 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color)
|
||||
{
|
||||
LLGLEnable offset(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(-1.f, -1.f);
|
||||
gGL.multMatrix(volume->getRelativeXform().getF32ptr());
|
||||
gGL.multMatrix(volume->getRelativeXform());
|
||||
const LLVolumeFace& vol_face = rigged->getVolumeFace(getTEOffset());
|
||||
|
||||
// Singu Note: Implementation changed to utilize a VBO, avoiding fixed functions unless required
|
||||
@@ -956,9 +966,9 @@ LLVector2 LLFace::surfaceToTexture(LLVector2 surface_coord, const LLVector4a& po
|
||||
|
||||
if (mTextureMatrix) // if we have a texture matrix, use it
|
||||
{
|
||||
LLVector3 tc3(tc);
|
||||
tc3 = tc3 * *mTextureMatrix;
|
||||
tc = LLVector2(tc3);
|
||||
LLVector4a tc4(tc.mV[VX],tc.mV[VY],0.f);
|
||||
mTextureMatrix->affineTransform(tc4,tc4);
|
||||
tc.set(tc4.getF32ptr());
|
||||
}
|
||||
|
||||
else // otherwise use the texture entry parameters
|
||||
@@ -975,7 +985,7 @@ LLVector2 LLFace::surfaceToTexture(LLVector2 surface_coord, const LLVector4a& po
|
||||
// by planarProjection(). This is needed to match planar texgen parameters.
|
||||
void LLFace::getPlanarProjectedParams(LLQuaternion* face_rot, LLVector3* face_pos, F32* scale) const
|
||||
{
|
||||
const LLMatrix4& vol_mat = getWorldMatrix();
|
||||
const LLMatrix4a& vol_mat = getWorldMatrix();
|
||||
const LLVolumeFace& vf = getViewerObject()->getVolume()->getVolumeFace(mTEOffset);
|
||||
const LLVector4a& normal4a = vf.mNormals[0];
|
||||
const LLVector4a& tangent = vf.mTangents[0];
|
||||
@@ -994,13 +1004,20 @@ void LLFace::getPlanarProjectedParams(LLQuaternion* face_rot, LLVector3* face_po
|
||||
F32 ang = acos(projected_binormal.mV[VY]);
|
||||
ang = (projected_binormal.mV[VX] < 0.f) ? -ang : ang;
|
||||
|
||||
//VECTORIZE THIS
|
||||
LLVector3 binormal(binormal4a.getF32ptr());
|
||||
LLVector3 normal(normal4a.getF32ptr());
|
||||
binormal.rotVec(ang, normal);
|
||||
LLQuaternion local_rot( binormal % normal, binormal, normal );
|
||||
*face_rot = local_rot * vol_mat.quaternion();
|
||||
*face_pos = vol_mat.getTranslation();
|
||||
LLMatrix4a rot = gGL.genRot(ang, normal4a);
|
||||
rot.rotate(binormal4a, binormal4a);
|
||||
|
||||
LLVector4a x_axis;
|
||||
x_axis.setCross3(binormal4a, normal4a);
|
||||
|
||||
LLQuaternion2 local_rot(LLQuaternion( LLVector3(x_axis.getF32ptr()), LLVector3(binormal4a.getF32ptr()), LLVector3(normal4a.getF32ptr()) ));
|
||||
|
||||
LLMatrix4 vol_mat2(vol_mat.getF32ptr());
|
||||
|
||||
local_rot.mul(LLQuaternion2(vol_mat2.quaternion()));
|
||||
|
||||
*face_rot = LLQuaternion(local_rot.getVector4a().getF32ptr());
|
||||
face_pos->set(vol_mat.getRow<VW>().getF32ptr());
|
||||
}
|
||||
|
||||
// Returns the necessary texture transform to align this face's TE to align_to's TE
|
||||
@@ -1409,7 +1426,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
|
||||
LLGLSLShader* cur_shader = LLGLSLShader::sCurBoundShaderPtr;
|
||||
|
||||
gGL.pushMatrix();
|
||||
gGL.loadMatrix(mat_vert_in.getF32ptr());
|
||||
gGL.loadMatrix(mat_vert_in);
|
||||
|
||||
if (rebuild_pos)
|
||||
{
|
||||
@@ -1551,7 +1568,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
|
||||
LLQuaternion bump_quat;
|
||||
if (mDrawablep->isActive())
|
||||
{
|
||||
bump_quat = LLQuaternion(mDrawablep->getRenderMatrix());
|
||||
bump_quat = LLQuaternion(LLMatrix4(mDrawablep->getRenderMatrix().getF32ptr()));
|
||||
}
|
||||
|
||||
if (bump_code)
|
||||
@@ -1713,16 +1730,12 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
|
||||
else
|
||||
{ //do tex mat, no texgen, no atlas, no bump
|
||||
for (S32 i = 0; i < num_vertices; i++)
|
||||
{
|
||||
LLVector2 tc(vf.mTexCoords[i]);
|
||||
{
|
||||
//LLVector4a& norm = vf.mNormals[i];
|
||||
//LLVector4a& center = *(vf.mCenter);
|
||||
|
||||
LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f);
|
||||
tmp = tmp * *mTextureMatrix;
|
||||
tc.mV[0] = tmp.mV[0];
|
||||
tc.mV[1] = tmp.mV[1];
|
||||
*tex_coords0++ = tc;
|
||||
LLVector4a tc(vf.mTexCoords[i].mV[VX],vf.mTexCoords[i].mV[VY],0.f);
|
||||
mTextureMatrix->affineTransform(tc,tc);
|
||||
(tex_coords0++)->set(tc.getF32ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1740,12 +1753,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
|
||||
vec.mul(scalea);
|
||||
planarProjection(tc, norm, center, vec);
|
||||
|
||||
LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f);
|
||||
tmp = tmp * *mTextureMatrix;
|
||||
tc.mV[0] = tmp.mV[0];
|
||||
tc.mV[1] = tmp.mV[1];
|
||||
|
||||
*tex_coords0++ = tc;
|
||||
LLVector4a tmp(tc.mV[VX],tc.mV[VY],0.f);
|
||||
mTextureMatrix->affineTransform(tmp,tmp);
|
||||
(tex_coords0++)->set(tmp.getF32ptr());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1855,10 +1865,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
|
||||
|
||||
if (tex_mode && mTextureMatrix)
|
||||
{
|
||||
LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f);
|
||||
tmp = tmp * *mTextureMatrix;
|
||||
tc.mV[0] = tmp.mV[0];
|
||||
tc.mV[1] = tmp.mV[1];
|
||||
LLVector4a tmp(tc.mV[VX],tc.mV[VY],0.f);
|
||||
mTextureMatrix->affineTransform(tmp,tmp);
|
||||
tc.set(tmp.getF32ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2053,10 +2062,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
|
||||
|
||||
mVObjp->getVolume()->genTangents(f);
|
||||
|
||||
LLVector4Logical mask;
|
||||
mask.clear();
|
||||
mask.setElement<3>();
|
||||
|
||||
LLVector4a* src = vf.mTangents;
|
||||
LLVector4a* end = vf.mTangents+num_vertices;
|
||||
|
||||
@@ -2065,7 +2070,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
|
||||
LLVector4a tangent_out;
|
||||
mat_normal.rotate(*src, tangent_out);
|
||||
tangent_out.normalize3fast();
|
||||
tangent_out.setSelectWithMask(mask, *src, tangent_out);
|
||||
tangent_out.copyComponent<3>(*src);
|
||||
tangent_out.store4a(tangents);
|
||||
|
||||
src++;
|
||||
@@ -2540,7 +2545,7 @@ S32 LLFace::pushVertices(const U16* index_array) const
|
||||
return mIndicesCount;
|
||||
}
|
||||
|
||||
const LLMatrix4& LLFace::getRenderMatrix() const
|
||||
const LLMatrix4a& LLFace::getRenderMatrix() const
|
||||
{
|
||||
return mDrawablep->getRenderMatrix();
|
||||
}
|
||||
@@ -2556,7 +2561,7 @@ S32 LLFace::renderElements(const U16 *index_array) const
|
||||
else
|
||||
{
|
||||
gGL.pushMatrix();
|
||||
gGL.multMatrix((float*)getRenderMatrix().mMatrix);
|
||||
gGL.multMatrix(getRenderMatrix());
|
||||
ret = pushVertices(index_array);
|
||||
gGL.popMatrix();
|
||||
}
|
||||
@@ -2616,7 +2621,10 @@ LLVector3 LLFace::getPositionAgent() const
|
||||
}
|
||||
else
|
||||
{
|
||||
return mCenterLocal * getRenderMatrix();
|
||||
LLVector4a center_local;
|
||||
center_local.load3(mCenterLocal.mV);
|
||||
getRenderMatrix().affineTransform(center_local,center_local);
|
||||
return LLVector3(center_local.getF32ptr());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,8 +100,8 @@ public:
|
||||
LLFace(LLDrawable* drawablep, LLViewerObject* objp) { init(drawablep, objp); }
|
||||
~LLFace() { destroy(); }
|
||||
|
||||
const LLMatrix4& getWorldMatrix() const { return mVObjp->getWorldMatrix(mXform); }
|
||||
const LLMatrix4& getRenderMatrix() const;
|
||||
const LLMatrix4a& getWorldMatrix() const { return mVObjp->getWorldMatrix(mXform); }
|
||||
const LLMatrix4a& getRenderMatrix() const;
|
||||
U32 getIndicesCount() const { return mIndicesCount; };
|
||||
S32 getIndicesStart() const { return mIndicesIndex; };
|
||||
U16 getGeomCount() const { return mGeomCount; } // vertex count for this face
|
||||
@@ -258,9 +258,7 @@ public:
|
||||
F32 mLastUpdateTime;
|
||||
F32 mLastSkinTime;
|
||||
F32 mLastMoveTime;
|
||||
LLMatrix4* mTextureMatrix;
|
||||
LLMatrix4* mSpecMapMatrix;
|
||||
LLMatrix4* mNormalMapMatrix;
|
||||
LLMatrix4a* mTextureMatrix;
|
||||
LLDrawInfo* mDrawInfo;
|
||||
|
||||
bool mShinyInAlpha;
|
||||
|
||||
@@ -914,7 +914,7 @@ void LLVolumeImplFlexible::updateRelativeXform(bool force_identity)
|
||||
vo->mRelativeXformInvTrans.transpose();
|
||||
}
|
||||
|
||||
const LLMatrix4& LLVolumeImplFlexible::getWorldMatrix(LLXformMatrix* xform) const
|
||||
const LLMatrix4a& LLVolumeImplFlexible::getWorldMatrix(LLXformMatrix* xform) const
|
||||
{
|
||||
return xform->getWorldMatrix();
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ private:
|
||||
bool isVolumeUnique() const { return true; }
|
||||
bool isVolumeGlobal() const { return true; }
|
||||
bool isActive() const { return true; }
|
||||
const LLMatrix4& getWorldMatrix(LLXformMatrix* xform) const;
|
||||
const LLMatrix4a& getWorldMatrix(LLXformMatrix* xform) const;
|
||||
void updateRelativeXform(bool force_identity);
|
||||
void doFlexibleUpdate(); // Called to update the simulation
|
||||
void doFlexibleRebuild(); // Called to rebuild the geometry
|
||||
|
||||
@@ -5090,9 +5090,10 @@ BOOL LLModelPreview::render()
|
||||
}
|
||||
|
||||
gGL.pushMatrix();
|
||||
LLMatrix4 mat = instance.mTransform;
|
||||
LLMatrix4a mat;
|
||||
mat.loadu((F32*)instance.mTransform.mMatrix);
|
||||
|
||||
gGL.multMatrix((GLfloat*) mat.mMatrix);
|
||||
gGL.multMatrix(mat);
|
||||
|
||||
for (U32 i = 0; i < mVertexBuffer[mPreviewLOD][model].size(); ++i)
|
||||
{
|
||||
@@ -5173,9 +5174,10 @@ BOOL LLModelPreview::render()
|
||||
}
|
||||
|
||||
gGL.pushMatrix();
|
||||
LLMatrix4 mat = instance.mTransform;
|
||||
LLMatrix4a mat;
|
||||
mat.loadu((F32*)instance.mTransform.mMatrix);
|
||||
|
||||
gGL.multMatrix((GLfloat*) mat.mMatrix);
|
||||
gGL.multMatrix(mat);
|
||||
|
||||
|
||||
bool render_mesh = true;
|
||||
@@ -5280,9 +5282,10 @@ BOOL LLModelPreview::render()
|
||||
}
|
||||
|
||||
gGL.pushMatrix();
|
||||
LLMatrix4 mat = instance.mTransform;
|
||||
LLMatrix4a mat;
|
||||
mat.loadu((F32*)instance.mTransform.mMatrix);
|
||||
|
||||
gGL.multMatrix((GLfloat*) mat.mMatrix);
|
||||
gGL.multMatrix(mat);
|
||||
|
||||
|
||||
LLPhysicsDecomp* decomp = gMeshRepo.mDecompThread;
|
||||
|
||||
@@ -183,9 +183,12 @@ void LLManipRotate::render()
|
||||
LLMatrix4 mat;
|
||||
mat.initRows(a, b, c, LLVector4(0.f, 0.f, 0.f, 1.f));
|
||||
|
||||
gGL.multMatrix( &mat.mMatrix[0][0] );
|
||||
LLMatrix4a mata;
|
||||
mata.loadu((F32*)mat.mMatrix);
|
||||
gGL.multMatrix( mata );
|
||||
|
||||
gGL.rotatef( -90, 0.f, 1.f, 0.f);
|
||||
static const LLMatrix4a rot = gGL.genRot(-90, 0.f, 1.f, 0.f);
|
||||
gGL.rotatef(rot);
|
||||
LLColor4 color;
|
||||
if (mManipPart == LL_ROT_ROLL || mHighlightedPart == LL_ROT_ROLL)
|
||||
{
|
||||
@@ -253,7 +256,8 @@ void LLManipRotate::render()
|
||||
mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
|
||||
gGL.pushMatrix();
|
||||
{
|
||||
gGL.rotatef( 90.f, 1.f, 0.f, 0.f );
|
||||
static const LLMatrix4a rot = gGL.genRot( 90.f, 1.f, 0.f, 0.f );
|
||||
gGL.rotatef(rot);
|
||||
gGL.scalef(mManipulatorScales.mV[VY], mManipulatorScales.mV[VY], mManipulatorScales.mV[VY]);
|
||||
renderActiveRing( mRadiusMeters, width_meters, LLColor4( 0.f, 1.f, 0.f, 1.f), LLColor4( 0.f, 1.f, 0.f, 0.3f));
|
||||
}
|
||||
@@ -264,7 +268,8 @@ void LLManipRotate::render()
|
||||
mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
|
||||
gGL.pushMatrix();
|
||||
{
|
||||
gGL.rotatef( 90.f, 0.f, 1.f, 0.f );
|
||||
static const LLMatrix4a rot = gGL.genRot( 90.f, 0.f, 1.f, 0.f );
|
||||
gGL.rotatef( rot );
|
||||
gGL.scalef(mManipulatorScales.mV[VX], mManipulatorScales.mV[VX], mManipulatorScales.mV[VX]);
|
||||
renderActiveRing( mRadiusMeters, width_meters, LLColor4( 1.f, 0.f, 0.f, 1.f), LLColor4( 1.f, 0.f, 0.f, 0.3f));
|
||||
}
|
||||
@@ -308,7 +313,8 @@ void LLManipRotate::render()
|
||||
|
||||
gGL.pushMatrix();
|
||||
{
|
||||
gGL.rotatef( 90.f, 1.f, 0.f, 0.f );
|
||||
static const LLMatrix4a rot = gGL.genRot( 90.f, 1.f, 0.f, 0.f );
|
||||
gGL.rotatef( rot );
|
||||
if (mHighlightedPart == LL_ROT_Y)
|
||||
{
|
||||
mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
|
||||
@@ -326,7 +332,8 @@ void LLManipRotate::render()
|
||||
|
||||
gGL.pushMatrix();
|
||||
{
|
||||
gGL.rotatef( 90.f, 0.f, 1.f, 0.f );
|
||||
static const LLMatrix4a rot = gGL.genRot( 90.f, 0.f, 1.f, 0.f );
|
||||
gGL.rotatef( rot );
|
||||
if (mHighlightedPart == LL_ROT_X)
|
||||
{
|
||||
mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
|
||||
|
||||
@@ -429,7 +429,7 @@ void LLManipScale::highlightManipulators(S32 x, S32 y)
|
||||
{
|
||||
LLVector4 translation(bbox.getPositionAgent());
|
||||
transform.initRotTrans(bbox.getRotation(), translation);
|
||||
LLMatrix4 cfr(OGL_TO_CFR_ROTATION);
|
||||
LLMatrix4 cfr(OGL_TO_CFR_ROTATION.getF32ptr());
|
||||
transform *= cfr;
|
||||
LLMatrix4 window_scale;
|
||||
F32 zoom_level = 2.f * gAgentCamera.mHUDCurZoom;
|
||||
@@ -440,8 +440,8 @@ void LLManipScale::highlightManipulators(S32 x, S32 y)
|
||||
}
|
||||
else
|
||||
{
|
||||
LLMatrix4 projMatrix = LLViewerCamera::getInstance()->getProjection();
|
||||
LLMatrix4 modelView = LLViewerCamera::getInstance()->getModelview();
|
||||
LLMatrix4 projMatrix( LLViewerCamera::getInstance()->getProjection().getF32ptr() );
|
||||
LLMatrix4 modelView( LLViewerCamera::getInstance()->getModelview().getF32ptr() );
|
||||
transform.initAll(LLVector3(1.f, 1.f, 1.f), bbox.getRotation(), bbox.getPositionAgent());
|
||||
|
||||
transform *= modelView;
|
||||
|
||||
@@ -807,8 +807,8 @@ void LLManipTranslate::highlightManipulators(S32 x, S32 y)
|
||||
}
|
||||
|
||||
//LLBBox bbox = LLSelectMgr::getInstance()->getBBoxOfSelection();
|
||||
LLMatrix4 projMatrix = LLViewerCamera::getInstance()->getProjection();
|
||||
LLMatrix4 modelView = LLViewerCamera::getInstance()->getModelview();
|
||||
LLMatrix4 projMatrix( LLViewerCamera::getInstance()->getProjection().getF32ptr() );
|
||||
LLMatrix4 modelView( LLViewerCamera::getInstance()->getModelview().getF32ptr() );
|
||||
|
||||
LLVector3 object_position = getPivotPoint();
|
||||
|
||||
@@ -827,7 +827,7 @@ void LLManipTranslate::highlightManipulators(S32 x, S32 y)
|
||||
relative_camera_dir = LLVector3(1.f, 0.f, 0.f) * ~grid_rotation;
|
||||
LLVector4 translation(object_position);
|
||||
transform.initRotTrans(grid_rotation, translation);
|
||||
LLMatrix4 cfr(OGL_TO_CFR_ROTATION);
|
||||
LLMatrix4 cfr(OGL_TO_CFR_ROTATION.getF32ptr());
|
||||
transform *= cfr;
|
||||
LLMatrix4 window_scale;
|
||||
F32 zoom_level = 2.f * gAgentCamera.mHUDCurZoom;
|
||||
@@ -1693,12 +1693,15 @@ void LLManipTranslate::highlightIntersection(LLVector3 normal,
|
||||
normal = -normal;
|
||||
}
|
||||
F32 d = -(selection_center * normal);
|
||||
glh::vec4f plane(normal.mV[0], normal.mV[1], normal.mV[2], d );
|
||||
LLVector4a plane(normal.mV[0], normal.mV[1], normal.mV[2], d );
|
||||
|
||||
gGL.getModelviewMatrix().inverse().mult_vec_matrix(plane);
|
||||
LLMatrix4a inv_mat = gGL.getModelviewMatrix();
|
||||
inv_mat.invert();
|
||||
inv_mat.transpose();
|
||||
inv_mat.rotate4(plane,plane);
|
||||
|
||||
static LLStaticHashedString sClipPlane("clip_plane");
|
||||
gClipProgram.uniform4fv(sClipPlane, 1, plane.v);
|
||||
gClipProgram.uniform4fv(sClipPlane, 1, plane.getF32ptr());
|
||||
|
||||
BOOL particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES);
|
||||
#if ENABLE_CLASSIC_CLOUDS
|
||||
|
||||
@@ -70,8 +70,8 @@
|
||||
#include "lllayoutstack.h"
|
||||
|
||||
// Functions pulled from pipeline.cpp
|
||||
glh::matrix4f glh_get_current_modelview();
|
||||
glh::matrix4f glh_get_current_projection();
|
||||
const LLMatrix4a& glh_get_current_modelview();
|
||||
const LLMatrix4a& glh_get_current_projection();
|
||||
// Functions pulled from llviewerdisplay.cpp
|
||||
bool get_hud_matrices(glh::matrix4f &proj, glh::matrix4f &model);
|
||||
|
||||
@@ -609,37 +609,49 @@ void LLPanelPrimMediaControls::updateShape()
|
||||
vert_it = vect_face.begin();
|
||||
vert_end = vect_face.end();
|
||||
|
||||
glh::matrix4f mat;
|
||||
LLMatrix4a mat;
|
||||
if (!is_hud)
|
||||
{
|
||||
mat = glh_get_current_projection() * glh_get_current_modelview();
|
||||
mat.setMul(glh_get_current_projection(),glh_get_current_modelview());
|
||||
}
|
||||
else {
|
||||
glh::matrix4f proj, modelview;
|
||||
if (get_hud_matrices(proj, modelview))
|
||||
mat = proj * modelview;
|
||||
{
|
||||
//mat = proj * modelview;
|
||||
LLMatrix4a P;
|
||||
P.loadu(proj.m);
|
||||
LLMatrix4a M;
|
||||
M.loadu(modelview.m);
|
||||
mat.setMul(P,M);
|
||||
}
|
||||
}
|
||||
LLVector3 min = LLVector3(1,1,1);
|
||||
LLVector3 max = LLVector3(-1,-1,-1);
|
||||
LLVector4a min;
|
||||
min.splat(1.f);
|
||||
LLVector4a max;
|
||||
max.splat(-1.f);
|
||||
for(; vert_it != vert_end; ++vert_it)
|
||||
{
|
||||
// project silhouette vertices into screen space
|
||||
glh::vec3f screen_vert = glh::vec3f(vert_it->mV);
|
||||
mat.mult_matrix_vec(screen_vert);
|
||||
|
||||
LLVector4a screen_vert;
|
||||
screen_vert.load3(vert_it->mV,1.f);
|
||||
|
||||
mat.perspectiveTransform(screen_vert,screen_vert);
|
||||
|
||||
// add to screenspace bounding box
|
||||
update_min_max(min, max, LLVector3(screen_vert.v));
|
||||
min.setMin(screen_vert,min);
|
||||
max.setMax(screen_vert,max);
|
||||
}
|
||||
|
||||
// convert screenspace bbox to pixels (in screen coords)
|
||||
LLRect window_rect = gViewerWindow->getWorldViewRectScaled();
|
||||
LLCoordGL screen_min;
|
||||
screen_min.mX = llround((F32)window_rect.mLeft + (F32)window_rect.getWidth() * (min.mV[VX] + 1.f) * 0.5f);
|
||||
screen_min.mY = llround((F32)window_rect.mBottom + (F32)window_rect.getHeight() * (min.mV[VY] + 1.f) * 0.5f);
|
||||
screen_min.mX = llround((F32)window_rect.mLeft + (F32)window_rect.getWidth() * (min.getF32ptr()[VX] + 1.f) * 0.5f);
|
||||
screen_min.mY = llround((F32)window_rect.mBottom + (F32)window_rect.getHeight() * (min.getF32ptr()[VY] + 1.f) * 0.5f);
|
||||
|
||||
LLCoordGL screen_max;
|
||||
screen_max.mX = llround((F32)window_rect.mLeft + (F32)window_rect.getWidth() * (max.mV[VX] + 1.f) * 0.5f);
|
||||
screen_max.mY = llround((F32)window_rect.mBottom + (F32)window_rect.getHeight() * (max.mV[VY] + 1.f) * 0.5f);
|
||||
screen_max.mX = llround((F32)window_rect.mLeft + (F32)window_rect.getWidth() * (max.getF32ptr()[VX] + 1.f) * 0.5f);
|
||||
screen_max.mY = llround((F32)window_rect.mBottom + (F32)window_rect.getHeight() * (max.getF32ptr()[VY] + 1.f) * 0.5f);
|
||||
|
||||
// grow panel so that screenspace bounding box fits inside "media_region" element of panel
|
||||
LLRect media_panel_rect;
|
||||
|
||||
@@ -1262,12 +1262,12 @@ void LLSelectMgr::getGrid(LLVector3& origin, LLQuaternion &rotation, LLVector3 &
|
||||
size.setSub(max_extents, min_extents);
|
||||
size.mul(0.5f);
|
||||
|
||||
mGridOrigin.set(center.getF32ptr());
|
||||
LLDrawable* drawable = first_grid_object->mDrawable;
|
||||
if (drawable && drawable->isActive())
|
||||
{
|
||||
mGridOrigin = mGridOrigin * first_grid_object->getRenderMatrix();
|
||||
first_grid_object->getRenderMatrix().affineTransform(center,center);
|
||||
}
|
||||
mGridOrigin.set(center.getF32ptr());
|
||||
mGridScale.set(size.getF32ptr());
|
||||
}
|
||||
}
|
||||
@@ -6119,7 +6119,7 @@ void pushWireframe(LLDrawable* drawable)
|
||||
{
|
||||
LLVertexBuffer::unbind();
|
||||
gGL.pushMatrix();
|
||||
gGL.multMatrix(vobj->getRelativeXform().getF32ptr());
|
||||
gGL.multMatrix(vobj->getRelativeXform());
|
||||
|
||||
LLVolume* volume = NULL;
|
||||
|
||||
@@ -6175,13 +6175,13 @@ void LLSelectNode::renderOneWireframe(const LLColor4& color)
|
||||
|
||||
if (drawable->isActive())
|
||||
{
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
gGL.multMatrix((F32*) objectp->getRenderMatrix().mMatrix);
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.multMatrix(objectp->getRenderMatrix());
|
||||
}
|
||||
else if (!is_hud_object)
|
||||
{
|
||||
gGL.loadIdentity();
|
||||
gGL.multMatrix(gGLModelView.getF32ptr());
|
||||
gGL.multMatrix(gGLModelView);
|
||||
LLVector3 trans = objectp->getRegion()->getOriginAgent();
|
||||
gGL.translatef(trans.mV[0], trans.mV[1], trans.mV[2]);
|
||||
}
|
||||
@@ -6291,13 +6291,13 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color)
|
||||
if (!is_hud_object)
|
||||
{
|
||||
gGL.loadIdentity();
|
||||
gGL.multMatrix(gGLModelView.getF32ptr());
|
||||
gGL.multMatrix(gGLModelView);
|
||||
}
|
||||
|
||||
|
||||
if (drawable->isActive())
|
||||
{
|
||||
gGL.multMatrix((F32*) objectp->getRenderMatrix().mMatrix);
|
||||
gGL.multMatrix(objectp->getRenderMatrix());
|
||||
}
|
||||
|
||||
LLVolume *volume = objectp->getVolume();
|
||||
|
||||
@@ -2917,7 +2917,7 @@ void renderNormals(LLDrawable* drawablep)
|
||||
{
|
||||
LLVolume* volume = vol->getVolume();
|
||||
gGL.pushMatrix();
|
||||
gGL.multMatrix(vol->getRelativeXform().getF32ptr());
|
||||
gGL.multMatrix(vol->getRelativeXform());
|
||||
|
||||
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
|
||||
|
||||
@@ -3071,7 +3071,7 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume)
|
||||
LLVector3 size(0.25f,0.25f,0.25f);
|
||||
|
||||
gGL.pushMatrix();
|
||||
gGL.multMatrix(volume->getRelativeXform().getF32ptr());
|
||||
gGL.multMatrix(volume->getRelativeXform());
|
||||
|
||||
if (type == LLPhysicsShapeBuilderUtil::PhysicsShapeSpecification::USER_MESH)
|
||||
{
|
||||
@@ -3369,7 +3369,7 @@ void renderPhysicsShapes(LLSpatialGroup* group)
|
||||
if (object && object->getPCode() == LLViewerObject::LL_VO_SURFACE_PATCH)
|
||||
{
|
||||
gGL.pushMatrix();
|
||||
gGL.multMatrix((F32*) object->getRegion()->mRenderMatrix.mMatrix);
|
||||
gGL.multMatrix(object->getRegion()->mRenderMatrix);
|
||||
//push face vertices for terrain
|
||||
for (S32 i = 0; i < drawable->getNumFaces(); ++i)
|
||||
{
|
||||
@@ -3683,7 +3683,7 @@ void renderRaycast(LLDrawable* drawablep)
|
||||
|
||||
gGL.pushMatrix();
|
||||
gGL.translatef(trans.mV[0], trans.mV[1], trans.mV[2]);
|
||||
gGL.multMatrix(vobj->getRelativeXform().getF32ptr());
|
||||
gGL.multMatrix(vobj->getRelativeXform());
|
||||
|
||||
LLVector4a start, end;
|
||||
if (transform)
|
||||
@@ -3748,7 +3748,7 @@ void renderRaycast(LLDrawable* drawablep)
|
||||
{
|
||||
// draw intersection point
|
||||
gGL.pushMatrix();
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
LLVector3 translate(gDebugRaycastIntersection.getF32ptr());
|
||||
gGL.translatef(translate.mV[0], translate.mV[1], translate.mV[2]);
|
||||
LLCoordFrame orient;
|
||||
@@ -3760,10 +3760,13 @@ void renderRaycast(LLDrawable* drawablep)
|
||||
LLVector3 normal(gDebugRaycastNormal.getF32ptr());
|
||||
LLVector3 binormal(debug_binormal.getF32ptr());
|
||||
|
||||
//LLCoordFrame isn't vectorized, for now.
|
||||
orient.lookDir(normal, binormal);
|
||||
LLMatrix4 rotation;
|
||||
orient.getRotMatrixToParent(rotation);
|
||||
gGL.multMatrix((float*)rotation.mMatrix);
|
||||
LLMatrix4a rotationa;
|
||||
rotationa.loadu((F32*)rotation.mMatrix);
|
||||
gGL.multMatrix(rotationa);
|
||||
|
||||
gGL.diffuseColor4f(1,0,0,0.5f);
|
||||
drawBox(LLVector3(0, 0, 0), LLVector3(0.1f, 0.022f, 0.022f));
|
||||
@@ -3850,7 +3853,7 @@ public:
|
||||
gGL.flush();
|
||||
gGL.pushMatrix();
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
renderVisibility(group, mCamera);
|
||||
stop_glerror();
|
||||
gGLLastMatrix = NULL;
|
||||
@@ -4330,14 +4333,11 @@ public:
|
||||
|
||||
if (group->mSpatialPartition->isBridge())
|
||||
{
|
||||
LLMatrix4 local_matrix = group->mSpatialPartition->asBridge()->mDrawable->getRenderMatrix();
|
||||
LLMatrix4a local_matrix = group->mSpatialPartition->asBridge()->mDrawable->getRenderMatrix();
|
||||
local_matrix.invert();
|
||||
|
||||
LLMatrix4a local_matrix4a;
|
||||
local_matrix4a.loadu(local_matrix);
|
||||
|
||||
local_matrix4a.affineTransform(mStart, local_start);
|
||||
local_matrix4a.affineTransform(mEnd, local_end);
|
||||
local_matrix.affineTransform(mStart, local_start);
|
||||
local_matrix.affineTransform(mEnd, local_end);
|
||||
}
|
||||
|
||||
if (LLLineSegmentBoxIntersect(local_start, local_end, center, size))
|
||||
|
||||
@@ -109,8 +109,8 @@ public:
|
||||
std::vector<LLPointer<LLViewerTexture> > mTextureList;
|
||||
|
||||
S32 mDebugColor;
|
||||
const LLMatrix4* mTextureMatrix;
|
||||
const LLMatrix4* mModelMatrix;
|
||||
const LLMatrix4a* mTextureMatrix;
|
||||
const LLMatrix4a* mModelMatrix;
|
||||
U16 mStart;
|
||||
U16 mEnd;
|
||||
U32 mCount;
|
||||
|
||||
@@ -77,31 +77,6 @@ glh::matrix4f gl_pick_matrix(GLfloat x, GLfloat y, GLfloat width, GLfloat height
|
||||
return glh::matrix4f(m);
|
||||
}
|
||||
|
||||
glh::matrix4f gl_perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar)
|
||||
{
|
||||
GLfloat f = 1.f/tanf(DEG_TO_RAD*fovy/2.f);
|
||||
|
||||
return glh::matrix4f(f/aspect, 0, 0, 0,
|
||||
0, f, 0, 0,
|
||||
0, 0, (zFar+zNear)/(zNear-zFar), (2.f*zFar*zNear)/(zNear-zFar),
|
||||
0, 0, -1.f, 0);
|
||||
}
|
||||
|
||||
glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up)
|
||||
{
|
||||
LLVector3 f = center-eye;
|
||||
f.normVec();
|
||||
up.normVec();
|
||||
LLVector3 s = f % up;
|
||||
LLVector3 u = s % f;
|
||||
|
||||
return glh::matrix4f(s[0], s[1], s[2], 0,
|
||||
u[0], u[1], u[2], 0,
|
||||
-f[0], -f[1], -f[2], 0,
|
||||
0, 0, 0, 1);
|
||||
|
||||
}
|
||||
|
||||
LLViewerCamera::LLViewerCamera() : LLCamera()
|
||||
{
|
||||
calcProjection(getFar());
|
||||
@@ -171,37 +146,26 @@ void LLViewerCamera::updateCameraLocation(const LLVector3 ¢er,
|
||||
mScreenPixelArea =(S32)((F32)getViewHeightInPixels() * ((F32)getViewHeightInPixels() * getAspect()));
|
||||
}
|
||||
|
||||
const LLMatrix4 &LLViewerCamera::getProjection() const
|
||||
const LLMatrix4a &LLViewerCamera::getProjection() const
|
||||
{
|
||||
calcProjection(getFar());
|
||||
return mProjectionMatrix;
|
||||
|
||||
}
|
||||
|
||||
const LLMatrix4 &LLViewerCamera::getModelview() const
|
||||
const LLMatrix4a &LLViewerCamera::getModelview() const
|
||||
{
|
||||
LLMatrix4 cfr(OGL_TO_CFR_ROTATION);
|
||||
getMatrixToLocal(mModelviewMatrix);
|
||||
mModelviewMatrix *= cfr;
|
||||
LLMatrix4 modelview;
|
||||
getMatrixToLocal(modelview);
|
||||
LLMatrix4a modelviewa;
|
||||
modelviewa.loadu((F32*)modelview.mMatrix);
|
||||
mModelviewMatrix.setMul(OGL_TO_CFR_ROTATION,modelviewa);
|
||||
return mModelviewMatrix;
|
||||
}
|
||||
|
||||
void LLViewerCamera::calcProjection(const F32 far_distance) const
|
||||
{
|
||||
F32 fov_y, z_far, z_near, aspect, f;
|
||||
fov_y = getView();
|
||||
z_far = far_distance;
|
||||
z_near = getNear();
|
||||
aspect = getAspect();
|
||||
|
||||
f = 1/tan(fov_y*0.5f);
|
||||
|
||||
mProjectionMatrix.setZero();
|
||||
mProjectionMatrix.mMatrix[0][0] = f/aspect;
|
||||
mProjectionMatrix.mMatrix[1][1] = f;
|
||||
mProjectionMatrix.mMatrix[2][2] = (z_far + z_near)/(z_near - z_far);
|
||||
mProjectionMatrix.mMatrix[3][2] = (2*z_far*z_near)/(z_near - z_far);
|
||||
mProjectionMatrix.mMatrix[2][3] = -1;
|
||||
mProjectionMatrix = gGL.genPersp( getView()*RAD_TO_DEG, getAspect(), getNear(), far_distance );
|
||||
}
|
||||
|
||||
// Sets up opengl state for 3D drawing. If for selection, also
|
||||
@@ -357,23 +321,23 @@ void LLViewerCamera::setPerspective(BOOL for_selection,
|
||||
|
||||
calcProjection(z_far); // Update the projection matrix cache
|
||||
|
||||
proj_mat *= gl_perspective(fov_y,aspect,z_near,z_far);
|
||||
|
||||
gGL.loadMatrix(proj_mat.m);
|
||||
|
||||
gGLProjection.loadu(proj_mat.m);
|
||||
LLMatrix4a proj_mata;
|
||||
proj_mata.loadu(proj_mat.m);
|
||||
proj_mata.mul(gGL.genPersp(fov_y,aspect,z_near,z_far));
|
||||
|
||||
gGL.loadMatrix(proj_mata);
|
||||
|
||||
gGLProjection = proj_mata;
|
||||
|
||||
gGL.matrixMode(LLRender::MM_MODELVIEW );
|
||||
|
||||
glh::matrix4f modelview((GLfloat*) OGL_TO_CFR_ROTATION);
|
||||
LLMatrix4a ogl_matrix;
|
||||
getOpenGLTransform(ogl_matrix.getF32ptr());
|
||||
|
||||
GLfloat ogl_matrix[16];
|
||||
|
||||
getOpenGLTransform(ogl_matrix);
|
||||
|
||||
modelview *= glh::matrix4f(ogl_matrix);
|
||||
LLMatrix4a modelview;
|
||||
modelview.setMul(OGL_TO_CFR_ROTATION, ogl_matrix);
|
||||
|
||||
gGL.loadMatrix(modelview.m);
|
||||
gGL.loadMatrix(modelview);
|
||||
|
||||
if (for_selection && (width > 1 || height > 1))
|
||||
{
|
||||
@@ -392,7 +356,7 @@ void LLViewerCamera::setPerspective(BOOL for_selection,
|
||||
{
|
||||
// Save GL matrices for access elsewhere in code, especially project_world_to_screen
|
||||
//glGetDoublev(GL_MODELVIEW_MATRIX, gGLModelView);
|
||||
gGLModelView.loadu(modelview.m);
|
||||
glh_set_current_modelview(modelview);
|
||||
}
|
||||
|
||||
updateFrustumPlanes(*this);
|
||||
|
||||
@@ -32,16 +32,17 @@
|
||||
#include "llstat.h"
|
||||
#include "lltimer.h"
|
||||
#include "m4math.h"
|
||||
#include "llmatrix4a.h"
|
||||
#include "llcoord.h"
|
||||
|
||||
class LLViewerObject;
|
||||
|
||||
// This rotation matrix moves the default OpenGL reference frame
|
||||
// (-Z at, Y up) to Cory's favorite reference frame (X at, Z up)
|
||||
const F32 OGL_TO_CFR_ROTATION[16] = { 0.f, 0.f, -1.f, 0.f, // -Z becomes X
|
||||
-1.f, 0.f, 0.f, 0.f, // -X becomes Y
|
||||
0.f, 1.f, 0.f, 0.f, // Y becomes Z
|
||||
0.f, 0.f, 0.f, 1.f };
|
||||
static LL_ALIGN_16(const LLMatrix4a OGL_TO_CFR_ROTATION(LLVector4a( 0.f, 0.f, -1.f, 0.f), // -Z becomes X
|
||||
LLVector4a(-1.f, 0.f, 0.f, 0.f), // -X becomes Y
|
||||
LLVector4a( 0.f, 1.f, 0.f, 0.f), // Y becomes Z
|
||||
LLVector4a( 0.f, 0.f, 0.f, 1.f) ));
|
||||
|
||||
const BOOL FOR_SELECTION = TRUE;
|
||||
const BOOL NOT_FOR_SELECTION = FALSE;
|
||||
@@ -88,8 +89,8 @@ public:
|
||||
static void updateCameraAngle(void* user_data, const LLSD& value);
|
||||
void setPerspective(BOOL for_selection, S32 x, S32 y_from_bot, S32 width, S32 height, BOOL limit_select_distance, F32 z_near = 0, F32 z_far = 0);
|
||||
|
||||
const LLMatrix4 &getProjection() const;
|
||||
const LLMatrix4 &getModelview() const;
|
||||
const LLMatrix4a &getProjection() const;
|
||||
const LLMatrix4a &getModelview() const;
|
||||
|
||||
// Warning! These assume the current global matrices are correct
|
||||
void projectScreenToPosAgent(const S32 screen_x, const S32 screen_y, LLVector3* pos_agent ) const;
|
||||
@@ -137,8 +138,8 @@ protected:
|
||||
F32 mAverageSpeed ;
|
||||
F32 mAverageAngularSpeed ;
|
||||
|
||||
mutable LLMatrix4 mProjectionMatrix; // Cache of perspective matrix
|
||||
mutable LLMatrix4 mModelviewMatrix;
|
||||
mutable LLMatrix4a mProjectionMatrix; // Cache of perspective matrix
|
||||
mutable LLMatrix4a mModelviewMatrix;
|
||||
F32 mCameraFOVDefault;
|
||||
F32 mSavedFOVDefault; // <exodus/>
|
||||
F32 mCosHalfCameraFOV;
|
||||
|
||||
@@ -767,8 +767,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
|
||||
LLGLState::checkTextureChannels();
|
||||
LLGLState::checkClientArrays();
|
||||
|
||||
const LLMatrix4a& proj = glh_get_current_projection();
|
||||
const LLMatrix4a& mod = glh_get_current_modelview();
|
||||
const LLMatrix4a saved_proj = glh_get_current_projection();
|
||||
const LLMatrix4a saved_mod = glh_get_current_modelview();
|
||||
glViewport(0,0,512,512);
|
||||
LLVOAvatar::updateFreezeCounter() ;
|
||||
|
||||
@@ -777,12 +777,12 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
|
||||
LLVOAvatar::updateImpostors();
|
||||
}
|
||||
|
||||
glh_set_current_projection(proj);
|
||||
glh_set_current_modelview(mod);
|
||||
glh_set_current_projection(saved_proj);
|
||||
glh_set_current_modelview(saved_mod);
|
||||
gGL.matrixMode(LLRender::MM_PROJECTION);
|
||||
gGL.loadMatrix(proj.getF32ptr());
|
||||
gGL.loadMatrix(saved_proj);
|
||||
gGL.matrixMode(LLRender::MM_MODELVIEW);
|
||||
gGL.loadMatrix(mod.getF32ptr());
|
||||
gGL.loadMatrix(saved_mod);
|
||||
gViewerWindow->setup3DViewport();
|
||||
|
||||
LLGLState::checkStates();
|
||||
@@ -1272,7 +1272,7 @@ bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::mat
|
||||
LLBBox hud_bbox = gAgentAvatarp->getHUDBBox();
|
||||
|
||||
F32 hud_depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f);
|
||||
proj = gl_ortho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, hud_depth);
|
||||
proj.set_value(gGL.genOrtho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, hud_depth).getF32ptr());
|
||||
proj.element(2,2) = -0.01f;
|
||||
|
||||
F32 aspect_ratio = LLViewerCamera::getInstance()->getAspect();
|
||||
@@ -1287,7 +1287,7 @@ bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::mat
|
||||
0.f));
|
||||
proj *= mat;
|
||||
|
||||
glh::matrix4f tmp_model((GLfloat*) OGL_TO_CFR_ROTATION);
|
||||
glh::matrix4f tmp_model((GLfloat*) OGL_TO_CFR_ROTATION.getF32ptr());
|
||||
|
||||
mat.set_scale(glh::vec3f(zoom_level, zoom_level, zoom_level));
|
||||
mat.set_translate(glh::vec3f(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f));
|
||||
@@ -1327,11 +1327,11 @@ BOOL setup_hud_matrices(const LLRect& screen_region)
|
||||
|
||||
// set up transform to keep HUD objects in front of camera
|
||||
gGL.matrixMode(LLRender::MM_PROJECTION);
|
||||
gGL.loadMatrix(proj.getF32ptr());
|
||||
gGL.loadMatrix(proj);
|
||||
glh_set_current_projection(proj);
|
||||
|
||||
gGL.matrixMode(LLRender::MM_MODELVIEW);
|
||||
gGL.loadMatrix(model.getF32ptr());
|
||||
gGL.loadMatrix(model);
|
||||
glh_set_current_modelview(model);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1347,7 +1347,7 @@ void render_ui(F32 zoom_factor, int subfield, bool tiling)
|
||||
if (!gSnapshot)
|
||||
{
|
||||
gGL.pushMatrix();
|
||||
gGL.loadMatrix(gGLLastModelView.getF32ptr());
|
||||
gGL.loadMatrix(gGLLastModelView);
|
||||
glh_set_current_modelview(gGLLastModelView);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,14 +118,15 @@ void LLViewerJointMesh::uploadJointMatrices()
|
||||
//calculate joint matrices
|
||||
for (joint_num = 0; joint_num < reference_mesh->mJointRenderData.count(); joint_num++)
|
||||
{
|
||||
LLMatrix4 joint_mat = *reference_mesh->mJointRenderData[joint_num]->mWorldMatrix;
|
||||
LLMatrix4a joint_mat = *reference_mesh->mJointRenderData[joint_num]->mWorldMatrix;
|
||||
|
||||
if (hardware_skinning)
|
||||
{
|
||||
joint_mat *= LLDrawPoolAvatar::getModelView();
|
||||
joint_mat.setMul(LLDrawPoolAvatar::getModelView(),joint_mat);
|
||||
//joint_mat *= LLDrawPoolAvatar::getModelView();
|
||||
}
|
||||
gJointMatUnaligned[joint_num] = joint_mat;
|
||||
gJointRotUnaligned[joint_num] = joint_mat.getMat3();
|
||||
gJointMatUnaligned[joint_num] = LLMatrix4(joint_mat.getF32ptr());
|
||||
gJointRotUnaligned[joint_num] = gJointMatUnaligned[joint_num].getMat3();
|
||||
}
|
||||
|
||||
BOOL last_pivot_uploaded = FALSE;
|
||||
@@ -334,8 +335,7 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy)
|
||||
else
|
||||
{
|
||||
gGL.pushMatrix();
|
||||
LLMatrix4 jointToWorld = getWorldMatrix();
|
||||
gGL.multMatrix((GLfloat*)jointToWorld.mMatrix);
|
||||
gGL.multMatrix(getWorldMatrix());
|
||||
buff->setBuffer(mask);
|
||||
buff->drawRange(LLRender::TRIANGLES, start, end, count, offset);
|
||||
gGL.popMatrix();
|
||||
|
||||
@@ -3718,18 +3718,18 @@ const LLQuaternion LLViewerObject::getRenderRotation() const
|
||||
{
|
||||
if (!mDrawable->isRoot())
|
||||
{
|
||||
ret = getRotation() * LLQuaternion(mDrawable->getParent()->getWorldMatrix());
|
||||
ret = getRotation() * LLQuaternion(LLMatrix4(mDrawable->getParent()->getWorldMatrix().getF32ptr()));
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = LLQuaternion(mDrawable->getWorldMatrix());
|
||||
ret = LLQuaternion(mDrawable->getWorldMatrix().getF32ptr());
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
const LLMatrix4 LLViewerObject::getRenderMatrix() const
|
||||
const LLMatrix4a& LLViewerObject::getRenderMatrix() const
|
||||
{
|
||||
return mDrawable->getWorldMatrix();
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ public:
|
||||
const LLQuaternion getRotationRegion() const;
|
||||
const LLQuaternion getRotationEdit() const;
|
||||
const LLQuaternion getRenderRotation() const;
|
||||
virtual const LLMatrix4 getRenderMatrix() const;
|
||||
virtual const LLMatrix4a& getRenderMatrix() const;
|
||||
|
||||
void setPosition(const LLVector3 &pos, BOOL damped = FALSE);
|
||||
void setPositionGlobal(const LLVector3d &position, BOOL damped = FALSE);
|
||||
@@ -298,7 +298,7 @@ public:
|
||||
void setPositionParent(const LLVector3 &pos_parent, BOOL damped = FALSE);
|
||||
void setPositionAbsoluteGlobal( const LLVector3d &pos_global, BOOL damped = FALSE );
|
||||
|
||||
virtual const LLMatrix4& getWorldMatrix(LLXformMatrix* xform) const { return xform->getWorldMatrix(); }
|
||||
virtual const LLMatrix4a& getWorldMatrix(LLXformMatrix* xform) const { return xform->getWorldMatrix(); }
|
||||
|
||||
inline void setRotation(const F32 x, const F32 y, const F32 z, BOOL damped = FALSE);
|
||||
inline void setRotation(const LLQuaternion& quat, BOOL damped = FALSE);
|
||||
|
||||
@@ -320,6 +320,9 @@ LLViewerRegion::LLViewerRegion(const U64 &handle,
|
||||
{
|
||||
// Moved this up... -> mWidth = region_width_meters;
|
||||
// </FS:CR>
|
||||
|
||||
mRenderMatrix.setIdentity();
|
||||
|
||||
mImpl->mOriginGlobal = from_region_handle(handle);
|
||||
updateRenderMatrix();
|
||||
|
||||
@@ -546,7 +549,7 @@ void LLViewerRegion::setOriginGlobal(const LLVector3d &origin_global)
|
||||
|
||||
void LLViewerRegion::updateRenderMatrix()
|
||||
{
|
||||
mRenderMatrix.setTranslation(getOriginAgent());
|
||||
mRenderMatrix.setTranslate_affine(getOriginAgent());
|
||||
}
|
||||
|
||||
void LLViewerRegion::setTimeDilation(F32 time_dilation)
|
||||
|
||||
@@ -114,6 +114,16 @@ public:
|
||||
const F32 region_width_meters);
|
||||
~LLViewerRegion();
|
||||
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
return ll_aligned_malloc_16(size);
|
||||
}
|
||||
|
||||
void operator delete(void* ptr)
|
||||
{
|
||||
ll_aligned_free_16(ptr);
|
||||
}
|
||||
|
||||
// Call this after you have the region name and handle.
|
||||
void loadObjectCache();
|
||||
void saveObjectCache();
|
||||
@@ -400,7 +410,7 @@ public:
|
||||
LLStat mPacketsStat;
|
||||
LLStat mPacketsLostStat;
|
||||
|
||||
LLMatrix4 mRenderMatrix;
|
||||
LL_ALIGN_16(LLMatrix4a mRenderMatrix);
|
||||
|
||||
// These arrays are maintained in parallel. Ideally they'd be combined into a
|
||||
// single array of an aggrigate data type but for compatibility with the old
|
||||
|
||||
@@ -1583,7 +1583,10 @@ const LLVector3 LLVOAvatar::getRenderPosition() const
|
||||
}
|
||||
else
|
||||
{
|
||||
return getPosition() * mDrawable->getParent()->getRenderMatrix();
|
||||
LLVector4a pos;
|
||||
pos.load3(getPosition().mV);
|
||||
mDrawable->getParent()->getRenderMatrix().affineTransform(pos,pos);
|
||||
return LLVector3(pos.getF32ptr());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1641,9 +1644,7 @@ void LLVOAvatar::getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax)
|
||||
LLPolyMesh* mesh = i->second;
|
||||
for (S32 joint_num = 0; joint_num < mesh->mJointRenderData.count(); joint_num++)
|
||||
{
|
||||
LLVector4a trans;
|
||||
trans.load3( mesh->mJointRenderData[joint_num]->mWorldMatrix->getTranslation().mV);
|
||||
update_min_max(newMin, newMax, trans);
|
||||
update_min_max(newMin, newMax, mesh->mJointRenderData[joint_num]->mWorldMatrix->getRow<LLMatrix4a::ROW_TRANS>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1767,7 +1768,7 @@ void LLVOAvatar::renderJoints()
|
||||
jointp->updateWorldMatrix();
|
||||
|
||||
gGL.pushMatrix();
|
||||
gGL.multMatrix( &jointp->getXform()->getWorldMatrix().mMatrix[0][0] );
|
||||
gGL.multMatrix(jointp->getXform()->getWorldMatrix());
|
||||
|
||||
gGL.diffuseColor3f( 1.f, 0.f, 1.f );
|
||||
|
||||
@@ -1856,36 +1857,37 @@ BOOL LLVOAvatar::lineSegmentIntersect(const LLVector4a& start, const LLVector4a&
|
||||
{
|
||||
mCollisionVolumes[i].updateWorldMatrix();
|
||||
|
||||
glh::matrix4f mat((F32*) mCollisionVolumes[i].getXform()->getWorldMatrix().mMatrix);
|
||||
glh::matrix4f inverse = mat.inverse();
|
||||
glh::matrix4f norm_mat = inverse.transpose();
|
||||
const LLMatrix4a& mat = mCollisionVolumes[i].getXform()->getWorldMatrix();
|
||||
LLMatrix4a inverse = mat;
|
||||
inverse.invert();
|
||||
LLMatrix4a norm_mat = inverse;
|
||||
norm_mat.transpose();
|
||||
|
||||
glh::vec3f p1(start.getF32ptr());
|
||||
glh::vec3f p2(end.getF32ptr());
|
||||
|
||||
inverse.mult_matrix_vec(p1);
|
||||
inverse.mult_matrix_vec(p2);
|
||||
LLVector4a p1, p2;
|
||||
inverse.affineTransform(start,p1); //Might need to use perspectiveTransform here.
|
||||
inverse.affineTransform(end,p2);
|
||||
|
||||
LLVector3 position;
|
||||
LLVector3 norm;
|
||||
|
||||
if (linesegment_sphere(LLVector3(p1.v), LLVector3(p2.v), LLVector3(0,0,0), 1.f, position, norm))
|
||||
if (linesegment_sphere(LLVector3(p1.getF32ptr()), LLVector3(p2.getF32ptr()), LLVector3(0,0,0), 1.f, position, norm))
|
||||
{
|
||||
glh::vec3f res_pos(position.mV);
|
||||
mat.mult_matrix_vec(res_pos);
|
||||
|
||||
norm.normalize();
|
||||
glh::vec3f res_norm(norm.mV);
|
||||
norm_mat.mult_matrix_dir(res_norm);
|
||||
|
||||
if (intersection)
|
||||
{
|
||||
intersection->load3(res_pos.v);
|
||||
LLVector4a res_pos;
|
||||
res_pos.load3(position.mV);
|
||||
mat.affineTransform(res_pos,res_pos);
|
||||
*intersection = res_pos;
|
||||
}
|
||||
|
||||
if (normal)
|
||||
{
|
||||
normal->load3(res_norm.v);
|
||||
LLVector4a res_norm;
|
||||
res_norm.load3(norm.mV);
|
||||
res_norm.normalize3fast();
|
||||
norm_mat.perspectiveTransform(res_norm,res_norm);
|
||||
*normal = res_norm;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -4034,7 +4036,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
|
||||
|
||||
}
|
||||
|
||||
LLQuaternion root_rotation = mRoot->getWorldMatrix().quaternion();
|
||||
LLQuaternion root_rotation = LLMatrix4(mRoot->getWorldMatrix().getF32ptr()).quaternion();
|
||||
F32 root_roll, root_pitch, root_yaw;
|
||||
root_rotation.getEulerAngles(&root_roll, &root_pitch, &root_yaw);
|
||||
|
||||
@@ -4051,7 +4053,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
|
||||
// and head turn. Once in motion, it must conform however.
|
||||
BOOL self_in_mouselook = isSelf() && gAgentCamera.cameraMouselook();
|
||||
|
||||
LLVector3 pelvisDir( mRoot->getWorldMatrix().getFwdRow4().mV );
|
||||
LLVector3 pelvisDir( mRoot->getWorldMatrix().getRow<LLMatrix4a::ROW_FWD>().getF32ptr() );
|
||||
|
||||
static const LLCachedControl<F32> s_pelvis_rot_threshold_slow(gSavedSettings, "AvatarRotateThresholdSlow");
|
||||
static const LLCachedControl<F32> s_pelvis_rot_threshold_fast(gSavedSettings, "AvatarRotateThresholdFast");
|
||||
@@ -8764,7 +8766,6 @@ void LLVOAvatar::updateSoftwareSkinnedVertices(const LLMeshSkinInfo* skin, const
|
||||
|
||||
//build matrix palette
|
||||
LLMatrix4a mp[JOINT_COUNT];
|
||||
LLMatrix4* mat = (LLMatrix4*) mp;
|
||||
|
||||
U32 count = llmin((U32) skin->mJointNames.size(), (U32) JOINT_COUNT);
|
||||
|
||||
@@ -8779,8 +8780,9 @@ void LLVOAvatar::updateSoftwareSkinnedVertices(const LLMeshSkinInfo* skin, const
|
||||
}
|
||||
if (joint)
|
||||
{
|
||||
mat[j] = skin->mInvBindMatrix[j];
|
||||
mat[j] *= joint->getWorldMatrix();
|
||||
LLMatrix4a mat;
|
||||
mat.loadu((F32*)skin->mInvBindMatrix[j].mMatrix);
|
||||
mp[j].setMul(joint->getWorldMatrix(),mat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -903,14 +903,12 @@ BOOL LLVOTree::updateGeometry(LLDrawable *drawable)
|
||||
|
||||
void LLVOTree::updateMesh()
|
||||
{
|
||||
LLMatrix4 matrix;
|
||||
|
||||
// Translate to tree base HACK - adjustment in Z plants tree underground
|
||||
const LLVector3 &pos_region = getPositionRegion();
|
||||
//gGL.translatef(pos_agent.mV[VX], pos_agent.mV[VY], pos_agent.mV[VZ] - 0.1f);
|
||||
LLMatrix4 trans_mat;
|
||||
trans_mat.setTranslation(pos_region.mV[VX], pos_region.mV[VY], pos_region.mV[VZ] - 0.1f);
|
||||
trans_mat *= matrix;
|
||||
LLMatrix4a trans_mat;
|
||||
trans_mat.setIdentity();
|
||||
trans_mat.setTranslate_affine(pos_region - LLVector3(0.f,0.f,0.1f));
|
||||
|
||||
// Rotate to tree position and bend for current trunk/wind
|
||||
// Note that trunk stiffness controls the amount of bend at the trunk as
|
||||
@@ -923,16 +921,13 @@ void LLVOTree::updateMesh()
|
||||
LLQuaternion(90.f*DEG_TO_RAD, LLVector4(0,0,1)) *
|
||||
getRotation();
|
||||
|
||||
LLMatrix4 rot_mat(rot);
|
||||
rot_mat *= trans_mat;
|
||||
|
||||
LLMatrix4a rot_mat = trans_mat;
|
||||
rot_mat.mul(LLQuaternion2(rot));
|
||||
|
||||
F32 radius = getScale().magVec()*0.05f;
|
||||
LLMatrix4 scale_mat;
|
||||
scale_mat.mMatrix[0][0] =
|
||||
scale_mat.mMatrix[1][1] =
|
||||
scale_mat.mMatrix[2][2] = radius;
|
||||
|
||||
scale_mat *= rot_mat;
|
||||
LLMatrix4a scale_mat = rot_mat;
|
||||
rot_mat.applyScale_affine(radius);
|
||||
|
||||
// const F32 THRESH_ANGLE_FOR_BILLBOARD = 15.f;
|
||||
// const F32 BLEND_RANGE_FOR_BILLBOARD = 3.f;
|
||||
@@ -953,8 +948,8 @@ void LLVOTree::updateMesh()
|
||||
buff->allocateBuffer(vert_count, index_count, TRUE);
|
||||
facep->setVertexBuffer(buff);
|
||||
|
||||
LLStrider<LLVector3> vertices;
|
||||
LLStrider<LLVector3> normals;
|
||||
LLStrider<LLVector4a> vertices;
|
||||
LLStrider<LLVector4a> normals;
|
||||
LLStrider<LLVector2> tex_coords;
|
||||
LLStrider<U16> indices;
|
||||
U16 idx_offset = 0;
|
||||
@@ -964,26 +959,26 @@ void LLVOTree::updateMesh()
|
||||
buff->getTexCoord0Strider(tex_coords);
|
||||
buff->getIndexStrider(indices);
|
||||
|
||||
genBranchPipeline(vertices, normals, tex_coords, indices, idx_offset, scale_mat, mTrunkLOD, stop_depth, mDepth, mTrunkDepth, 1.0, mTwist, droop, mBranches, alpha);
|
||||
genBranchPipeline(vertices, normals, tex_coords, indices, idx_offset, rot_mat, mTrunkLOD, stop_depth, mDepth, mTrunkDepth, 1.0, mTwist, droop, mBranches, alpha);
|
||||
|
||||
mReferenceBuffer->flush();
|
||||
buff->flush();
|
||||
}
|
||||
|
||||
void LLVOTree::appendMesh(LLStrider<LLVector3>& vertices,
|
||||
LLStrider<LLVector3>& normals,
|
||||
void LLVOTree::appendMesh(LLStrider<LLVector4a>& vertices,
|
||||
LLStrider<LLVector4a>& normals,
|
||||
LLStrider<LLVector2>& tex_coords,
|
||||
LLStrider<U16>& indices,
|
||||
U16& cur_idx,
|
||||
LLMatrix4& matrix,
|
||||
LLMatrix4& norm_mat,
|
||||
LLMatrix4a& matrix,
|
||||
LLMatrix4a& norm_mat,
|
||||
S32 vert_start,
|
||||
S32 vert_count,
|
||||
S32 index_count,
|
||||
S32 index_offset)
|
||||
{
|
||||
LLStrider<LLVector3> v;
|
||||
LLStrider<LLVector3> n;
|
||||
LLStrider<LLVector4a> v;
|
||||
LLStrider<LLVector4a> n;
|
||||
LLStrider<LLVector2> t;
|
||||
LLStrider<U16> idx;
|
||||
|
||||
@@ -996,10 +991,10 @@ void LLVOTree::appendMesh(LLStrider<LLVector3>& vertices,
|
||||
for (S32 i = 0; i < vert_count; i++)
|
||||
{
|
||||
U16 index = vert_start + i;
|
||||
*vertices++ = v[index] * matrix;
|
||||
LLVector3 norm = n[index] * norm_mat;
|
||||
norm.normalize();
|
||||
*normals++ = norm;
|
||||
matrix.affineTransform(v[index],*vertices++);
|
||||
LLVector4a& norm = *normals++;
|
||||
norm_mat.perspectiveTransform(n[index],norm);
|
||||
norm.normalize3fast();
|
||||
*tex_coords++ = t[index];
|
||||
}
|
||||
|
||||
@@ -1015,12 +1010,12 @@ void LLVOTree::appendMesh(LLStrider<LLVector3>& vertices,
|
||||
}
|
||||
|
||||
|
||||
void LLVOTree::genBranchPipeline(LLStrider<LLVector3>& vertices,
|
||||
LLStrider<LLVector3>& normals,
|
||||
void LLVOTree::genBranchPipeline(LLStrider<LLVector4a>& vertices,
|
||||
LLStrider<LLVector4a>& normals,
|
||||
LLStrider<LLVector2>& tex_coords,
|
||||
LLStrider<U16>& indices,
|
||||
U16& index_offset,
|
||||
LLMatrix4& matrix,
|
||||
LLMatrix4a& matrix,
|
||||
S32 trunk_LOD,
|
||||
S32 stop_level,
|
||||
U16 depth,
|
||||
@@ -1049,46 +1044,44 @@ void LLVOTree::genBranchPipeline(LLStrider<LLVector3>& vertices,
|
||||
{
|
||||
llassert(sLODIndexCount[trunk_LOD] > 0);
|
||||
width = scale * length * aspect;
|
||||
LLMatrix4 scale_mat;
|
||||
scale_mat.mMatrix[0][0] = width;
|
||||
scale_mat.mMatrix[1][1] = width;
|
||||
scale_mat.mMatrix[2][2] = scale*length;
|
||||
scale_mat *= matrix;
|
||||
|
||||
glh::matrix4f norm((F32*) scale_mat.mMatrix);
|
||||
LLMatrix4 norm_mat = LLMatrix4(norm.inverse().transpose().m);
|
||||
LLMatrix4a scale_mat = matrix;
|
||||
scale_mat.applyScale_affine(width,width,scale*length);
|
||||
|
||||
LLMatrix4a norm_mat = scale_mat;
|
||||
norm_mat.invert();
|
||||
norm_mat.transpose();
|
||||
|
||||
appendMesh(vertices, normals, tex_coords, indices, index_offset, scale_mat, norm_mat,
|
||||
sLODVertexOffset[trunk_LOD], sLODVertexCount[trunk_LOD], sLODIndexCount[trunk_LOD], sLODIndexOffset[trunk_LOD]);
|
||||
}
|
||||
|
||||
|
||||
LLMatrix4a trans_matrix = matrix;
|
||||
trans_matrix.applyTranslation_affine(0.f,0.f,scale*length);
|
||||
const LLMatrix4a& trans_mat = trans_matrix;
|
||||
|
||||
// Recurse to create more branches
|
||||
for (S32 i=0; i < (S32)branches; i++)
|
||||
{
|
||||
LLMatrix4 trans_mat;
|
||||
trans_mat.setTranslation(0,0,scale*length);
|
||||
trans_mat *= matrix;
|
||||
|
||||
LLQuaternion rot =
|
||||
LLQuaternion(20.f*DEG_TO_RAD, LLVector4(0.f, 0.f, 1.f)) *
|
||||
LLQuaternion(droop*DEG_TO_RAD, LLVector4(0.f, 1.f, 0.f)) *
|
||||
LLQuaternion(((constant_twist + ((i%2==0)?twist:-twist))*i)*DEG_TO_RAD, LLVector4(0.f, 0.f, 1.f));
|
||||
|
||||
LLMatrix4 rot_mat(rot);
|
||||
rot_mat *= trans_mat;
|
||||
|
||||
LLMatrix4a rot_mat = trans_mat;
|
||||
rot_mat.mul(LLQuaternion2(rot));
|
||||
|
||||
genBranchPipeline(vertices, normals, tex_coords, indices, index_offset, rot_mat, trunk_LOD, stop_level, depth - 1, 0, scale*mScaleStep, twist, droop, branches, alpha);
|
||||
}
|
||||
// Recurse to continue trunk
|
||||
if (trunk_depth)
|
||||
{
|
||||
LLMatrix4 trans_mat;
|
||||
trans_mat.setTranslation(0,0,scale*length);
|
||||
trans_mat *= matrix;
|
||||
|
||||
LLMatrix4 rot_mat(70.5f*DEG_TO_RAD, LLVector4(0,0,1));
|
||||
rot_mat *= trans_mat; // rotate a bit around Z when ascending
|
||||
static const LLMatrix4a srot_mat = gGL.genRot(70.5f,0.f,0.f,1.f);
|
||||
LLMatrix4a rot_mat;
|
||||
rot_mat.setMul(trans_mat, srot_mat); // rotate a bit around Z when ascending
|
||||
|
||||
genBranchPipeline(vertices, normals, tex_coords, indices, index_offset, rot_mat, trunk_LOD, stop_level, depth, trunk_depth-1, scale*mScaleStep, twist, droop, branches, alpha);
|
||||
}
|
||||
}
|
||||
@@ -1098,15 +1091,12 @@ void LLVOTree::genBranchPipeline(LLStrider<LLVector3>& vertices,
|
||||
// Append leaves as two 90 deg crossed quads with leaf textures
|
||||
//
|
||||
{
|
||||
LLMatrix4 scale_mat;
|
||||
scale_mat.mMatrix[0][0] =
|
||||
scale_mat.mMatrix[1][1] =
|
||||
scale_mat.mMatrix[2][2] = scale*mLeafScale;
|
||||
LLMatrix4a scale_mat = matrix;
|
||||
scale_mat.applyScale_affine(scale*mLeafScale);
|
||||
|
||||
scale_mat *= matrix;
|
||||
|
||||
glh::matrix4f norm((F32*) scale_mat.mMatrix);
|
||||
LLMatrix4 norm_mat = LLMatrix4(norm.inverse().transpose().m);
|
||||
LLMatrix4a norm_mat = scale_mat;
|
||||
norm_mat.invert();
|
||||
norm_mat.transpose();
|
||||
|
||||
appendMesh(vertices, normals, tex_coords, indices, index_offset, scale_mat, norm_mat, 0, LEAF_VERTICES, LEAF_INDICES, 0);
|
||||
}
|
||||
@@ -1150,7 +1140,7 @@ void LLVOTree::calcNumVerts(U32& vert_count, U32& index_count, S32 trunk_LOD, S3
|
||||
}
|
||||
}
|
||||
|
||||
U32 LLVOTree::drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD, S32 stop_level, U16 depth, U16 trunk_depth, F32 scale, F32 twist, F32 droop, F32 branches, F32 alpha)
|
||||
U32 LLVOTree::drawBranchPipeline(LLMatrix4a& matrix, U16* indicesp, S32 trunk_LOD, S32 stop_level, U16 depth, U16 trunk_depth, F32 scale, F32 twist, F32 droop, F32 branches, F32 alpha)
|
||||
{
|
||||
U32 ret = 0;
|
||||
//
|
||||
@@ -1178,13 +1168,10 @@ U32 LLVOTree::drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD
|
||||
{
|
||||
llassert(sLODIndexCount[trunk_LOD] > 0);
|
||||
width = scale * length * aspect;
|
||||
LLMatrix4 scale_mat;
|
||||
scale_mat.mMatrix[0][0] = width;
|
||||
scale_mat.mMatrix[1][1] = width;
|
||||
scale_mat.mMatrix[2][2] = scale*length;
|
||||
scale_mat *= matrix;
|
||||
LLMatrix4a scale_mat = matrix;
|
||||
scale_mat.applyScale_affine(width, width, scale*length);
|
||||
|
||||
gGL.loadMatrix((F32*) scale_mat.mMatrix);
|
||||
gGL.loadMatrix(scale_mat);
|
||||
gGL.syncMatrices();
|
||||
glDrawElements(GL_TRIANGLES, sLODIndexCount[trunk_LOD], GL_UNSIGNED_SHORT, indicesp + sLODIndexOffset[trunk_LOD]);
|
||||
gPipeline.addTrianglesDrawn(LEAF_INDICES);
|
||||
@@ -1192,32 +1179,31 @@ U32 LLVOTree::drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD
|
||||
ret += sLODIndexCount[trunk_LOD];
|
||||
}
|
||||
|
||||
LLMatrix4a trans_matrix = matrix;
|
||||
trans_matrix.applyTranslation_affine(0.f,0.f,scale*length);
|
||||
const LLMatrix4a& trans_mat = trans_matrix;
|
||||
|
||||
// Recurse to create more branches
|
||||
for (S32 i=0; i < (S32)branches; i++)
|
||||
{
|
||||
LLMatrix4 trans_mat;
|
||||
trans_mat.setTranslation(0,0,scale*length);
|
||||
trans_mat *= matrix;
|
||||
|
||||
LLQuaternion rot =
|
||||
LLQuaternion(20.f*DEG_TO_RAD, LLVector4(0.f, 0.f, 1.f)) *
|
||||
LLQuaternion(droop*DEG_TO_RAD, LLVector4(0.f, 1.f, 0.f)) *
|
||||
LLQuaternion(((constant_twist + ((i%2==0)?twist:-twist))*i)*DEG_TO_RAD, LLVector4(0.f, 0.f, 1.f));
|
||||
|
||||
LLMatrix4 rot_mat(rot);
|
||||
rot_mat *= trans_mat;
|
||||
|
||||
LLMatrix4a rot_mat = trans_mat;
|
||||
rot_mat.mul(LLQuaternion2(rot));
|
||||
|
||||
ret += drawBranchPipeline(rot_mat, indicesp, trunk_LOD, stop_level, depth - 1, 0, scale*mScaleStep, twist, droop, branches, alpha);
|
||||
}
|
||||
// Recurse to continue trunk
|
||||
if (trunk_depth)
|
||||
{
|
||||
LLMatrix4 trans_mat;
|
||||
trans_mat.setTranslation(0,0,scale*length);
|
||||
trans_mat *= matrix;
|
||||
static const LLMatrix4a srot_mat = gGL.genRot(70.5f,0.f,0.f,1.f);
|
||||
LLMatrix4a rot_mat;
|
||||
rot_mat.setMul(trans_mat, srot_mat); // rotate a bit around Z when ascending
|
||||
|
||||
LLMatrix4 rot_mat(70.5f*DEG_TO_RAD, LLVector4(0,0,1));
|
||||
rot_mat *= trans_mat; // rotate a bit around Z when ascending
|
||||
ret += drawBranchPipeline(rot_mat, indicesp, trunk_LOD, stop_level, depth, trunk_depth-1, scale*mScaleStep, twist, droop, branches, alpha);
|
||||
}
|
||||
}
|
||||
@@ -1227,15 +1213,10 @@ U32 LLVOTree::drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD
|
||||
// Draw leaves as two 90 deg crossed quads with leaf textures
|
||||
//
|
||||
{
|
||||
LLMatrix4 scale_mat;
|
||||
scale_mat.mMatrix[0][0] =
|
||||
scale_mat.mMatrix[1][1] =
|
||||
scale_mat.mMatrix[2][2] = scale*mLeafScale;
|
||||
LLMatrix4a scale_mat = matrix;
|
||||
scale_mat.applyScale_affine(scale*mLeafScale);
|
||||
|
||||
scale_mat *= matrix;
|
||||
|
||||
|
||||
gGL.loadMatrix((F32*) scale_mat.mMatrix);
|
||||
gGL.loadMatrix(scale_mat);
|
||||
gGL.syncMatrices();
|
||||
glDrawElements(GL_TRIANGLES, LEAF_INDICES, GL_UNSIGNED_SHORT, indicesp);
|
||||
gPipeline.addTrianglesDrawn(LEAF_INDICES);
|
||||
@@ -1250,18 +1231,14 @@ U32 LLVOTree::drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD
|
||||
// Draw the tree as a single billboard texture
|
||||
//
|
||||
|
||||
LLMatrix4 scale_mat;
|
||||
scale_mat.mMatrix[0][0] =
|
||||
scale_mat.mMatrix[1][1] =
|
||||
scale_mat.mMatrix[2][2] = mBillboardScale*mBillboardRatio;
|
||||
|
||||
scale_mat *= matrix;
|
||||
LLMatrix4a scale_mat = matrix;
|
||||
scale_mat.applyScale_affine(mBillboardScale*mBillboardRatio);
|
||||
|
||||
gGL.matrixMode(LLRender::MM_TEXTURE);
|
||||
gGL.translatef(0.0, -0.5, 0.0);
|
||||
gGL.matrixMode(LLRender::MM_MODELVIEW);
|
||||
|
||||
gGL.loadMatrix((F32*) scale_mat.mMatrix);
|
||||
gGL.loadMatrix(scale_mat);
|
||||
gGL.syncMatrices();
|
||||
glDrawElements(GL_TRIANGLES, LEAF_INDICES, GL_UNSIGNED_SHORT, indicesp);
|
||||
gPipeline.addTrianglesDrawn(LEAF_INDICES);
|
||||
@@ -1370,8 +1347,8 @@ LLTreePartition::LLTreePartition()
|
||||
void LLVOTree::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
|
||||
std::vector<LLVector3> &normals,
|
||||
const LLVector3& obj_cam_vec,
|
||||
const LLMatrix4& local_matrix,
|
||||
const LLMatrix3& normal_matrix)
|
||||
const LLMatrix4a& local_matrix_,
|
||||
const LLMatrix4a& normal_matrix)
|
||||
{
|
||||
vertices.clear();
|
||||
normals.clear();
|
||||
@@ -1379,6 +1356,8 @@ void LLVOTree::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
|
||||
F32 height = mBillboardScale; // *mBillboardRatio * 0.5;
|
||||
F32 width = height * mTrunkAspect;
|
||||
|
||||
LLMatrix4 local_matrix(local_matrix_.getF32ptr());
|
||||
|
||||
LLVector3 position1 = LLVector3(-width * 0.5, 0, 0) * local_matrix;
|
||||
LLVector3 position2 = LLVector3(-width * 0.5, 0, height) * local_matrix;
|
||||
LLVector3 position3 = LLVector3(width * 0.5, 0, height) * local_matrix;
|
||||
@@ -1468,9 +1447,13 @@ void LLVOTree::generateSilhouette(LLSelectNode* nodep, const LLVector3& view_poi
|
||||
// compose final matrix
|
||||
LLMatrix4 local_matrix;
|
||||
local_matrix.initAll(scale, rotation, position);
|
||||
LLMatrix4a lmat;
|
||||
lmat.loadu(local_matrix);
|
||||
LLMatrix4a nmat;
|
||||
nmat.setIdentity();
|
||||
|
||||
generateSilhouetteVertices(nodep->mSilhouetteVertices, nodep->mSilhouetteNormals,
|
||||
LLVector3(0, 0, 0), local_matrix, LLMatrix3());
|
||||
LLVector3(0, 0, 0), lmat, nmat);
|
||||
|
||||
nodep->mSilhouetteExists = TRUE;
|
||||
}
|
||||
|
||||
@@ -85,24 +85,24 @@ public:
|
||||
|
||||
void updateMesh();
|
||||
|
||||
void appendMesh(LLStrider<LLVector3>& vertices,
|
||||
LLStrider<LLVector3>& normals,
|
||||
void appendMesh(LLStrider<LLVector4a>& vertices,
|
||||
LLStrider<LLVector4a>& normals,
|
||||
LLStrider<LLVector2>& tex_coords,
|
||||
LLStrider<U16>& indices,
|
||||
U16& idx_offset,
|
||||
LLMatrix4& matrix,
|
||||
LLMatrix4& norm_mat,
|
||||
LLMatrix4a& matrix,
|
||||
LLMatrix4a& norm_mat,
|
||||
S32 vertex_offset,
|
||||
S32 vertex_count,
|
||||
S32 index_count,
|
||||
S32 index_offset);
|
||||
|
||||
void genBranchPipeline(LLStrider<LLVector3>& vertices,
|
||||
LLStrider<LLVector3>& normals,
|
||||
void genBranchPipeline(LLStrider<LLVector4a>& vertices,
|
||||
LLStrider<LLVector4a>& normals,
|
||||
LLStrider<LLVector2>& tex_coords,
|
||||
LLStrider<U16>& indices,
|
||||
U16& index_offset,
|
||||
LLMatrix4& matrix,
|
||||
LLMatrix4a& matrix,
|
||||
S32 trunk_LOD,
|
||||
S32 stop_level,
|
||||
U16 depth,
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
F32 branches,
|
||||
F32 alpha);
|
||||
|
||||
U32 drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD, S32 stop_level, U16 depth, U16 trunk_depth, F32 scale, F32 twist, F32 droop, F32 branches, F32 alpha);
|
||||
U32 drawBranchPipeline(LLMatrix4a& matrix, U16* indicesp, S32 trunk_LOD, S32 stop_level, U16 depth, U16 trunk_depth, F32 scale, F32 twist, F32 droop, F32 branches, F32 alpha);
|
||||
|
||||
|
||||
/*virtual*/ BOOL lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end,
|
||||
@@ -210,8 +210,8 @@ private:
|
||||
void generateSilhouetteVertices(std::vector<LLVector3> &vertices,
|
||||
std::vector<LLVector3> &normals,
|
||||
const LLVector3& view_vec,
|
||||
const LLMatrix4& mat,
|
||||
const LLMatrix3& norm_mat);
|
||||
const LLMatrix4a& mat,
|
||||
const LLMatrix4a& norm_mat);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -557,29 +557,28 @@ void LLVOVolume::animateTextures()
|
||||
|
||||
if (!facep->mTextureMatrix)
|
||||
{
|
||||
facep->mTextureMatrix = new LLMatrix4();
|
||||
facep->mTextureMatrix = new LLMatrix4a();
|
||||
}
|
||||
|
||||
LLMatrix4& tex_mat = *facep->mTextureMatrix;
|
||||
LLMatrix4a& tex_mat = *facep->mTextureMatrix;
|
||||
tex_mat.setIdentity();
|
||||
LLVector3 trans ;
|
||||
{
|
||||
trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f));
|
||||
tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f));
|
||||
trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f));
|
||||
tex_mat.setTranslate_affine(LLVector3(-0.5f, -0.5f, 0.f));
|
||||
}
|
||||
|
||||
LLVector3 scale(scale_s, scale_t, 1.f);
|
||||
LLQuaternion quat;
|
||||
quat.setQuat(rot, 0, 0, -1.f);
|
||||
LLVector3 scale(scale_s, scale_t, 1.f);
|
||||
|
||||
tex_mat.setMul(gGL.genRot(rot*RAD_TO_DEG,0.f,0.f,-1.f),tex_mat); //left mul
|
||||
|
||||
tex_mat.rotate(quat);
|
||||
LLMatrix4a scale_mat;
|
||||
scale_mat.setIdentity();
|
||||
scale_mat.applyScale_affine(scale);
|
||||
tex_mat.setMul(scale_mat, tex_mat); //left mul
|
||||
|
||||
LLMatrix4 mat;
|
||||
mat.initAll(scale, LLQuaternion(), LLVector3());
|
||||
tex_mat *= mat;
|
||||
|
||||
tex_mat.translate(trans);
|
||||
}
|
||||
tex_mat.translate_affine(trans);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1503,93 +1502,53 @@ void LLVOVolume::updateRelativeXform(bool force_identity)
|
||||
{ //rigged volume (which is in agent space) is used for generating bounding boxes etc
|
||||
//inverse of render matrix should go to partition space
|
||||
mRelativeXform = getRenderMatrix();
|
||||
|
||||
F32* dst = (F32*) mRelativeXformInvTrans.mMatrix;
|
||||
F32* src = (F32*) mRelativeXform.mMatrix;
|
||||
dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2];
|
||||
dst[3] = src[4]; dst[4] = src[5]; dst[5] = src[6];
|
||||
dst[6] = src[8]; dst[7] = src[9]; dst[8] = src[10];
|
||||
|
||||
mRelativeXformInvTrans = mRelativeXform;
|
||||
mRelativeXform.invert();
|
||||
mRelativeXformInvTrans.transpose();
|
||||
}
|
||||
else if (drawable->isActive() || force_identity)
|
||||
{
|
||||
// setup relative transforms
|
||||
LLQuaternion delta_rot;
|
||||
LLVector3 delta_pos, delta_scale;
|
||||
|
||||
//matrix from local space to parent relative/global space
|
||||
|
||||
bool use_identity = force_identity || drawable->isSpatialRoot();
|
||||
delta_rot = use_identity ? LLQuaternion() : mDrawable->getRotation();
|
||||
delta_pos = use_identity ? LLVector3(0,0,0) : mDrawable->getPosition();
|
||||
delta_scale = mDrawable->getScale();
|
||||
|
||||
// Vertex transform (4x4)
|
||||
LLVector3 x_axis = LLVector3(delta_scale.mV[VX], 0.f, 0.f) * delta_rot;
|
||||
LLVector3 y_axis = LLVector3(0.f, delta_scale.mV[VY], 0.f) * delta_rot;
|
||||
LLVector3 z_axis = LLVector3(0.f, 0.f, delta_scale.mV[VZ]) * delta_rot;
|
||||
|
||||
mRelativeXform.initRows(LLVector4(x_axis, 0.f),
|
||||
LLVector4(y_axis, 0.f),
|
||||
LLVector4(z_axis, 0.f),
|
||||
LLVector4(delta_pos, 1.f));
|
||||
|
||||
|
||||
// compute inverse transpose for normals
|
||||
// mRelativeXformInvTrans.setRows(x_axis, y_axis, z_axis);
|
||||
// mRelativeXformInvTrans.invert();
|
||||
// mRelativeXformInvTrans.setRows(x_axis, y_axis, z_axis);
|
||||
// grumble - invert is NOT a matrix invert, so we do it by hand:
|
||||
|
||||
LLMatrix3 rot_inverse = LLMatrix3(~delta_rot);
|
||||
|
||||
LLMatrix3 scale_inverse;
|
||||
scale_inverse.setRows(LLVector3(1.0, 0.0, 0.0) / delta_scale.mV[VX],
|
||||
LLVector3(0.0, 1.0, 0.0) / delta_scale.mV[VY],
|
||||
LLVector3(0.0, 0.0, 1.0) / delta_scale.mV[VZ]);
|
||||
|
||||
|
||||
mRelativeXformInvTrans = rot_inverse * scale_inverse;
|
||||
if(use_identity)
|
||||
{
|
||||
mRelativeXform.setIdentity();
|
||||
mRelativeXform.applyScale_affine(mDrawable->getScale());
|
||||
}
|
||||
else
|
||||
{
|
||||
mRelativeXform = LLQuaternion2(mDrawable->getRotation());
|
||||
mRelativeXform.applyScale_affine(mDrawable->getScale());
|
||||
mRelativeXform.setTranslate_affine(mDrawable->getPosition());
|
||||
}
|
||||
|
||||
mRelativeXformInvTrans = mRelativeXform;
|
||||
mRelativeXformInvTrans.invert();
|
||||
mRelativeXformInvTrans.transpose();
|
||||
}
|
||||
else
|
||||
{
|
||||
LLVector3 pos = getPosition();
|
||||
LLVector3 scale = getScale();
|
||||
LLQuaternion rot = getRotation();
|
||||
|
||||
LLVector4a pos;
|
||||
pos.load3(getPosition().mV);
|
||||
LLQuaternion2 rot(getRotation());
|
||||
if (mParent)
|
||||
{
|
||||
pos *= mParent->getRotation();
|
||||
pos += mParent->getPosition();
|
||||
rot *= mParent->getRotation();
|
||||
LLMatrix4a lrot = LLQuaternion2(mParent->getRotation());
|
||||
lrot.rotate(pos,pos);
|
||||
LLVector4a lpos;
|
||||
lpos.load3(mParent->getPosition().mV);
|
||||
pos.add(lpos);
|
||||
rot.mul(LLQuaternion2(mParent->getRotation()));
|
||||
}
|
||||
|
||||
//LLViewerRegion* region = getRegion();
|
||||
//pos += region->getOriginAgent();
|
||||
|
||||
LLVector3 x_axis = LLVector3(scale.mV[VX], 0.f, 0.f) * rot;
|
||||
LLVector3 y_axis = LLVector3(0.f, scale.mV[VY], 0.f) * rot;
|
||||
LLVector3 z_axis = LLVector3(0.f, 0.f, scale.mV[VZ]) * rot;
|
||||
|
||||
mRelativeXform.initRows(LLVector4(x_axis, 0.f),
|
||||
LLVector4(y_axis, 0.f),
|
||||
LLVector4(z_axis, 0.f),
|
||||
LLVector4(pos, 1.f));
|
||||
|
||||
// compute inverse transpose for normals
|
||||
LLMatrix3 rot_inverse = LLMatrix3(~rot);
|
||||
|
||||
LLMatrix3 scale_inverse;
|
||||
scale_inverse.setRows(LLVector3(1.0, 0.0, 0.0) / scale.mV[VX],
|
||||
LLVector3(0.0, 1.0, 0.0) / scale.mV[VY],
|
||||
LLVector3(0.0, 0.0, 1.0) / scale.mV[VZ]);
|
||||
|
||||
|
||||
mRelativeXformInvTrans = rot_inverse * scale_inverse;
|
||||
mRelativeXform = rot;
|
||||
mRelativeXform.applyScale_affine(getScale());
|
||||
mRelativeXform.setTranslate_affine(LLVector3(pos.getF32ptr()));
|
||||
|
||||
mRelativeXformInvTrans = mRelativeXform;
|
||||
mRelativeXformInvTrans.invert();
|
||||
mRelativeXformInvTrans.transpose();
|
||||
}
|
||||
}
|
||||
@@ -3025,10 +2984,10 @@ void LLVOVolume::generateSilhouette(LLSelectNode* nodep, const LLVector3& view_p
|
||||
}
|
||||
|
||||
updateRelativeXform();
|
||||
LLMatrix4 trans_mat = mRelativeXform;
|
||||
LLMatrix4a trans_mat = mRelativeXform;
|
||||
if (mDrawable->isStatic())
|
||||
{
|
||||
trans_mat.translate(getRegion()->getOriginAgent());
|
||||
trans_mat.translate_affine(getRegion()->getOriginAgent());
|
||||
}
|
||||
|
||||
volume->generateSilhouetteVertices(nodep->mSilhouetteVertices, nodep->mSilhouetteNormals, view_vector, trans_mat, mRelativeXformInvTrans, nodep->getTESelectMask());
|
||||
@@ -3075,7 +3034,7 @@ BOOL LLVOVolume::isHUDAttachment() const
|
||||
}
|
||||
|
||||
|
||||
const LLMatrix4 LLVOVolume::getRenderMatrix() const
|
||||
const LLMatrix4a& LLVOVolume::getRenderMatrix() const
|
||||
{
|
||||
if (mDrawable->isActive() && !mDrawable->isRoot())
|
||||
{
|
||||
@@ -3557,7 +3516,7 @@ void LLVOVolume::onShift(const LLVector4a &shift_vector)
|
||||
updateRelativeXform();
|
||||
}
|
||||
|
||||
const LLMatrix4& LLVOVolume::getWorldMatrix(LLXformMatrix* xform) const
|
||||
const LLMatrix4a& LLVOVolume::getWorldMatrix(LLXformMatrix* xform) const
|
||||
{
|
||||
if (mVolumeImpl)
|
||||
{
|
||||
@@ -3917,7 +3876,6 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons
|
||||
|
||||
//build matrix palette
|
||||
LLMatrix4a mp[JOINT_COUNT];
|
||||
LLMatrix4* mat = (LLMatrix4*) mp;
|
||||
|
||||
U32 count = llmin((U32) skin->mJointNames.size(), (U32) JOINT_COUNT);
|
||||
|
||||
@@ -3932,8 +3890,9 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons
|
||||
}
|
||||
if (joint)
|
||||
{
|
||||
mat[j] = skin->mInvBindMatrix[j];
|
||||
mat[j] *= joint->getWorldMatrix();
|
||||
LLMatrix4a mat;
|
||||
mat.loadu((F32*)skin->mInvBindMatrix[j].mMatrix);
|
||||
mp[j].setMul(joint->getWorldMatrix(), mat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4176,13 +4135,13 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
|
||||
return;
|
||||
}
|
||||
|
||||
const LLMatrix4* tex_mat = NULL;
|
||||
const LLMatrix4a* tex_mat = NULL;
|
||||
if (facep->isState(LLFace::TEXTURE_ANIM) && facep->getVirtualSize() > MIN_TEX_ANIM_SIZE)
|
||||
{
|
||||
tex_mat = facep->mTextureMatrix;
|
||||
}
|
||||
|
||||
const LLMatrix4* model_mat = NULL;
|
||||
const LLMatrix4a* model_mat = NULL;
|
||||
|
||||
LLDrawable* drawable = facep->getDrawable();
|
||||
|
||||
@@ -4199,6 +4158,11 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
|
||||
model_mat = &(drawable->getRegion()->mRenderMatrix);
|
||||
}
|
||||
|
||||
if(model_mat && model_mat->isIdentity())
|
||||
{
|
||||
model_mat = NULL;
|
||||
}
|
||||
|
||||
//drawable->getVObj()->setDebugText(llformat("%d", drawable->isState(LLDrawable::ANIMATED_CHILD)));
|
||||
|
||||
LLMaterial* mat = facep->getTextureEntry()->getMaterialParams().get();
|
||||
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
virtual bool isVolumeUnique() const = 0; // Do we need a unique LLVolume instance?
|
||||
virtual bool isVolumeGlobal() const = 0; // Are we in global space?
|
||||
virtual bool isActive() const = 0; // Is this object currently active?
|
||||
virtual const LLMatrix4& getWorldMatrix(LLXformMatrix* xform) const = 0;
|
||||
virtual const LLMatrix4a& getWorldMatrix(LLXformMatrix* xform) const = 0;
|
||||
virtual void updateRelativeXform(bool force_identity = false) = 0;
|
||||
virtual U32 getID() const = 0;
|
||||
virtual void preRebuild() = 0;
|
||||
@@ -113,6 +113,16 @@ public:
|
||||
(1 << LLVertexBuffer::TYPE_COLOR)
|
||||
};
|
||||
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
return ll_aligned_malloc_16(size);
|
||||
}
|
||||
|
||||
void operator delete(void* ptr)
|
||||
{
|
||||
ll_aligned_free_16(ptr);
|
||||
}
|
||||
|
||||
public:
|
||||
LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
|
||||
/*virtual*/ void markDead(); // Override (and call through to parent) to clean up media references
|
||||
@@ -133,9 +143,9 @@ public:
|
||||
/*virtual*/ BOOL setParent(LLViewerObject* parent);
|
||||
S32 getLOD() const { return mLOD; }
|
||||
const LLVector3 getPivotPositionAgent() const;
|
||||
const LLMatrix4& getRelativeXform() const { return mRelativeXform; }
|
||||
const LLMatrix3& getRelativeXformInvTrans() const { return mRelativeXformInvTrans; }
|
||||
/*virtual*/ const LLMatrix4 getRenderMatrix() const;
|
||||
const LLMatrix4a& getRelativeXform() const { return mRelativeXform; }
|
||||
const LLMatrix4a& getRelativeXformInvTrans() const { return mRelativeXformInvTrans; }
|
||||
/*virtual*/ const LLMatrix4a& getRenderMatrix() const;
|
||||
typedef std::map<LLUUID, S32> texture_cost_t;
|
||||
U32 getRenderCost(texture_cost_t &textures) const;
|
||||
/*virtual*/ F32 getStreamingCost(S32* bytes = NULL, S32* visible_bytes = NULL, F32* unscaled_value = NULL) const;
|
||||
@@ -161,7 +171,7 @@ public:
|
||||
BOOL getVolumeChanged() const { return mVolumeChanged; }
|
||||
|
||||
/*virtual*/ F32 getRadius() const { return mVObjRadius; };
|
||||
const LLMatrix4& getWorldMatrix(LLXformMatrix* xform) const;
|
||||
const LLMatrix4a& getWorldMatrix(LLXformMatrix* xform) const;
|
||||
|
||||
void markForUpdate(BOOL priority) { LLViewerObject::markForUpdate(priority); mVolumeChanged = TRUE; }
|
||||
void faceMappingChanged() { mFaceMappingChanged=TRUE; };
|
||||
@@ -365,8 +375,8 @@ private:
|
||||
BOOL mLODChanged;
|
||||
BOOL mSculptChanged;
|
||||
F32 mSpotLightPriority;
|
||||
LLMatrix4 mRelativeXform;
|
||||
LLMatrix3 mRelativeXformInvTrans;
|
||||
LL_ALIGN_16(LLMatrix4a mRelativeXform);
|
||||
LL_ALIGN_16(LLMatrix4a mRelativeXformInvTrans);
|
||||
BOOL mVolumeChanged;
|
||||
F32 mVObjRadius;
|
||||
LLVolumeInterface *mVolumeImpl;
|
||||
|
||||
@@ -390,18 +390,23 @@ void LLWaterParamManager::update(LLViewerCamera * cam)
|
||||
if(gPipeline.canUseVertexShaders())
|
||||
{
|
||||
//transform water plane to eye space
|
||||
glh::vec3f norm(0.f, 0.f, 1.f);
|
||||
glh::vec3f p(0.f, 0.f, gAgent.getRegion()->getWaterHeight()+0.1f);
|
||||
LLVector4a enorm(0.f, 0.f, 1.f);
|
||||
LLVector4a ep(0.f, 0.f, gAgent.getRegion()->getWaterHeight()+0.1f);
|
||||
|
||||
glh::matrix4f mat(gGLModelView.getF32ptr());
|
||||
glh::matrix4f invtrans = mat.inverse().transpose();
|
||||
glh::vec3f enorm;
|
||||
glh::vec3f ep;
|
||||
invtrans.mult_matrix_vec(norm, enorm);
|
||||
enorm.normalize();
|
||||
mat.mult_matrix_vec(p, ep);
|
||||
const LLMatrix4a& mat = gGLModelView;
|
||||
LLMatrix4a invtrans = mat;
|
||||
invtrans.invert();
|
||||
invtrans.transpose();
|
||||
|
||||
mWaterPlane = LLVector4(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm));
|
||||
invtrans.perspectiveTransform(enorm,enorm);
|
||||
enorm.normalize3fast();
|
||||
mat.affineTransform(ep,ep);
|
||||
|
||||
ep.setAllDot3(ep,enorm);
|
||||
ep.negate();
|
||||
enorm.copyComponent<3>(ep);
|
||||
|
||||
mWaterPlane.set(enorm.getF32ptr());
|
||||
|
||||
LLVector3 sunMoonDir;
|
||||
if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -81,13 +81,10 @@ BOOL compute_min_max(LLMatrix4& box, LLVector2& min, LLVector2& max); // Shouldn
|
||||
bool LLRayAABB(const LLVector3 ¢er, const LLVector3 &size, const LLVector3& origin, const LLVector3& dir, LLVector3 &coord, F32 epsilon = 0);
|
||||
BOOL setup_hud_matrices(); // use whole screen to render hud
|
||||
BOOL setup_hud_matrices(const LLRect& screen_region); // specify portion of screen (in pixels) to render hud attachments from (for picking)
|
||||
glh::matrix4f glh_get_current_modelview();
|
||||
void glh_set_current_modelview(const glh::matrix4f& mat);
|
||||
glh::matrix4f glh_get_current_projection();
|
||||
void glh_set_current_projection(glh::matrix4f& mat);
|
||||
glh::matrix4f gl_ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat znear, GLfloat zfar);
|
||||
glh::matrix4f gl_perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar);
|
||||
glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up);
|
||||
const LLMatrix4a& glh_get_current_modelview();
|
||||
void glh_set_current_modelview(const LLMatrix4a& mat);
|
||||
const LLMatrix4a& glh_get_current_projection();
|
||||
void glh_set_current_projection(const LLMatrix4a& mat);
|
||||
|
||||
extern LLFastTimer::DeclareTimer FTM_RENDER_GEOMETRY;
|
||||
extern LLFastTimer::DeclareTimer FTM_RENDER_GRASS;
|
||||
@@ -111,6 +108,7 @@ extern LLFastTimer::DeclareTimer FTM_PIPELINE;
|
||||
extern LLFastTimer::DeclareTimer FTM_CLIENT_COPY;
|
||||
|
||||
|
||||
LL_ALIGN_PREFIX(16)
|
||||
class LLPipeline
|
||||
{
|
||||
public:
|
||||
@@ -305,7 +303,7 @@ public:
|
||||
void generateSunShadow(LLCamera& camera);
|
||||
|
||||
|
||||
void renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera& camera, LLCullResult& result, BOOL use_shader, BOOL use_occlusion, U32 target_width);
|
||||
void renderShadow(const LLMatrix4a& view, const LLMatrix4a& proj, LLCamera& camera, LLCullResult& result, BOOL use_shader, BOOL use_occlusion, U32 target_width);
|
||||
void renderHighlights();
|
||||
void renderDebug();
|
||||
void renderPhysicsDisplay();
|
||||
@@ -637,17 +635,9 @@ public:
|
||||
LLVector3 mShadowFrustOrigin[4];
|
||||
LLCamera mShadowCamera[8];
|
||||
LLVector3 mShadowExtents[4][2];
|
||||
glh::matrix4f mSunShadowMatrix[6];
|
||||
LLMatrix4a mSunShadowMatrix[6];
|
||||
LLMatrix4a mShadowModelview[6];
|
||||
LLMatrix4a mShadowProjection[6];
|
||||
glh::matrix4f mGIMatrix;
|
||||
glh::matrix4f mGIMatrixProj;
|
||||
glh::matrix4f mGIModelview;
|
||||
glh::matrix4f mGIProjection;
|
||||
glh::matrix4f mGINormalMatrix;
|
||||
glh::matrix4f mGIInvProj;
|
||||
LLVector2 mGIRange;
|
||||
F32 mGILightRadius;
|
||||
|
||||
LLPointer<LLDrawable> mShadowSpotLight[2];
|
||||
F32 mSpotLightFade[2];
|
||||
@@ -674,7 +664,7 @@ public:
|
||||
|
||||
LLColor4 mSunDiffuse;
|
||||
LLVector3 mSunDir;
|
||||
LLVector3 mTransformedSunDir;
|
||||
LL_ALIGN_16(LLVector4a mTransformedSunDir);
|
||||
|
||||
BOOL mInitialized;
|
||||
BOOL mVertexShadersEnabled;
|
||||
@@ -846,13 +836,13 @@ public:
|
||||
|
||||
//debug use
|
||||
static U32 sCurRenderPoolType ;
|
||||
};
|
||||
} LL_ALIGN_POSTFIX(16);
|
||||
|
||||
void render_bbox(const LLVector3 &min, const LLVector3 &max);
|
||||
void render_hud_elements();
|
||||
|
||||
extern LLPipeline gPipeline;
|
||||
extern BOOL gDebugPipeline;
|
||||
extern const LLMatrix4* gGLLastMatrix;
|
||||
extern const LLMatrix4a* gGLLastMatrix;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -123,7 +123,7 @@ BOOL QToolAlign::findSelectedManipulator(S32 x, S32 y)
|
||||
{
|
||||
LLVector4 translation(mBBox.getCenterAgent());
|
||||
transform.initRotTrans(mBBox.getRotation(), translation);
|
||||
LLMatrix4 cfr(OGL_TO_CFR_ROTATION);
|
||||
LLMatrix4 cfr(OGL_TO_CFR_ROTATION.getF32ptr());
|
||||
transform *= cfr;
|
||||
LLMatrix4 window_scale;
|
||||
F32 zoom_level = 2.f * gAgentCamera.mHUDCurZoom;
|
||||
@@ -136,8 +136,8 @@ BOOL QToolAlign::findSelectedManipulator(S32 x, S32 y)
|
||||
{
|
||||
transform.initAll(LLVector3(1.f, 1.f, 1.f), mBBox.getRotation(), mBBox.getCenterAgent());
|
||||
|
||||
LLMatrix4 projection_matrix = LLViewerCamera::getInstance()->getProjection();
|
||||
LLMatrix4 model_matrix = LLViewerCamera::getInstance()->getModelview();
|
||||
LLMatrix4 projection_matrix( LLViewerCamera::getInstance()->getProjection().getF32ptr() );
|
||||
LLMatrix4 model_matrix( LLViewerCamera::getInstance()->getModelview().getF32ptr() );
|
||||
|
||||
transform *= model_matrix;
|
||||
transform *= projection_matrix;
|
||||
|
||||
Reference in New Issue
Block a user