summaryrefslogtreecommitdiff
path: root/indra/newview/llvovolume.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llvovolume.cpp')
-rw-r--r--indra/newview/llvovolume.cpp83
1 files changed, 20 insertions, 63 deletions
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 8f0b233f01..465f8fe0d6 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -54,6 +54,7 @@
#include "llspatialpartition.h"
#include "llhudmanager.h"
#include "llflexibleobject.h"
+#include "llskinningutil.h"
#include "llsky.h"
#include "lltexturefetch.h"
#include "llvector4a.h"
@@ -80,7 +81,7 @@
const F32 FORCE_SIMPLE_RENDER_AREA = 512.f;
const F32 FORCE_CULL_AREA = 8.f;
-U32 JOINT_COUNT_REQUIRED_FOR_FULLRIG = 20;
+U32 JOINT_COUNT_REQUIRED_FOR_FULLRIG = 1;
BOOL gAnimateTextures = TRUE;
//extern BOOL gHideSelectedObjects;
@@ -4182,27 +4183,11 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons
}
//build matrix palette
- static const size_t kMaxJoints = 52;
+ static const size_t kMaxJoints = LL_MAX_JOINTS_PER_MESH_OBJECT;
- LLMatrix4a mp[kMaxJoints];
- LLMatrix4* mat = (LLMatrix4*) mp;
-
- U32 maxJoints = llmin(skin->mJointNames.size(), kMaxJoints);
- for (U32 j = 0; j < maxJoints; ++j)
- {
- LLJoint* joint = avatar->getJoint(skin->mJointNames[j]);
- if (!joint)
- {
- // Fall back to a point inside the avatar if mesh is
- // rigged to an unknown joint.
- joint = avatar->getJoint("mPelvis");
- }
- if (joint)
- {
- mat[j] = skin->mInvBindMatrix[j];
- mat[j] *= joint->getWorldMatrix();
- }
- }
+ LLMatrix4a mat[kMaxJoints];
+ U32 maxJoints = LLSkinningUtil::getMeshJointCount(skin);
+ LLSkinningUtil::initSkinningMatrixPalette((LLMatrix4*)mat, maxJoints, skin, avatar);
for (S32 i = 0; i < volume->getNumVolumeFaces(); ++i)
{
@@ -4214,6 +4199,7 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons
if ( weight )
{
+ LLSkinningUtil::checkSkinWeights(weight, dst_face.mNumVertices, skin);
LLMatrix4a bind_shape_matrix;
bind_shape_matrix.loadu(skin->mBindShapeMatrix);
@@ -4223,40 +4209,11 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons
{
LL_RECORD_BLOCK_TIME(FTM_SKIN_RIGGED);
+ U32 max_joints = LLSkinningUtil::getMaxJointCount();
for (U32 j = 0; j < dst_face.mNumVertices; ++j)
{
LLMatrix4a final_mat;
- final_mat.clear();
-
- S32 idx[4];
-
- LLVector4 wght;
-
- F32 scale = 0.f;
- for (U32 k = 0; k < 4; k++)
- {
- F32 w = weight[j][k];
-
- idx[k] = (S32) floorf(w);
- wght[k] = w - floorf(w);
- scale += wght[k];
- }
- // 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;
- // Insure ref'd bone is in our clamped array of mats
- // clamp idx to maxJoints to avoid reading garbage off stack in release
- S32 index = llclamp((S32)idx[k],(S32)0,(S32)kMaxJoints-1);
- src.setMul(mp[index], w);
- final_mat.add(src);
- }
-
+ LLSkinningUtil::getPerVertexSkinMatrix(weight[j].getF32ptr(), mat, false, final_mat, max_joints);
LLVector4a& v = vol_face.mPositions[j];
LLVector4a t;
@@ -4814,13 +4771,22 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
drawablep->clearState(LLDrawable::HAS_ALPHA);
bool rigged = vobj->isAttachment() &&
- vobj->isMesh() &&
- gMeshRepo.getSkinInfo(vobj->getVolume()->getParams().getSculptID(), vobj);
+ vobj->isMesh() &&
+ gMeshRepo.getSkinInfo(vobj->getVolume()->getParams().getSculptID(), vobj);
bool bake_sunlight = LLPipeline::sBakeSunlight && drawablep->isStatic();
bool is_rigged = false;
+ if (rigged && pAvatarVO)
+ {
+ pAvatarVO->addAttachmentPosOverridesForObject(vobj);
+ if (pAvatarVO->isSelf())
+ {
+ //pAvatarVO->showAttachmentPosOverrides();
+ }
+ }
+
//for each face
for (S32 i = 0; i < drawablep->getNumFaces(); i++)
{
@@ -4837,8 +4803,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
//sum up face verts and indices
drawablep->updateFaceSize(i);
-
-
if (rigged)
{
if (!facep->isState(LLFace::RIGGED))
@@ -4852,13 +4816,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
//get drawpool of avatar with rigged face
LLDrawPoolAvatar* pool = get_avatar_drawpool(vobj);
- // FIXME should this be inside the face loop?
- // doesn't seem to depend on any per-face state.
- if ( pAvatarVO )
- {
- pAvatarVO->addAttachmentPosOverridesForObject(vobj);
- }
-
if (pool)
{
const LLTextureEntry* te = facep->getTextureEntry();