SL-375, SL-378 - rudimentary logging info to list joint offsets during mesh import. dae_tool.py work to enable joint offset tweaking.

master
Brad Payne (Vir Linden) 2016-04-29 11:25:17 -04:00
parent 3da9762eee
commit ec471497f5
6 changed files with 91 additions and 31 deletions

View File

@ -382,6 +382,13 @@ void showJointPosOverrides( const LLJoint& joint, const std::string& note, const
LL_DEBUGS("Avatar") << av_info << " joint " << joint.getName() << " " << note << " " << os.str() << LL_ENDL; LL_DEBUGS("Avatar") << av_info << " joint " << joint.getName() << " " << note << " " << os.str() << LL_ENDL;
} }
bool above_joint_pos_threshold(const LLVector3& diff)
{
//return !diff.isNull();
const F32 max_joint_pos_offset = 0.0001f; // 0.1 mm
return diff.lengthSquared() > max_joint_pos_offset * max_joint_pos_offset;
}
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// addAttachmentPosOverride() // addAttachmentPosOverride()
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -391,6 +398,15 @@ void LLJoint::addAttachmentPosOverride( const LLVector3& pos, const LLUUID& mesh
{ {
return; return;
} }
if (!above_joint_pos_threshold(pos-getDefaultPosition()))
{
if (do_debug_joint(getName()))
{
LL_DEBUGS("Avatar") << "Attachment pos override ignored for " << getName()
<< ", pos " << pos << " is same as default pos" << LL_ENDL;
}
return;
}
if (!m_attachmentOverrides.count()) if (!m_attachmentOverrides.count())
{ {
if (do_debug_joint(getName())) if (do_debug_joint(getName()))

View File

@ -489,10 +489,18 @@ void LLFloaterModelPreview::onClickCalculateBtn()
bool upload_skinweights = childGetValue("upload_skin").asBoolean(); bool upload_skinweights = childGetValue("upload_skin").asBoolean();
bool upload_joint_positions = childGetValue("upload_joints").asBoolean(); bool upload_joint_positions = childGetValue("upload_joints").asBoolean();
if (upload_joint_positions)
{
// Diagnostic message showing list of joints for which joint offsets are defined.
// FIXME - given time, would be much better to put this in the UI, in updateStatusMessages().
mModelPreview->getPreviewAvatar()->showAttachmentPosOverrides();
}
mUploadModelUrl.clear(); mUploadModelUrl.clear();
gMeshRepo.uploadModel(mModelPreview->mUploadData, mModelPreview->mPreviewScale, gMeshRepo.uploadModel(mModelPreview->mUploadData, mModelPreview->mPreviewScale,
childGetValue("upload_textures").asBoolean(), upload_skinweights, upload_joint_positions, mUploadModelUrl, false, childGetValue("upload_textures").asBoolean(), upload_skinweights, upload_joint_positions,
mUploadModelUrl, false,
getWholeModelFeeObserverHandle()); getWholeModelFeeObserverHandle());
toggleCalculateButton(false); toggleCalculateButton(false);

View File

@ -5315,13 +5315,6 @@ void LLVOAvatar::clearAttachmentPosOverrides()
} }
} }
bool above_joint_pos_threshold(const LLVector3& diff)
{
//return !diff.isNull();
const F32 max_joint_pos_offset = 0.0001f; // 0.1 mm
return diff.lengthSquared() > max_joint_pos_offset * max_joint_pos_offset;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// addAttachmentPosOverridesForObject // addAttachmentPosOverridesForObject
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -5382,22 +5375,14 @@ void LLVOAvatar::addAttachmentPosOverridesForObject(LLViewerObject *vo)
{ {
pJoint->setId( currentId ); pJoint->setId( currentId );
const LLVector3& jointPos = pSkinData->mAlternateBindMatrix[i].getTranslation(); const LLVector3& jointPos = pSkinData->mAlternateBindMatrix[i].getTranslation();
if (!above_joint_pos_threshold(jointPos-pJoint->getDefaultPosition())) //Set the joint position
{ pJoint->addAttachmentPosOverride( jointPos, mesh_id, avString() );
LL_DEBUGS("Avatar") << "Attachment pos override ignored for " << pJoint->getName()
<< ", pos " << jointPos << " is same as default pos" << LL_ENDL;
}
else
{
//Set the joint position
pJoint->addAttachmentPosOverride( jointPos, mesh_id, avString() );
//If joint is a pelvis then handle old/new pelvis to foot values //If joint is a pelvis then handle old/new pelvis to foot values
if ( lookingForJoint == "mPelvis" ) if ( lookingForJoint == "mPelvis" )
{ {
pelvisGotSet = true; pelvisGotSet = true;
} }
}
} }
} }
if (pelvisZOffset != 0.0F) if (pelvisZOffset != 0.0F)
@ -5414,22 +5399,68 @@ void LLVOAvatar::addAttachmentPosOverridesForObject(LLViewerObject *vo)
{ {
postPelvisSetRecalc(); postPelvisSetRecalc();
} }
}
if (isSelf()) //-----------------------------------------------------------------------------
{ // getAttachmentOverrideNames
showAttachmentPosOverrides(); //-----------------------------------------------------------------------------
void LLVOAvatar::getAttachmentOverrideNames(std::set<std::string>& names) const
{
LLVector3 pos;
LLUUID mesh_id;
// Bones
for (avatar_joint_list_t::const_iterator iter = mSkeleton.begin();
iter != mSkeleton.end(); ++iter)
{
const LLJoint* pJoint = (*iter);
if (pJoint && pJoint->hasAttachmentPosOverride(pos,mesh_id))
{
names.insert(pJoint->getName());
}
}
// Attachment points
for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin();
iter != mAttachmentPoints.end();
++iter)
{
const LLViewerJointAttachment *attachment_pt = (*iter).second;
if (attachment_pt && attachment_pt->hasAttachmentPosOverride(pos,mesh_id))
{
names.insert(attachment_pt->getName());
}
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// showAttachmentPosOverrides // showAttachmentPosOverrides
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void LLVOAvatar::showAttachmentPosOverrides() const void LLVOAvatar::showAttachmentPosOverrides(bool verbose) const
{ {
std::set<std::string> joint_names;
getAttachmentOverrideNames(joint_names);
if (joint_names.size())
{
std::stringstream ss;
std::copy(joint_names.begin(), joint_names.end(), std::ostream_iterator<std::string>(ss, ","));
LL_INFOS() << getFullname() << " attachment positions defined for joints: " << ss.str() << "\n" << LL_ENDL;
}
else
{
LL_INFOS() << getFullname() << " no attachment positions defined for any joints" << "\n" << LL_ENDL;
}
if (!verbose)
{
return;
}
LLVector3 pos; LLVector3 pos;
LLUUID mesh_id; LLUUID mesh_id;
S32 count = 0; S32 count = 0;
// Bones // Bones
for (avatar_joint_list_t::const_iterator iter = mSkeleton.begin(); for (avatar_joint_list_t::const_iterator iter = mSkeleton.begin();
iter != mSkeleton.end(); ++iter) iter != mSkeleton.end(); ++iter)

View File

@ -206,7 +206,8 @@ public:
bool jointIsRiggedTo(const std::string& joint_name); bool jointIsRiggedTo(const std::string& joint_name);
bool jointIsRiggedTo(const std::string& joint_name, const LLViewerObject *vo); bool jointIsRiggedTo(const std::string& joint_name, const LLViewerObject *vo);
void clearAttachmentPosOverrides(); void clearAttachmentPosOverrides();
void showAttachmentPosOverrides() const; void showAttachmentPosOverrides(bool verbose = false) const;
void getAttachmentOverrideNames(std::set<std::string>& names) const;
/*virtual*/ const LLUUID& getID() const; /*virtual*/ const LLUUID& getID() const;
/*virtual*/ void addDebugText(const std::string& text); /*virtual*/ void addDebugText(const std::string& text);

View File

@ -4777,6 +4777,10 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
if (rigged && pAvatarVO) if (rigged && pAvatarVO)
{ {
pAvatarVO->addAttachmentPosOverridesForObject(vobj); pAvatarVO->addAttachmentPosOverridesForObject(vobj);
if (pAvatarVO->isSelf())
{
//pAvatarVO->showAttachmentPosOverrides();
}
} }
//for each face //for each face

View File

@ -47,8 +47,8 @@ def mesh_lock_offsets(tree, joints):
continue continue
if joint_node.get("type") != "JOINT": if joint_node.get("type") != "JOINT":
continue continue
if joint_node.get("name") in joints: if joint_node.get("name") in joints or "bone" in joints:
for matrix_node in joint_node.iter(): for matrix_node in list(joint_node):
if "matrix" in matrix_node.tag: if "matrix" in matrix_node.tag:
floats = [float(x) for x in matrix_node.text.split()] floats = [float(x) for x in matrix_node.text.split()]
if len(floats) == 16: if len(floats) == 16: