Skip to content
Snippets Groups Projects
Commit f1e6f5c7 authored by Brad Payne (Vir Linden)'s avatar Brad Payne (Vir Linden)
Browse files

SL-287 WIP - fixed default avatar crash caused by added spine joints. Still renders distorted.

parent 4282de6e
Branches
Tags
No related merge requests found
......@@ -79,6 +79,28 @@ LLSkinJoint::~LLSkinJoint()
}
LLAvatarJoint *getBaseSkeletonAncestor(LLAvatarJoint* joint)
{
LLJoint *ancestor = joint->getParent();
while (ancestor->getParent() && (ancestor->getSupport() != LLJoint::SUPPORT_BASE))
{
LL_DEBUGS("Avatar") << "skipping non-base ancestor " << ancestor->getName() << LL_ENDL;
ancestor = ancestor->getParent();
}
return (LLAvatarJoint*) ancestor;
}
LLVector3 totalSkinOffset(LLAvatarJoint *joint)
{
LLVector3 totalOffset;
while (joint)
{
totalOffset += joint->getSkinOffset();
joint = (LLAvatarJoint*)joint->getParent();
}
return totalOffset;
}
//-----------------------------------------------------------------------------
// LLSkinJoint::setupSkinJoint()
//-----------------------------------------------------------------------------
......@@ -92,18 +114,12 @@ BOOL LLSkinJoint::setupSkinJoint( LLAvatarJoint *joint)
}
// compute the inverse root skin matrix
mRootToJointSkinOffset.clearVec();
mRootToJointSkinOffset = totalSkinOffset(joint);
mRootToJointSkinOffset = -mRootToJointSkinOffset;
LLVector3 rootSkinOffset;
while (joint)
{
rootSkinOffset += joint->getSkinOffset();
joint = (LLAvatarJoint*)joint->getParent();
}
mRootToJointSkinOffset = -rootSkinOffset;
mRootToParentJointSkinOffset = mRootToJointSkinOffset;
mRootToParentJointSkinOffset += mJoint->getSkinOffset();
//mRootToParentJointSkinOffset = totalSkinOffset((LLAvatarJoint*)joint->getParent());
mRootToParentJointSkinOffset = totalSkinOffset(getBaseSkeletonAncestor(joint));
mRootToParentJointSkinOffset = -mRootToParentJointSkinOffset;
return TRUE;
}
......@@ -315,9 +331,9 @@ void LLAvatarJointMesh::setMesh( LLPolyMesh *mesh )
if (!mMesh->isLOD())
{
setupJoint((LLAvatarJoint*)getRoot());
LL_DEBUGS("Avatar") << getName() << " joint render entries: " << mMesh->mJointRenderData.size() << LL_ENDL;
}
LL_DEBUGS() << "joint render entries: " << mMesh->mJointRenderData.size() << LL_ENDL;
}
//-----------------------------------------------------------------------------
......@@ -325,8 +341,6 @@ void LLAvatarJointMesh::setMesh( LLPolyMesh *mesh )
//-----------------------------------------------------------------------------
void LLAvatarJointMesh::setupJoint(LLAvatarJoint* current_joint)
{
LL_DEBUGS() << "Mesh: " << getName() << LL_ENDL;
S32 joint_count = 0;
U32 sj;
......@@ -340,22 +354,28 @@ void LLAvatarJointMesh::setupJoint(LLAvatarJoint* current_joint)
}
// we've found a skinjoint for this joint..
LL_DEBUGS("Avatar") << "Mesh: " << getName() << " joint " << current_joint->getName() << " matches skinjoint " << sj << LL_ENDL;
// is the last joint in the array our parent?
if(mMesh->mJointRenderData.size() && mMesh->mJointRenderData[mMesh->mJointRenderData.size() - 1]->mWorldMatrix == &current_joint->getParent()->getWorldMatrix())
// SL-287 - need to update this so the results are the same if
// additional extended-skeleton joints lie between this joint
// and the original parent.
LLJoint *ancestor = getBaseSkeletonAncestor(current_joint);
if(mMesh->mJointRenderData.size() && mMesh->mJointRenderData[mMesh->mJointRenderData.size() - 1]->mWorldMatrix == &ancestor->getWorldMatrix())
{
// ...then just add ourselves
LLAvatarJoint* jointp = js.mJoint;
mMesh->mJointRenderData.push_back(new LLJointRenderData(&jointp->getWorldMatrix(), &js));
LL_DEBUGS() << "joint " << joint_count++ << js.mJoint->getName() << LL_ENDL;
LL_DEBUGS("Avatar") << "add joint " << joint_count++ << " " << js.mJoint->getName() << LL_ENDL;
}
// otherwise add our parent and ourselves
// otherwise add our ancestor and ourselves
else
{
mMesh->mJointRenderData.push_back(new LLJointRenderData(&current_joint->getParent()->getWorldMatrix(), NULL));
LL_DEBUGS() << "joint " << joint_count++ << current_joint->getParent()->getName() << LL_ENDL;
mMesh->mJointRenderData.push_back(new LLJointRenderData(&ancestor->getWorldMatrix(), NULL));
LL_DEBUGS("Avatar") << "add2 ancestor joint " << joint_count++ << " " << ancestor->getName() << LL_ENDL;
mMesh->mJointRenderData.push_back(new LLJointRenderData(&current_joint->getWorldMatrix(), &js));
LL_DEBUGS() << "joint " << joint_count++ << current_joint->getName() << LL_ENDL;
LL_DEBUGS("Avatar") << "add2 joint " << joint_count++ << " " << current_joint->getName() << LL_ENDL;
}
}
......
......@@ -42,7 +42,7 @@
const S32 LL_CHARACTER_MAX_JOINTS_PER_MESH = 15;
// BENTO JOINT COUNT LIMIT - need to set this to final skeleton size
// (bones + attachments) + 2, rounded to next multiple of 4.
const U32 LL_CHARACTER_MAX_ANIMATED_JOINTS = 164; // must be divisible by 4!
const U32 LL_CHARACTER_MAX_ANIMATED_JOINTS = 180; // must be divisible by 4!
const U32 LL_MAX_JOINTS_PER_MESH_OBJECT = 110;
// These should be higher than the joint_num of any
......
......@@ -127,7 +127,7 @@ class StackWalker
// in older compilers in order to use it... starting with VC7 we can declare it as "protected"
protected:
#endif
enum { STACKWALK_MAX_NAMELEN = 1024 }; // max name length for found symbols
enum { STACKWALK_MAX_NAMELEN = 2048 }; // max name length for found symbols
protected:
// Entry for each Callstack-Entry
......
This diff is collapsed.
......@@ -203,7 +203,7 @@ void LLViewerJointMesh::uploadJointMatrices()
// DrawElementsBLEND and utility code
//--------------------------------------------------------------------
// compate_int is used by the qsort function to sort the index array
// compare_int is used by the qsort function to sort the index array
int compare_int(const void *a, const void *b)
{
if (*(U32*)a < *(U32*)b)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment