Migration to LLMatrix4a instead of glh::matrix4f

This commit is contained in:
Shyotl
2014-06-15 22:42:32 -05:00
parent 24ca32f9f7
commit 8f6a578ec0
14 changed files with 113 additions and 103 deletions

View File

@@ -2185,7 +2185,7 @@ BOOL LLVolume::generate()
0, 0, scale[2], 0,
0, 0, 0, 1 };
LLMatrix4 rot((F32*) mPathp->mPath[s].mRot.mMatrix);
LLMatrix4 rot(mPathp->mPath[s].mRot.getF32ptr());
LLMatrix4 scale_mat(sc);
scale_mat *= rot;
@@ -3671,16 +3671,14 @@ S32 LLVolume::getNumTriangles(S32* vcount) const
void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices,
std::vector<LLVector3> &normals,
const LLVector3& obj_cam_vec_in,
const LLMatrix4& mat_in,
const LLMatrix3& norm_mat_in,
const LLMatrix4a& mat_in,
const LLMatrix4a& norm_mat_in,
S32 face_mask)
{
LLMatrix4a mat;
mat.loadu(mat_in);
const LLMatrix4a& mat = mat_in;
const LLMatrix4a& norm_mat = norm_mat_in;
LLMatrix4a norm_mat;
norm_mat.loadu(norm_mat_in);
LLVector4a obj_cam_vec;
obj_cam_vec.load3(obj_cam_vec_in.mV);

View File

@@ -27,6 +27,9 @@
#ifndef LL_LLVOLUME_H
#define LL_LLVOLUME_H
#ifdef IN_PCH
#error "llvolume.h should not be in pch include chain."
#endif
#include <iostream>
class LLProfileParams;
@@ -1017,8 +1020,8 @@ public:
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,
S32 face_index);
//get the face index of the face that intersects with the given line segment at the point

View File

@@ -266,9 +266,9 @@ void LLCubeMap::setMatrix(S32 stage)
gGL.getTexUnit(stage)->activate();
}
LLVector3 x(gGLModelView.mMatrix[0].getF32ptr());
LLVector3 y(gGLModelView.mMatrix[1].getF32ptr());
LLVector3 z(gGLModelView.mMatrix[2].getF32ptr());
LLVector3 x(gGLModelView.getRow<0>().getF32ptr());
LLVector3 y(gGLModelView.getRow<1>().getF32ptr());
LLVector3 z(gGLModelView.getRow<2>().getF32ptr());
LLMatrix3 mat3;
mat3.setRows(x,y,z);

View File

