From a587fbafebfe28dd97e88e270d74fde14065e380 Mon Sep 17 00:00:00 2001 From: Hazim Gazov Date: Fri, 2 Jul 2010 03:22:01 +0000 Subject: [PATCH] Fix a few animation crashers, change default imported object name --- indra/llcharacter/lleditingmotion.cpp | 3 ++- indra/llcharacter/lljoint.cpp | 31 ++++++++++++++++++++++ indra/llcharacter/lljoint.h | 4 +++ indra/llcharacter/llkeyframemotion.cpp | 36 ++++++++++++++++++++++++-- indra/llcharacter/llpose.cpp | 3 +++ indra/newview/llimportobject.cpp | 2 +- 6 files changed, 75 insertions(+), 4 deletions(-) diff --git a/indra/llcharacter/lleditingmotion.cpp b/indra/llcharacter/lleditingmotion.cpp index 4a2de6215..6ed1c011a 100644 --- a/indra/llcharacter/lleditingmotion.cpp +++ b/indra/llcharacter/lleditingmotion.cpp @@ -40,6 +40,7 @@ #include "llhandmotion.h" #include "llcriticaldamp.h" + //----------------------------------------------------------------------------- // Constants //----------------------------------------------------------------------------- @@ -220,7 +221,7 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask) target = target * target_dist; if (!target.isFinite()) { - llerrs << "Non finite target in editing motion with target distance of " << target_dist << + llwarns << "Non finite target in editing motion with target distance of " << target_dist << " and focus point " << focus_pt << " and pointAtPt: " << *pointAtPt << llendl; } diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index 37afcb7cd..ad745f9c2 100644 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -526,4 +526,35 @@ void LLJoint::clampRotation(LLQuaternion old_rot, LLQuaternion new_rot) // } } +// +std::string LLJoint::exportString(U32 tabs) +{ + std::string out; + for(U32 i = 0; i < tabs; i++) out.append("\t"); + out.append("mName.c_str())); + LLVector3 position = getPosition(); + out.append(llformat("pos=\"<%f, %f, %f>\" ", position.mV[0], position.mV[1], position.mV[2])); + LLQuaternion rotation = getRotation(); + out.append(llformat("rot=\"<%f, %f, %f, %f>\" ", rotation.mQ[0], rotation.mQ[1], rotation.mQ[2], rotation.mQ[3])); + if(mChildren.empty()) + { + out.append("/>\n"); + } + else + { + out.append(">\n"); + int next_tab = tabs + 1; + child_list_t::iterator end = mChildren.end(); + for(child_list_t::iterator iter = mChildren.begin(); iter != end; ++iter) + { + out.append((*iter)->exportString(next_tab)); + } + for(U32 i = 0; i < tabs; i++) out.append("\t"); + out.append("\n"); + } + return out; +} +// + // End diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index b1a0b74f8..75114a223 100644 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -178,6 +178,10 @@ public: S32 getJointNum() const { return mJointNum; } void setJointNum(S32 joint_num) { mJointNum = joint_num; } + + // + std::string exportString(U32 tabs = 0); + // }; #endif // LL_LLJOINT_H diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index 32dcde12c..b28e7387d 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -468,7 +468,14 @@ LLMotion *LLKeyframeMotion::create(const LLUUID &id) //----------------------------------------------------------------------------- LLPointer& LLKeyframeMotion::getJointState(U32 index) { - llassert_always (index < (S32)mJointStates.size()); + // + //llassert_always (index < (S32)mJointStates.size()); + if(index >= (S32)mJointStates.size()) + { + llwarns << "LLKeyframeMotion::getJointState: index >= size" << llendl; + index = (S32)mJointStates.size() - 1; + } + // return mJointStates[index]; } @@ -477,7 +484,11 @@ LLPointer& LLKeyframeMotion::getJointState(U32 index) //----------------------------------------------------------------------------- LLJoint* LLKeyframeMotion::getJoint(U32 index) { - llassert_always (index < (S32)mJointStates.size()); + // + //llassert_always (index < (S32)mJointStates.size()); + if(index >= (S32)mJointStates.size()) + index = (S32)mJointStates.size() - 1; + // LLJoint* joint = mJointStates[index]->getJoint(); llassert_always (joint); return joint; @@ -1372,6 +1383,18 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) } else { + // + int sz = joint_name.size(); + int i = 0; + while (i < sz) + { + if ('\a' == joint_name[i]) + { + joint_name.replace(i, 1, " "); + } + i++; + } + // llwarns << "joint not found: " << joint_name << llendl; //return FALSE; } @@ -1650,6 +1673,15 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) str = (char*)bin_data; constraintp->mSourceConstraintVolume = mCharacter->getCollisionVolumeID(str); + // + if(constraintp->mSourceConstraintVolume == -1) + { + llwarns << "can't get source constraint volume" << llendl; + delete constraintp; + return FALSE; + } + // + if (!dp.unpackVector3(constraintp->mSourceConstraintOffset, "source_offset")) { llwarns << "can't read constraint source offset" << llendl; diff --git a/indra/llcharacter/llpose.cpp b/indra/llcharacter/llpose.cpp index 93255d702..8e6a3edda 100644 --- a/indra/llcharacter/llpose.cpp +++ b/indra/llcharacter/llpose.cpp @@ -158,6 +158,9 @@ void LLPose::setWeight(F32 weight) iter != mJointMap.end(); ++iter) { + // + // there was a crash here + // iter->second->setWeight(weight); } mWeight = weight; diff --git a/indra/newview/llimportobject.cpp b/indra/newview/llimportobject.cpp index f0d285f8d..6067daa44 100644 --- a/indra/newview/llimportobject.cpp +++ b/indra/newview/llimportobject.cpp @@ -421,7 +421,7 @@ LLImportObject::LLImportObject(std::string id, LLSD prim) importIsAttachment = false; mId = id; mParentId = ""; - mPrimName = "Primitive"; + mPrimName = "Object"; if(prim.has("parent")) { mParentId = prim["parent"].asString();