diff options
Diffstat (limited to 'indra/llcharacter/llkeyframemotion.cpp')
-rw-r--r-- | indra/llcharacter/llkeyframemotion.cpp | 422 |
1 files changed, 234 insertions, 188 deletions
diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index d95ec159f2..2706e2ed31 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -66,7 +66,7 @@ static F32 MAX_CONSTRAINTS = 10; //----------------------------------------------------------------------------- LLKeyframeMotion::JointMotionList::JointMotionList() : mDuration(0.f), - mLoop(FALSE), + mLoop(false), mLoopInPoint(0.f), mLoopOutPoint(0.f), mEaseInDuration(0.f), @@ -505,11 +505,12 @@ LLMotion::LLMotionInitStatus LLKeyframeMotion::onInitialize(LLCharacter *charact LLAssetType::AT_ANIMATION, onLoadComplete, (void*)character_id, - FALSE); + false); } else { - LL_INFOS("Animation") << "Attempted to fetch animation " << mName << " with null id for character " << mCharacter->getID() << LL_ENDL; + LL_INFOS("Animation") << "Attempted to fetch animation '" << mName << "' with null id" + << " for character " << mCharacter->getID() << LL_ENDL; } return STATUS_HOLD; @@ -565,7 +566,7 @@ LLMotion::LLMotionInitStatus LLKeyframeMotion::onInitialize(LLCharacter *charact U8 *anim_data; S32 anim_file_size; - BOOL success = FALSE; + bool success = false; LLFileSystem* anim_file = new LLFileSystem(mID, LLAssetType::AT_ANIMATION); if (!anim_file || !anim_file->getSize()) { @@ -620,7 +621,7 @@ LLMotion::LLMotionInitStatus LLKeyframeMotion::onInitialize(LLCharacter *charact //----------------------------------------------------------------------------- // setupPose() //----------------------------------------------------------------------------- -BOOL LLKeyframeMotion::setupPose() +bool LLKeyframeMotion::setupPose() { // add all valid joint states to the pose for (U32 jm=0; jm<mJointMotionList->getNumJointMotions(); jm++) @@ -645,7 +646,7 @@ BOOL LLKeyframeMotion::setupPose() mPelvisp = mCharacter->getJoint("mPelvis"); if (!mPelvisp) { - return FALSE; + return false; } } @@ -653,34 +654,33 @@ BOOL LLKeyframeMotion::setupPose() setLoopIn(mJointMotionList->mLoopInPoint); setLoopOut(mJointMotionList->mLoopOutPoint); - return TRUE; + return true; } //----------------------------------------------------------------------------- // LLKeyframeMotion::onActivate() //----------------------------------------------------------------------------- -BOOL LLKeyframeMotion::onActivate() +bool LLKeyframeMotion::onActivate() { - // If the keyframe anim has an associated emote, trigger it. - if( mJointMotionList->mEmoteName.length() > 0 ) + // If the keyframe anim has an associated emote, trigger it. + if (mJointMotionList->mEmoteID.notNull()) { - LLUUID emote_anim_id = gAnimLibrary.stringToAnimState(mJointMotionList->mEmoteName); // don't start emote if already active to avoid recursion - if (!mCharacter->isMotionActive(emote_anim_id)) + if (!mCharacter->isMotionActive(mJointMotionList->mEmoteID)) { - mCharacter->startMotion( emote_anim_id ); + mCharacter->startMotion(mJointMotionList->mEmoteID); } } mLastLoopedTime = 0.f; - return TRUE; + return true; } //----------------------------------------------------------------------------- // LLKeyframeMotion::onUpdate() //----------------------------------------------------------------------------- -BOOL LLKeyframeMotion::onUpdate(F32 time, U8* joint_mask) +bool LLKeyframeMotion::onUpdate(F32 time, U8* joint_mask) { LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; // llassert(time >= 0.f); // This will fire @@ -869,7 +869,7 @@ void LLKeyframeMotion::initializeConstraint(JointConstraint* constraint) void LLKeyframeMotion::activateConstraint(JointConstraint* constraint) { JointConstraintSharedData *shared_data = constraint->mSharedData; - constraint->mActive = TRUE; + constraint->mActive = true; S32 joint_num; // grab ground position if we need to @@ -901,17 +901,17 @@ void LLKeyframeMotion::deactivateConstraint(JointConstraint *constraintp) { if (constraintp->mSourceVolume) { - constraintp->mSourceVolume->mUpdateXform = FALSE; + constraintp->mSourceVolume->mUpdateXform = false; } if (constraintp->mSharedData->mConstraintTargetType != CONSTRAINT_TARGET_TYPE_GROUND) { if (constraintp->mTargetVolume) { - constraintp->mTargetVolume->mUpdateXform = FALSE; + constraintp->mTargetVolume->mUpdateXform = false; } } - constraintp->mActive = FALSE; + constraintp->mActive = false; } //----------------------------------------------------------------------------- @@ -1088,9 +1088,9 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 // convert intermediate joint positions to world coordinates positions[joint_num] = ( constraint->mPositions[joint_num] * mPelvisp->getWorldRotation()) + mPelvisp->getWorldPosition(); F32 time_constant = 1.f / clamp_rescale(constraint->mFixupDistanceRMS, 0.f, 0.5f, 0.2f, 8.f); -// LL_INFOS() << "Interpolant " << LLSmoothInterpolation::getInterpolant(time_constant, FALSE) << " and fixup distance " << constraint->mFixupDistanceRMS << " on " << mCharacter->findCollisionVolume(shared_data->mSourceConstraintVolume)->getName() << LL_ENDL; - positions[joint_num] = lerp(positions[joint_num], kinematic_position, - LLSmoothInterpolation::getInterpolant(time_constant, FALSE)); +// LL_INFOS() << "Interpolant " << LLSmoothInterpolation::getInterpolant(time_constant, false) << " and fixup distance " << constraint->mFixupDistanceRMS << " on " << mCharacter->findCollisionVolume(shared_data->mSourceConstraintVolume)->getName() << LL_ENDL; + positions[joint_num] = lerp(positions[joint_num], kinematic_position, + LLSmoothInterpolation::getInterpolant(time_constant, false)); } S32 iteration_count; @@ -1225,9 +1225,9 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 // 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 allow_invalid_joints) +bool LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, bool allow_invalid_joints) { - BOOL old_version = FALSE; + bool old_version = false; std::unique_ptr<LLKeyframeMotion::JointMotionList> joint_motion_list(new LLKeyframeMotion::JointMotionList); //------------------------------------------------------------------------- @@ -1237,39 +1237,47 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo U16 version; U16 sub_version; + // Amimation identifier for log messages + auto asset = [&]() -> std::string + { + return asset_id.asString() + ", char " + mCharacter->getID().asString(); + }; + if (!dp.unpackU16(version, "version")) { - LL_WARNS() << "can't read version number for animation " << asset_id << LL_ENDL; - return FALSE; + LL_WARNS() << "can't read version number" + << " for animation " << asset() << LL_ENDL; + return false; } if (!dp.unpackU16(sub_version, "sub_version")) { - LL_WARNS() << "can't read sub version number for animation " << asset_id << LL_ENDL; - return FALSE; + LL_WARNS() << "can't read sub version number" + << " for animation " << asset() << LL_ENDL; + return false; } if (version == 0 && sub_version == 1) { - old_version = TRUE; + old_version = true; } else if (version != KEYFRAME_MOTION_VERSION || sub_version != KEYFRAME_MOTION_SUBVERSION) { #if LL_RELEASE LL_WARNS() << "Bad animation version " << version << "." << sub_version - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; #else LL_ERRS() << "Bad animation version " << version << "." << sub_version - << " for animation " << asset_id << LL_ENDL; + << " for animation " << asset() << LL_ENDL; #endif } if (!dp.unpackS32(temp_priority, "base_priority")) { LL_WARNS() << "can't read animation base_priority" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } joint_motion_list->mBasePriority = (LLJoint::JointPriority) temp_priority; @@ -1281,8 +1289,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo else if (joint_motion_list->mBasePriority < LLJoint::USE_MOTION_PRIORITY) { LL_WARNS() << "bad animation base_priority " << joint_motion_list->mBasePriority - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } //------------------------------------------------------------------------- @@ -1291,16 +1299,16 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (!dp.unpackF32(joint_motion_list->mDuration, "duration")) { LL_WARNS() << "can't read duration" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if (joint_motion_list->mDuration > MAX_ANIM_DURATION || !llfinite(joint_motion_list->mDuration)) { LL_WARNS() << "invalid animation duration" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } //------------------------------------------------------------------------- @@ -1308,16 +1316,34 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo //------------------------------------------------------------------------- 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; + LL_WARNS() << "can't read emote_name" + << " for animation " << asset() << LL_ENDL; + return false; } - if(joint_motion_list->mEmoteName==mID.asString()) + if (!joint_motion_list->mEmoteName.empty()) { - LL_WARNS() << "Malformed animation mEmoteName==mID" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + if (joint_motion_list->mEmoteName == mID.asString()) + { + LL_WARNS() << "Malformed animation mEmoteName==mID" + << " for animation " << asset() << LL_ENDL; + return false; + } + // "Closed_Mouth" is a very popular emote name we should ignore + if (joint_motion_list->mEmoteName == "Closed_Mouth") + { + joint_motion_list->mEmoteName.clear(); + } + else + { + joint_motion_list->mEmoteID = gAnimLibrary.stringToAnimState(joint_motion_list->mEmoteName); + if (joint_motion_list->mEmoteID.isNull()) + { + LL_WARNS() << "unknown emote_name '" << joint_motion_list->mEmoteName << "'" + << " for animation " << asset() << LL_ENDL; + joint_motion_list->mEmoteName.clear(); + } + } } //------------------------------------------------------------------------- @@ -1327,32 +1353,34 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo !llfinite(joint_motion_list->mLoopInPoint)) { LL_WARNS() << "can't read loop point" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } 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; + << " for animation " << asset() << LL_ENDL; + return false; } - if (!dp.unpackS32(joint_motion_list->mLoop, "loop")) + S32 loop{ 0 }; + if (!dp.unpackS32(loop, "loop")) { LL_WARNS() << "can't read loop" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } + joint_motion_list->mLoop = static_cast<bool>(loop); //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; + LL_WARNS() << "Animation " << asset() << " won't be looped." << LL_ENDL; + joint_motion_list->mLoop = false; } //------------------------------------------------------------------------- @@ -1362,16 +1390,16 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo !llfinite(joint_motion_list->mEaseInDuration)) { LL_WARNS() << "can't read easeIn" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } 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; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } //------------------------------------------------------------------------- @@ -1381,15 +1409,15 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (!dp.unpackU32(word, "hand_pose")) { LL_WARNS() << "can't read hand pose" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } - if(word > LLHandMotion::NUM_HAND_POSES) + if (word > LLHandMotion::NUM_HAND_POSES) { LL_WARNS() << "invalid LLHandMotion::eHandPose index: " << word - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } joint_motion_list->mHandPose = (LLHandMotion::eHandPose)word; @@ -1398,26 +1426,26 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo // get number of joint motions //------------------------------------------------------------------------- U32 num_motions = 0; - S32 rotation_dupplicates = 0; - S32 position_dupplicates = 0; + S32 rotation_duplicates = 0; + S32 position_duplicates = 0; if (!dp.unpackU32(num_motions, "num_joints")) { LL_WARNS() << "can't read number of joints" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if (num_motions == 0) { LL_WARNS() << "no joints" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } else if (num_motions > LL_CHARACTER_MAX_ANIMATED_JOINTS) { LL_WARNS() << "too many joints" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } joint_motion_list->mJointMotionArray.clear(); @@ -1429,7 +1457,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo // initialize joint motions //------------------------------------------------------------------------- - for(U32 i=0; i<num_motions; ++i) + for (U32 i = 0; i < num_motions; ++i) { JointMotion* joint_motion = new JointMotion; joint_motion_list->mJointMotionArray.push_back(joint_motion); @@ -1438,15 +1466,15 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (!dp.unpackString(joint_name, "joint_name")) { LL_WARNS() << "can't read joint name" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if (joint_name == "mScreen" || joint_name == "mRoot") { LL_WARNS() << "attempted to animate special " << joint_name << " joint" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } //--------------------------------------------------------------------- @@ -1463,17 +1491,17 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo LL_WARNS() << "Joint will be omitted from animation: joint_num " << joint_num << " is outside of legal range [0-" << LL_CHARACTER_MAX_ANIMATED_JOINTS << ") for joint " << joint->getName() - << " for animation " << asset_id << LL_ENDL; + << " for animation " << asset() << LL_ENDL; joint = NULL; } } else { LL_WARNS() << "invalid joint name: " << joint_name - << " for animation " << asset_id << LL_ENDL; + << " for animation " << asset() << LL_ENDL; if (!allow_invalid_joints) { - return FALSE; + return false; } } @@ -1491,15 +1519,15 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (!dp.unpackS32(joint_priority, "joint_priority")) { LL_WARNS() << "can't read joint priority." - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if (joint_priority < LLJoint::USE_MOTION_PRIORITY) { LL_WARNS() << "joint priority unknown - too low." - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } joint_motion->mPriority = (LLJoint::JointPriority)joint_priority; @@ -1517,8 +1545,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (!dp.unpackS32(joint_motion->mRotationCurve.mNumKeys, "num_rot_keys") || joint_motion->mRotationCurve.mNumKeys < 0) { LL_WARNS() << "can't read number of rotation keys" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } joint_motion->mRotationCurve.mInterpolationType = IT_LINEAR; @@ -1543,8 +1571,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo !llfinite(time)) { LL_WARNS() << "can't read rotation key (" << k << ")" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } } @@ -1553,8 +1581,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (!dp.unpackU16(time_short, "time")) { LL_WARNS() << "can't read rotation key (" << k << ")" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } time = U16_to_F32(time_short, 0.f, joint_motion_list->mDuration); @@ -1562,8 +1590,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (time < 0 || time > joint_motion_list->mDuration) { LL_WARNS() << "invalid frame time" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } } @@ -1576,13 +1604,15 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo { if (!dp.unpackVector3(rot_angles, "rot_angles")) { - LL_WARNS() << "can't read rot_angles in rotation key (" << k << ")" << LL_ENDL; - return FALSE; + LL_WARNS() << "can't read rot_angles in rotation key (" << k << ")" + << " for animation " << asset() << LL_ENDL; + return false; } if (!rot_angles.isFinite()) { - LL_WARNS() << "non-finite angle in rotation key (" << k << ")" << LL_ENDL; - return FALSE; + LL_WARNS() << "non-finite angle in rotation key (" << k << ")" + << " for animation " << asset() << LL_ENDL; + return false; } LLQuaternion::Order ro = StringToOrder("ZYX"); @@ -1592,18 +1622,21 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo { if (!dp.unpackU16(x, "rot_angle_x")) { - LL_WARNS() << "can't read rot_angle_x in rotation key (" << k << ")" << LL_ENDL; - return FALSE; + LL_WARNS() << "can't read rot_angle_x in rotation key (" << k << ")" + << " for animation " << asset() << 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; + LL_WARNS() << "can't read rot_angle_y in rotation key (" << k << ")" + << " for animation " << asset() << 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; + LL_WARNS() << "can't read rot_angle_z in rotation key (" << k << ")" + << " for animation " << asset() << LL_ENDL; + return false; } LLVector3 rot_vec; @@ -1611,20 +1644,20 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo 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()) + if (!rot_vec.isFinite()) { LL_WARNS() << "non-finite angle in rotation key (" << k << ")" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << 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 (" << k << ")" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } rCurve->mKeys[time] = rot_key; @@ -1632,8 +1665,10 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (joint_motion->mRotationCurve.mNumKeys > joint_motion->mRotationCurve.mKeys.size()) { - rotation_dupplicates++; - LL_INFOS() << "Motion: " << asset_id << " had dupplicate rotation keys that were removed" << LL_ENDL; + rotation_duplicates++; + LL_INFOS() << "Motion " << asset() << " had duplicated rotation keys that were removed: " + << joint_motion->mRotationCurve.mNumKeys << " > " << joint_motion->mRotationCurve.mKeys.size() + << " (" << rotation_duplicates << ")" << LL_ENDL; } //--------------------------------------------------------------------- @@ -1642,8 +1677,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (!dp.unpackS32(joint_motion->mPositionCurve.mNumKeys, "num_pos_keys") || joint_motion->mPositionCurve.mNumKeys < 0) { LL_WARNS() << "can't read number of position keys" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } joint_motion->mPositionCurve.mInterpolationType = IT_LINEAR; @@ -1656,7 +1691,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo // scan position curve keys //--------------------------------------------------------------------- PositionCurve *pCurve = &joint_motion->mPositionCurve; - BOOL is_pelvis = joint_motion->mJointName == "mPelvis"; + bool is_pelvis = joint_motion->mJointName == "mPelvis"; for (S32 k = 0; k < joint_motion->mPositionCurve.mNumKeys; k++) { U16 time_short; @@ -1668,8 +1703,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo !llfinite(pos_key.mTime)) { LL_WARNS() << "can't read position key (" << k << ")" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } } else @@ -1677,8 +1712,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (!dp.unpackU16(time_short, "time")) { LL_WARNS() << "can't read position key (" << k << ")" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } pos_key.mTime = U16_to_F32(time_short, 0.f, joint_motion_list->mDuration); @@ -1688,8 +1723,9 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo { if (!dp.unpackVector3(pos_key.mPosition, "pos")) { - LL_WARNS() << "can't read pos in position key (" << k << ")" << LL_ENDL; - return FALSE; + LL_WARNS() << "can't read pos in position key (" << k << ")" + << " for animation " << asset() << LL_ENDL; + return false; } //MAINT-6162 @@ -1704,18 +1740,21 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (!dp.unpackU16(x, "pos_x")) { - LL_WARNS() << "can't read pos_x in position key (" << k << ")" << LL_ENDL; - return FALSE; + LL_WARNS() << "can't read pos_x in position key (" << k << ")" + << " for animation " << asset() << 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; + LL_WARNS() << "can't read pos_y in position key (" << k << ")" + << " for animation " << asset() << 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; + LL_WARNS() << "can't read pos_z in position key (" << k << ")" + << " for animation " << asset() << LL_ENDL; + return false; } pos_key.mPosition.mV[VX] = U16_to_F32(x, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); @@ -1723,11 +1762,11 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo 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; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } pCurve->mKeys[pos_key.mTime] = pos_key; @@ -1740,20 +1779,25 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (joint_motion->mPositionCurve.mNumKeys > joint_motion->mPositionCurve.mKeys.size()) { - position_dupplicates++; + position_duplicates++; + LL_INFOS() << "Motion " << asset() << " had duplicated position keys that were removed: " + << joint_motion->mPositionCurve.mNumKeys << " > " << joint_motion->mPositionCurve.mKeys.size() + << " (" << position_duplicates << ")" << LL_ENDL; } joint_motion->mUsage = joint_state->getUsage(); } - if (rotation_dupplicates > 0) + if (rotation_duplicates > 0) { - LL_INFOS() << "Motion: " << asset_id << " had " << rotation_dupplicates << " dupplicate rotation keys that were removed" << LL_ENDL; + LL_INFOS() << "Motion " << asset() << " had " << rotation_duplicates + << " duplicated rotation keys that were removed" << LL_ENDL; } - if (position_dupplicates > 0) + if (position_duplicates > 0) { - LL_INFOS() << "Motion: " << asset_id << " had " << position_dupplicates << " dupplicate position keys that were removed" << LL_ENDL; + LL_INFOS() << "Motion " << asset() << " had " << position_duplicates + << " duplicated position keys that were removed" << LL_ENDL; } //------------------------------------------------------------------------- @@ -1763,14 +1807,14 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (!dp.unpackS32(num_constraints, "num_constraints")) { LL_WARNS() << "can't read number of constraints" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if (num_constraints > MAX_CONSTRAINTS || num_constraints < 0) { LL_WARNS() << "Bad number of constraints... ignoring: " << num_constraints - << " for animation " << asset_id << LL_ENDL; + << " for animation " << asset() << LL_ENDL; } else { @@ -1787,30 +1831,30 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (!dp.unpackU8(byte, "chain_length")) { LL_WARNS() << "can't read constraint chain length" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } constraintp->mChainLength = (S32) byte; if((U32)constraintp->mChainLength > joint_motion_list->getNumJointMotions()) { LL_WARNS() << "invalid constraint chain length" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if (!dp.unpackU8(byte, "constraint_type")) { LL_WARNS() << "can't read constraint type" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if( byte >= NUM_CONSTRAINT_TYPES ) { LL_WARNS() << "invalid constraint type" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } constraintp->mConstraintType = (EConstraintType)byte; @@ -1819,8 +1863,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (!dp.unpackBinaryDataFixed(bin_data, BIN_DATA_LENGTH, "source_volume")) { LL_WARNS() << "can't read source volume name" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } bin_data[BIN_DATA_LENGTH] = 0; // Ensure null termination @@ -1829,29 +1873,29 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (constraintp->mSourceConstraintVolume == -1) { LL_WARNS() << "not a valid source constraint volume " << str - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if (!dp.unpackVector3(constraintp->mSourceConstraintOffset, "source_offset")) { LL_WARNS() << "can't read constraint source offset" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if( !(constraintp->mSourceConstraintOffset.isFinite()) ) { LL_WARNS() << "non-finite constraint source offset" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if (!dp.unpackBinaryDataFixed(bin_data, BIN_DATA_LENGTH, "target_volume")) { LL_WARNS() << "can't read target volume name" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } bin_data[BIN_DATA_LENGTH] = 0; // Ensure null termination @@ -1868,78 +1912,78 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (constraintp->mTargetConstraintVolume == -1) { LL_WARNS() << "not a valid target constraint volume " << str - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } } if (!dp.unpackVector3(constraintp->mTargetConstraintOffset, "target_offset")) { LL_WARNS() << "can't read constraint target offset" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if( !(constraintp->mTargetConstraintOffset.isFinite()) ) { LL_WARNS() << "non-finite constraint target offset" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if (!dp.unpackVector3(constraintp->mTargetConstraintDir, "target_dir")) { LL_WARNS() << "can't read constraint target direction" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if( !(constraintp->mTargetConstraintDir.isFinite()) ) { LL_WARNS() << "non-finite constraint target direction" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if (!constraintp->mTargetConstraintDir.isExactlyZero()) { - constraintp->mUseTargetOffset = TRUE; + constraintp->mUseTargetOffset = true; // constraintp->mTargetConstraintDir *= constraintp->mSourceConstraintOffset.magVec(); } if (!dp.unpackF32(constraintp->mEaseInStartTime, "ease_in_start") || !llfinite(constraintp->mEaseInStartTime)) { LL_WARNS() << "can't read constraint ease in start time" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if (!dp.unpackF32(constraintp->mEaseInStopTime, "ease_in_stop") || !llfinite(constraintp->mEaseInStopTime)) { LL_WARNS() << "can't read constraint ease in stop time" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if (!dp.unpackF32(constraintp->mEaseOutStartTime, "ease_out_start") || !llfinite(constraintp->mEaseOutStartTime)) { LL_WARNS() << "can't read constraint ease out start time" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } if (!dp.unpackF32(constraintp->mEaseOutStopTime, "ease_out_stop") || !llfinite(constraintp->mEaseOutStopTime)) { LL_WARNS() << "can't read constraint ease out stop time" - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } LLJoint* joint = mCharacter->findCollisionVolume(constraintp->mSourceConstraintVolume); // get joint to which this collision volume is attached if (!joint) { - return FALSE; + return false; } constraintp->mJointStateIndices = new S32[constraintp->mChainLength + 1]; // note: mChainLength is size-limited - comes from a byte @@ -1951,8 +1995,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo { LL_WARNS() << "Joint with no parent: " << joint->getName() << " Emote: " << joint_motion_list->mEmoteName - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } joint = parent; constraintp->mJointStateIndices[i] = -1; @@ -1963,10 +2007,10 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if ( !constraint_joint ) { LL_WARNS() << "Invalid joint " << j - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } - + if(constraint_joint == joint) { constraintp->mJointStateIndices[i] = (S32)j; @@ -1976,8 +2020,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo if (constraintp->mJointStateIndices[i] < 0 ) { LL_WARNS() << "No joint index for constraint " << i - << " for animation " << asset_id << LL_ENDL; - return FALSE; + << " for animation " << asset() << LL_ENDL; + return false; } } @@ -1992,15 +2036,15 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo setupPose(); - return TRUE; + return true; } //----------------------------------------------------------------------------- // serialize() //----------------------------------------------------------------------------- -BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const +bool LLKeyframeMotion::serialize(LLDataPacker& dp) const { - BOOL success = TRUE; + bool success = true; LL_DEBUGS("BVH") << "serializing" << LL_ENDL; @@ -2241,10 +2285,12 @@ void LLKeyframeMotion::setEmote(const LLUUID& emote_id) if (emote_name) { mJointMotionList->mEmoteName = emote_name; + mJointMotionList->mEmoteID = emote_id; } else { - mJointMotionList->mEmoteName = ""; + mJointMotionList->mEmoteName.clear(); + mJointMotionList->mEmoteID.setNull(); } } @@ -2283,7 +2329,7 @@ void LLKeyframeMotion::flushKeyframeCache() //----------------------------------------------------------------------------- // setLoop() //----------------------------------------------------------------------------- -void LLKeyframeMotion::setLoop(BOOL loop) +void LLKeyframeMotion::setLoop(bool loop) { if (mJointMotionList) { @@ -2515,7 +2561,7 @@ LLKeyframeMotion::JointConstraint::JointConstraint(JointConstraintSharedData* sh { mWeight = 0.f; mTotalLength = 0.f; - mActive = FALSE; + mActive = false; mSourceVolume = NULL; mTargetVolume = NULL; mFixupDistanceRMS = 0.f; |