Permalink
Browse files

Bento hell and back, and back to hell, and back.

  • Loading branch information...
Shyotl committed Jan 11, 2017
1 parent 9dbdf75 commit 98516a2a22d779d8f11d814c4d51f6849877d85a
Showing with 8,674 additions and 2,615 deletions.
  1. +210 −59 indra/llappearance/llavatarappearance.cpp
  2. +19 −5 indra/llappearance/llavatarappearance.h
  3. +6 −7 indra/llappearance/llavatarjoint.cpp
  4. +62 −29 indra/llappearance/llavatarjointmesh.cpp
  5. +4 −1 indra/llappearance/llavatarjointmesh.h
  6. +8 −0 indra/llappearance/lldriverparam.cpp
  7. +4 −1 indra/llappearance/lldriverparam.h
  8. +16 −2 indra/llappearance/llpolymorph.cpp
  9. +1 −0 indra/llappearance/llpolymorph.h
  10. +22 −11 indra/llappearance/llpolyskeletaldistortion.cpp
  11. +122 −78 indra/llcharacter/llheadrotmotion.cpp
  12. +5 −0 indra/llcharacter/llheadrotmotion.h
  13. +411 −48 indra/llcharacter/lljoint.cpp
  14. +85 −27 indra/llcharacter/lljoint.h
  15. +64 −16 indra/llcharacter/llkeyframemotion.cpp
  16. +11 −5 indra/llcharacter/llmotion.cpp
  17. +1 −1 indra/llcharacter/llmotion.h
  18. +5 −5 indra/llcharacter/llmotioncontroller.cpp
  19. +1 −1 indra/llcharacter/llmotioncontroller.h
  20. +21 −11 indra/llmath/llvolume.cpp
  21. +2 −0 indra/llmath/llvolume.h
  22. +116 −86 indra/llprimitive/lldaeloader.cpp
  23. +6 −4 indra/llprimitive/lldaeloader.h
  24. +36 −6 indra/llprimitive/llmodel.cpp
  25. +9 −5 indra/llprimitive/llmodel.h
  26. +69 −226 indra/llprimitive/llmodelloader.cpp
  27. +13 −15 indra/llprimitive/llmodelloader.h
  28. +2 −0 indra/newview/CMakeLists.txt
  29. +1 −1 indra/newview/app_settings/shaders/class1/avatar/objectSkinV.glsl
  30. +5,764 −1,377 indra/newview/character/avatar_lad.xml
  31. +232 −81 indra/newview/character/avatar_skeleton.xml
  32. +2 −2 indra/newview/llagent.cpp
  33. +2 −2 indra/newview/llappearancemgr.cpp
  34. +5 −0 indra/newview/llappviewer.cpp
  35. +8 −22 indra/newview/lldrawpoolavatar.cpp
  36. +64 −28 indra/newview/llfloatermodelpreview.cpp
  37. +2 −1 indra/newview/llfloatermodelpreview.h
  38. +225 −0 indra/newview/llskinningutil.cpp
  39. +47 −0 indra/newview/llskinningutil.h
  40. +5 −1 indra/newview/llspatialpartition.cpp
  41. +3 −4 indra/newview/llviewerjoint.cpp
  42. +33 −2 indra/newview/llviewermenu.cpp
  43. +2 −2 indra/newview/llviewermenu.h
  44. +1 −1 indra/newview/llviewerobject.cpp
  45. +10 −2 indra/newview/llviewershadermgr.cpp
  46. +740 −193 indra/newview/llvoavatar.cpp
  47. +22 −6 indra/newview/llvoavatar.h
  48. +95 −169 indra/newview/llvoavatarself.cpp
  49. +25 −61 indra/newview/llvovolume.cpp
  50. +1 −1 indra/newview/llvovolume.h
  51. +10 −4 indra/newview/skins/default/xui/en-us/menu_pie_avatar.xml
  52. +1 −0 indra/newview/skins/default/xui/en-us/menu_pie_object.xml
  53. +9 −3 indra/newview/skins/default/xui/en-us/menu_pie_self.xml
  54. +34 −3 indra/newview/skins/default/xui/en-us/strings.xml

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -66,6 +66,7 @@ class LLAvatarAppearance : public LLCharacter
LLAvatarAppearance(LLWearableData* wearable_data);
virtual ~LLAvatarAppearance();
static void initClass(const std::string& avatar_file_name, const std::string& skeleton_file_name); // initializes static members
static void initClass(); // initializes static members
static void cleanupClass(); // Cleanup data that's only init'd once per class.
virtual void initInstance(); // Called after construction to initialize the instance.
@@ -132,34 +133,46 @@ class LLAvatarAppearance : public LLCharacter
virtual LLAvatarJoint* createAvatarJoint() = 0;
virtual LLAvatarJoint* createAvatarJoint(S32 joint_num) = 0;
virtual LLAvatarJointMesh* createAvatarJointMesh() = 0;
void makeJointAliases(LLAvatarBoneInfo *bone_info);
public:
F32 getPelvisToFoot() const { return mPelvisToFoot; }
/*virtual*/ LLJoint* getRootJoint() { return mRoot; }
LLVector3 mHeadOffset; // current head position
LLAvatarJoint *mRoot;
typedef std::map<std::string, LLJoint*> joint_map_t;
typedef std::vector<std::pair<char[64], LLJoint*>> joint_map_t;
joint_map_t mJointMap;
typedef std::map<std::string, LLVector3> joint_state_map_t;
joint_state_map_t mLastBodySizeState;
joint_state_map_t mCurrBodySizeState;
void compareJointStateMaps(joint_state_map_t& last_state,
joint_state_map_t& curr_state);
void computeBodySize();
public:
typedef std::vector<LLAvatarJoint*> avatar_joint_list_t;
const avatar_joint_list_t& getSkeleton() { return mSkeleton; }
typedef std::map<std::string, std::string> joint_alias_map_t;
const joint_alias_map_t& getJointAliases();
protected:
static BOOL parseSkeletonFile(const std::string& filename);
virtual void buildCharacter();
virtual BOOL loadAvatar();
virtual void bodySizeChanged() = 0;
BOOL setupBone(const LLAvatarBoneInfo* info, LLJoint* parent, S32 &current_volume_num, S32 &current_joint_num);
BOOL allocateCharacterJoints(U32 num);
BOOL buildSkeleton(const LLAvatarSkeletonInfo *info);
protected:
void clearSkeleton();
BOOL mIsBuilt; // state of deferred character building
typedef std::vector<LLAvatarJoint*> avatar_joint_list_t;
avatar_joint_list_t mSkeleton;
LLPosOverrideMap mPelvisFixups;
LLVector3OverrideMap mPelvisFixups;
joint_alias_map_t mJointAliasMap;
//--------------------------------------------------------------------
// Pelvis height adjustment members.
@@ -343,6 +356,7 @@ class LLAvatarAppearance : public LLCharacter
// Collision volumes
//--------------------------------------------------------------------
public:
S32 mNumBones;
std::vector<LLAvatarJointCollisionVolume*> mCollisionVolumes;
protected:
BOOL allocateCollisionVolumes(U32 num);
@@ -53,19 +53,18 @@ LLAvatarJoint::LLAvatarJoint() :
init();
}
LLAvatarJoint::LLAvatarJoint(const std::string &name, LLJoint *parent) :
LLJoint(name, parent)
LLAvatarJoint::LLAvatarJoint(S32 joint_num) :
LLJoint(joint_num)
{
init();
init();
}
LLAvatarJoint::LLAvatarJoint(S32 joint_num) :
LLJoint(joint_num)
LLAvatarJoint::LLAvatarJoint(const std::string &name, LLJoint *parent) :
LLJoint(name, parent)
{
init();
}
void LLAvatarJoint::init()
{
mValid = FALSE;
@@ -57,6 +57,41 @@
#include "llmatrix4a.h"
// Utility functions added with Bento to simplify handling of extra
// spine joints, or other new joints internal to the original
// skeleton, and unknown to the system avatar.
//-----------------------------------------------------------------------------
// getBaseSkeletonAncestor()
//-----------------------------------------------------------------------------
LLJoint *getBaseSkeletonAncestor(LLJoint* 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 ancestor;
}
//-----------------------------------------------------------------------------
// totalSkinOffset()
//-----------------------------------------------------------------------------
LLVector3 totalSkinOffset(LLJoint *joint)
{
LLVector3 totalOffset;
while (joint)
{
if (joint->getSupport() == LLJoint::SUPPORT_BASE)
{
totalOffset += joint->getSkinOffset();
}
joint = joint->getParent();
}
return totalOffset;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// LLAvatarJointMesh::LLSkinJoint
@@ -83,29 +118,24 @@ LLSkinJoint::~LLSkinJoint()
//-----------------------------------------------------------------------------
// LLSkinJoint::setupSkinJoint()
//-----------------------------------------------------------------------------
void LLSkinJoint::setupSkinJoint( LLJoint *joint)
BOOL LLSkinJoint::setupSkinJoint( LLJoint *joint)
{
// find the named joint
if (!(mJoint = joint))
if (!(mJoint = dynamic_cast<LLAvatarJoint*>(joint)))
{
LL_INFOS() << "Can't find joint" << LL_ENDL;
return;
return FALSE;
}
// compute the inverse root skin matrix
mRootToJointSkinOffset.clearVec();
mRootToParentJointSkinOffset.clearVec();
do
{
mRootToJointSkinOffset -= joint->getSkinOffset();
} while (joint = joint->getParent());
mRootToJointSkinOffset = totalSkinOffset((LLAvatarJoint*)joint);
mRootToJointSkinOffset = -mRootToJointSkinOffset;
mRootToParentJointSkinOffset = mRootToJointSkinOffset;
mRootToParentJointSkinOffset += mJoint->getSkinOffset();
//mRootToParentJointSkinOffset = totalSkinOffset((LLAvatarJoint*)joint->getParent());
mRootToParentJointSkinOffset = totalSkinOffset(getBaseSkeletonAncestor((LLAvatarJoint*)joint));
mRootToParentJointSkinOffset = -mRootToParentJointSkinOffset;
return;
return TRUE;
}
@@ -314,20 +344,18 @@ void LLAvatarJointMesh::setMesh( LLPolyMesh *mesh )
if (!mMesh->isLOD())
{
setupJoint(getRoot());
LL_DEBUGS("Avatar") << getName() << " joint render entries: " << mMesh->mJointRenderData.size() << LL_ENDL;
}
LL_DEBUGS() << "joint render entries: " << mMesh->mJointRenderData.size() << LL_ENDL;
}
//-----------------------------------------------------------------------------
// setupJoint()
//-----------------------------------------------------------------------------
void LLAvatarJointMesh::setupJoint(LLJoint* current_joint)
{
// LL_INFOS() << "Mesh: " << getName() << LL_ENDL;
// S32 joint_count = 0;
U32 sj;
for (sj=0; sj<mNumSkinJoints; sj++)
{
LLSkinJoint &js = mSkinJoints[sj];
@@ -338,25 +366,30 @@ void LLAvatarJointMesh::setupJoint(LLJoint* 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())
std::vector<LLJointRenderData*> &jrd = mMesh->mJointRenderData;
// 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(jrd.size() && jrd.back()->mWorldMatrix == &ancestor->getWorldMatrix())
{
// ...then just add ourselves
LLJoint* jointp = js.mJoint;
mMesh->mJointRenderData.push_back(new LLJointRenderData(&jointp->getWorldMatrix(), &js));
// LL_INFOS() << "joint " << joint_count << js.mJoint->getName() << LL_ENDL;
// joint_count++;
jrd.push_back(new LLJointRenderData(&jointp->getWorldMatrix(), &js));
LL_DEBUGS("Avatar") << "add joint[" << (jrd.size()-1) << "] = " << 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_INFOS() << "joint " << joint_count << current_joint->getParent()->getName() << LL_ENDL;
// joint_count++;
mMesh->mJointRenderData.push_back(new LLJointRenderData(&current_joint->getWorldMatrix(), &js));
// LL_INFOS() << "joint " << joint_count << current_joint->getName() << LL_ENDL;
// joint_count++;
jrd.push_back(new LLJointRenderData(&ancestor->getWorldMatrix(), NULL));
LL_DEBUGS("Avatar") << "add2 ancestor joint[" << (jrd.size()-1) << "] = " << ancestor->getName() << LL_ENDL;
jrd.push_back(new LLJointRenderData(&current_joint->getWorldMatrix(), &js));
LL_DEBUGS("Avatar") << "add2 joint[" << (jrd.size()-1) << "] = " << current_joint->getName() << LL_ENDL;
}
}
@@ -49,7 +49,7 @@ class LLSkinJoint
public:
LLSkinJoint();
~LLSkinJoint();
void setupSkinJoint( LLJoint *joint);
BOOL setupSkinJoint( LLJoint *joint);
LLJoint* mJoint;
LLVector3 mRootToJointSkinOffset;
@@ -124,6 +124,9 @@ class LLAvatarJointMesh : public virtual LLAvatarJoint
// Sets up joint matrix data for rendering
void setupJoint(LLJoint* current_joint);
// Render time method to upload batches of joint matrices
void uploadJointMatrices();
// Sets ID for picking
void setMeshID( S32 id ) {mMeshID = id;}
@@ -110,6 +110,14 @@ void LLDriverParamInfo::toStream(std::ostream &out)
out << std::endl;
// FIXME - this mDriverParam backlink makes no sense, because the
// LLDriverParamInfos are static objects - there's only one copy
// for each param type, so the backlink will just reference the
// corresponding param in the most recently created
// avatar. Apparently these toStream() methods are not currently
// used anywhere, so it's not an urgent problem.
LL_WARNS_ONCE() << "Invalid usage of mDriverParam." << LL_ENDL;
if(mDriverParam && mDriverParam->getAvatarAppearance()->isSelf() &&
mDriverParam->getAvatarAppearance()->isValid())
{
@@ -130,14 +130,17 @@ class LLDriverParam : public LLViewerVisualParam
S32 getDrivenParamsCount() const;
const LLViewerVisualParam* getDrivenParam(S32 index) const;
typedef std::vector<LLDrivenEntry> entry_list_t;
entry_list_t& getDrivenList() { return mDriven; }
void setDrivenList(entry_list_t& driven_list) { mDriven = driven_list; }
protected:
LLDriverParam(const LLDriverParam& pOther);
F32 getDrivenWeight(const LLDrivenEntry* driven, F32 input_weight);
void setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight, bool upload_bake = false);
LL_ALIGN_16(LLVector4a mDefaultVec); // temp holder
typedef std::vector<LLDrivenEntry> entry_list_t;
entry_list_t mDriven;
LLViewerVisualParam* mCurrentDistortionParam;
// Backlink only; don't make this an LLPointer.
@@ -680,8 +680,8 @@ BOOL LLPolyMorphTarget::setInfo(LLPolyMorphTargetInfo* info)
if (!mMorphData)
{
const std::string driven_tag = "_Driven";
size_t pos = morph_param_name.find(driven_tag);
if (pos != std::string::npos)
U32 pos = morph_param_name.find(driven_tag);
if (pos > 0)
{
morph_param_name = morph_param_name.substr(0,pos);
mMorphData = mMesh->getMorphData(morph_param_name);
@@ -1027,6 +1027,20 @@ void LLPolyMorphTarget::applyMask(U8 *maskTextureData, S32 width, S32 height, S3
apply(mLastSex);
}
void LLPolyMorphTarget::applyVolumeChanges(F32 delta_weight)
{
// now apply volume changes
for( volume_list_t::iterator iter = mVolumeMorphs.begin(); iter != mVolumeMorphs.end(); iter++ )
{
LLPolyVolumeMorph* volume_morph = &(*iter);
LLVector3 scale_delta = volume_morph->mScale * delta_weight;
LLVector3 pos_delta = volume_morph->mPos * delta_weight;
volume_morph->mVolume->setScale(volume_morph->mVolume->getScale() + scale_delta);
// SL-315
volume_morph->mVolume->setPosition(volume_morph->mVolume->getPosition() + pos_delta);
}
}
//-----------------------------------------------------------------------------
// LLPolyVertexMask()
@@ -186,6 +186,7 @@ class LLPolyMorphTarget : public LLViewerVisualParam
void applyMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert);
void addPendingMorphMask() { mNumMorphMasksPending++; }
void applyVolumeChanges(F32 delta_weight); // SL-315 - for resetSkeleton()
void* operator new(size_t size)
{
@@ -155,7 +155,7 @@ BOOL LLPolySkeletalDistortion::setInfo(LLPolySkeletalDistortionInfo *info)
if (!joint)
{
LL_WARNS() << "Joint " << bone_info->mBoneName << " not found." << LL_ENDL;
continue;
return FALSE;
}
if (mJointScales.find(joint) != mJointScales.end())
@@ -205,20 +205,29 @@ void LLPolySkeletalDistortion::apply( ESex avatar_sex )
{
LLFastTimer t(FTM_POLYSKELETAL_DISTORTION_APPLY);
F32 effective_weight = ( getSex() & avatar_sex ) ? mCurWeight : getDefaultWeight();
F32 effective_weight = ( getSex() & avatar_sex ) ? mCurWeight : getDefaultWeight();
LLJoint* joint;
joint_vec_map_t::iterator iter;
LLJoint* joint;
joint_vec_map_t::iterator iter;
for (iter = mJointScales.begin();
iter != mJointScales.end();
iter++)
{
joint = iter->first;
LLVector3 newScale = joint->getScale();
LLVector3 scaleDelta = iter->second;
newScale = newScale + (effective_weight * scaleDelta) - (mLastWeight * scaleDelta);
joint->setScale(newScale);
LLVector3 scaleDelta = iter->second;
LLVector3 offset = (effective_weight - mLastWeight) * scaleDelta;
newScale = newScale + offset;
//An aspect of attached mesh objects (which contain joint offsets) that need to be cleaned up when detached
// needed?
// joint->storeScaleForReset( newScale );
// BENTO for detailed stack tracing of params.
// std::stringstream ostr;
// ostr << "LLPolySkeletalDistortion::apply, id " << getID() << " " << getName() << " effective wt " << effective_weight << " last wt " << mLastWeight << " scaleDelta " << scaleDelta << " offset " << offset;
joint->setScale(newScale, true);
}
for (iter = mJointOffsets.begin();
@@ -229,14 +238,16 @@ void LLPolySkeletalDistortion::apply( ESex avatar_sex )
LLVector3 newPosition = joint->getPosition();
LLVector3 positionDelta = iter->second;
newPosition = newPosition + (effective_weight * positionDelta) - (mLastWeight * positionDelta);
joint->setPosition(newPosition);
}
// SL-315
bool allow_attachment_pos_overrides = true;
joint->setPosition(newPosition, allow_attachment_pos_overrides);
}
if (mLastWeight != mCurWeight && !mIsAnimating)
if (mLastWeight != effective_weight && !mIsAnimating)
{
mAvatar->setSkeletonSerialNum(mAvatar->getSkeletonSerialNum() + 1);
}
mLastWeight = mCurWeight;
mLastWeight = effective_weight;
}
Oops, something went wrong.

0 comments on commit 98516a2

Please sign in to comment.