summaryrefslogtreecommitdiff
path: root/indra/newview/llskinningutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llskinningutil.cpp')
-rw-r--r--indra/newview/llskinningutil.cpp71
1 files changed, 59 insertions, 12 deletions
diff --git a/indra/newview/llskinningutil.cpp b/indra/newview/llskinningutil.cpp
index 8e1f80abfc..1fb63c7444 100644
--- a/indra/newview/llskinningutil.cpp
+++ b/indra/newview/llskinningutil.cpp
@@ -34,8 +34,12 @@
#include "llvolume.h"
#include "llrigginginfo.h"
+#define DEBUG_SKINNING LL_DEBUG
+#define MAT_USE_SSE 1
+
void dump_avatar_and_skin_state(const std::string& reason, LLVOAvatar *avatar, const LLMeshSkinInfo *skin)
{
+#if DEBUG_SKINNING
static S32 dump_count = 0;
const S32 max_dump = 10;
@@ -81,12 +85,12 @@ void dump_avatar_and_skin_state(const std::string& reason, LLVOAvatar *avatar, c
dump_count++;
}
+#endif
}
-U32 LLSkinningUtil::getMaxJointCount()
+S32 LLSkinningUtil::getMaxJointCount()
{
- U32 result = LL_MAX_JOINTS_PER_MESH_OBJECT;
- return result;
+ return (S32)LL_MAX_JOINTS_PER_MESH_OBJECT;
}
U32 LLSkinningUtil::getMeshJointCount(const LLMeshSkinInfo *skin)
@@ -116,6 +120,8 @@ void LLSkinningUtil::scrubInvalidJoints(LLVOAvatar *avatar, LLMeshSkinInfo* skin
skin->mInvalidJointsScrubbed = true;
}
+#define MAT_USE_SSE 1
+
void LLSkinningUtil::initSkinningMatrixPalette(
LLMatrix4* mat,
S32 count,
@@ -126,9 +132,9 @@ void LLSkinningUtil::initSkinningMatrixPalette(
for (U32 j = 0; j < count; ++j)
{
LLJoint *joint = avatar->getJoint(skin->mJointNums[j]);
+ llassert(joint);
if (joint)
{
-#define MAT_USE_SSE
#ifdef MAT_USE_SSE
LLMatrix4a bind, world, res;
bind.loadu(skin->mInvBindMatrix[j]);
@@ -143,6 +149,7 @@ void LLSkinningUtil::initSkinningMatrixPalette(
else
{
mat[j] = skin->mInvBindMatrix[j];
+#if DEBUG_SKINNING
// This shouldn't happen - in mesh upload, skinned
// rendering should be disabled unless all joints are
// valid. In other cases of skinned rendering, invalid
@@ -153,16 +160,15 @@ void LLSkinningUtil::initSkinningMatrixPalette(
LL_WARNS_ONCE("Avatar") << avatar->getFullname()
<< " avatar build state: isBuilt() " << avatar->isBuilt()
<< " mInitFlags " << avatar->mInitFlags << LL_ENDL;
-#if 0
- dump_avatar_and_skin_state("initSkinningMatrixPalette joint not found", avatar, skin);
#endif
+ dump_avatar_and_skin_state("initSkinningMatrixPalette joint not found", avatar, skin);
}
}
}
void LLSkinningUtil::checkSkinWeights(LLVector4a* weights, U32 num_vertices, const LLMeshSkinInfo* skin)
{
-#ifdef SHOW_ASSERT // same condition that controls llassert()
+#if DEBUG_SKINNING
const S32 max_joints = skin->mJointNames.size();
for (U32 j=0; j<num_vertices; j++)
{
@@ -261,6 +267,7 @@ void LLSkinningUtil::initJointNums(LLMeshSkinInfo* skin, LLVOAvatar *avatar)
{
for (U32 j = 0; j < skin->mJointNames.size(); ++j)
{
+ #if DEBUG_SKINNING
LLJoint *joint = NULL;
if (skin->mJointNums[j] == -1)
{
@@ -278,11 +285,16 @@ void LLSkinningUtil::initJointNums(LLMeshSkinInfo* skin, LLVOAvatar *avatar)
{
LL_WARNS_ONCE("Avatar") << avatar->getFullname() << " unable to find joint " << skin->mJointNames[j] << LL_ENDL;
LL_WARNS_ONCE("Avatar") << avatar->getFullname() << " avatar build state: isBuilt() " << avatar->isBuilt() << " mInitFlags " << avatar->mInitFlags << LL_ENDL;
-#if 0
dump_avatar_and_skin_state("initJointNums joint not found", avatar, skin);
-#endif
+ skin->mJointNums[j] = 0;
}
}
+ #else
+ LLJoint *joint = (skin->mJointNums[j] == -1) ? avatar->getJoint(skin->mJointNames[j]) : avatar->getJoint(skin->mJointNums[j]);
+ skin->mJointNums[j] = joint ? joint->getJointNum() : 0;
+ #endif
+ // insure we have *a* valid joint to reference
+ llassert(skin->mJointNums[j] >= 0);
}
skin->mJointNumsInitialized = true;
}
@@ -340,14 +352,17 @@ void LLSkinningUtil::updateRiggingInfo(const LLMeshSkinInfo* skin, LLVOAvatar *a
// FIXME could precompute these matMuls.
LLMatrix4a bind_shape;
- bind_shape.loadu(skin->mBindShapeMatrix);
LLMatrix4a inv_bind;
- inv_bind.loadu(skin->mInvBindMatrix[joint_index]);
LLMatrix4a mat;
- matMul(bind_shape, inv_bind, mat);
LLVector4a pos_joint_space;
+
+ bind_shape.loadu(skin->mBindShapeMatrix);
+ inv_bind.loadu(skin->mInvBindMatrix[joint_index]);
+ matMul(bind_shape, inv_bind, mat);
+
mat.affineTransform(pos, pos_joint_space);
pos_joint_space.mul(wght[k]);
+
LLVector4a *extents = rig_info_tab[joint_num].getRiggedExtents();
update_min_max(extents[0], extents[1], pos_joint_space);
}
@@ -362,6 +377,8 @@ void LLSkinningUtil::updateRiggingInfo(const LLMeshSkinInfo* skin, LLVOAvatar *a
vol_face.mJointRiggingInfoTab.setNeedsUpdate(false);
}
}
+
+#if DEBUG_SKINNING
if (vol_face.mJointRiggingInfoTab.size()!=0)
{
LL_DEBUGS("RigSpammish") << "we have rigging info for vf " << &vol_face
@@ -372,10 +389,40 @@ void LLSkinningUtil::updateRiggingInfo(const LLMeshSkinInfo* skin, LLVOAvatar *a
LL_DEBUGS("RigSpammish") << "no rigging info for vf " << &vol_face
<< " num_verts " << vol_face.mNumVertices << LL_ENDL;
}
+#endif
}
}
+void LLSkinningUtil::updateRiggingInfo_(LLMeshSkinInfo* skin, LLVOAvatar *avatar, S32 num_verts, LLVector4a* weights, LLVector4a* positions, U8* joint_indices, LLJointRiggingInfoTab &rig_info_tab)
+{
+ LL_RECORD_BLOCK_TIME(FTM_FACE_RIGGING_INFO);
+ for (S32 i=0; i < num_verts; i++)
+ {
+ LLVector4a& pos = positions[i];
+ LLVector4a& wght = weights[i];
+ for (U32 k=0; k<4; ++k)
+ {
+ S32 joint_num = skin->mJointNums[joint_indices[k]];
+ llassert(joint_num >= 0 && joint_num < LL_CHARACTER_MAX_ANIMATED_JOINTS);
+ {
+ rig_info_tab[joint_num].setIsRiggedTo(true);
+ LLMatrix4a bind_shape;
+ bind_shape.loadu(skin->mBindShapeMatrix);
+ LLMatrix4a inv_bind;
+ inv_bind.loadu(skin->mInvBindMatrix[joint_indices[k]]);
+ LLMatrix4a mat;
+ matMul(bind_shape, inv_bind, mat);
+ LLVector4a pos_joint_space;
+ mat.affineTransform(pos, pos_joint_space);
+ pos_joint_space.mul(wght[k]);
+ LLVector4a *extents = rig_info_tab[joint_num].getRiggedExtents();
+ update_min_max(extents[0], extents[1], pos_joint_space);
+ }
+ }
+ }
+}
+
// This is used for extracting rotation from a bind shape matrix that
// already has scales baked in
LLQuaternion LLSkinningUtil::getUnscaledQuaternion(const LLMatrix4& mat4)