summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolavatar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lldrawpoolavatar.cpp')
-rw-r--r--[-rwxr-xr-x]indra/newview/lldrawpoolavatar.cpp137
1 files changed, 41 insertions, 96 deletions
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index b3821fda85..843cd9b249 100755..100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -27,6 +27,7 @@
#include "llviewerprecompiledheaders.h"
#include "lldrawpoolavatar.h"
+#include "llskinningutil.h"
#include "llrender.h"
#include "llvoavatar.h"
@@ -50,6 +51,7 @@
#include "llrendersphere.h"
#include "llviewerpartsim.h"
#include "llviewercontrol.h" // for gSavedSettings
+#include "llviewertexturelist.h"
static U32 sDataMask = LLDrawPoolAvatar::VERTEX_DATA_MASK;
static U32 sBufferUsage = GL_STREAM_DRAW_ARB;
@@ -61,6 +63,7 @@ BOOL LLDrawPoolAvatar::sSkipTransparent = FALSE;
S32 LLDrawPoolAvatar::sDiffuseChannel = 0;
F32 LLDrawPoolAvatar::sMinimumAlpha = 0.2f;
+LLUUID gBlackSquareID;
static bool is_deferred_render = false;
static bool is_post_deferred_render = false;
@@ -470,7 +473,9 @@ void LLDrawPoolAvatar::renderShadow(S32 pass)
}
BOOL impostor = avatarp->isImpostor();
- if (impostor)
+ if (impostor
+ && LLVOAvatar::AV_DO_NOT_RENDER != avatarp->getVisualMuteSettings()
+ && LLVOAvatar::AV_ALWAYS_RENDER != avatarp->getVisualMuteSettings())
{
return;
}
@@ -1244,7 +1249,9 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
BOOL impostor = avatarp->isImpostor() && !single_avatar;
- if (impostor && pass != 0)
+ if (( avatarp->isInMuteList()
+ || impostor
+ || (LLVOAvatar::AV_DO_NOT_RENDER == avatarp->getVisualMuteSettings() && !avatarp->needsImpostorUpdate()) ) && pass != 0)
{ //don't draw anything but the impostor for impostored avatars
return;
}
@@ -1261,7 +1268,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
LLVOAvatar::sNumVisibleAvatars++;
}
- if (impostor)
+ if (impostor || (LLVOAvatar::AV_DO_NOT_RENDER == avatarp->getVisualMuteSettings() && !avatarp->needsImpostorUpdate()))
{
if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender && avatarp->mImpostor.isComplete())
{
@@ -1274,18 +1281,11 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
avatarp->mImpostor.bindTexture(1, specular_channel);
}
}
- avatarp->renderImpostor(LLColor4U(255,255,255,255), sDiffuseChannel);
+ avatarp->renderImpostor(avatarp->getMutedAVColor(), sDiffuseChannel);
}
return;
}
- llassert(LLPipeline::sImpostorRender || !avatarp->isVisuallyMuted());
-
- /*if (single_avatar && avatarp->mSpecialRenderMode >= 1) // 1=anim preview, 2=image preview, 3=morph view
- {
- gPipeline.enableLightsAvatarEdit(LLColor4(.5f, .5f, .5f, 1.f));
- }*/
-
if (pass == 1)
{
// render rigid meshes (eyeballs) first
@@ -1537,85 +1537,6 @@ void LLDrawPoolAvatar::getRiggedGeometry(
buffer->flush();
}
-// static
-void LLDrawPoolAvatar::initSkinningMatrixPalette(
- LLMatrix4* mat,
- S32 count,
- const LLMeshSkinInfo* skin,
- LLVOAvatar *avatar)
-{
- // BENTO - switching to use Matrix4a and SSE might speed this up.
- // Note that we are mostly passing Matrix4a's to this routine anyway, just dubiously casted.
- for (U32 j = 0; j < count; ++j)
- {
- LLJoint* joint = avatar->getJoint(skin->mJointNames[j]);
- if (!joint)
- {
- joint = avatar->getJoint("mPelvis");
- }
- if (joint)
- {
- mat[j] = skin->mInvBindMatrix[j];
- mat[j] *= joint->getWorldMatrix();
- }
- }
- // This handles a bogus weights case that has turned up in
- // practice, without the overhead of zeroing every matrix. We are
- // doing this here instead of in getPerVertexSkinMatrix so the fix
- // will also work in the HW skinning case.
- if (count < LL_MAX_JOINTS_PER_MESH_OBJECT)
- {
- mat[count].setIdentity();
- }
-}
-
-// static
-void LLDrawPoolAvatar::getPerVertexSkinMatrix(F32* weights, LLMatrix4a* mat, bool handle_bad_scale, LLMatrix4a& final_mat)
-{
- final_mat.clear();
-
- S32 idx[4];
-
- LLVector4 wght;
-
- F32 scale = 0.f;
- for (U32 k = 0; k < 4; k++)
- {
- F32 w = weights[k];
-
- // BENTO potential optimizations
- // - Do clamping in unpackVolumeFaces() (once instead of every time)
- // - int vs floor: if we know w is
- // >= 0.0, we can use int instead of floorf; the latter
- // allegedly has a lot of overhead due to ieeefp error
- // checking which we should not need.
- idx[k] = llclamp((S32) floorf(w), (S32)0, (S32)LL_MAX_JOINTS_PER_MESH_OBJECT-1);
-
- wght[k] = w - floorf(w);
- scale += wght[k];
- }
- if (handle_bad_scale && scale <= 0.f)
- {
- wght = LLVector4(1.0f, 0.0f, 0.0f, 0.0f);
- }
- else
- {
- // This is enforced in unpackVolumeFaces()
- llassert(scale>0.f);
- wght *= 1.f/scale;
- }
-
- for (U32 k = 0; k < 4; k++)
- {
- F32 w = wght[k];
-
- LLMatrix4a src;
- src.setMul(mat[idx[k]], w);
-
- final_mat.add(src);
- }
-}
-
void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(
LLVOAvatar* avatar,
LLFace* face,
@@ -1628,12 +1549,20 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(
{
return;
}
+ // FIXME ugly const cast
+ LLSkinningUtil::remapSkinInfoJoints(avatar, const_cast<LLMeshSkinInfo*>(skin));
LLPointer<LLVertexBuffer> buffer = face->getVertexBuffer();
LLDrawable* drawable = face->getDrawable();
U32 data_mask = face->getRiggedVertexBufferDataMask();
+ if (!vol_face.mWeightsRemapped)
+ {
+ LLSkinningUtil::remapSkinWeights(weight, vol_face.mNumVertices, skin);
+ vol_face.mWeightsRemapped = TRUE;
+ }
+
if (buffer.isNull() ||
buffer->getTypeMask() != data_mask ||
buffer->getNumVerts() != vol_face.mNumVertices ||
@@ -1685,16 +1614,18 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(
//build matrix palette
LLMatrix4a mat[LL_MAX_JOINTS_PER_MESH_OBJECT];
- U32 count = llmin((U32) skin->mJointNames.size(), (U32) LL_MAX_JOINTS_PER_MESH_OBJECT);
- initSkinningMatrixPalette((LLMatrix4*)mat, count, skin, avatar);
+ U32 count = LLSkinningUtil::getMeshJointCount(skin);
+ LLSkinningUtil::initSkinningMatrixPalette((LLMatrix4*)mat, count, skin, avatar);
+ LLSkinningUtil::checkSkinWeights(weight, buffer->getNumVerts(), skin);
LLMatrix4a bind_shape_matrix;
bind_shape_matrix.loadu(skin->mBindShapeMatrix);
+ const U32 max_joints = LLSkinningUtil::getMaxJointCount();
for (U32 j = 0; j < buffer->getNumVerts(); ++j)
{
LLMatrix4a final_mat;
- getPerVertexSkinMatrix(weight[j].getF32ptr(), mat, false, final_mat);
+ LLSkinningUtil::getPerVertexSkinMatrix(weight[j].getF32ptr(), mat, false, final_mat, max_joints);
LLVector4a& v = vol_face.mPositions[j];
LLVector4a t;
@@ -1777,8 +1708,8 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
{
// upload matrix palette to shader
LLMatrix4a mat[LL_MAX_JOINTS_PER_MESH_OBJECT];
- U32 count = llmin((U32) skin->mJointNames.size(), (U32) LL_MAX_JOINTS_PER_MESH_OBJECT);
- initSkinningMatrixPalette((LLMatrix4*)mat, count, skin, avatar);
+ U32 count = LLSkinningUtil::getMeshJointCount(skin);
+ LLSkinningUtil::initSkinningMatrixPalette((LLMatrix4*)mat, count, skin, avatar);
stop_glerror();
@@ -1843,7 +1774,21 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
{
//order is important here LLRender::DIFFUSE_MAP should be last, becouse it change
//(gGL).mCurrTextureUnitIndex
- gGL.getTexUnit(specular_channel)->bind(face->getTexture(LLRender::SPECULAR_MAP));
+ LLViewerTexture* specular = NULL;
+ if (LLPipeline::sImpostorRender)
+ {
+ specular = LLViewerTextureManager::findFetchedTexture(gBlackSquareID, TEX_LIST_STANDARD);
+ llassert(NULL != specular);
+ }
+ else
+ {
+ specular = face->getTexture(LLRender::SPECULAR_MAP);
+ }
+ if (specular)
+ {
+ gGL.getTexUnit(specular_channel)->bind(specular);
+ }
+
gGL.getTexUnit(normal_channel)->bind(face->getTexture(LLRender::NORMAL_MAP));
gGL.getTexUnit(sDiffuseChannel)->bind(face->getTexture(LLRender::DIFFUSE_MAP), false, true);