@@ -2179,7 +2179,7 @@ void parse_glsl_version(S32& major, S32& minor)
LLStringUtil::convertToS32(minor_str, minor);
}
LLGLUserClipPlane::LLGLUserClipPlane(const LLPlane& p, const glh::matrix4f& modelview, const glh::matrix4f& projection, bool apply)
LLGLUserClipPlane::LLGLUserClipPlane(const LLPlane& p, const LLMatrix4a& modelview, const LLMatrix4a& projection, bool apply)
{
mApply = apply;
@@ -2194,27 +2194,33 @@ LLGLUserClipPlane::LLGLUserClipPlane(const LLPlane& p, const glh::matrix4f& mode
void LLGLUserClipPlane::setPlane(F32 a, F32 b, F32 c, F32 d)
{
glh::matrix4f& P = mProjection;
glh::matrix4f& M = mModelview;
glh::matrix4f invtrans_MVP = (P * M).inverse().transpose();
glh::vec4f oplane(a,b,c,d);
glh::vec4f cplane;
invtrans_MVP.mult_matrix_vec(oplane, cplane);
LLMatrix4a& P = mProjection;
LLMatrix4a& M = mModelview;
cplane /= fabs(cplane[2]); // normalize such that depth is not scaled
cplane[3] -= 1;
LLMatrix4a invtrans_MVP;
invtrans_MVP.setMul(P,M);
invtrans_MVP.invert();
invtrans_MVP.transpose();
if(cplane[2] < 0)
cplane *= -1;
LLVector4a oplane(a,b,c,d);
LLVector4a cplane;
invtrans_MVP.rotate4(oplane,cplane);
cplane.div(cplane.getScalarAt<2>().getAbs());
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 );
LLMatrix4a suffix;
suffix.setIdentity();
suffix.setColumn<2>(cplane);
LLMatrix4a newP;
newP.setMul(suffix,P);
glh::matrix4f suffix;
suffix.set_row(2, cplane);
glh::matrix4f newP = suffix * P;
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.pushMatrix();
gGL.loadMatrix(newP.m);
gGLObliqueProjectionInverse = LLMatrix4(newP.inverse().transpose().m);
gGL.loadMatrix(newP.getF32ptr());
//gGLObliqueProjectionInverse = LLMatrix4(newP.inverse().transpose().m);
gGL.matrixMode(LLRender::MM_MODELVIEW);
}

View File

@@ -38,6 +38,7 @@
#include "llstring.h"
#include "stdtypes.h"
#include "v4math.h"
#include "llmatrix4a.h"
#include "llplane.h"
#include "llgltypes.h"
#include "llinstancetracker.h"
@@ -325,7 +326,7 @@ class LLGLUserClipPlane
{
public:
LLGLUserClipPlane(const LLPlane& plane, const glh::matrix4f& modelview, const glh::matrix4f& projection, bool apply = true);
LLGLUserClipPlane(const LLPlane& plane, const LLMatrix4a& modelview, const LLMatrix4a& projection, bool apply = true);
~LLGLUserClipPlane();
void setPlane(F32 a, F32 b, F32 c, F32 d);
@@ -333,8 +334,8 @@ public:
private:
bool mApply;
glh::matrix4f mProjection;
glh::matrix4f mModelview;
LLMatrix4a mProjection;
LLMatrix4a mModelview;
};
/*

View File

@@ -311,16 +311,19 @@ public:
/*virtual*/ S32 getDepthChannel() const { return 1; }
/*virtual*/ QuadType preDraw()
{
glh::matrix4f inv_proj(gGLModelView.getF32ptr());
inv_proj.mult_left(gGLProjection.getF32ptr());
inv_proj = inv_proj.inverse();
glh::matrix4f prev_proj(gGLPreviousModelView.getF32ptr());
prev_proj.mult_left(gGLProjection.getF32ptr());
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);
LLVector2 screen_rect = LLPostProcess::getInstance()->getDimensions();
getShader().uniformMatrix4fv(sPrevProj, 1, GL_FALSE, prev_proj.m);
getShader().uniformMatrix4fv(sInvProj, 1, GL_FALSE, inv_proj.m);
getShader().uniformMatrix4fv(sPrevProj, 1, GL_FALSE, prev_proj.getF32ptr());
getShader().uniformMatrix4fv(sInvProj, 1, GL_FALSE, inv_proj.getF32ptr());
getShader().uniform2fv(sScreenRes, 1, screen_rect.mV);
getShader().uniform1i(sBlurStrength, mStrength);

View File

@@ -1387,16 +1387,11 @@ void LLDrawPoolAvatar::getRiggedGeometry(LLFace* face, LLPointer<LLVertexBuffer>
U16 offset = 0;
LLMatrix4 mat_vert = skin->mBindShapeMatrix;
glh::matrix4f m((F32*) mat_vert.mMatrix);
m = m.inverse().transpose();
F32 mat3[] =
{ m.m[0], m.m[1], m.m[2],
m.m[4], m.m[5], m.m[6],
m.m[8], m.m[9], m.m[10] };
LLMatrix3 mat_normal(mat3);
LLMatrix4a mat_vert;
mat_vert.loadu(skin->mBindShapeMatrix);
LLMatrix4a mat_inv_trans = mat_vert;
mat_inv_trans.invert();
mat_inv_trans.transpose();
//let getGeometryVolume know if alpha should override shiny
U32 type = gPipeline.getPoolTypeFromTE(face->getTextureEntry(), face->getTexture());
@@ -1411,7 +1406,7 @@ void LLDrawPoolAvatar::getRiggedGeometry(LLFace* face, LLPointer<LLVertexBuffer>
}
//llinfos << "Rebuilt face " << face->getTEOffset() << " of " << face->getDrawable() << " at " << gFrameTimeSeconds << llendl;
face->getGeometryVolume(*volume, face->getTEOffset(), mat_vert, mat_normal, offset, true);
face->getGeometryVolume(*volume, face->getTEOffset(), mat_vert, mat_inv_trans, offset, true);
buffer->flush();
}

View File

@@ -540,7 +540,7 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color)
{
LLGLEnable offset(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.f, -1.f);
gGL.multMatrix((F32*) volume->getRelativeXform().mMatrix);
gGL.multMatrix(volume->getRelativeXform().getF32ptr());
const LLVolumeFace& vol_face = rigged->getVolumeFace(getTEOffset());
// Singu Note: Implementation changed to utilize a VBO, avoiding fixed functions unless required
@@ -808,14 +808,14 @@ bool less_than_max_mag(const LLVector4a& vec)
}
BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f,
const LLMatrix4& mat_vert_in, BOOL global_volume)
const LLMatrix4a& mat_vert_in, BOOL global_volume)
{
//get bounding box
if (mDrawablep->isState(LLDrawable::REBUILD_VOLUME | LLDrawable::REBUILD_POSITION | LLDrawable::REBUILD_RIGGED))
{
//VECTORIZE THIS
LLMatrix4a mat_vert;
mat_vert.loadu(mat_vert_in);
const LLMatrix4a& mat_vert = mat_vert_in;
//mat_vert.loadu(mat_vert_in);
LLVector4a min,max;
@@ -1202,7 +1202,7 @@ static LLFastTimer::DeclareTimer FTM_FACE_TEX_QUICK_PLANAR("Quick Planar");
BOOL LLFace::getGeometryVolume(const LLVolume& volume,
const S32 &f,
const LLMatrix4& mat_vert_in, const LLMatrix3& mat_norm_in,
const LLMatrix4a& mat_vert_in, const LLMatrix4a& mat_norm_in,
const U16 &index_offset,
bool force_rebuild)
{
@@ -1350,8 +1350,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
}
}
LLMatrix4a mat_normal;
mat_normal.loadu(mat_norm_in);
const LLMatrix4a& mat_normal = mat_norm_in;
F32 r = 0, os = 0, ot = 0, ms = 0, mt = 0, cos_ang = 0, sin_ang = 0;
bool do_xform = false;
@@ -1410,7 +1409,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
LLGLSLShader* cur_shader = LLGLSLShader::sCurBoundShaderPtr;
gGL.pushMatrix();
gGL.loadMatrix((GLfloat*) mat_vert_in.mMatrix);
gGL.loadMatrix(mat_vert_in.getF32ptr());
if (rebuild_pos)
{
@@ -1937,8 +1936,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
mVertexBuffer->getVertexStrider(vert, mGeomIndex, mGeomCount, map_range);
LLMatrix4a mat_vert;
mat_vert.loadu(mat_vert_in);
const LLMatrix4a& mat_vert = mat_vert_in;
F32* dst = (F32*) vert.get();
F32* end_f32 = dst+mGeomCount*4;

View File

@@ -173,7 +173,7 @@ public:
bool canRenderAsMask(); // logic helper
BOOL getGeometryVolume(const LLVolume& volume,
const S32 &f,
const LLMatrix4& mat_vert, const LLMatrix3& mat_normal,
const LLMatrix4a& mat_vert, const LLMatrix4a& mat_normal,
const U16 &index_offset,
bool force_rebuild = false);
@@ -196,7 +196,7 @@ public:
void setSize(S32 numVertices, S32 num_indices = 0, bool align = false);
BOOL genVolumeBBoxes(const LLVolume &volume, S32 f,const LLMatrix4& mat, BOOL global_volume = FALSE);
BOOL genVolumeBBoxes(const LLVolume &volume, S32 f,const LLMatrix4a& mat, BOOL global_volume = FALSE);
void init(LLDrawable* drawablep, LLViewerObject* objp);
void destroy();

View File

@@ -883,32 +883,35 @@ LLQuaternion LLVolumeImplFlexible::getEndRotation()
void LLVolumeImplFlexible::updateRelativeXform(bool force_identity)
{
LLQuaternion delta_rot;
LLVector3 delta_pos, delta_scale;
LLVOVolume* vo = (LLVOVolume*) mVO;
bool use_identity = vo->mDrawable->isSpatialRoot() || force_identity;
vo->mRelativeXform.setIdentity();
//matrix from local space to parent relative/global space
delta_rot = use_identity ? LLQuaternion() : vo->mDrawable->getRotation();
delta_pos = use_identity ? LLVector3(0,0,0) : vo->mDrawable->getPosition();
delta_scale = LLVector3(1,1,1);
LLVector4a delta_pos;
LLQuaternion2 delta_rot;
if(use_identity)
{
delta_pos.set(0,0,0,1.f);
delta_rot.getVector4aRw() = delta_pos;
}
else
{
delta_pos.load3(vo->mDrawable->getPosition().mV,1.f);
delta_rot.getVector4aRw().loadua(vo->mDrawable->getRotation().mQ);
vo->mRelativeXform.getRow<0>().setRotated(delta_rot,vo->mRelativeXform.getRow<0>());
vo->mRelativeXform.getRow<1>().setRotated(delta_rot,vo->mRelativeXform.getRow<1>());
vo->mRelativeXform.getRow<2>().setRotated(delta_rot,vo->mRelativeXform.getRow<2>());
}
// 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;
vo->mRelativeXform.setRow<3>(delta_pos);
vo->mRelativeXform.initRows(LLVector4(x_axis, 0.f),
LLVector4(y_axis, 0.f),
LLVector4(z_axis, 0.f),
LLVector4(delta_pos, 1.f));
x_axis.normVec();
y_axis.normVec();
z_axis.normVec();
vo->mRelativeXformInvTrans.setRows(x_axis, y_axis, z_axis);
vo->mRelativeXformInvTrans = vo->mRelativeXform;
vo->mRelativeXformInvTrans.invert();
vo->mRelativeXformInvTrans.transpose();
}
const LLMatrix4& LLVolumeImplFlexible::getWorldMatrix(LLXformMatrix* xform) const

View File

@@ -6119,7 +6119,7 @@ void pushWireframe(LLDrawable* drawable)
{
LLVertexBuffer::unbind();
gGL.pushMatrix();
gGL.multMatrix((F32*) vobj->getRelativeXform().mMatrix);
gGL.multMatrix(vobj->getRelativeXform().getF32ptr());
LLVolume* volume = NULL;

View File

@@ -2917,7 +2917,7 @@ void renderNormals(LLDrawable* drawablep)
{
LLVolume* volume = vol->getVolume();
gGL.pushMatrix();
gGL.multMatrix((F32*) vol->getRelativeXform().mMatrix);
gGL.multMatrix(vol->getRelativeXform().getF32ptr());
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((F32*) volume->getRelativeXform().mMatrix);
gGL.multMatrix(volume->getRelativeXform().getF32ptr());
if (type == LLPhysicsShapeBuilderUtil::PhysicsShapeSpecification::USER_MESH)
{
@@ -3683,7 +3683,7 @@ void renderRaycast(LLDrawable* drawablep)
gGL.pushMatrix();
gGL.translatef(trans.mV[0], trans.mV[1], trans.mV[2]);
gGL.multMatrix((F32*) vobj->getRelativeXform().mMatrix);
gGL.multMatrix(vobj->getRelativeXform().getF32ptr());
LLVector4a start, end;
if (transform)

View File

@@ -736,14 +736,12 @@ BOOL LLViewerCamera::areVertsVisible(LLViewerObject* volumep, BOOL all_verts)
LLVOVolume* vo_volume = (LLVOVolume*) volumep;
vo_volume->updateRelativeXform();
LLMatrix4 mat = vo_volume->getRelativeXform();
LLMatrix4 render_mat(vo_volume->getRenderRotation(), LLVector4(vo_volume->getRenderPosition()));
LLMatrix4a render_mata;
render_mata.loadu(render_mat);
LLMatrix4a mata;
mata.loadu(mat);
const LLMatrix4a& mata = vo_volume->getRelativeXform();;
num_faces = volume->getNumVolumeFaces();
for (i = 0; i < num_faces; i++)

View File

@@ -767,8 +767,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
LLGLState::checkTextureChannels();
LLGLState::checkClientArrays();
glh::matrix4f proj = glh_get_current_projection();
glh::matrix4f mod = glh_get_current_modelview();
const LLMatrix4a& proj = glh_get_current_projection();
const LLMatrix4a& mod = glh_get_current_modelview();
glViewport(0,0,512,512);
LLVOAvatar::updateFreezeCounter() ;
@@ -780,9 +780,9 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
glh_set_current_projection(proj);
glh_set_current_modelview(mod);
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.loadMatrix(proj.m);
gGL.loadMatrix(proj.getF32ptr());
gGL.matrixMode(LLRender::MM_MODELVIEW);
gGL.loadMatrix(mod.m);
gGL.loadMatrix(mod.getF32ptr());
gViewerWindow->setup3DViewport();
LLGLState::checkStates();
@@ -1143,8 +1143,8 @@ void render_hud_attachments()
gGL.matrixMode(LLRender::MM_MODELVIEW);
gGL.pushMatrix();
glh::matrix4f current_proj = glh_get_current_projection();
glh::matrix4f current_mod = glh_get_current_modelview();
const LLMatrix4a saved_proj = glh_get_current_projection();
const LLMatrix4a saved_mod = glh_get_current_modelview();
// clamp target zoom level to reasonable values
// gAgentCamera.mHUDTargetZoom = llclamp(gAgentCamera.mHUDTargetZoom, 0.1f, 1.f);
@@ -1240,8 +1240,8 @@ void render_hud_attachments()
gGL.matrixMode(LLRender::MM_MODELVIEW);
gGL.popMatrix();
glh_set_current_projection(current_proj);
glh_set_current_modelview(current_mod);
glh_set_current_projection(saved_proj);
glh_set_current_modelview(saved_mod);
}
LLRect get_whole_screen_region()
@@ -1316,17 +1316,22 @@ BOOL setup_hud_matrices()
BOOL setup_hud_matrices(const LLRect& screen_region)
{
glh::matrix4f proj, model;
bool result = get_hud_matrices(screen_region, proj, model);
glh::matrix4f P, M;
bool result = get_hud_matrices(screen_region, P, M);
if (!result) return result;
LLMatrix4a proj;
proj.loadu(P.m);
LLMatrix4a model;
model.loadu(M.m);
// set up transform to keep HUD objects in front of camera
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.loadMatrix(proj.m);
gGL.loadMatrix(proj.getF32ptr());
glh_set_current_projection(proj);
gGL.matrixMode(LLRender::MM_MODELVIEW);
gGL.loadMatrix(model.m);
gGL.loadMatrix(model.getF32ptr());
glh_set_current_modelview(model);
return TRUE;
}
@@ -1337,13 +1342,13 @@ void render_ui(F32 zoom_factor, int subfield, bool tiling)
{
LLGLState::checkStates();
glh::matrix4f saved_view = glh_get_current_modelview();
const LLMatrix4a saved_view = glh_get_current_modelview();
if (!gSnapshot)
{
gGL.pushMatrix();
gGL.loadMatrix(gGLLastModelView.getF32ptr());
glh_set_current_modelview(glh::matrix4f(gGLLastModelView.getF32ptr()));
glh_set_current_modelview(gGLLastModelView);
}
{