summaryrefslogtreecommitdiff
path: root/indra/llcharacter/llkeyframemotion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcharacter/llkeyframemotion.cpp')
-rw-r--r--indra/llcharacter/llkeyframemotion.cpp265
1 files changed, 147 insertions, 118 deletions
diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp
index a25ff16786..6720f902bd 100644
--- a/indra/llcharacter/llkeyframemotion.cpp
+++ b/indra/llcharacter/llkeyframemotion.cpp
@@ -626,10 +626,8 @@ BOOL LLKeyframeMotion::setupPose()
}
// initialize joint constraints
- for (JointMotionList::constraint_list_t::iterator iter = mJointMotionList->mConstraints.begin();
- iter != mJointMotionList->mConstraints.end(); ++iter)
+ for (JointConstraintSharedData* shared_constraintp : mJointMotionList->mConstraints)
{
- JointConstraintSharedData* shared_constraintp = *iter;
JointConstraint* constraintp = new JointConstraint(shared_constraintp);
initializeConstraint(constraintp);
mConstraints.push_front(constraintp);
@@ -764,19 +762,15 @@ void LLKeyframeMotion::applyConstraints(F32 time, U8* joint_mask)
if (mCharacter->getSkeletonSerialNum() != mLastSkeletonSerialNum)
{
mLastSkeletonSerialNum = mCharacter->getSkeletonSerialNum();
- for (constraint_list_t::iterator iter = mConstraints.begin();
- iter != mConstraints.end(); ++iter)
+ for (JointConstraint* constraintp : mConstraints)
{
- JointConstraint* constraintp = *iter;
initializeConstraint(constraintp);
}
}
// apply constraints
- for (constraint_list_t::iterator iter = mConstraints.begin();
- iter != mConstraints.end(); ++iter)
+ for (JointConstraint* constraintp : mConstraints)
{
- JointConstraint* constraintp = *iter;
applyConstraint(constraintp, time, joint_mask);
}
}
@@ -786,10 +780,8 @@ void LLKeyframeMotion::applyConstraints(F32 time, U8* joint_mask)
//-----------------------------------------------------------------------------
void LLKeyframeMotion::onDeactivate()
{
- for (constraint_list_t::iterator iter = mConstraints.begin();
- iter != mConstraints.end(); ++iter)
+ for (JointConstraint* constraintp : mConstraints)
{
- JointConstraint* constraintp = *iter;
deactivateConstraint(constraintp);
}
}
@@ -1222,11 +1214,14 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8
//-----------------------------------------------------------------------------
// deserialize()
+//
+// allow_invalid_joints should be true when handling existing content, to avoid breakage.
+// During upload, we should be more restrictive and reject such animations.
//-----------------------------------------------------------------------------
-BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
+BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, bool allow_invalid_joints)
{
BOOL old_version = FALSE;
- mJointMotionList = new LLKeyframeMotion::JointMotionList;
+ std::unique_ptr<LLKeyframeMotion::JointMotionList> joint_motion_list(new LLKeyframeMotion::JointMotionList);
//-------------------------------------------------------------------------
// get base priority
@@ -1269,16 +1264,16 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
<< " for animation " << asset_id << LL_ENDL;
return FALSE;
}
- mJointMotionList->mBasePriority = (LLJoint::JointPriority) temp_priority;
+ joint_motion_list->mBasePriority = (LLJoint::JointPriority) temp_priority;
- if (mJointMotionList->mBasePriority >= LLJoint::ADDITIVE_PRIORITY)
+ if (joint_motion_list->mBasePriority >= LLJoint::ADDITIVE_PRIORITY)
{
- mJointMotionList->mBasePriority = (LLJoint::JointPriority)((S32)LLJoint::ADDITIVE_PRIORITY-1);
- mJointMotionList->mMaxPriority = mJointMotionList->mBasePriority;
+ joint_motion_list->mBasePriority = (LLJoint::JointPriority)((S32)LLJoint::ADDITIVE_PRIORITY-1);
+ joint_motion_list->mMaxPriority = joint_motion_list->mBasePriority;
}
- else if (mJointMotionList->mBasePriority < LLJoint::USE_MOTION_PRIORITY)
+ else if (joint_motion_list->mBasePriority < LLJoint::USE_MOTION_PRIORITY)
{
- LL_WARNS() << "bad animation base_priority " << mJointMotionList->mBasePriority
+ LL_WARNS() << "bad animation base_priority " << joint_motion_list->mBasePriority
<< " for animation " << asset_id << LL_ENDL;
return FALSE;
}
@@ -1286,15 +1281,15 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
//-------------------------------------------------------------------------
// get duration
//-------------------------------------------------------------------------
- if (!dp.unpackF32(mJointMotionList->mDuration, "duration"))
+ if (!dp.unpackF32(joint_motion_list->mDuration, "duration"))
{
LL_WARNS() << "can't read duration"
<< " for animation " << asset_id << LL_ENDL;
return FALSE;
}
- if (mJointMotionList->mDuration > MAX_ANIM_DURATION ||
- !llfinite(mJointMotionList->mDuration))
+ if (joint_motion_list->mDuration > MAX_ANIM_DURATION ||
+ !llfinite(joint_motion_list->mDuration))
{
LL_WARNS() << "invalid animation duration"
<< " for animation " << asset_id << LL_ENDL;
@@ -1304,14 +1299,14 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
//-------------------------------------------------------------------------
// get emote (optional)
//-------------------------------------------------------------------------
- if (!dp.unpackString(mJointMotionList->mEmoteName, "emote_name"))
+ if (!dp.unpackString(joint_motion_list->mEmoteName, "emote_name"))
{
LL_WARNS() << "can't read optional_emote_animation"
<< " for animation " << asset_id << LL_ENDL;
return FALSE;
}
- if(mJointMotionList->mEmoteName==mID.asString())
+ if(joint_motion_list->mEmoteName==mID.asString())
{
LL_WARNS() << "Malformed animation mEmoteName==mID"
<< " for animation " << asset_id << LL_ENDL;
@@ -1321,42 +1316,51 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
//-------------------------------------------------------------------------
// get loop
//-------------------------------------------------------------------------
- if (!dp.unpackF32(mJointMotionList->mLoopInPoint, "loop_in_point") ||
- !llfinite(mJointMotionList->mLoopInPoint))
+ if (!dp.unpackF32(joint_motion_list->mLoopInPoint, "loop_in_point") ||
+ !llfinite(joint_motion_list->mLoopInPoint))
{
LL_WARNS() << "can't read loop point"
<< " for animation " << asset_id << LL_ENDL;
return FALSE;
}
- if (!dp.unpackF32(mJointMotionList->mLoopOutPoint, "loop_out_point") ||
- !llfinite(mJointMotionList->mLoopOutPoint))
+ if (!dp.unpackF32(joint_motion_list->mLoopOutPoint, "loop_out_point") ||
+ !llfinite(joint_motion_list->mLoopOutPoint))
{
LL_WARNS() << "can't read loop point"
<< " for animation " << asset_id << LL_ENDL;
return FALSE;
}
- if (!dp.unpackS32(mJointMotionList->mLoop, "loop"))
+ if (!dp.unpackS32(joint_motion_list->mLoop, "loop"))
{
LL_WARNS() << "can't read loop"
<< " for animation " << asset_id << LL_ENDL;
return FALSE;
}
+ //SL-17206 hack to alter Female_land loop setting, while current behavior won't be changed serverside
+ LLUUID const female_land_anim("ca1baf4d-0a18-5a1f-0330-e4bd1e71f09e");
+ LLUUID const formal_female_land_anim("6a9a173b-61fa-3ad5-01fa-a851cfc5f66a");
+ if (female_land_anim == asset_id || formal_female_land_anim == asset_id)
+ {
+ LL_WARNS() << "Animation(" << asset_id << ") won't be looped." << LL_ENDL;
+ joint_motion_list->mLoop = FALSE;
+ }
+
//-------------------------------------------------------------------------
// get easeIn and easeOut
//-------------------------------------------------------------------------
- if (!dp.unpackF32(mJointMotionList->mEaseInDuration, "ease_in_duration") ||
- !llfinite(mJointMotionList->mEaseInDuration))
+ if (!dp.unpackF32(joint_motion_list->mEaseInDuration, "ease_in_duration") ||
+ !llfinite(joint_motion_list->mEaseInDuration))
{
LL_WARNS() << "can't read easeIn"
<< " for animation " << asset_id << LL_ENDL;
return FALSE;
}
- if (!dp.unpackF32(mJointMotionList->mEaseOutDuration, "ease_out_duration") ||
- !llfinite(mJointMotionList->mEaseOutDuration))
+ if (!dp.unpackF32(joint_motion_list->mEaseOutDuration, "ease_out_duration") ||
+ !llfinite(joint_motion_list->mEaseOutDuration))
{
LL_WARNS() << "can't read easeOut"
<< " for animation " << asset_id << LL_ENDL;
@@ -1381,7 +1385,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
return FALSE;
}
- mJointMotionList->mHandPose = (LLHandMotion::eHandPose)word;
+ joint_motion_list->mHandPose = (LLHandMotion::eHandPose)word;
//-------------------------------------------------------------------------
// get number of joint motions
@@ -1407,8 +1411,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
return FALSE;
}
- mJointMotionList->mJointMotionArray.clear();
- mJointMotionList->mJointMotionArray.reserve(num_motions);
+ joint_motion_list->mJointMotionArray.clear();
+ joint_motion_list->mJointMotionArray.reserve(num_motions);
mJointStates.clear();
mJointStates.reserve(num_motions);
@@ -1419,7 +1423,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
for(U32 i=0; i<num_motions; ++i)
{
JointMotion* joint_motion = new JointMotion;
- mJointMotionList->mJointMotionArray.push_back(joint_motion);
+ joint_motion_list->mJointMotionArray.push_back(joint_motion);
std::string joint_name;
if (!dp.unpackString(joint_name, "joint_name"))
@@ -1443,6 +1447,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
if (joint)
{
S32 joint_num = joint->getJointNum();
+ joint_name = joint->getName(); // canonical name in case this is an alias.
// LL_INFOS() << " joint: " << joint_name << LL_ENDL;
if ((joint_num >= (S32)LL_CHARACTER_MAX_ANIMATED_JOINTS) || (joint_num < 0))
{
@@ -1457,7 +1462,10 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "invalid joint name: " << joint_name
<< " for animation " << asset_id << LL_ENDL;
- //return FALSE;
+ if (!allow_invalid_joints)
+ {
+ return FALSE;
+ }
}
joint_motion->mJointName = joint_name;
@@ -1487,9 +1495,9 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
joint_motion->mPriority = (LLJoint::JointPriority)joint_priority;
if (joint_priority != LLJoint::USE_MOTION_PRIORITY &&
- joint_priority > mJointMotionList->mMaxPriority)
+ joint_priority > joint_motion_list->mMaxPriority)
{
- mJointMotionList->mMaxPriority = (LLJoint::JointPriority)joint_priority;
+ joint_motion_list->mMaxPriority = (LLJoint::JointPriority)joint_priority;
}
joint_state->setPriority((LLJoint::JointPriority)joint_priority);
@@ -1540,9 +1548,9 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
return FALSE;
}
- time = U16_to_F32(time_short, 0.f, mJointMotionList->mDuration);
+ time = U16_to_F32(time_short, 0.f, joint_motion_list->mDuration);
- if (time < 0 || time > mJointMotionList->mDuration)
+ if (time < 0 || time > joint_motion_list->mDuration)
{
LL_WARNS() << "invalid frame time"
<< " for animation " << asset_id << LL_ENDL;
@@ -1555,38 +1563,57 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
LLVector3 rot_angles;
U16 x, y, z;
- BOOL success = TRUE;
-
if (old_version)
{
- success = dp.unpackVector3(rot_angles, "rot_angles") && rot_angles.isFinite();
+ if (!dp.unpackVector3(rot_angles, "rot_angles"))
+ {
+ LL_WARNS() << "can't read rot_angles in rotation key (" << k << ")" << LL_ENDL;
+ return FALSE;
+ }
+ if (!rot_angles.isFinite())
+ {
+ LL_WARNS() << "non-finite angle in rotation key (" << k << ")" << LL_ENDL;
+ return FALSE;
+ }
LLQuaternion::Order ro = StringToOrder("ZYX");
rot_key.mRotation = mayaQ(rot_angles.mV[VX], rot_angles.mV[VY], rot_angles.mV[VZ], ro);
}
else
{
- success &= dp.unpackU16(x, "rot_angle_x");
- success &= dp.unpackU16(y, "rot_angle_y");
- success &= dp.unpackU16(z, "rot_angle_z");
+ if (!dp.unpackU16(x, "rot_angle_x"))
+ {
+ LL_WARNS() << "can't read rot_angle_x in rotation key (" << k << ")" << LL_ENDL;
+ return FALSE;
+ }
+ if (!dp.unpackU16(y, "rot_angle_y"))
+ {
+ LL_WARNS() << "can't read rot_angle_y in rotation key (" << k << ")" << LL_ENDL;
+ return FALSE;
+ }
+ if (!dp.unpackU16(z, "rot_angle_z"))
+ {
+ LL_WARNS() << "can't read rot_angle_z in rotation key (" << k << ")" << LL_ENDL;
+ return FALSE;
+ }
LLVector3 rot_vec;
rot_vec.mV[VX] = U16_to_F32(x, -1.f, 1.f);
rot_vec.mV[VY] = U16_to_F32(y, -1.f, 1.f);
rot_vec.mV[VZ] = U16_to_F32(z, -1.f, 1.f);
+
+ if(!rot_vec.isFinite())
+ {
+ LL_WARNS() << "non-finite angle in rotation key (" << k << ")"
+ << " for animation " << asset_id << LL_ENDL;
+ return FALSE;
+ }
rot_key.mRotation.unpackFromVector3(rot_vec);
}
- if( !(rot_key.mRotation.isFinite()) )
+ if(!rot_key.mRotation.isFinite())
{
- LL_WARNS() << "non-finite angle in rotation key"
- << " for animation " << asset_id << LL_ENDL;
- success = FALSE;
- }
-
- if (!success)
- {
- LL_WARNS() << "can't read rotation key (" << k << ")"
+ LL_WARNS() << "non-finite angle in rotation key (" << k << ")"
<< " for animation " << asset_id << LL_ENDL;
return FALSE;
}
@@ -1639,14 +1666,16 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
return FALSE;
}
- pos_key.mTime = U16_to_F32(time_short, 0.f, mJointMotionList->mDuration);
+ pos_key.mTime = U16_to_F32(time_short, 0.f, joint_motion_list->mDuration);
}
- BOOL success = TRUE;
-
if (old_version)
{
- success = dp.unpackVector3(pos_key.mPosition, "pos");
+ if (!dp.unpackVector3(pos_key.mPosition, "pos"))
+ {
+ LL_WARNS() << "can't read pos in position key (" << k << ")" << LL_ENDL;
+ return FALSE;
+ }
//MAINT-6162
pos_key.mPosition.mV[VX] = llclamp( pos_key.mPosition.mV[VX], -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET);
@@ -1658,26 +1687,31 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
U16 x, y, z;
- success &= dp.unpackU16(x, "pos_x");
- success &= dp.unpackU16(y, "pos_y");
- success &= dp.unpackU16(z, "pos_z");
+ if (!dp.unpackU16(x, "pos_x"))
+ {
+ LL_WARNS() << "can't read pos_x in position key (" << k << ")" << LL_ENDL;
+ return FALSE;
+ }
+ if (!dp.unpackU16(y, "pos_y"))
+ {
+ LL_WARNS() << "can't read pos_y in position key (" << k << ")" << LL_ENDL;
+ return FALSE;
+ }
+ if (!dp.unpackU16(z, "pos_z"))
+ {
+ LL_WARNS() << "can't read pos_z in position key (" << k << ")" << LL_ENDL;
+ return FALSE;
+ }
pos_key.mPosition.mV[VX] = U16_to_F32(x, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET);
pos_key.mPosition.mV[VY] = U16_to_F32(y, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET);
pos_key.mPosition.mV[VZ] = U16_to_F32(z, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET);
}
- if( !(pos_key.mPosition.isFinite()) )
+ if(!pos_key.mPosition.isFinite())
{
LL_WARNS() << "non-finite position in key"
<< " for animation " << asset_id << LL_ENDL;
- success = FALSE;
- }
-
- if (!success)
- {
- LL_WARNS() << "can't read position key (" << k << ")"
- << " for animation " << asset_id << LL_ENDL;
return FALSE;
}
@@ -1685,7 +1719,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
if (is_pelvis)
{
- mJointMotionList->mPelvisBBox.addPoint(pos_key.mPosition);
+ joint_motion_list->mPelvisBBox.addPoint(pos_key.mPosition);
}
}
@@ -1717,23 +1751,21 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
for(S32 i = 0; i < num_constraints; ++i)
{
// read in constraint data
- JointConstraintSharedData* constraintp = new JointConstraintSharedData;
+ std::unique_ptr<JointConstraintSharedData> constraintp(new JointConstraintSharedData);
U8 byte = 0;
if (!dp.unpackU8(byte, "chain_length"))
{
LL_WARNS() << "can't read constraint chain length"
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
constraintp->mChainLength = (S32) byte;
- if((U32)constraintp->mChainLength > mJointMotionList->getNumJointMotions())
+ if((U32)constraintp->mChainLength > joint_motion_list->getNumJointMotions())
{
LL_WARNS() << "invalid constraint chain length"
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
@@ -1741,7 +1773,6 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "can't read constraint type"
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
@@ -1749,7 +1780,6 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "invalid constraint type"
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
constraintp->mConstraintType = (EConstraintType)byte;
@@ -1760,7 +1790,6 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "can't read source volume name"
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
@@ -1771,7 +1800,6 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "not a valid source constraint volume " << str
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
@@ -1779,7 +1807,6 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "can't read constraint source offset"
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
@@ -1787,7 +1814,6 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "non-finite constraint source offset"
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
@@ -1795,7 +1821,6 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "can't read target volume name"
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
@@ -1814,7 +1839,6 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "not a valid target constraint volume " << str
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
}
@@ -1823,7 +1847,6 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "can't read constraint target offset"
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
@@ -1831,7 +1854,6 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "non-finite constraint target offset"
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
@@ -1839,7 +1861,6 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "can't read constraint target direction"
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
@@ -1847,7 +1868,6 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "non-finite constraint target direction"
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
@@ -1861,7 +1881,6 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "can't read constraint ease in start time"
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
@@ -1869,7 +1888,6 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "can't read constraint ease in stop time"
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
@@ -1877,7 +1895,6 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "can't read constraint ease out start time"
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
@@ -1885,33 +1902,31 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "can't read constraint ease out stop time"
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
- mJointMotionList->mConstraints.push_front(constraintp);
-
- constraintp->mJointStateIndices = new S32[constraintp->mChainLength + 1]; // note: mChainLength is size-limited - comes from a byte
-
LLJoint* joint = mCharacter->findCollisionVolume(constraintp->mSourceConstraintVolume);
// get joint to which this collision volume is attached
if (!joint)
{
return FALSE;
}
+
+ constraintp->mJointStateIndices = new S32[constraintp->mChainLength + 1]; // note: mChainLength is size-limited - comes from a byte
+
for (S32 i = 0; i < constraintp->mChainLength + 1; i++)
{
LLJoint* parent = joint->getParent();
if (!parent)
{
LL_WARNS() << "Joint with no parent: " << joint->getName()
- << " Emote: " << mJointMotionList->mEmoteName
+ << " Emote: " << joint_motion_list->mEmoteName
<< " for animation " << asset_id << LL_ENDL;
return FALSE;
}
joint = parent;
constraintp->mJointStateIndices[i] = -1;
- for (U32 j = 0; j < mJointMotionList->getNumJointMotions(); j++)
+ for (U32 j = 0; j < joint_motion_list->getNumJointMotions(); j++)
{
LLJoint* constraint_joint = getJoint(j);
@@ -1932,14 +1947,16 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id)
{
LL_WARNS() << "No joint index for constraint " << i
<< " for animation " << asset_id << LL_ENDL;
- delete constraintp;
return FALSE;
}
}
+
+ joint_motion_list->mConstraints.push_front(constraintp.release());
}
}
// *FIX: support cleanup of old keyframe data
+ mJointMotionList = joint_motion_list.release(); // release from unique_ptr to member;
LLKeyframeDataCache::addKeyframeData(getID(), mJointMotionList);
mAssetStatus = ASSET_LOADED;
@@ -1991,10 +2008,9 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
success &= dp.packS32(joint_motionp->mRotationCurve.mNumKeys, "num_rot_keys");
LL_DEBUGS("BVH") << "Joint " << joint_motionp->mJointName << LL_ENDL;
- for (RotationCurve::key_map_t::iterator iter = joint_motionp->mRotationCurve.mKeys.begin();
- iter != joint_motionp->mRotationCurve.mKeys.end(); ++iter)
+ for (RotationCurve::key_map_t::value_type& rot_pair : joint_motionp->mRotationCurve.mKeys)
{
- RotationKey& rot_key = iter->second;
+ RotationKey& rot_key = rot_pair.second;
U16 time_short = F32_to_U16(rot_key.mTime, 0.f, mJointMotionList->mDuration);
success &= dp.packU16(time_short, "time");
@@ -2013,10 +2029,9 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
}
success &= dp.packS32(joint_motionp->mPositionCurve.mNumKeys, "num_pos_keys");
- for (PositionCurve::key_map_t::iterator iter = joint_motionp->mPositionCurve.mKeys.begin();
- iter != joint_motionp->mPositionCurve.mKeys.end(); ++iter)
+ for (PositionCurve::key_map_t::value_type& pos_pair : joint_motionp->mPositionCurve.mKeys)
{
- PositionKey& pos_key = iter->second;
+ PositionKey& pos_key = pos_pair.second;
U16 time_short = F32_to_U16(pos_key.mTime, 0.f, mJointMotionList->mDuration);
success &= dp.packU16(time_short, "time");
@@ -2035,10 +2050,8 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
success &= dp.packS32(mJointMotionList->mConstraints.size(), "num_constraints");
LL_DEBUGS("BVH") << "num_constraints " << mJointMotionList->mConstraints.size() << LL_ENDL;
- for (JointMotionList::constraint_list_t::const_iterator iter = mJointMotionList->mConstraints.begin();
- iter != mJointMotionList->mConstraints.end(); ++iter)
+ for (JointConstraintSharedData* shared_constraintp : mJointMotionList->mConstraints)
{
- JointConstraintSharedData* shared_constraintp = *iter;
success &= dp.packU8(shared_constraintp->mChainLength, "chain_length");
success &= dp.packU8(shared_constraintp->mConstraintType, "constraint_type");
char source_volume[16]; /* Flawfinder: ignore */
@@ -2096,8 +2109,9 @@ U32 LLKeyframeMotion::getFileSize()
//-----------------------------------------------------------------------------
// dumpToFile()
//-----------------------------------------------------------------------------
-void LLKeyframeMotion::dumpToFile(const std::string& name)
+bool LLKeyframeMotion::dumpToFile(const std::string& name)
{
+ bool succ = false;
if (isLoaded())
{
std::string outfile_base;
@@ -2114,10 +2128,24 @@ void LLKeyframeMotion::dumpToFile(const std::string& name)
const LLUUID& id = getID();
outfile_base = id.asString();
}
- std::string outfilename = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,outfile_base + ".anim");
+
+ if (gDirUtilp->getExtension(outfile_base).empty())
+ {
+ outfile_base += ".anim";
+ }
+ std::string outfilename;
+ if (gDirUtilp->getDirName(outfile_base).empty())
+ {
+ outfilename = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,outfile_base);
+ }
+ else
+ {
+ outfilename = outfile_base;
+ }
if (LLFile::isfile(outfilename))
{
- return;
+ LL_WARNS() << outfilename << " already exists, write failed" << LL_ENDL;
+ return false;
}
S32 file_size = getFileSize();
@@ -2131,11 +2159,13 @@ void LLKeyframeMotion::dumpToFile(const std::string& name)
outfile.open(outfilename, LL_APR_WPB);
if (outfile.getFileHandle())
{
- outfile.write(buffer, file_size);
+ S32 wrote_bytes = outfile.write(buffer, file_size);
+ succ = (wrote_bytes == file_size);
}
}
delete [] buffer;
}
+ return succ;
}
//-----------------------------------------------------------------------------
@@ -2373,14 +2403,13 @@ void LLKeyframeDataCache::dumpDiagInfo()
LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
// print each loaded mesh, and it's memory usage
- for (keyframe_data_map_t::iterator map_it = sKeyframeDataMap.begin();
- map_it != sKeyframeDataMap.end(); ++map_it)
+ for (keyframe_data_map_t::value_type& data_pair : sKeyframeDataMap)
{
U32 joint_motion_kb;
- LLKeyframeMotion::JointMotionList *motion_list_p = map_it->second;
+ LLKeyframeMotion::JointMotionList *motion_list_p = data_pair.second;
- LL_INFOS() << "Motion: " << map_it->first << LL_ENDL;
+ LL_INFOS() << "Motion: " << data_pair.first << LL_ENDL;
joint_motion_kb = motion_list_p->dumpDiagInfo();