From b6cc06db968ecf29de89415fe10d81fdea760ed3 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Sat, 5 Jun 2010 09:41:30 -0700 Subject: Updated llcharacter with some bits from Emerald and SnowGlobe --- linden/indra/llcharacter/llhandmotion.cpp | 23 +++++++++++++---------- linden/indra/llcharacter/llheadrotmotion.cpp | 14 ++++++++++++++ linden/indra/llcharacter/llkeyframemotion.cpp | 21 +++++++++++++++++++++ 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/linden/indra/llcharacter/llhandmotion.cpp b/linden/indra/llcharacter/llhandmotion.cpp index 4c97fcd..2499bb5 100644 --- a/linden/indra/llcharacter/llhandmotion.cpp +++ b/linden/indra/llcharacter/llhandmotion.cpp @@ -113,9 +113,9 @@ BOOL LLHandMotion::onActivate() // Note: 0 is the default for (S32 i = 1; i < LLHandMotion::NUM_HAND_POSES; i++) { - mCharacter->setVisualParamWeight(gHandPoseNames[i], 0.f); + mCharacter->setVisualParamWeight(getHandPoseName((eHandPose)i).c_str(), 0.f); } - mCharacter->setVisualParamWeight(gHandPoseNames[mCurrentPose], 1.f); + mCharacter->setVisualParamWeight(getHandPoseName(mCurrentPose).c_str(), 1.f); mCharacter->updateVisualParams(); } return TRUE; @@ -138,7 +138,7 @@ BOOL LLHandMotion::onUpdate(F32 time, U8* joint_mask) { if (mNewPose != HAND_POSE_RELAXED && mNewPose != mCurrentPose) { - mCharacter->setVisualParamWeight(gHandPoseNames[mNewPose], 0.f); + mCharacter->setVisualParamWeight(getHandPoseName(mNewPose).c_str(), 0.f); } mNewPose = HAND_POSE_RELAXED; } @@ -147,7 +147,7 @@ BOOL LLHandMotion::onUpdate(F32 time, U8* joint_mask) // this is a new morph we didn't know about before if (*requestedHandPose != mNewPose && mNewPose != mCurrentPose && mNewPose != HAND_POSE_SPREAD) { - mCharacter->setVisualParamWeight(gHandPoseNames[mNewPose], 0.f); + mCharacter->setVisualParamWeight(getHandPoseName(mNewPose).c_str(), 0.f); } mNewPose = *requestedHandPose; } @@ -166,18 +166,18 @@ BOOL LLHandMotion::onUpdate(F32 time, U8* joint_mask) if (mNewPose != HAND_POSE_SPREAD) { - incomingWeight = mCharacter->getVisualParamWeight(gHandPoseNames[mNewPose]); + incomingWeight = mCharacter->getVisualParamWeight(getHandPoseName(mNewPose).c_str()); incomingWeight += (timeDelta / HAND_MORPH_BLEND_TIME); incomingWeight = llclamp(incomingWeight, 0.f, 1.f); - mCharacter->setVisualParamWeight(gHandPoseNames[mNewPose], incomingWeight); + mCharacter->setVisualParamWeight(getHandPoseName(mNewPose).c_str(), incomingWeight); } if (mCurrentPose != HAND_POSE_SPREAD) { - outgoingWeight = mCharacter->getVisualParamWeight(gHandPoseNames[mCurrentPose]); + outgoingWeight = mCharacter->getVisualParamWeight(getHandPoseName(mCurrentPose).c_str()); outgoingWeight -= (timeDelta / HAND_MORPH_BLEND_TIME); outgoingWeight = llclamp(outgoingWeight, 0.f, 1.f); - mCharacter->setVisualParamWeight(gHandPoseNames[mCurrentPose], outgoingWeight); + mCharacter->setVisualParamWeight(getHandPoseName(mCurrentPose).c_str(), outgoingWeight); } mCharacter->updateVisualParams(); @@ -199,6 +199,8 @@ void LLHandMotion::onDeactivate() { } +//Zwag: Changed the defaults here so things look right. Otherwise the hand ends up +// in a pose that nobody is used to when something messes up. //----------------------------------------------------------------------------- // LLHandMotion::getHandPoseName() //----------------------------------------------------------------------------- @@ -208,7 +210,8 @@ std::string LLHandMotion::getHandPoseName(eHandPose pose) { return std::string(gHandPoseNames[pose]); } - return LLStringUtil::null; + LL_WARNS("Bounds") << "Was passed an invalid hand pose: " << (S32)pose << LL_ENDL; + return std::string("Hands_Relaxed"); } LLHandMotion::eHandPose LLHandMotion::getHandPose(std::string posename) @@ -220,7 +223,7 @@ LLHandMotion::eHandPose LLHandMotion::getHandPose(std::string posename) return (eHandPose)pose; } } - return (eHandPose)0; + return (eHandPose)1; } // End diff --git a/linden/indra/llcharacter/llheadrotmotion.cpp b/linden/indra/llcharacter/llheadrotmotion.cpp index 88cd77f..92e7f7e 100644 --- a/linden/indra/llcharacter/llheadrotmotion.cpp +++ b/linden/indra/llcharacter/llheadrotmotion.cpp @@ -507,6 +507,20 @@ BOOL LLEyeMotion::onUpdate(F32 time, U8* joint_mask) vergence_quat.transQuat(); right_eye_rot = vergence_quat * eye_jitter_rot * right_eye_rot; + //if in appearance, set the eyes straight forward + if(mCharacter->getAppearanceFlag()) // no idea why this variable is reversed + { + LLVector3 forward(1.f, 0.0, 0.0); + LLVector3 left; + LLVector3 up; + left.setVec(forward % forward); + up.setVec(forward % left); + target_eye_rot = LLQuaternion(forward, left, up); + mLeftEyeState->setRotation( target_eye_rot ); + mRightEyeState->setRotation( target_eye_rot ); + return TRUE; + } + mLeftEyeState->setRotation( left_eye_rot ); mRightEyeState->setRotation( right_eye_rot ); diff --git a/linden/indra/llcharacter/llkeyframemotion.cpp b/linden/indra/llcharacter/llkeyframemotion.cpp index 3b4cf7e..6e80e8d 100644 --- a/linden/indra/llcharacter/llkeyframemotion.cpp +++ b/linden/indra/llcharacter/llkeyframemotion.cpp @@ -1460,6 +1460,10 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) LLQuaternion::Order ro = StringToOrder("ZYX"); rot_key.mRotation = mayaQ(rot_angles.mV[VX], rot_angles.mV[VY], rot_angles.mV[VZ], ro); + if(!(rot_key.mRotation.isFinite())) + { + return FALSE; + } } else { @@ -1538,6 +1542,10 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) if (old_version) { success = dp.unpackVector3(pos_key.mPosition, "pos"); + if(!(pos_key.mPosition.isFinite())) + { + return FALSE; + } } else { @@ -1644,6 +1652,13 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) str = (char*)bin_data; constraintp->mSourceConstraintVolume = mCharacter->getCollisionVolumeID(str); + if(constraintp->mSourceConstraintVolume == -1) + { + llwarns << "can't find a valid source collision volume." << llendl; + delete constraintp; + return FALSE; + } + if (!dp.unpackVector3(constraintp->mSourceConstraintOffset, "source_offset")) { llwarns << "can't read constraint source offset" << llendl; @@ -1676,6 +1691,12 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) { constraintp->mConstraintTargetType = CONSTRAINT_TARGET_TYPE_BODY; constraintp->mTargetConstraintVolume = mCharacter->getCollisionVolumeID(str); + if(constraintp->mTargetConstraintVolume == -1) + { + llwarns << "can't find a valid target collision volume." << llendl; + delete constraintp; + return FALSE; + } } if (!dp.unpackVector3(constraintp->mTargetConstraintOffset, "target_offset")) -- cgit v1.1