summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerjointmesh.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewerjointmesh.cpp')
-rw-r--r--indra/newview/llviewerjointmesh.cpp132
1 files changed, 18 insertions, 114 deletions
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 3ecf3c39b2..a910d8ec2a 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -56,12 +56,6 @@
#include "llmatrix4a.h"
#include "llperfstats.h"
-#if !LL_DARWIN && !LL_LINUX && !__FreeBSD__
-extern PFNGLWEIGHTPOINTERARBPROC glWeightPointerARB;
-extern PFNGLWEIGHTFVARBPROC glWeightfvARB;
-extern PFNGLVERTEXBLENDARBPROC glVertexBlendARB;
-#endif
-
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// LLViewerJointMesh
@@ -95,10 +89,9 @@ const S32 NUM_AXES = 3;
// rotation Z 0-n
// pivot parent 0-n -- child = n+1
-static LLMatrix4 gJointMatUnaligned[32];
-static LLMatrix4a gJointMatAligned[32];
-static LLMatrix3 gJointRotUnaligned[32];
-static LLVector4 gJointPivot[32];
+static LLMatrix4 gJointMatUnaligned[LL_CHARACTER_MAX_JOINTS_PER_MESH];
+static LLMatrix3 gJointRotUnaligned[LL_CHARACTER_MAX_JOINTS_PER_MESH];
+static LLVector4 gJointPivot[LL_CHARACTER_MAX_JOINTS_PER_MESH];
//-----------------------------------------------------------------------------
// uploadJointMatrices()
@@ -107,18 +100,14 @@ void LLViewerJointMesh::uploadJointMatrices()
{
S32 joint_num;
LLPolyMesh *reference_mesh = mMesh->getReferenceMesh();
- LLDrawPool *poolp = mFace ? mFace->getPool() : NULL;
- bool hardware_skinning = (poolp && poolp->getShaderLevel() > 0);
//calculate joint matrices
- for (joint_num = 0; joint_num < reference_mesh->mJointRenderData.size(); joint_num++)
+ size_t num_joints = llmin(reference_mesh->mJointRenderData.size(), LL_CHARACTER_MAX_JOINTS_PER_MESH);
+ for (joint_num = 0; joint_num < num_joints; joint_num++)
{
LLMatrix4 joint_mat = *reference_mesh->mJointRenderData[joint_num]->mWorldMatrix;
- if (hardware_skinning)
- {
- joint_mat *= LLDrawPoolAvatar::getModelView();
- }
+ joint_mat *= LLDrawPoolAvatar::getModelView();
gJointMatUnaligned[joint_num] = joint_mat;
gJointRotUnaligned[joint_num] = joint_mat.getMat3();
}
@@ -137,12 +126,20 @@ void LLViewerJointMesh::uploadJointMatrices()
LLVector4 parent_pivot(sj->mRootToParentJointSkinOffset);
parent_pivot.mV[VW] = 0.f;
gJointPivot[j++] = parent_pivot;
+ if (j >= LL_CHARACTER_MAX_JOINTS_PER_MESH)
+ {
+ break;
+ }
}
LLVector4 child_pivot(sj->mRootToJointSkinOffset);
child_pivot.mV[VW] = 0.f;
gJointPivot[j++] = child_pivot;
+ if (j >= LL_CHARACTER_MAX_JOINTS_PER_MESH)
+ {
+ break;
+ }
last_pivot_uploaded = true;
}
@@ -162,12 +159,10 @@ void LLViewerJointMesh::uploadJointMatrices()
}
// upload matrices
- if (hardware_skinning)
- {
GLfloat mat[45*4];
memset(mat, 0, sizeof(GLfloat)*45*4);
- for (joint_num = 0; joint_num < reference_mesh->mJointRenderData.size(); joint_num++)
+ for (joint_num = 0; joint_num < num_joints; joint_num++)
{
gJointMatUnaligned[joint_num].transpose();
@@ -184,15 +179,6 @@ void LLViewerJointMesh::uploadJointMatrices()
LLGLSLShader::sCurBoundShaderPtr->uniform4fv(LLViewerShaderMgr::AVATAR_MATRIX, 45, mat);
}
stop_glerror();
- }
- else
- {
- //load gJointMatUnaligned into gJointMatAligned
- for (joint_num = 0; joint_num < reference_mesh->mJointRenderData.size(); ++joint_num)
- {
- gJointMatAligned[joint_num].loadu(gJointMatUnaligned[joint_num]);
- }
- }
}
//--------------------------------------------------------------------
@@ -221,6 +207,7 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, bool first_pass, bool is_dummy)
if (!mValid || !mMesh || !mFace || !mVisible ||
!mFace->getVertexBuffer() ||
mMesh->getNumFaces() == 0 ||
+ mMesh->mFaceVertexCount == 0 ||
LLGLSLShader::sCurBoundShaderPtr == NULL)
{
return 0;
@@ -242,10 +229,6 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, bool first_pass, bool is_dummy)
stop_glerror();
-#if GL_VERSION_1_1
- LLGLSSpecular specular(LLColor4(1.f,1.f,1.f,1.f), 0.f);
-#endif
-
//----------------------------------------------------------------
// setup current texture
//----------------------------------------------------------------
@@ -294,12 +277,9 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, bool first_pass, bool is_dummy)
if (mMesh->hasWeights())
{
- if ((mFace->getPool()->getShaderLevel() > 0))
+ if (first_pass)
{
- if (first_pass)
- {
- uploadJointMatrices();
- }
+ uploadJointMatrices();
}
buff->setBuffer();
@@ -359,15 +339,6 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, bool damp_w
return;
}
- LLDrawPool *poolp = mFace->getPool();
- bool hardware_skinning = (poolp && poolp->getShaderLevel() > 0);
-
- if (!hardware_skinning && terse_update)
- { //no need to do terse updates if we're doing software vertex skinning
- // since mMesh is being copied into mVertexBuffer every frame
- return;
- }
-
LL_PROFILE_ZONE_SCOPED;
LLStrider<LLVector3> verticesp;
@@ -451,75 +422,8 @@ bool LLViewerJointMesh::updateLOD(F32 pixel_area, bool activate)
return (valid != activate);
}
-// static
-void LLViewerJointMesh::updateGeometry(LLFace *mFace, LLPolyMesh *mMesh)
-{
- LLStrider<LLVector3> o_vertices;
- LLStrider<LLVector3> o_normals;
-
- //get vertex and normal striders
- LLVertexBuffer* buffer = mFace->getVertexBuffer();
- buffer->getVertexStrider(o_vertices, 0);
- buffer->getNormalStrider(o_normals, 0);
-
- F32* __restrict vert = o_vertices[0].mV;
- F32* __restrict norm = o_normals[0].mV;
-
- const F32* __restrict weights = mMesh->getWeights();
- const LLVector4a* __restrict coords = (LLVector4a*) mMesh->getCoords();
- const LLVector4a* __restrict normals = (LLVector4a*) mMesh->getNormals();
-
- U32 offset = mMesh->mFaceVertexOffset*4;
- vert += offset;
- norm += offset;
-
- for (U32 index = 0; index < mMesh->getNumVertices(); index++)
- {
- // equivalent to joint = floorf(weights[index]);
- S32 joint = _mm_cvtt_ss2si(_mm_load_ss(weights+index));
- F32 w = weights[index] - joint;
-
- LLMatrix4a gBlendMat;
-
- if (w != 0.f)
- {
- // blend between matrices and apply
- gBlendMat.setLerp(gJointMatAligned[joint+0],
- gJointMatAligned[joint+1], w);
-
- LLVector4a res;
- gBlendMat.affineTransform(coords[index], res);
- res.store4a(vert+index*4);
- gBlendMat.rotate(normals[index], res);
- res.store4a(norm+index*4);
- }
- else
- { // No lerp required in this case.
- LLVector4a res;
- gJointMatAligned[joint].affineTransform(coords[index], res);
- res.store4a(vert+index*4);
- gJointMatAligned[joint].rotate(normals[index], res);
- res.store4a(norm+index*4);
- }
- }
-
- buffer->unmapBuffer();
-}
-
void LLViewerJointMesh::updateJointGeometry()
{
- if (!(mValid
- && mMesh
- && mFace
- && mMesh->hasWeights()
- && mFace->getVertexBuffer()
- && LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) == 0))
- {
- return;
- }
-
- uploadJointMatrices();
- updateGeometry(mFace, mMesh);
}
void LLViewerJointMesh::dump()