Removed glh_linear and glu dependencies from viewer.

This commit is contained in:
Shyotl
2014-07-03 02:11:45 -05:00
parent 21f677cf58
commit 9cbcf8fe34
11 changed files with 79 additions and 1839 deletions

View File

@@ -1578,9 +1578,11 @@ bool LLModelLoader::doLoadModel()
mesh_scale *= normalized_transformation;
normalized_transformation = mesh_scale;
glh::matrix4f inv_mat((F32*) normalized_transformation.mMatrix);
inv_mat = inv_mat.inverse();
LLMatrix4 inverse_normalized_transformation(inv_mat.m);
LLMatrix4a inv_mat;
inv_mat.loadu(normalized_transformation);
inv_mat.invert();
LLMatrix4 inverse_normalized_transformation(inv_mat.getF32ptr());
domSkin::domBind_shape_matrix* bind_mat = skin->getBind_shape_matrix();

View File

@@ -73,7 +73,7 @@
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);
bool get_hud_matrices(LLMatrix4a &proj, LLMatrix4a &model);
// Warning: make sure these two match!
const LLPanelPrimMediaControls::EZoomLevel LLPanelPrimMediaControls::kZoomLevels[] = { ZOOM_NONE, ZOOM_MEDIUM };
@@ -615,15 +615,11 @@ void LLPanelPrimMediaControls::updateShape()
mat.setMul(glh_get_current_projection(),glh_get_current_modelview());
}
else {
glh::matrix4f proj, modelview;
LLMatrix4a proj, modelview;
if (get_hud_matrices(proj, modelview))
{
//mat = proj * modelview;
LLMatrix4a P;
P.loadu(proj.m);
LLMatrix4a M;
M.loadu(modelview.m);
mat.setMul(P,M);
mat.setMul(proj,modelview);
}
}
LLVector4a min;

View File

