Replace gluProjectf/gluUnprojectf with own versions. Also changed gGLModelView/gGLProjection and other related matrices to LLMatrix4a.
This commit is contained in:
29
LICENSES/LEGAL-intel_matrixlib.txt
Normal file
29
LICENSES/LEGAL-intel_matrixlib.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
INTEL LICENSE AGREEMENT
|
||||
|
||||
IMPORTANT - READ BEFORE COPYING OR USING.
|
||||
Do not use or load this library and any associated materials (collectively,
|
||||
the "Software") until you have read the following terms and conditions. By
|
||||
loading or using the Software, you agree to the terms of this Agreement. If
|
||||
you do not wish to so agree, do not use the Software.
|
||||
|
||||
LICENSE: Subject to the restrictions below, Intel Corporation ("Intel")
|
||||
grants to you the permission to use, copy, distribute and prepare derivative
|
||||
works of this Software for any purpose and without fee, provided, that
|
||||
Intel's copyright notice appear in all copies of the Software files.
|
||||
The distribution of derivative works of the Software is also subject to the
|
||||
following limitations: you (i) are solely responsible to your customers for
|
||||
any liability which may arise from the distribution, (ii) do not make any
|
||||
statement that your product is "certified", or that its performance is
|
||||
guaranteed, by Intel, and (iii) do not use Intel's name or trademarks to
|
||||
market your product without written permission.
|
||||
|
||||
EXCLUSION OF ALL WARRANTIES. The Software is provided "AS IS" without any
|
||||
express or implies warranty of any kind including warranties of
|
||||
merchantability, noninfringement, or fitness for a particular purpose.
|
||||
Intel does not warrant or assume responsibility for the accuracy or
|
||||
completeness of any information contained within the Software.
|
||||
As this Software is given free of charge, in no event shall Intel be liable
|
||||
for any damages whatsoever arising out of the use of or inability to use the
|
||||
Software, even if Intel has been adviced of the possibility of such damages.
|
||||
Intel does not assume any responsibility for any errors which may appear in
|
||||
this Software nor any responsibility to update it.
|
||||
@@ -36,6 +36,11 @@ class LLMatrix4a
|
||||
public:
|
||||
LL_ALIGN_16(LLVector4a mMatrix[4]);
|
||||
|
||||
inline F32* getF32ptr()
|
||||
{
|
||||
return mMatrix[0].getF32ptr();
|
||||
}
|
||||
|
||||
inline void clear()
|
||||
{
|
||||
mMatrix[0].clear();
|
||||
@@ -44,13 +49,21 @@ public:
|
||||
mMatrix[3].clear();
|
||||
}
|
||||
|
||||
inline void setIdentity()
|
||||
{
|
||||
static __m128 ones = _mm_set_ps(1.f,0.f,0.f,1.f);
|
||||
mMatrix[0] = _mm_movelh_ps(ones,_mm_setzero_ps());
|
||||
mMatrix[1] = _mm_movehl_ps(_mm_setzero_ps(),ones);
|
||||
mMatrix[2] = _mm_movelh_ps(_mm_setzero_ps(),ones);
|
||||
mMatrix[3] = _mm_movehl_ps(ones,_mm_setzero_ps());
|
||||
}
|
||||
|
||||
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]);
|
||||
|
||||
}
|
||||
|
||||
inline void loadu(const LLMatrix3& src)
|
||||
@@ -61,6 +74,14 @@ public:
|
||||
mMatrix[3].set(0,0,0,1.f);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
inline void add(const LLMatrix4a& rhs)
|
||||
{
|
||||
mMatrix[0].add(rhs.mMatrix[0]);
|
||||
@@ -84,6 +105,14 @@ public:
|
||||
mMatrix[3].setMul(m.mMatrix[3], s);
|
||||
}
|
||||
|
||||
inline void setMul(const LLMatrix4a& m0, const LLMatrix4a& m1)
|
||||
{
|
||||
m0.rotate4(m1.mMatrix[0],mMatrix[0]);
|
||||
m0.rotate4(m1.mMatrix[1],mMatrix[1]);
|
||||
m0.rotate4(m1.mMatrix[2],mMatrix[2]);
|
||||
m0.rotate4(m1.mMatrix[3],mMatrix[3]);
|
||||
}
|
||||
|
||||
inline void setLerp(const LLMatrix4a& a, const LLMatrix4a& b, F32 w)
|
||||
{
|
||||
LLVector4a d0,d1,d2,d3;
|
||||
@@ -158,6 +187,135 @@ public:
|
||||
z.add(mMatrix[3]);
|
||||
res.setAdd(x,z);
|
||||
}
|
||||
|
||||
inline void transpose()
|
||||
{
|
||||
__m128 q1 = _mm_unpackhi_ps(mMatrix[0],mMatrix[1]);
|
||||
__m128 q2 = _mm_unpacklo_ps(mMatrix[0],mMatrix[1]);
|
||||
__m128 q3 = _mm_unpacklo_ps(mMatrix[2],mMatrix[3]);
|
||||
__m128 q4 = _mm_unpackhi_ps(mMatrix[2],mMatrix[3]);
|
||||
|
||||
mMatrix[0] = _mm_movelh_ps(q2,q3);
|
||||
mMatrix[1] = _mm_movehl_ps(q3,q2);
|
||||
mMatrix[2] = _mm_movelh_ps(q1,q4);
|
||||
mMatrix[3] = _mm_movehl_ps(q4,q1);
|
||||
}
|
||||
|
||||
// Following procedure adapted from:
|
||||
// http://software.intel.com/en-us/articles/optimized-matrix-library-for-use-with-the-intel-pentiumr-4-processors-sse2-instructions/
|
||||
//
|
||||
// License/Copyright Statement:
|
||||
//
|
||||
// Copyright (c) 2001 Intel Corporation.
|
||||
//
|
||||
// Permition is granted to use, copy, distribute and prepare derivative works
|
||||
// of this library for any purpose and without fee, provided, that the above
|
||||
// copyright notice and this statement appear in all copies.
|
||||
// Intel makes no representations about the suitability of this library for
|
||||
// any purpose, and specifically disclaims all warranties.
|
||||
// See LEGAL-intel_matrixlib.TXT for all the legal information.
|
||||
inline float invert()
|
||||
{
|
||||
LL_ALIGN_16(const unsigned int Sign_PNNP[4]) = { 0x00000000, 0x80000000, 0x80000000, 0x00000000 };
|
||||
|
||||
// The inverse is calculated using "Divide and Conquer" technique. The
|
||||
// original matrix is divide into four 2x2 sub-matrices. Since each
|
||||
// register holds four matrix element, the smaller matrices are
|
||||
// represented as a registers. Hence we get a better locality of the
|
||||
// calculations.
|
||||
|
||||
LLVector4a A = _mm_movelh_ps(mMatrix[0], mMatrix[1]), // the four sub-matrices
|
||||
B = _mm_movehl_ps(mMatrix[1], mMatrix[0]),
|
||||
C = _mm_movelh_ps(mMatrix[2], mMatrix[3]),
|
||||
D = _mm_movehl_ps(mMatrix[3], mMatrix[2]);
|
||||
LLVector4a iA, iB, iC, iD, // partial inverse of the sub-matrices
|
||||
DC, AB;
|
||||
LLSimdScalar dA, dB, dC, dD; // determinant of the sub-matrices
|
||||
LLSimdScalar det, d, d1, d2;
|
||||
LLVector4a rd;
|
||||
|
||||
// AB = A# * B
|
||||
AB.setMul(_mm_shuffle_ps(A,A,0x0F), B);
|
||||
AB.sub(_mm_mul_ps(_mm_shuffle_ps(A,A,0xA5), _mm_shuffle_ps(B,B,0x4E)));
|
||||
// DC = D# * C
|
||||
DC.setMul(_mm_shuffle_ps(D,D,0x0F), C);
|
||||
DC.sub(_mm_mul_ps(_mm_shuffle_ps(D,D,0xA5), _mm_shuffle_ps(C,C,0x4E)));
|
||||
|
||||
// dA = |A|
|
||||
dA = _mm_mul_ps(_mm_shuffle_ps(A, A, 0x5F),A);
|
||||
dA -= _mm_movehl_ps(dA,dA);
|
||||
// dB = |B|
|
||||
dB = _mm_mul_ps(_mm_shuffle_ps(B, B, 0x5F),B);
|
||||
dB -= _mm_movehl_ps(dB,dB);
|
||||
|
||||
// dC = |C|
|
||||
dC = _mm_mul_ps(_mm_shuffle_ps(C, C, 0x5F),C);
|
||||
dC -= _mm_movehl_ps(dC,dC);
|
||||
// dD = |D|
|
||||
dD = _mm_mul_ps(_mm_shuffle_ps(D, D, 0x5F),D);
|
||||
dD -= _mm_movehl_ps(dD,dD);
|
||||
|
||||
// d = trace(AB*DC) = trace(A#*B*D#*C)
|
||||
d = _mm_mul_ps(_mm_shuffle_ps(DC,DC,0xD8),AB);
|
||||
|
||||
// iD = C*A#*B
|
||||
iD.setMul(_mm_shuffle_ps(C,C,0xA0), _mm_movelh_ps(AB,AB));
|
||||
iD.add(_mm_mul_ps(_mm_shuffle_ps(C,C,0xF5), _mm_movehl_ps(AB,AB)));
|
||||
// iA = B*D#*C
|
||||
iA.setMul(_mm_shuffle_ps(B,B,0xA0), _mm_movelh_ps(DC,DC));
|
||||
iA.add(_mm_mul_ps(_mm_shuffle_ps(B,B,0xF5), _mm_movehl_ps(DC,DC)));
|
||||
|
||||
// d = trace(AB*DC) = trace(A#*B*D#*C) [continue]
|
||||
d = _mm_add_ps(d, _mm_movehl_ps(d, d));
|
||||
d += _mm_shuffle_ps(d, d, 1);
|
||||
d1 = dA*dD;
|
||||
d2 = dB*dC;
|
||||
|
||||
// iD = D*|A| - C*A#*B
|
||||
iD.setSub(_mm_mul_ps(D,_mm_shuffle_ps(dA,dA,0)), iD);
|
||||
|
||||
// iA = A*|D| - B*D#*C;
|
||||
iA.setSub(_mm_mul_ps(A,_mm_shuffle_ps(dD,dD,0)), iA);
|
||||
|
||||
// det = |A|*|D| + |B|*|C| - trace(A#*B*D#*C)
|
||||
det = d1+d2-d;
|
||||
|
||||
__m128 is_zero_mask = _mm_cmpeq_ps(det,_mm_setzero_ps());
|
||||
rd = _mm_div_ss(_mm_set_ss(1.f),_mm_or_ps(_mm_andnot_ps(is_zero_mask, det), _mm_and_ps(is_zero_mask, _mm_set_ss(1.f))));
|
||||
#ifdef ZERO_SINGULAR
|
||||
rd = _mm_and_ps(_mm_cmpneq_ss(det,_mm_setzero_ps()), rd);
|
||||
#endif
|
||||
|
||||
// iB = D * (A#B)# = D*B#*A
|
||||
iB.setMul(D, _mm_shuffle_ps(AB,AB,0x33));
|
||||
iB.sub(_mm_mul_ps(_mm_shuffle_ps(D,D,0xB1), _mm_shuffle_ps(AB,AB,0x66)));
|
||||
// iC = A * (D#C)# = A*C#*D
|
||||
iC.setMul(A, _mm_shuffle_ps(DC,DC,0x33));
|
||||
iC.sub(_mm_mul_ps(_mm_shuffle_ps(A,A,0xB1), _mm_shuffle_ps(DC,DC,0x66)));
|
||||
|
||||
rd = _mm_shuffle_ps(rd,rd,0);
|
||||
rd = _mm_xor_ps(rd, _mm_load_ps((const float*)Sign_PNNP));
|
||||
|
||||
// iB = C*|B| - D*B#*A
|
||||
iB.setSub(_mm_mul_ps(C,_mm_shuffle_ps(dB,dB,0)), iB);
|
||||
|
||||
// iC = B*|C| - A*C#*D;
|
||||
iC.setSub(_mm_mul_ps(B,_mm_shuffle_ps(dC,dC,0)), iC);
|
||||
|
||||
|
||||
// iX = iX / det
|
||||
iA.mul(rd);
|
||||
iB.mul(rd);
|
||||
iC.mul(rd);
|
||||
iD.mul(rd);
|
||||
|
||||
mMatrix[0] = _mm_shuffle_ps(iA,iB,0x77);
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
#include "llstl.h"
|
||||
#include "llsdserialize.h"
|
||||
#include "llvector4a.h"
|
||||
#include "llmatrix4a.h"
|
||||
#include "lltimer.h"
|
||||
|
||||
#define DEBUG_SILHOUETTE_BINORMALS 0
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "LLConvexDecomposition.h"
|
||||
#include "llsdserialize.h"
|
||||
#include "llvector4a.h"
|
||||
#include "llmatrix4a.h"
|
||||
#if LL_MSVC
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable : 4068)
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "v3dmath.h"
|
||||
#include "m3math.h"
|
||||
#include "m4math.h"
|
||||
#include "llmatrix4a.h"
|
||||
|
||||
#include "llrender.h"
|
||||
#include "llglslshader.h"
|
||||
@@ -265,18 +266,19 @@ void LLCubeMap::setMatrix(S32 stage)
|
||||
gGL.getTexUnit(stage)->activate();
|
||||
}
|
||||
|
||||
LLVector3 x(gGLModelView+0);
|
||||
LLVector3 y(gGLModelView+4);
|
||||
LLVector3 z(gGLModelView+8);
|
||||
LLVector3 x(gGLModelView.mMatrix[0].getF32ptr());
|
||||
LLVector3 y(gGLModelView.mMatrix[1].getF32ptr());
|
||||
LLVector3 z(gGLModelView.mMatrix[2].getF32ptr());
|
||||
|
||||
LLMatrix3 mat3;
|
||||
mat3.setRows(x,y,z);
|
||||
LLMatrix4 trans(mat3);
|
||||
LLMatrix4a trans;
|
||||
trans.loadu(mat3);
|
||||
trans.transpose();
|
||||
|
||||
gGL.matrixMode(LLRender::MM_TEXTURE);
|
||||
gGL.pushMatrix();
|
||||
gGL.loadMatrix((F32 *)trans.mMatrix);
|
||||
gGL.loadMatrix(trans.getF32ptr());
|
||||
gGL.matrixMode(LLRender::MM_MODELVIEW);
|
||||
|
||||
/*if (stage > 0)
|
||||
|
||||
@@ -455,8 +455,6 @@ public:
|
||||
void wait();
|
||||
};
|
||||
|
||||
extern LLMatrix4 gGLObliqueProjectionInverse;
|
||||
|
||||
#include "llglstates.h"
|
||||
|
||||
void init_glstates();
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "llsdutil_math.h"
|
||||
#include "llvertexbuffer.h"
|
||||
#include "llfasttimer.h"
|
||||
#include "llmatrix4a.h"
|
||||
|
||||
extern LLGLSLShader gPostColorFilterProgram;
|
||||
extern LLGLSLShader gPostNightVisionProgram;
|
||||
@@ -305,16 +306,16 @@ public:
|
||||
{
|
||||
addSetting(mStrength);
|
||||
}
|
||||
/*virtual*/ bool isEnabled() const { return LLPostProcessShader::isEnabled() && llabs(gGLModelView[0] - gGLPreviousModelView[0]) > .0000001; }
|
||||
/*virtual*/ bool isEnabled() const { return LLPostProcessShader::isEnabled() && llabs(gGLModelView.getF32ptr()[0] - gGLPreviousModelView.getF32ptr()[0]) > .0000001; }
|
||||
/*virtual*/ S32 getColorChannel() const { return 0; }
|
||||
/*virtual*/ S32 getDepthChannel() const { return 1; }
|
||||
/*virtual*/ QuadType preDraw()
|
||||
{
|
||||
glh::matrix4f inv_proj(gGLModelView);
|
||||
inv_proj.mult_left(gGLProjection);
|
||||
glh::matrix4f inv_proj(gGLModelView.getF32ptr());
|
||||
inv_proj.mult_left(gGLProjection.getF32ptr());
|
||||
inv_proj = inv_proj.inverse();
|
||||
glh::matrix4f prev_proj(gGLPreviousModelView);
|
||||
prev_proj.mult_left(gGLProjection);
|
||||
glh::matrix4f prev_proj(gGLPreviousModelView.getF32ptr());
|
||||
prev_proj.mult_left(gGLProjection.getF32ptr());
|
||||
|
||||
LLVector2 screen_rect = LLPostProcess::getInstance()->getDimensions();
|
||||
|
||||
|
||||
@@ -35,17 +35,18 @@
|
||||
#include "llrendertarget.h"
|
||||
#include "lltexture.h"
|
||||
#include "llshadermgr.h"
|
||||
#include "llmatrix4a.h"
|
||||
|
||||
LLRender gGL;
|
||||
|
||||
// Handy copies of last good GL matrices
|
||||
//Would be best to migrate these to LLMatrix4a and LLVector4a, but that's too divergent right now.
|
||||
LL_ALIGN_16(F32 gGLModelView[16]);
|
||||
LL_ALIGN_16(F32 gGLLastModelView[16]);
|
||||
LL_ALIGN_16(F32 gGLPreviousModelView[16]);
|
||||
LL_ALIGN_16(F32 gGLLastProjection[16]);
|
||||
LL_ALIGN_16(F32 gGLProjection[16]);
|
||||
LL_ALIGN_16(S32 gGLViewport[4]);
|
||||
LLMatrix4a gGLModelView;
|
||||
LLMatrix4a gGLLastModelView;
|
||||
LLMatrix4a gGLPreviousModelView;
|
||||
LLMatrix4a gGLLastProjection;
|
||||
LLMatrix4a gGLProjection;
|
||||
S32 gGLViewport[4];
|
||||
|
||||
U32 LLRender::sUICalls = 0;
|
||||
U32 LLRender::sUIVerts = 0;
|
||||
@@ -1400,6 +1401,120 @@ void LLRender::rotatef(const GLfloat& a, const GLfloat& x, const GLfloat& y, con
|
||||
}
|
||||
}
|
||||
|
||||
//LLRender::projectf & LLRender::unprojectf adapted from gluProject & gluUnproject in Mesa's GLU 9.0 library.
|
||||
// License/Copyright Statement:
|
||||
/*
|
||||
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
||||
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice including the dates of first publication and
|
||||
* either this permission notice or a reference to
|
||||
* http://oss.sgi.com/projects/FreeB/
|
||||
* shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
||||
* shall not be used in advertising or otherwise to promote the sale, use or
|
||||
* other dealings in this Software without prior written authorization from
|
||||
* Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
bool LLRender::projectf(const LLVector3& object, const LLMatrix4a& modelview, const LLMatrix4a& projection, const LLRect& viewport, LLVector3& windowCoordinate)
|
||||
{
|
||||
//Begin SSE intrinsics
|
||||
|
||||
// Declare locals
|
||||
const LLVector4a obj_vector(object.mV[VX],object.mV[VY],object.mV[VZ]);
|
||||
const LLVector4a one(1.f);
|
||||
LLVector4a temp_vec; //Scratch vector
|
||||
LLVector4a w; //Splatted W-component.
|
||||
|
||||
modelview.affineTransform(obj_vector, temp_vec); //temp_vec = modelview * obj_vector;
|
||||
|
||||
//Passing temp_matrix as v and res is safe. res not altered until after all other calculations
|
||||
projection.rotate4(temp_vec, temp_vec); //temp_vec = projection * temp_vec
|
||||
|
||||
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);
|
||||
|
||||
//Map x, y to range 0-1
|
||||
temp_vec.mul(.5f);
|
||||
temp_vec.add(.5f);
|
||||
|
||||
//End SSE intrinsics
|
||||
|
||||
if(temp_vec[VW]==0.f)
|
||||
return false;
|
||||
|
||||
//Window coordinates
|
||||
windowCoordinate[0]=temp_vec[VX]*viewport.getWidth()+viewport.mLeft;
|
||||
windowCoordinate[1]=temp_vec[VY]*viewport.getHeight()+viewport.mBottom;
|
||||
//This is only correct when glDepthRange(0.0, 1.0)
|
||||
windowCoordinate[2]=temp_vec[VZ];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LLRender::unprojectf(const LLVector3& windowCoordinate, const LLMatrix4a& modelview, const LLMatrix4a& projection, const LLRect& viewport, LLVector3& object)
|
||||
{
|
||||
//Begin SSE intrinsics
|
||||
|
||||
// Declare locals
|
||||
static const LLVector4a one(1.f);
|
||||
static const LLVector4a two(2.f);
|
||||
LLVector4a norm_view(
|
||||
((windowCoordinate.mV[VX] - (F32)viewport.mLeft) / (F32)viewport.getWidth()),
|
||||
((windowCoordinate.mV[VY] - (F32)viewport.mBottom) / (F32)viewport.getHeight()),
|
||||
windowCoordinate.mV[VZ],
|
||||
1.f);
|
||||
|
||||
LLMatrix4a inv_mat; //Inverse transformation matrix
|
||||
LLVector4a temp_vec; //Scratch vector
|
||||
LLVector4a w; //Splatted W-component.
|
||||
|
||||
inv_mat.setMul(projection,modelview); //inv_mat = projection*modelview
|
||||
|
||||
float det = inv_mat.invert();
|
||||
|
||||
//Normalize. -1.0 : +1.0
|
||||
norm_view.mul(two); // norm_view *= vec4(.2f)
|
||||
norm_view.sub(one); // norm_view -= vec4(1.f)
|
||||
|
||||
inv_mat.rotate4(norm_view,temp_vec); //inv_mat * norm_view
|
||||
|
||||
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);
|
||||
|
||||
//End SSE intrinsics
|
||||
|
||||
if(det == 0.f || temp_vec[VW]==0.f)
|
||||
return false;
|
||||
|
||||
object.set(temp_vec.getF32ptr());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void LLRender::pushMatrix()
|
||||
{
|
||||
flush();
|
||||
|
||||
@@ -42,14 +42,15 @@
|
||||
#include "llstrider.h"
|
||||
#include "llpointer.h"
|
||||
#include "llglheaders.h"
|
||||
#include "llmatrix4a.h"
|
||||
#include "glh/glh_linear.h"
|
||||
#include "llrect.h"
|
||||
|
||||
class LLVertexBuffer;
|
||||
class LLCubeMap;
|
||||
class LLImageGL;
|
||||
class LLRenderTarget;
|
||||
class LLTexture ;
|
||||
class LLMatrix4a;
|
||||
|
||||
#define LL_MATRIX_STACK_DEPTH 32
|
||||
|
||||
@@ -347,6 +348,8 @@ public:
|
||||
void scalef(const GLfloat& x, const GLfloat& y, const GLfloat& z);
|
||||
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);
|
||||
bool unprojectf(const LLVector3& windowCoordinate, const LLMatrix4a& modelview, const LLMatrix4a& projection, const LLRect& viewport, LLVector3& object);
|
||||
|
||||
void pushMatrix();
|
||||
void popMatrix();
|
||||
@@ -480,11 +483,11 @@ private:
|
||||
LLAlignedArray<LLVector4a, 64> mUIScale;
|
||||
};
|
||||
|
||||
extern F32 gGLModelView[16];
|
||||
extern F32 gGLLastModelView[16];
|
||||
extern F32 gGLLastProjection[16];
|
||||
extern F32 gGLPreviousModelView[16];
|
||||
extern F32 gGLProjection[16];
|
||||
extern LLMatrix4a gGLModelView;
|
||||
extern LLMatrix4a gGLLastModelView;
|
||||
extern LLMatrix4a gGLLastProjection;
|
||||
extern LLMatrix4a gGLPreviousModelView;
|
||||
extern LLMatrix4a gGLProjection;
|
||||
extern S32 gGLViewport[4];
|
||||
|
||||
extern LLRender gGL;
|
||||
|
||||
@@ -28,6 +28,9 @@ class LLFace;
|
||||
class LLPolyMesh;
|
||||
class LLViewerObject;
|
||||
class LLVOAvatar;
|
||||
class LLVolume;
|
||||
class LLVolumeFace;
|
||||
class LLXform;
|
||||
|
||||
typedef std::vector<std::pair<LLVector3, LLVector2> > vert_t;
|
||||
typedef std::vector<LLVector3> vec3_t;
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
#include "llprimitive.h"
|
||||
#include "llurlaction.h"
|
||||
#include "llurlentry.h"
|
||||
#include "llvolumemgr.h"
|
||||
#include "llnotifications.h"
|
||||
#include "llnotificationsutil.h"
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
@@ -445,7 +445,7 @@ void LLRenderPass::applyModelMatrix(LLDrawInfo& params)
|
||||
if (params.mModelMatrix != gGLLastMatrix)
|
||||
{
|
||||
gGLLastMatrix = params.mModelMatrix;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
if (params.mModelMatrix)
|
||||
{
|
||||
llassert(gGL.getMatrixMode() == LLRender::MM_MODELVIEW);
|
||||
|
||||
@@ -159,10 +159,7 @@ LLMatrix4& LLDrawPoolAvatar::getModelView()
|
||||
{
|
||||
static LLMatrix4 ret;
|
||||
|
||||
ret.initRows(LLVector4(gGLModelView+0),
|
||||
LLVector4(gGLModelView+4),
|
||||
LLVector4(gGLModelView+8),
|
||||
LLVector4(gGLModelView+12));
|
||||
ret = LLMatrix4(gGLModelView.getF32ptr());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -373,11 +373,7 @@ void LLDrawPoolBump::bindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& di
|
||||
{
|
||||
if (!invisible && shader )
|
||||
{
|
||||
LLMatrix4 mat;
|
||||
mat.initRows(LLVector4(gGLModelView+0),
|
||||
LLVector4(gGLModelView+4),
|
||||
LLVector4(gGLModelView+8),
|
||||
LLVector4(gGLModelView+12));
|
||||
LLMatrix4 mat(gGLModelView.getF32ptr());
|
||||
LLVector3 vec = LLVector3(gShinyOrigin) * mat;
|
||||
LLVector4 vec4(vec, gShinyOrigin.mV[3]);
|
||||
shader->uniform4fv(LLViewerShaderMgr::SHINY_ORIGIN, 1, vec4.mV);
|
||||
@@ -521,11 +517,7 @@ void LLDrawPoolBump::beginFullbrightShiny()
|
||||
LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL;
|
||||
if( cube_map )
|
||||
{
|
||||
LLMatrix4 mat;
|
||||
mat.initRows(LLVector4(gGLModelView+0),
|
||||
LLVector4(gGLModelView+4),
|
||||
LLVector4(gGLModelView+8),
|
||||
LLVector4(gGLModelView+12));
|
||||
LLMatrix4 mat(gGLModelView.getF32ptr());
|
||||
shader->bind();
|
||||
LLVector3 vec = LLVector3(gShinyOrigin) * mat;
|
||||
LLVector4 vec4(vec, gShinyOrigin.mV[3]);
|
||||
|
||||
@@ -320,7 +320,7 @@ void LLDrawPoolTerrain::drawLoop()
|
||||
{
|
||||
llassert(gGL.getMatrixMode() == LLRender::MM_MODELVIEW);
|
||||
gGLLastMatrix = model_matrix;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
if (model_matrix)
|
||||
{
|
||||
gGL.multMatrix((GLfloat*) model_matrix->mMatrix);
|
||||
|
||||
@@ -125,7 +125,7 @@ void LLDrawPoolTree::render(S32 pass)
|
||||
if (model_matrix != gGLLastMatrix)
|
||||
{
|
||||
gGLLastMatrix = model_matrix;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
if (model_matrix)
|
||||
{
|
||||
llassert(gGL.getMatrixMode() == LLRender::MM_MODELVIEW);
|
||||
@@ -250,10 +250,10 @@ void LLDrawPoolTree::renderTree(BOOL selecting)
|
||||
}
|
||||
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
//gGL.pushMatrix();
|
||||
|
||||
LLMatrix4 matrix(gGLModelView);
|
||||
LLMatrix4 matrix(gGLModelView.getF32ptr());
|
||||
|
||||
// Translate to tree base HACK - adjustment in Z plants tree underground
|
||||
const LLVector3 &pos_agent = treep->getPositionAgent();
|
||||
|
||||
@@ -56,8 +56,6 @@ void hud_render_utf8text(const std::string &str, const LLVector3 &pos_agent,
|
||||
hud_render_text(wstr, pos_agent, font, style, shadow, x_offset, y_offset, color, orthographic);
|
||||
}
|
||||
|
||||
int glProjectf(const LLVector3& object, const F32* modelview, const F32* projection, const LLRect& viewport, LLVector3& windowCoordinate);
|
||||
|
||||
void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent,
|
||||
const LLFontGL &font,
|
||||
const U8 style,
|
||||
@@ -115,7 +113,7 @@ void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent,
|
||||
|
||||
const LLRect& world_view_rect = gViewerWindow->getWorldViewRectRaw();
|
||||
|
||||
glProjectf(render_pos, gGLModelView, gGLProjection, world_view_rect, window_coordinates);
|
||||
gGL.projectf(render_pos, gGLModelView, gGLProjection, world_view_rect, window_coordinates);
|
||||
|
||||
//fonts all render orthographically, set up projection``
|
||||
gGL.matrixMode(LLRender::MM_PROJECTION);
|
||||
|
||||
@@ -6175,13 +6175,13 @@ void LLSelectNode::renderOneWireframe(const LLColor4& color)
|
||||
|
||||
if (drawable->isActive())
|
||||
{
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
gGL.multMatrix((F32*) objectp->getRenderMatrix().mMatrix);
|
||||
}
|
||||
else if (!is_hud_object)
|
||||
{
|
||||
gGL.loadIdentity();
|
||||
gGL.multMatrix(gGLModelView);
|
||||
gGL.multMatrix(gGLModelView.getF32ptr());
|
||||
LLVector3 trans = objectp->getRegion()->getOriginAgent();
|
||||
gGL.translatef(trans.mV[0], trans.mV[1], trans.mV[2]);
|
||||
}
|
||||
@@ -6291,7 +6291,7 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color)
|
||||
if (!is_hud_object)
|
||||
{
|
||||
gGL.loadIdentity();
|
||||
gGL.multMatrix(gGLModelView);
|
||||
gGL.multMatrix(gGLModelView.getF32ptr());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3748,7 +3748,7 @@ void renderRaycast(LLDrawable* drawablep)
|
||||
{
|
||||
// draw intersection point
|
||||
gGL.pushMatrix();
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
LLVector3 translate(gDebugRaycastIntersection.getF32ptr());
|
||||
gGL.translatef(translate.mV[0], translate.mV[1], translate.mV[2]);
|
||||
LLCoordFrame orient;
|
||||
@@ -3850,7 +3850,7 @@ public:
|
||||
gGL.flush();
|
||||
gGL.pushMatrix();
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
renderVisibility(group, mCamera);
|
||||
stop_glerror();
|
||||
gGLLastMatrix = NULL;
|
||||
|
||||
@@ -27,10 +27,9 @@
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
|
||||
#include "llviewercamera.h"
|
||||
|
||||
#include "llagent.h"
|
||||
#include "llagentcamera.h"
|
||||
#include "llmatrix4a.h"
|
||||
|
||||
#include "llviewercontrol.h"
|
||||
#include "llviewerobjectlist.h"
|
||||
#include "llviewerregion.h"
|
||||
@@ -213,59 +212,33 @@ void LLViewerCamera::calcProjection(const F32 far_distance) const
|
||||
//static
|
||||
void LLViewerCamera::updateFrustumPlanes(LLCamera& camera, BOOL ortho, BOOL zflip, BOOL no_hacks)
|
||||
{
|
||||
GLint* viewport = (GLint*) gGLViewport;
|
||||
F64 model[16];
|
||||
F64 proj[16];
|
||||
|
||||
for (U32 i = 0; i < 16; i++)
|
||||
{
|
||||
model[i] = (F64) gGLModelView[i];
|
||||
proj[i] = (F64) gGLProjection[i];
|
||||
}
|
||||
|
||||
GLdouble objX,objY,objZ;
|
||||
|
||||
LLVector3 frust[8];
|
||||
|
||||
LLRect view_port(gGLViewport[0],gGLViewport[1]+gGLViewport[3],gGLViewport[0]+gGLViewport[2],gGLViewport[1]);
|
||||
|
||||
if (no_hacks)
|
||||
{
|
||||
gluUnProject(viewport[0],viewport[1],0,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[0].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gluUnProject(viewport[0]+viewport[2],viewport[1],0,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[1].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gluUnProject(viewport[0]+viewport[2],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[2].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gluUnProject(viewport[0],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[3].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gGL.unprojectf(LLVector3(view_port.mLeft,view_port.mBottom,0.f),gGLModelView,gGLProjection,view_port,frust[0]);
|
||||
gGL.unprojectf(LLVector3(view_port.mRight,view_port.mBottom,0.f),gGLModelView,gGLProjection,view_port,frust[1]);
|
||||
gGL.unprojectf(LLVector3(view_port.mRight,view_port.mTop,0.f),gGLModelView,gGLProjection,view_port,frust[2]);
|
||||
gGL.unprojectf(LLVector3(view_port.mLeft,view_port.mTop,0.f),gGLModelView,gGLProjection,view_port,frust[3]);
|
||||
|
||||
gluUnProject(viewport[0],viewport[1],1,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[4].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gluUnProject(viewport[0]+viewport[2],viewport[1],1,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[5].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gluUnProject(viewport[0]+viewport[2],viewport[1]+viewport[3],1,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[6].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gluUnProject(viewport[0],viewport[1]+viewport[3],1,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[7].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gGL.unprojectf(LLVector3(view_port.mLeft,view_port.mBottom,1.f),gGLModelView,gGLProjection,view_port,frust[4]);
|
||||
gGL.unprojectf(LLVector3(view_port.mRight,view_port.mBottom,1.f),gGLModelView,gGLProjection,view_port,frust[5]);
|
||||
gGL.unprojectf(LLVector3(view_port.mRight,view_port.mTop,1.f),gGLModelView,gGLProjection,view_port,frust[6]);
|
||||
gGL.unprojectf(LLVector3(view_port.mLeft,view_port.mTop,1.f),gGLModelView,gGLProjection,view_port,frust[7]);
|
||||
}
|
||||
else if (zflip)
|
||||
{
|
||||
gluUnProject(viewport[0],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[0].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gluUnProject(viewport[0]+viewport[2],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[1].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gluUnProject(viewport[0]+viewport[2],viewport[1],0,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[2].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gluUnProject(viewport[0],viewport[1],0,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[3].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gGL.unprojectf(LLVector3(view_port.mLeft,view_port.mTop,0.f),gGLModelView,gGLProjection,view_port,frust[0]);
|
||||
gGL.unprojectf(LLVector3(view_port.mRight,view_port.mTop,0.f),gGLModelView,gGLProjection,view_port,frust[1]);
|
||||
gGL.unprojectf(LLVector3(view_port.mRight,view_port.mBottom,0.f),gGLModelView,gGLProjection,view_port,frust[2]);
|
||||
gGL.unprojectf(LLVector3(view_port.mLeft,view_port.mBottom,0.f),gGLModelView,gGLProjection,view_port,frust[3]);
|
||||
|
||||
gluUnProject(viewport[0],viewport[1]+viewport[3],1,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[4].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gluUnProject(viewport[0]+viewport[2],viewport[1]+viewport[3],1,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[5].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gluUnProject(viewport[0]+viewport[2],viewport[1],1,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[6].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gluUnProject(viewport[0],viewport[1],1,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[7].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gGL.unprojectf(LLVector3(view_port.mLeft,view_port.mTop,1.f),gGLModelView,gGLProjection,view_port,frust[4]);
|
||||
gGL.unprojectf(LLVector3(view_port.mRight,view_port.mTop,1.f),gGLModelView,gGLProjection,view_port,frust[5]);
|
||||
gGL.unprojectf(LLVector3(view_port.mRight,view_port.mBottom,1.f),gGLModelView,gGLProjection,view_port,frust[6]);
|
||||
gGL.unprojectf(LLVector3(view_port.mLeft,view_port.mBottom,1.f),gGLModelView,gGLProjection,view_port,frust[7]);
|
||||
|
||||
for (U32 i = 0; i < 4; i++)
|
||||
{
|
||||
@@ -276,14 +249,10 @@ void LLViewerCamera::updateFrustumPlanes(LLCamera& camera, BOOL ortho, BOOL zfli
|
||||
}
|
||||
else
|
||||
{
|
||||
gluUnProject(viewport[0],viewport[1],0,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[0].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gluUnProject(viewport[0]+viewport[2],viewport[1],0,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[1].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gluUnProject(viewport[0]+viewport[2],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[2].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gluUnProject(viewport[0],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ);
|
||||
frust[3].setVec((F32)objX,(F32)objY,(F32)objZ);
|
||||
gGL.unprojectf(LLVector3(view_port.mLeft,view_port.mBottom,0.f),gGLModelView,gGLProjection,view_port,frust[0]);
|
||||
gGL.unprojectf(LLVector3(view_port.mRight,view_port.mBottom,0.f),gGLModelView,gGLProjection,view_port,frust[1]);
|
||||
gGL.unprojectf(LLVector3(view_port.mRight,view_port.mTop,0.f),gGLModelView,gGLProjection,view_port,frust[2]);
|
||||
gGL.unprojectf(LLVector3(view_port.mLeft,view_port.mTop,0.f),gGLModelView,gGLProjection,view_port,frust[3]);
|
||||
|
||||
if (ortho)
|
||||
{
|
||||
@@ -392,10 +361,7 @@ void LLViewerCamera::setPerspective(BOOL for_selection,
|
||||
|
||||
gGL.loadMatrix(proj_mat.m);
|
||||
|
||||
for (U32 i = 0; i < 16; i++)
|
||||
{
|
||||
gGLProjection[i] = proj_mat.m[i];
|
||||
}
|
||||
gGLProjection.loadu(proj_mat.m);
|
||||
|
||||
gGL.matrixMode(LLRender::MM_MODELVIEW );
|
||||
|
||||
@@ -426,10 +392,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);
|
||||
for (U32 i = 0; i < 16; i++)
|
||||
{
|
||||
gGLModelView[i] = modelview.m[i];
|
||||
}
|
||||
gGLModelView.loadu(modelview.m);
|
||||
}
|
||||
|
||||
updateFrustumPlanes(*this);
|
||||
@@ -443,89 +406,14 @@ void LLViewerCamera::setPerspective(BOOL for_selection,
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
// Uses the last GL matrices set in set_perspective to project a point from
|
||||
// screen coordinates to the agent's region.
|
||||
void LLViewerCamera::projectScreenToPosAgent(const S32 screen_x, const S32 screen_y, LLVector3* pos_agent) const
|
||||
{
|
||||
GLdouble x, y, z;
|
||||
|
||||
F64 mdlv[16];
|
||||
F64 proj[16];
|
||||
|
||||
for (U32 i = 0; i < 16; i++)
|
||||
{
|
||||
mdlv[i] = (F64) gGLModelView[i];
|
||||
proj[i] = (F64) gGLProjection[i];
|
||||
}
|
||||
|
||||
gluUnProject(
|
||||
GLdouble(screen_x), GLdouble(screen_y), 0.0,
|
||||
mdlv, proj, (GLint*)gGLViewport,
|
||||
&x,
|
||||
&y,
|
||||
&z );
|
||||
pos_agent->setVec( (F32)x, (F32)y, (F32)z );
|
||||
}
|
||||
|
||||
//Based off of http://www.opengl.org/wiki/GluProject_and_gluUnProject_code
|
||||
int glProjectf(const LLVector3& object, const F32* modelview, const F32* projection, const LLRect& viewport, LLVector3& windowCoordinate)
|
||||
{
|
||||
const LLVector4a obj_vector(object.mV[VX],object.mV[VY],object.mV[VZ]);
|
||||
LLVector4a temp_matrix;
|
||||
|
||||
const LLMatrix4a &view_matrix=*(LLMatrix4a*)modelview;
|
||||
const LLMatrix4a &proj_matrix=*(LLMatrix4a*)projection;
|
||||
|
||||
view_matrix.affineTransform(obj_vector, temp_matrix);
|
||||
|
||||
//Passing temp_matrix as v and res is safe. res not altered until after all other calculations
|
||||
proj_matrix.rotate4(temp_matrix, temp_matrix);
|
||||
|
||||
if(temp_matrix[VW]==0.0)
|
||||
return 0;
|
||||
|
||||
temp_matrix.div(temp_matrix[VW]);
|
||||
|
||||
//Map x, y to range 0-1
|
||||
temp_matrix.mul(.5f);
|
||||
temp_matrix.add(.5f);
|
||||
|
||||
//Window coordinates
|
||||
windowCoordinate[0]=temp_matrix[VX]*viewport.getWidth()+viewport.mLeft;
|
||||
windowCoordinate[1]=temp_matrix[VY]*viewport.getHeight()+viewport.mBottom;
|
||||
//This is only correct when glDepthRange(0.0, 1.0)
|
||||
windowCoordinate[2]=temp_matrix[VZ];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void MultiplyMatrices4by4OpenGL_FLOAT(LLMatrix4a& dest_matrix, const LLMatrix4a& input_matrix1, const LLMatrix4a& input_matrix2)
|
||||
{
|
||||
input_matrix1.rotate4(input_matrix2.mMatrix[VX],dest_matrix.mMatrix[VX]);
|
||||
input_matrix1.rotate4(input_matrix2.mMatrix[VY],dest_matrix.mMatrix[VY]);
|
||||
input_matrix1.rotate4(input_matrix2.mMatrix[VZ],dest_matrix.mMatrix[VZ]);
|
||||
input_matrix1.rotate4(input_matrix2.mMatrix[VW],dest_matrix.mMatrix[VW]);
|
||||
|
||||
//Those four lines do this:
|
||||
/*
|
||||
result[0]=matrix1[0]*matrix2[0]+matrix1[4]*matrix2[1]+matrix1[8]*matrix2[2]+matrix1[12]*matrix2[3];
|
||||
result[1]=matrix1[1]*matrix2[0]+matrix1[5]*matrix2[1]+matrix1[9]*matrix2[2]+matrix1[13]*matrix2[3];
|
||||
result[2]=matrix1[2]*matrix2[0]+matrix1[6]*matrix2[1]+matrix1[10]*matrix2[2]+matrix1[14]*matrix2[3];
|
||||
result[3]=matrix1[3]*matrix2[0]+matrix1[7]*matrix2[1]+matrix1[11]*matrix2[2]+matrix1[15]*matrix2[3];
|
||||
result[4]=matrix1[0]*matrix2[4]+matrix1[4]*matrix2[5]+matrix1[8]*matrix2[6]+matrix1[12]*matrix2[7];
|
||||
result[5]=matrix1[1]*matrix2[4]+matrix1[5]*matrix2[5]+matrix1[9]*matrix2[6]+matrix1[13]*matrix2[7];
|
||||
result[6]=matrix1[2]*matrix2[4]+matrix1[6]*matrix2[5]+matrix1[10]*matrix2[6]+matrix1[14]*matrix2[7];
|
||||
result[7]=matrix1[3]*matrix2[4]+matrix1[7]*matrix2[5]+matrix1[11]*matrix2[6]+matrix1[15]*matrix2[7];
|
||||
result[8]=matrix1[0]*matrix2[8]+matrix1[4]*matrix2[9]+matrix1[8]*matrix2[10]+matrix1[12]*matrix2[11];
|
||||
result[9]=matrix1[1]*matrix2[8]+matrix1[5]*matrix2[9]+matrix1[9]*matrix2[10]+matrix1[13]*matrix2[11];
|
||||
result[10]=matrix1[2]*matrix2[8]+matrix1[6]*matrix2[9]+matrix1[10]*matrix2[10]+matrix1[14]*matrix2[11];
|
||||
result[11]=matrix1[3]*matrix2[8]+matrix1[7]*matrix2[9]+matrix1[11]*matrix2[10]+matrix1[15]*matrix2[11];
|
||||
result[12]=matrix1[0]*matrix2[12]+matrix1[4]*matrix2[13]+matrix1[8]*matrix2[14]+matrix1[12]*matrix2[15];
|
||||
result[13]=matrix1[1]*matrix2[12]+matrix1[5]*matrix2[13]+matrix1[9]*matrix2[14]+matrix1[13]*matrix2[15];
|
||||
result[14]=matrix1[2]*matrix2[12]+matrix1[6]*matrix2[13]+matrix1[10]*matrix2[14]+matrix1[14]*matrix2[15];
|
||||
result[15]=matrix1[3]*matrix2[12]+ matrix1[7]*matrix2[13]+matrix1[11]*matrix2[14]+matrix1[15]*matrix2[15];
|
||||
*/
|
||||
gGL.unprojectf(
|
||||
LLVector3(screen_x,screen_y,0.f),
|
||||
gGLModelView, gGLProjection, LLRect(gGLViewport[0],gGLViewport[1]+gGLViewport[3],gGLViewport[0]+gGLViewport[2],gGLViewport[1]),
|
||||
*pos_agent );
|
||||
}
|
||||
|
||||
// Uses the last GL matrices set in set_perspective to project a point from
|
||||
@@ -553,7 +441,7 @@ BOOL LLViewerCamera::projectPosAgentToScreen(const LLVector3 &pos_agent, LLCoord
|
||||
|
||||
const LLRect& world_view_rect = gViewerWindow->getWorldViewRectRaw();
|
||||
|
||||
if (GL_TRUE == glProjectf(pos_agent, gGLModelView, gGLProjection, world_view_rect, window_coordinates))
|
||||
if (gGL.projectf(pos_agent, gGLModelView, gGLProjection, world_view_rect, window_coordinates))
|
||||
{
|
||||
F32 &x = window_coordinates.mV[VX];
|
||||
F32 &y = window_coordinates.mV[VY];
|
||||
@@ -653,7 +541,7 @@ BOOL LLViewerCamera::projectPosAgentToScreenEdge(const LLVector3 &pos_agent,
|
||||
const LLRect& world_view_rect = gViewerWindow->getWorldViewRectRaw();
|
||||
LLVector3 window_coordinates;
|
||||
|
||||
if (GL_TRUE == glProjectf(pos_agent, gGLModelView, gGLProjection, world_view_rect, window_coordinates))
|
||||
if (gGL.projectf(pos_agent, gGLModelView, gGLProjection, world_view_rect, window_coordinates))
|
||||
{
|
||||
F32 &x = window_coordinates.mV[VX];
|
||||
F32 &y = window_coordinates.mV[VY];
|
||||
|
||||
@@ -1049,12 +1049,9 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
|
||||
|
||||
//store this frame's modelview matrix for use
|
||||
//when rendering next frame's occlusion queries
|
||||
for (U32 i = 0; i < 16; i++)
|
||||
{
|
||||
gGLPreviousModelView[i] = gGLLastModelView[i];
|
||||
gGLLastModelView[i] = gGLModelView[i];
|
||||
gGLLastProjection[i] = gGLProjection[i];
|
||||
}
|
||||
gGLPreviousModelView = gGLLastModelView;
|
||||
gGLLastModelView = gGLModelView;
|
||||
gGLLastProjection = gGLProjection;
|
||||
stop_glerror();
|
||||
}
|
||||
|
||||
@@ -1345,8 +1342,8 @@ void render_ui(F32 zoom_factor, int subfield, bool tiling)
|
||||
if (!gSnapshot)
|
||||
{
|
||||
gGL.pushMatrix();
|
||||
gGL.loadMatrix(gGLLastModelView);
|
||||
glh_set_current_modelview(glh_copy_matrix(gGLLastModelView));
|
||||
gGL.loadMatrix(gGLLastModelView.getF32ptr());
|
||||
glh_set_current_modelview(glh::matrix4f(gGLLastModelView.getF32ptr()));
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -187,7 +187,7 @@
|
||||
//#include "lltextureentry.h"
|
||||
#include "lltreeparams.h"
|
||||
//#include "llvolume.h"
|
||||
#include "llvolumemgr.h"
|
||||
//#include "llvolumemgr.h"
|
||||
#include "material_codes.h"
|
||||
|
||||
// Library includes from llxml
|
||||
|
||||
@@ -696,32 +696,35 @@ public:
|
||||
static const LLCachedControl<bool> debug_show_render_matrices("DebugShowRenderMatrices");
|
||||
if (debug_show_render_matrices)
|
||||
{
|
||||
addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", gGLProjection[12], gGLProjection[13], gGLProjection[14], gGLProjection[15]));
|
||||
F32* m = gGLProjection.getF32ptr();
|
||||
|
||||
addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", m[12], m[13], m[14], m[15]));
|
||||
ypos += y_inc;
|
||||
|
||||
addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", gGLProjection[8], gGLProjection[9], gGLProjection[10], gGLProjection[11]));
|
||||
addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", m[8], m[9], m[10], m[11]));
|
||||
ypos += y_inc;
|
||||
|
||||
addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", gGLProjection[4], gGLProjection[5], gGLProjection[6], gGLProjection[7]));
|
||||
addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", m[4], m[5], m[6], m[7]));
|
||||
ypos += y_inc;
|
||||
|
||||
addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", gGLProjection[0], gGLProjection[1], gGLProjection[2], gGLProjection[3]));
|
||||
addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", m[0], m[1], m[2], m[3]));
|
||||
ypos += y_inc;
|
||||
|
||||
addText(xpos, ypos, "Projection Matrix");
|
||||
ypos += y_inc;
|
||||
|
||||
m = gGLModelView.getF32ptr();
|
||||
|
||||
addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", gGLModelView[12], gGLModelView[13], gGLModelView[14], gGLModelView[15]));
|
||||
addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", m[12], m[13], m[14], m[15]));
|
||||
ypos += y_inc;
|
||||
|
||||
addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", gGLModelView[8], gGLModelView[9], gGLModelView[10], gGLModelView[11]));
|
||||
addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", m[8], m[9], m[10], m[11]));
|
||||
ypos += y_inc;
|
||||
|
||||
addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", gGLModelView[4], gGLModelView[5], gGLModelView[6], gGLModelView[7]));
|
||||
addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", m[4], m[5], m[6], m[7]));
|
||||
ypos += y_inc;
|
||||
|
||||
addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", gGLModelView[0], gGLModelView[1], gGLModelView[2], gGLModelView[3]));
|
||||
addText(xpos, ypos, llformat("%.4f .%4f %.4f %.4f", m[0], m[1], m[2], m[3]));
|
||||
ypos += y_inc;
|
||||
|
||||
addText(xpos, ypos, "View Matrix");
|
||||
|
||||
@@ -393,13 +393,7 @@ void LLWaterParamManager::update(LLViewerCamera * cam)
|
||||
glh::vec3f norm(0.f, 0.f, 1.f);
|
||||
glh::vec3f p(0.f, 0.f, gAgent.getRegion()->getWaterHeight()+0.1f);
|
||||
|
||||
F32 modelView[16];
|
||||
for (U32 i = 0; i < 16; i++)
|
||||
{
|
||||
modelView[i] = (F32) gGLModelView[i];
|
||||
}
|
||||
|
||||
glh::matrix4f mat(modelView);
|
||||
glh::matrix4f mat(gGLModelView.getF32ptr());
|
||||
glh::matrix4f invtrans = mat.inverse().transpose();
|
||||
glh::vec3f enorm;
|
||||
glh::vec3f ep;
|
||||
|
||||
@@ -249,49 +249,34 @@ void drawBoxOutline(const LLVector3& pos, const LLVector3& size);
|
||||
U32 nhpo2(U32 v);
|
||||
LLVertexBuffer* ll_create_cube_vb(U32 type_mask, U32 usage);
|
||||
|
||||
glh::matrix4f glh_copy_matrix(F32* src)
|
||||
{
|
||||
glh::matrix4f ret;
|
||||
ret.set_value(src);
|
||||
return ret;
|
||||
}
|
||||
|
||||
glh::matrix4f glh_get_current_modelview()
|
||||
{
|
||||
return glh_copy_matrix(gGLModelView);
|
||||
return glh::matrix4f(gGLModelView.getF32ptr());
|
||||
}
|
||||
|
||||
glh::matrix4f glh_get_current_projection()
|
||||
{
|
||||
return glh_copy_matrix(gGLProjection);
|
||||
return glh::matrix4f(gGLProjection.getF32ptr());
|
||||
}
|
||||
|
||||
glh::matrix4f glh_get_last_modelview()
|
||||
{
|
||||
return glh_copy_matrix(gGLLastModelView);
|
||||
return glh::matrix4f(gGLLastModelView.getF32ptr());
|
||||
}
|
||||
|
||||
glh::matrix4f glh_get_last_projection()
|
||||
{
|
||||
return glh_copy_matrix(gGLLastProjection);
|
||||
}
|
||||
|
||||
void glh_copy_matrix(const glh::matrix4f& src, F32* dst)
|
||||
{
|
||||
for (U32 i = 0; i < 16; i++)
|
||||
{
|
||||
dst[i] = src.m[i];
|
||||
}
|
||||
return glh::matrix4f(gGLLastProjection.getF32ptr());
|
||||
}
|
||||
|
||||
void glh_set_current_modelview(const glh::matrix4f& mat)
|
||||
{
|
||||
glh_copy_matrix(mat, gGLModelView);
|
||||
gGLModelView.loadu(mat.m);
|
||||
}
|
||||
|
||||
void glh_set_current_projection(glh::matrix4f& mat)
|
||||
{
|
||||
glh_copy_matrix(mat, gGLProjection);
|
||||
gGLProjection.loadu(mat.m);
|
||||
}
|
||||
|
||||
glh::matrix4f gl_ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat znear, GLfloat zfar)
|
||||
@@ -2339,11 +2324,11 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
|
||||
|
||||
gGL.matrixMode(LLRender::MM_PROJECTION);
|
||||
gGL.pushMatrix();
|
||||
gGL.loadMatrix(gGLLastProjection);
|
||||
gGL.loadMatrix(gGLLastProjection.getF32ptr());
|
||||
gGL.matrixMode(LLRender::MM_MODELVIEW);
|
||||
gGL.pushMatrix();
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLLastModelView);
|
||||
gGL.loadMatrix(gGLLastModelView.getF32ptr());
|
||||
|
||||
LLGLDisable blend(GL_BLEND);
|
||||
LLGLDisable test(GL_ALPHA_TEST);
|
||||
@@ -4105,17 +4090,14 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
|
||||
|
||||
assertInitialized();
|
||||
|
||||
F32 saved_modelview[16];
|
||||
F32 saved_projection[16];
|
||||
LLMatrix4a saved_modelview;
|
||||
LLMatrix4a saved_projection;
|
||||
|
||||
//HACK: preserve/restore matrices around HUD render
|
||||
if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD))
|
||||
{
|
||||
for (U32 i = 0; i < 16; i++)
|
||||
{
|
||||
saved_modelview[i] = gGLModelView[i];
|
||||
saved_projection[i] = gGLProjection[i];
|
||||
}
|
||||
saved_modelview = gGLModelView;
|
||||
saved_projection = gGLProjection;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
@@ -4219,7 +4201,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
|
||||
{
|
||||
occlude = FALSE;
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
LLGLSLShader::bindNoShader();
|
||||
doOcclusion(camera);
|
||||
}
|
||||
@@ -4230,7 +4212,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
|
||||
LLFastTimer t(FTM_POOLRENDER);
|
||||
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
|
||||
for( S32 i = 0; i < poolp->getNumPasses(); i++ )
|
||||
{
|
||||
@@ -4279,13 +4261,13 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
|
||||
LLVertexBuffer::unbind();
|
||||
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
|
||||
if (occlude)
|
||||
{
|
||||
occlude = FALSE;
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
LLGLSLShader::bindNoShader();
|
||||
doOcclusion(camera);
|
||||
}
|
||||
@@ -4348,11 +4330,8 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
|
||||
//HACK: preserve/restore matrices around HUD render
|
||||
if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD))
|
||||
{
|
||||
for (U32 i = 0; i < 16; i++)
|
||||
{
|
||||
gGLModelView[i] = saved_modelview[i];
|
||||
gGLProjection[i] = saved_projection[i];
|
||||
}
|
||||
gGLModelView = saved_modelview;
|
||||
gGLProjection = saved_projection;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4414,7 +4393,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera)
|
||||
LLFastTimer t(FTM_DEFERRED_POOLRENDER);
|
||||
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
|
||||
for( S32 i = 0; i < poolp->getNumDeferredPasses(); i++ )
|
||||
{
|
||||
@@ -4458,7 +4437,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera)
|
||||
}
|
||||
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
|
||||
gGL.setColorMask(true, false);
|
||||
}
|
||||
@@ -4491,7 +4470,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion)
|
||||
{
|
||||
occlude = FALSE;
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
LLGLSLShader::bindNoShader();
|
||||
doOcclusion(camera/*, mScreen, mOcclusionDepth, &mDeferredDepth*/);
|
||||
gGL.setColorMask(true, false);
|
||||
@@ -4503,7 +4482,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion)
|
||||
LLFastTimer t(FTM_POST_DEFERRED_POOLRENDER);
|
||||
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
|
||||
for( S32 i = 0; i < poolp->getNumPostDeferredPasses(); i++ )
|
||||
{
|
||||
@@ -4545,17 +4524,17 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion)
|
||||
}
|
||||
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
|
||||
if (occlude)
|
||||
{
|
||||
occlude = FALSE;
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
LLGLSLShader::bindNoShader();
|
||||
doOcclusion(camera);
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4581,7 +4560,7 @@ void LLPipeline::renderGeomShadow(LLCamera& camera)
|
||||
poolp->prerender() ;
|
||||
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
|
||||
for( S32 i = 0; i < poolp->getNumShadowPasses(); i++ )
|
||||
{
|
||||
@@ -4620,7 +4599,7 @@ void LLPipeline::renderGeomShadow(LLCamera& camera)
|
||||
}
|
||||
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
}
|
||||
|
||||
|
||||
@@ -4720,7 +4699,7 @@ void LLPipeline::renderDebug()
|
||||
gGL.color4f(1,1,1,1);
|
||||
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
gGL.setColorMask(true, false);
|
||||
bool hud_only = hasRenderType(LLPipeline::RENDER_TYPE_HUD);
|
||||
|
||||
@@ -4992,7 +4971,7 @@ void LLPipeline::renderDebug()
|
||||
gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sWhiteImagep);
|
||||
|
||||
gGL.pushMatrix();
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
gGLLastMatrix = NULL;
|
||||
|
||||
for (LLSpatialGroup::sg_vector_t::iterator iter = mGroupQ2.begin(); iter != mGroupQ2.end(); ++iter)
|
||||
@@ -6858,20 +6837,20 @@ void LLPipeline::doResetVertexBuffers()
|
||||
void LLPipeline::renderObjects(U32 type, U32 mask, BOOL texture, BOOL batch_texture)
|
||||
{
|
||||
assertInitialized();
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
gGLLastMatrix = NULL;
|
||||
mSimplePool->pushBatches(type, mask, texture, batch_texture);
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
gGLLastMatrix = NULL;
|
||||
}
|
||||
|
||||
void LLPipeline::renderMaskedObjects(U32 type, U32 mask, BOOL texture, BOOL batch_texture)
|
||||
{
|
||||
assertInitialized();
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
gGLLastMatrix = NULL;
|
||||
mAlphaMaskPool->pushMaskBatches(type, mask, texture, batch_texture);
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
gGLLastMatrix = NULL;
|
||||
}
|
||||
|
||||
@@ -7858,7 +7837,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n
|
||||
{
|
||||
cube_map->enable(channel);
|
||||
cube_map->bind();
|
||||
F32* m = gGLModelView;
|
||||
F32* m = gGLModelView.getF32ptr();
|
||||
|
||||
F32 mat[] = { m[0], m[1], m[2],
|
||||
m[4], m[5], m[6],
|
||||
@@ -7968,7 +7947,7 @@ void LLPipeline::renderDeferredLighting()
|
||||
LLGLEnable cull(GL_CULL_FACE);
|
||||
LLGLEnable blend(GL_BLEND);
|
||||
|
||||
glh::matrix4f mat = glh_copy_matrix(gGLModelView);
|
||||
glh::matrix4f mat(gGLModelView.getF32ptr());
|
||||
|
||||
if(mDeferredVB.isNull())
|
||||
{
|
||||
@@ -8643,7 +8622,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
|
||||
LLGLEnable cull(GL_CULL_FACE);
|
||||
LLGLEnable blend(GL_BLEND);
|
||||
|
||||
glh::matrix4f mat = glh_copy_matrix(gGLModelView);
|
||||
glh::matrix4f mat(gGLModelView.getF32ptr());
|
||||
|
||||
LLStrider<LLVector3> vert;
|
||||
mDeferredVB->getVertexStrider(vert);
|
||||
@@ -9827,7 +9806,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
|
||||
gGL.loadMatrix(proj.m);
|
||||
gGL.matrixMode(LLRender::MM_MODELVIEW);
|
||||
gGL.pushMatrix();
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
|
||||
stop_glerror();
|
||||
gGLLastMatrix = NULL;
|
||||
@@ -9906,7 +9885,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
|
||||
|
||||
gDeferredShadowCubeProgram.bind();
|
||||
gGLLastMatrix = NULL;
|
||||
gGL.loadMatrix(gGLModelView);
|
||||
gGL.loadMatrix(gGLModelView.getF32ptr());
|
||||
|
||||
//LLRenderTarget& occlusion_source = mShadow[LLViewerCamera::sCurCameraID-1];
|
||||
|
||||
@@ -10135,13 +10114,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
|
||||
gAgentAvatarp->updateAttachmentVisibility(CAMERA_MODE_THIRD_PERSON);
|
||||
}
|
||||
|
||||
F64 last_modelview[16];
|
||||
F64 last_projection[16];
|
||||
for (U32 i = 0; i < 16; i++)
|
||||
{ //store last_modelview of world camera
|
||||
last_modelview[i] = gGLLastModelView[i];
|
||||
last_projection[i] = gGLLastProjection[i];
|
||||
}
|
||||
LLMatrix4a last_modelview = gGLLastModelView;
|
||||
LLMatrix4a last_projection = gGLLastProjection;
|
||||
|
||||
pushRenderTypeMask();
|
||||
andRenderTypeMask(LLPipeline::RENDER_TYPE_SIMPLE,
|
||||
@@ -10675,14 +10649,11 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
|
||||
glh_set_current_modelview(view[j]);
|
||||
glh_set_current_projection(proj[j]);
|
||||
|
||||
for (U32 i = 0; i < 16; i++)
|
||||
{
|
||||
gGLLastModelView[i] = mShadowModelview[j].m[i];
|
||||
gGLLastProjection[i] = mShadowProjection[j].m[i];
|
||||
}
|
||||
gGLLastModelView = mShadowModelview[j];
|
||||
gGLLastProjection = mShadowProjection[j];
|
||||
|
||||
mShadowModelview[j] = view[j];
|
||||
mShadowProjection[j] = proj[j];
|
||||
mShadowModelview[j].loadu(view[j].m);
|
||||
mShadowProjection[j].loadu(proj[j].m);
|
||||
|
||||
|
||||
mSunShadowMatrix[j] = trans*proj[j]*view[j]*inv_view;
|
||||
@@ -10817,14 +10788,11 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
|
||||
|
||||
mSunShadowMatrix[i+4] = trans*proj[i+4]*view[i+4]*inv_view;
|
||||
|
||||
for (U32 j = 0; j < 16; j++)
|
||||
{
|
||||
gGLLastModelView[j] = mShadowModelview[i+4].m[j];
|
||||
gGLLastProjection[j] = mShadowProjection[i+4].m[j];
|
||||
}
|
||||
gGLLastModelView = mShadowModelview[i+4];
|
||||
gGLLastProjection = mShadowProjection[i+4];
|
||||
|
||||
mShadowModelview[i+4] = view[i+4];
|
||||
mShadowProjection[i+4] = proj[i+4];
|
||||
mShadowModelview[i+4].loadu(view[i+4].m);
|
||||
mShadowProjection[i+4].loadu(proj[i+4].m);
|
||||
|
||||
LLCamera shadow_cam = camera;
|
||||
shadow_cam.setFar(far_clip);
|
||||
@@ -10871,11 +10839,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
|
||||
}
|
||||
gGL.setColorMask(true, false);
|
||||
|
||||
for (U32 i = 0; i < 16; i++)
|
||||
{
|
||||
gGLLastModelView[i] = last_modelview[i];
|
||||
gGLLastProjection[i] = last_projection[i];
|
||||
}
|
||||
gGLLastModelView = last_modelview;
|
||||
gGLLastProjection = last_projection;
|
||||
|
||||
popRenderTypeMask();
|
||||
|
||||
|
||||
@@ -81,7 +81,6 @@ 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_copy_matrix(F32* src);
|
||||
glh::matrix4f glh_get_current_modelview();
|
||||
void glh_set_current_modelview(const glh::matrix4f& mat);
|
||||
glh::matrix4f glh_get_current_projection();
|
||||
@@ -639,8 +638,8 @@ public:
|
||||
LLCamera mShadowCamera[8];
|
||||
LLVector3 mShadowExtents[4][2];
|
||||
glh::matrix4f mSunShadowMatrix[6];
|
||||
glh::matrix4f mShadowModelview[6];
|
||||
glh::matrix4f mShadowProjection[6];
|
||||
LLMatrix4a mShadowModelview[6];
|
||||
LLMatrix4a mShadowProjection[6];
|
||||
glh::matrix4f mGIMatrix;
|
||||
glh::matrix4f mGIMatrixProj;
|
||||
glh::matrix4f mGIModelview;
|
||||
|
||||
Reference in New Issue
Block a user