@@ -55,28 +55,6 @@
U32 LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
//glu pick matrix implementation borrowed from Mesa3D
glh::matrix4f gl_pick_matrix(GLfloat x, GLfloat y, GLfloat width, GLfloat height, GLint* viewport)
{
GLfloat m[16];
GLfloat sx, sy;
GLfloat tx, ty;
sx = viewport[2] / width;
sy = viewport[3] / height;
tx = (viewport[2] + 2.f * (viewport[0] - x)) / width;
ty = (viewport[3] + 2.f * (viewport[1] - y)) / height;
#define M(row,col) m[col*4+row]
M(0,0) = sx; M(0,1) = 0.f; M(0,2) = 0.f; M(0,3) = tx;
M(1,0) = 0.f; M(1,1) = sy; M(1,2) = 0.f; M(1,3) = ty;
M(2,0) = 0.f; M(2,1) = 0.f; M(2,2) = 1.f; M(2,3) = 0.f;
M(3,0) = 0.f; M(3,1) = 0.f; M(3,2) = 0.f; M(3,3) = 1.f;
#undef M
return glh::matrix4f(m);
}
LLViewerCamera::LLViewerCamera() : LLCamera()
{
calcProjection(getFar());
@@ -263,20 +241,24 @@ void LLViewerCamera::setPerspective(BOOL for_selection,
gGL.matrixMode( LLRender::MM_PROJECTION );
gGL.loadIdentity();
glh::matrix4f proj_mat;
LLMatrix4a proj_mat;
proj_mat.setIdentity();
if (for_selection)
{
// make a tiny little viewport
// anything drawn into this viewport will be "selected"
GLint viewport[4];
viewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft;
viewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom;
viewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth();
viewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight();
const LLRect& rect = gViewerWindow->getWorldViewRectRaw();
proj_mat = gl_pick_matrix(x+width/2.f, y_from_bot+height/2.f, (GLfloat) width, (GLfloat) height, viewport);
const F32 scale_x = rect.getWidth() / F32(width);
const F32 scale_y = rect.getHeight() / F32(height);
const F32 trans_x = scale_x + (2.f * (rect.mLeft - x)) / F32(width) - 1.f;
const F32 trans_y = scale_y + (2.f * (rect.mBottom - y_from_bot)) / F32(height) - 1.f;
//Generate a pick matrix
proj_mat.applyScale_affine(scale_x, scale_y, 1.f);
proj_mat.setTranslate_affine(LLVector3(trans_x, trans_y, 0.f));
if (limit_select_distance)
{
@@ -310,24 +292,18 @@ void LLViewerCamera::setPerspective(BOOL for_selection,
float offset = mZoomFactor - 1.f;
int pos_y = mZoomSubregion / llceil(mZoomFactor);
int pos_x = mZoomSubregion - (pos_y*llceil(mZoomFactor));
glh::matrix4f translate;
translate.set_translate(glh::vec3f(offset - (F32)pos_x * 2.f, offset - (F32)pos_y * 2.f, 0.f));
glh::matrix4f scale;
scale.set_scale(glh::vec3f(mZoomFactor, mZoomFactor, 1.f));
proj_mat = scale*proj_mat;
proj_mat = translate*proj_mat;
proj_mat.applyScale_affine(mZoomFactor,mZoomFactor,1.f);
proj_mat.applyTranslation_affine(offset - (F32)pos_x * 2.f, offset - (F32)pos_y * 2.f, 0.f);
}
calcProjection(z_far); // Update the projection matrix cache
LLMatrix4a proj_mata;
proj_mata.loadu(proj_mat.m);
proj_mata.mul(gGL.genPersp(fov_y,aspect,z_near,z_far));
proj_mat.mul(gGL.genPersp(fov_y,aspect,z_near,z_far));
gGL.loadMatrix(proj_mata);
gGL.loadMatrix(proj_mat);
gGLProjection = proj_mata;
gGLProjection = proj_mat;
gGL.matrixMode(LLRender::MM_MODELVIEW );

View File

@@ -1264,7 +1264,7 @@ LLRect get_whole_screen_region()
return whole_screen;
}
bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::matrix4f &model)
bool get_hud_matrices(const LLRect& screen_region, LLMatrix4a &proj, LLMatrix4a &model)
{
if (isAgentAvatarValid() && gAgentAvatarp->hasHUDAttachment())
{
@@ -1272,28 +1272,24 @@ 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.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;
proj = gGL.genOrtho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, hud_depth);
proj.getRow<2>().copyComponent<2>(LLVector4a(-0.01f));
F32 aspect_ratio = LLViewerCamera::getInstance()->getAspect();
glh::matrix4f mat;
F32 scale_x = (F32)gViewerWindow->getWorldViewWidthScaled() / (F32)screen_region.getWidth();
F32 scale_y = (F32)gViewerWindow->getWorldViewHeightScaled() / (F32)screen_region.getHeight();
mat.set_scale(glh::vec3f(scale_x, scale_y, 1.f));
mat.set_translate(
glh::vec3f(clamp_rescale((F32)(screen_region.getCenterX() - screen_region.mLeft), 0.f, (F32)gViewerWindow->getWorldViewWidthScaled(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio),
clamp_rescale((F32)(screen_region.getCenterY() - screen_region.mBottom), 0.f, (F32)gViewerWindow->getWorldViewHeightScaled(), 0.5f * scale_y, -0.5f * scale_y),
0.f));
proj *= mat;
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));
tmp_model *= mat;
model = tmp_model;
proj.applyTranslation_affine(
clamp_rescale((F32)(screen_region.getCenterX() - screen_region.mLeft), 0.f, (F32)gViewerWindow->getWorldViewWidthScaled(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio),
clamp_rescale((F32)(screen_region.getCenterY() - screen_region.mBottom), 0.f, (F32)gViewerWindow->getWorldViewHeightScaled(), 0.5f * scale_y, -0.5f * scale_y),
0.f);
proj.applyScale_affine(scale_x, scale_y, 1.f);
model = OGL_TO_CFR_ROTATION;
model.applyTranslation_affine(LLVector3(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f));
model.applyScale_affine(zoom_level);
return TRUE;
}
else
@@ -1302,7 +1298,7 @@ bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::mat
}
}
bool get_hud_matrices(glh::matrix4f &proj, glh::matrix4f &model)
bool get_hud_matrices(LLMatrix4a &proj, LLMatrix4a &model)
{
LLRect whole_screen = get_whole_screen_region();
return get_hud_matrices(whole_screen, proj, model);
@@ -1316,14 +1312,9 @@ BOOL setup_hud_matrices()
BOOL setup_hud_matrices(const LLRect& screen_region)
{
glh::matrix4f P, M;
bool result = get_hud_matrices(screen_region, P, M);
LLMatrix4a proj, model;
bool result = get_hud_matrices(screen_region, proj, model);
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);