diff options
author | Steven Bennetts <steve@lindenlab.com> | 2007-12-07 20:27:13 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2007-12-07 20:27:13 +0000 |
commit | b01d567a5d9e2b5dd28bcc7b3f474fabd93e7a2f (patch) | |
tree | c45377783f53f033d43a4d06d36bbeb2a7f7e79b /indra | |
parent | a64f283477ea4db09c8b515ab94709e1fb5c82af (diff) |
EFFECTIVE MERGE: merge release@73232 maint-viewer-2@75100 -> maint-viewer-2-merge
EFFECTIVE MERGE: merge -r 74370 library-update -> maint-viewer-2-merge
ACTUAL MERGE: release@75267 maint-viewer-2-merge@75293 -> release
Diffstat (limited to 'indra')
43 files changed, 431 insertions, 399 deletions
diff --git a/indra/llcharacter/lleditingmotion.cpp b/indra/llcharacter/lleditingmotion.cpp index 6e878429fa..34fb6c423a 100644 --- a/indra/llcharacter/lleditingmotion.cpp +++ b/indra/llcharacter/lleditingmotion.cpp @@ -64,6 +64,12 @@ LLEditingMotion::LLEditingMotion( const LLUUID &id) : LLMotion(id) mElbowJoint.addChild( &mWristJoint ); mName = "editing"; + + mParentState = new LLJointState; + mShoulderState = new LLJointState; + mElbowState = new LLJointState; + mWristState = new LLJointState; + mTorsoState = new LLJointState; } @@ -93,13 +99,13 @@ LLMotion::LLMotionInitStatus LLEditingMotion::onInitialize(LLCharacter *characte } // get the shoulder, elbow, wrist joints from the character - mParentState.setJoint( mCharacter->getJoint("mShoulderLeft")->getParent() ); - mShoulderState.setJoint( mCharacter->getJoint("mShoulderLeft") ); - mElbowState.setJoint( mCharacter->getJoint("mElbowLeft") ); - mWristState.setJoint( mCharacter->getJoint("mWristLeft") ); - mTorsoState.setJoint( mCharacter->getJoint("mTorso")); + mParentState->setJoint( mCharacter->getJoint("mShoulderLeft")->getParent() ); + mShoulderState->setJoint( mCharacter->getJoint("mShoulderLeft") ); + mElbowState->setJoint( mCharacter->getJoint("mElbowLeft") ); + mWristState->setJoint( mCharacter->getJoint("mWristLeft") ); + mTorsoState->setJoint( mCharacter->getJoint("mTorso")); - if ( ! mParentState.getJoint() ) + if ( ! mParentState->getJoint() ) { llinfos << getName() << ": Can't get parent joint." << llendl; return STATUS_FAILURE; @@ -108,25 +114,25 @@ LLMotion::LLMotionInitStatus LLEditingMotion::onInitialize(LLCharacter *characte mWristOffset = LLVector3(0.0f, 0.2f, 0.0f); // add joint states to the pose - mShoulderState.setUsage(LLJointState::ROT); - mElbowState.setUsage(LLJointState::ROT); - mTorsoState.setUsage(LLJointState::ROT); - mWristState.setUsage(LLJointState::ROT); - addJointState( &mShoulderState ); - addJointState( &mElbowState ); - addJointState( &mTorsoState ); - addJointState( &mWristState ); + mShoulderState->setUsage(LLJointState::ROT); + mElbowState->setUsage(LLJointState::ROT); + mTorsoState->setUsage(LLJointState::ROT); + mWristState->setUsage(LLJointState::ROT); + addJointState( mShoulderState ); + addJointState( mElbowState ); + addJointState( mTorsoState ); + addJointState( mWristState ); // propagate joint positions to kinematic chain - mParentJoint.setPosition( mParentState.getJoint()->getWorldPosition() ); - mShoulderJoint.setPosition( mShoulderState.getJoint()->getPosition() ); - mElbowJoint.setPosition( mElbowState.getJoint()->getPosition() ); - mWristJoint.setPosition( mWristState.getJoint()->getPosition() + mWristOffset ); + mParentJoint.setPosition( mParentState->getJoint()->getWorldPosition() ); + mShoulderJoint.setPosition( mShoulderState->getJoint()->getPosition() ); + mElbowJoint.setPosition( mElbowState->getJoint()->getPosition() ); + mWristJoint.setPosition( mWristState->getJoint()->getPosition() + mWristOffset ); // propagate current joint rotations to kinematic chain - mParentJoint.setRotation( mParentState.getJoint()->getWorldRotation() ); - mShoulderJoint.setRotation( mShoulderState.getJoint()->getRotation() ); - mElbowJoint.setRotation( mElbowState.getJoint()->getRotation() ); + mParentJoint.setRotation( mParentState->getJoint()->getWorldRotation() ); + mShoulderJoint.setRotation( mShoulderState->getJoint()->getRotation() ); + mElbowJoint.setRotation( mElbowState->getJoint()->getRotation() ); // connect the ikSolver to the chain mIKSolver.setPoleVector( LLVector3( -1.0f, 1.0f, 0.0f ) ); @@ -144,15 +150,15 @@ LLMotion::LLMotionInitStatus LLEditingMotion::onInitialize(LLCharacter *characte BOOL LLEditingMotion::onActivate() { // propagate joint positions to kinematic chain - mParentJoint.setPosition( mParentState.getJoint()->getWorldPosition() ); - mShoulderJoint.setPosition( mShoulderState.getJoint()->getPosition() ); - mElbowJoint.setPosition( mElbowState.getJoint()->getPosition() ); - mWristJoint.setPosition( mWristState.getJoint()->getPosition() + mWristOffset ); + mParentJoint.setPosition( mParentState->getJoint()->getWorldPosition() ); + mShoulderJoint.setPosition( mShoulderState->getJoint()->getPosition() ); + mElbowJoint.setPosition( mElbowState->getJoint()->getPosition() ); + mWristJoint.setPosition( mWristState->getJoint()->getPosition() + mWristOffset ); // propagate current joint rotations to kinematic chain - mParentJoint.setRotation( mParentState.getJoint()->getWorldRotation() ); - mShoulderJoint.setRotation( mShoulderState.getJoint()->getRotation() ); - mElbowJoint.setRotation( mElbowState.getJoint()->getRotation() ); + mParentJoint.setRotation( mParentState->getJoint()->getWorldRotation() ); + mShoulderJoint.setRotation( mShoulderState->getJoint()->getRotation() ); + mElbowJoint.setRotation( mElbowState->getJoint()->getRotation() ); return TRUE; } @@ -182,15 +188,15 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask) focus_pt += mCharacter->getCharacterPosition(); // propagate joint positions to kinematic chain - mParentJoint.setPosition( mParentState.getJoint()->getWorldPosition() ); - mShoulderJoint.setPosition( mShoulderState.getJoint()->getPosition() ); - mElbowJoint.setPosition( mElbowState.getJoint()->getPosition() ); - mWristJoint.setPosition( mWristState.getJoint()->getPosition() + mWristOffset ); + mParentJoint.setPosition( mParentState->getJoint()->getWorldPosition() ); + mShoulderJoint.setPosition( mShoulderState->getJoint()->getPosition() ); + mElbowJoint.setPosition( mElbowState->getJoint()->getPosition() ); + mWristJoint.setPosition( mWristState->getJoint()->getPosition() + mWristOffset ); // propagate current joint rotations to kinematic chain - mParentJoint.setRotation( mParentState.getJoint()->getWorldRotation() ); - mShoulderJoint.setRotation( mShoulderState.getJoint()->getRotation() ); - mElbowJoint.setRotation( mElbowState.getJoint()->getRotation() ); + mParentJoint.setRotation( mParentState->getJoint()->getWorldRotation() ); + mShoulderJoint.setRotation( mShoulderState->getJoint()->getRotation() ); + mElbowJoint.setRotation( mElbowState->getJoint()->getRotation() ); // update target position from character LLVector3 target = focus_pt - mParentJoint.getPosition(); @@ -199,7 +205,7 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask) LLVector3 edit_plane_normal(1.f / F_SQRT2, 1.f / F_SQRT2, 0.f); edit_plane_normal.normVec(); - edit_plane_normal.rotVec(mTorsoState.getJoint()->getWorldRotation()); + edit_plane_normal.rotVec(mTorsoState->getJoint()->getWorldRotation()); F32 dot = edit_plane_normal * target; @@ -236,9 +242,9 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask) // now put blended values back into joints llassert(shoulderRot.isFinite()); llassert(elbowRot.isFinite()); - mShoulderState.setRotation(shoulderRot); - mElbowState.setRotation(elbowRot); - mWristState.setRotation(LLQuaternion::DEFAULT); + mShoulderState->setRotation(shoulderRot); + mElbowState->setRotation(elbowRot); + mWristState->setRotation(LLQuaternion::DEFAULT); } mCharacter->setAnimationData("Hand Pose", &sHandPose); diff --git a/indra/llcharacter/lleditingmotion.h b/indra/llcharacter/lleditingmotion.h index 18bfd7f88a..60ec4a34d9 100644 --- a/indra/llcharacter/lleditingmotion.h +++ b/indra/llcharacter/lleditingmotion.h @@ -116,11 +116,11 @@ public: LLCharacter *mCharacter; LLVector3 mWristOffset; - LLJointState mParentState; - LLJointState mShoulderState; - LLJointState mElbowState; - LLJointState mWristState; - LLJointState mTorsoState; + LLPointer<LLJointState> mParentState; + LLPointer<LLJointState> mShoulderState; + LLPointer<LLJointState> mElbowState; + LLPointer<LLJointState> mWristState; + LLPointer<LLJointState> mTorsoState; LLJoint mParentJoint; LLJoint mShoulderJoint; diff --git a/indra/llcharacter/llheadrotmotion.cpp b/indra/llcharacter/llheadrotmotion.cpp index 55af269376..7e25cc457e 100644 --- a/indra/llcharacter/llheadrotmotion.cpp +++ b/indra/llcharacter/llheadrotmotion.cpp @@ -82,6 +82,10 @@ LLHeadRotMotion::LLHeadRotMotion(const LLUUID &id) : mHeadJoint(NULL) { mName = "head_rot"; + + mTorsoState = new LLJointState; + mNeckState = new LLJointState; + mHeadState = new LLJointState; } @@ -130,34 +134,34 @@ LLMotion::LLMotionInitStatus LLHeadRotMotion::onInitialize(LLCharacter *characte return STATUS_FAILURE; } - mTorsoState.setJoint( character->getJoint("mTorso") ); - if ( ! mTorsoState.getJoint() ) + mTorsoState->setJoint( character->getJoint("mTorso") ); + if ( ! mTorsoState->getJoint() ) { llinfos << getName() << ": Can't get torso joint." << llendl; return STATUS_FAILURE; } - mNeckState.setJoint( character->getJoint("mNeck") ); - if ( ! mNeckState.getJoint() ) + mNeckState->setJoint( character->getJoint("mNeck") ); + if ( ! mNeckState->getJoint() ) { llinfos << getName() << ": Can't get neck joint." << llendl; return STATUS_FAILURE; } - mHeadState.setJoint( character->getJoint("mHead") ); - if ( ! mHeadState.getJoint() ) + mHeadState->setJoint( character->getJoint("mHead") ); + if ( ! mHeadState->getJoint() ) { llinfos << getName() << ": Can't get head joint." << llendl; return STATUS_FAILURE; } - mTorsoState.setUsage(LLJointState::ROT); - mNeckState.setUsage(LLJointState::ROT); - mHeadState.setUsage(LLJointState::ROT); + mTorsoState->setUsage(LLJointState::ROT); + mNeckState->setUsage(LLJointState::ROT); + mHeadState->setUsage(LLJointState::ROT); - addJointState( &mTorsoState ); - addJointState( &mNeckState ); - addJointState( &mHeadState ); + addJointState( mTorsoState ); + addJointState( mNeckState ); + addJointState( mHeadState ); mLastHeadRot.loadIdentity(); @@ -240,16 +244,16 @@ BOOL LLHeadRotMotion::onUpdate(F32 time, U8* joint_mask) // Set torso target rotation such that it lags behind the head rotation // by a fixed amount. LLQuaternion torso_rot_local = nlerp(TORSO_LAG, LLQuaternion::DEFAULT, head_rot_local ); - mTorsoState.setRotation( nlerp(torso_slerp_amt, mTorsoState.getRotation(), torso_rot_local) ); + mTorsoState->setRotation( nlerp(torso_slerp_amt, mTorsoState->getRotation(), torso_rot_local) ); head_rot_local = nlerp(head_slerp_amt, mLastHeadRot, head_rot_local); mLastHeadRot = head_rot_local; // Set the head rotation. - LLQuaternion torsoRotLocal = mNeckState.getJoint()->getParent()->getWorldRotation() * currentInvRootRotWorld; + LLQuaternion torsoRotLocal = mNeckState->getJoint()->getParent()->getWorldRotation() * currentInvRootRotWorld; head_rot_local = head_rot_local * ~torsoRotLocal; - mNeckState.setRotation( nlerp(NECK_LAG, LLQuaternion::DEFAULT, head_rot_local) ); - mHeadState.setRotation( nlerp(1.f - NECK_LAG, LLQuaternion::DEFAULT, head_rot_local)); + mNeckState->setRotation( nlerp(NECK_LAG, LLQuaternion::DEFAULT, head_rot_local) ); + mHeadState->setRotation( nlerp(1.f - NECK_LAG, LLQuaternion::DEFAULT, head_rot_local)); return TRUE; } @@ -284,6 +288,9 @@ LLEyeMotion::LLEyeMotion(const LLUUID &id) : LLMotion(id) mHeadJoint = NULL; mName = "eye_rot"; + + mLeftEyeState = new LLJointState; + mRightEyeState = new LLJointState; } @@ -309,25 +316,25 @@ LLMotion::LLMotionInitStatus LLEyeMotion::onInitialize(LLCharacter *character) return STATUS_FAILURE; } - mLeftEyeState.setJoint( character->getJoint("mEyeLeft") ); - if ( ! mLeftEyeState.getJoint() ) + mLeftEyeState->setJoint( character->getJoint("mEyeLeft") ); + if ( ! mLeftEyeState->getJoint() ) { llinfos << getName() << ": Can't get left eyeball joint." << llendl; return STATUS_FAILURE; } - mRightEyeState.setJoint( character->getJoint("mEyeRight") ); - if ( ! mRightEyeState.getJoint() ) + mRightEyeState->setJoint( character->getJoint("mEyeRight") ); + if ( ! mRightEyeState->getJoint() ) { llinfos << getName() << ": Can't get Right eyeball joint." << llendl; return STATUS_FAILURE; } - mLeftEyeState.setUsage(LLJointState::ROT); - mRightEyeState.setUsage(LLJointState::ROT); + mLeftEyeState->setUsage(LLJointState::ROT); + mRightEyeState->setUsage(LLJointState::ROT); - addJointState( &mLeftEyeState ); - addJointState( &mRightEyeState ); + addJointState( mLeftEyeState ); + addJointState( mRightEyeState ); return STATUS_SUCCESS; } @@ -443,11 +450,15 @@ BOOL LLEyeMotion::onUpdate(F32 time, U8* joint_mask) target_eye_rot = LLQuaternion(eye_look_at, left, up); // convert target rotation to head-local coordinates target_eye_rot *= ~mHeadJoint->getWorldRotation(); + // eliminate any Euler roll - we're lucky that roll is applied last. + F32 roll, pitch, yaw; + target_eye_rot.getEulerAngles(&roll, &pitch, &yaw); + target_eye_rot.setQuat(0.0f, pitch, yaw); // constrain target orientation to be in front of avatar's face target_eye_rot.constrain(EYE_ROT_LIMIT_ANGLE); // calculate vergence - F32 interocular_dist = (mLeftEyeState.getJoint()->getWorldPosition() - mRightEyeState.getJoint()->getWorldPosition()).magVec(); + F32 interocular_dist = (mLeftEyeState->getJoint()->getWorldPosition() - mRightEyeState->getJoint()->getWorldPosition()).magVec(); vergence = -atan2((interocular_dist / 2.f), lookAtDistance); llclamp(vergence, -F_PI_BY_TWO, 0.f); } @@ -495,8 +506,8 @@ BOOL LLEyeMotion::onUpdate(F32 time, U8* joint_mask) vergence_quat.transQuat(); right_eye_rot = vergence_quat * eye_jitter_rot * right_eye_rot; - mLeftEyeState.setRotation( left_eye_rot ); - mRightEyeState.setRotation( right_eye_rot ); + mLeftEyeState->setRotation( left_eye_rot ); + mRightEyeState->setRotation( right_eye_rot ); return TRUE; } @@ -507,13 +518,13 @@ BOOL LLEyeMotion::onUpdate(F32 time, U8* joint_mask) //----------------------------------------------------------------------------- void LLEyeMotion::onDeactivate() { - LLJoint* joint = mLeftEyeState.getJoint(); + LLJoint* joint = mLeftEyeState->getJoint(); if (joint) { joint->setRotation(LLQuaternion::DEFAULT); } - joint = mRightEyeState.getJoint(); + joint = mRightEyeState->getJoint(); if (joint) { joint->setRotation(LLQuaternion::DEFAULT); diff --git a/indra/llcharacter/llheadrotmotion.h b/indra/llcharacter/llheadrotmotion.h index efb9c3e0be..57c4db5dad 100644 --- a/indra/llcharacter/llheadrotmotion.h +++ b/indra/llcharacter/llheadrotmotion.h @@ -117,9 +117,9 @@ public: LLJoint *mRootJoint; LLJoint *mPelvisJoint; - LLJointState mTorsoState; - LLJointState mNeckState; - LLJointState mHeadState; + LLPointer<LLJointState> mTorsoState; + LLPointer<LLJointState> mNeckState; + LLPointer<LLJointState> mHeadState; LLQuaternion mLastHeadRot; }; @@ -196,8 +196,8 @@ public: LLCharacter *mCharacter; LLJoint *mHeadJoint; - LLJointState mLeftEyeState; - LLJointState mRightEyeState; + LLPointer<LLJointState> mLeftEyeState; + LLPointer<LLJointState> mRightEyeState; LLFrameTimer mEyeJitterTimer; F32 mEyeJitterTime; diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index 167598fc70..8ca8118e4c 100644 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -115,7 +115,7 @@ public: void touch(U32 flags = ALL_DIRTY); // get/set name - const std::string &getName() { return mName; } + const std::string& getName() const { return mName; } void setName( const std::string &name ) { mName = name; } // getParent @@ -175,7 +175,7 @@ public: virtual BOOL isAnimatable() { return TRUE; } - S32 getJointNum() { return mJointNum; } + S32 getJointNum() const { return mJointNum; } void setJointNum(S32 joint_num) { mJointNum = joint_num; } }; #endif // LL_LLJOINT_H diff --git a/indra/llcharacter/lljointstate.h b/indra/llcharacter/lljointstate.h index 202232243b..a1723b6dd9 100644 --- a/indra/llcharacter/lljointstate.h +++ b/indra/llcharacter/lljointstate.h @@ -36,11 +36,12 @@ // Header Files //----------------------------------------------------------------------------- #include "lljoint.h" +#include "llmemory.h" //----------------------------------------------------------------------------- // class LLJointState //----------------------------------------------------------------------------- -class LLJointState +class LLJointState : public LLRefCount { public: enum BlendPhase @@ -85,13 +86,9 @@ public: mPriority = LLJoint::USE_MOTION_PRIORITY; } - // Destructor - virtual ~LLJointState() - { - } - // joint that this state is applied to - LLJoint *getJoint() { return mJoint; } + LLJoint* getJoint() { return mJoint; } + const LLJoint* getJoint() const { return mJoint; } BOOL setJoint( LLJoint *joint ) { mJoint = joint; return mJoint != NULL; } // transform type (bitwise flags can be combined) @@ -103,26 +100,33 @@ public: ROT = 2, SCALE = 4, }; - U32 getUsage() { return mUsage; } - void setUsage( U32 usage ) { mUsage = usage; } - F32 getWeight() { return mWeight; } + U32 getUsage() const { return mUsage; } + void setUsage( U32 usage ) { mUsage = usage; } + F32 getWeight() const { return mWeight; } void setWeight( F32 weight ) { mWeight = weight; } // get/set position - const LLVector3& getPosition() { return mPosition; } + const LLVector3& getPosition() const { return mPosition; } void setPosition( const LLVector3& pos ) { llassert(mUsage & POS); mPosition = pos; } // get/set rotation - const LLQuaternion& getRotation() { return mRotation; } + const LLQuaternion& getRotation() const { return mRotation; } void setRotation( const LLQuaternion& rot ) { llassert(mUsage & ROT); mRotation = rot; } // get/set scale - const LLVector3& getScale() { return mScale; } - void setScale( const LLVector3& scale ) { llassert(mUsage & SCALE); mScale = scale; } + const LLVector3& getScale() const { return mScale; } + void setScale( const LLVector3& scale ) { llassert(mUsage & SCALE); mScale = scale; } // get/set priority - LLJoint::JointPriority getPriority() { return mPriority; } - void setPriority( const LLJoint::JointPriority priority ) { mPriority = priority; } + LLJoint::JointPriority getPriority() const { return mPriority; } + void setPriority( LLJoint::JointPriority priority ) { mPriority = priority; } + +private: + // Destructor + virtual ~LLJointState() + { + } + }; #endif // LL_LLJOINTSTATE_H diff --git a/indra/llcharacter/llkeyframefallmotion.cpp b/indra/llcharacter/llkeyframefallmotion.cpp index bcef7a3fda..13308f4e4a 100644 --- a/indra/llcharacter/llkeyframefallmotion.cpp +++ b/indra/llcharacter/llkeyframefallmotion.cpp @@ -75,13 +75,13 @@ LLMotion::LLMotionInitStatus LLKeyframeFallMotion::onInitialize(LLCharacter *cha // load keyframe data, setup pose and joint states LLMotion::LLMotionInitStatus result = LLKeyframeMotion::onInitialize(character); - for (U32 jm=0; jm<mJointMotionList->mNumJointMotions; jm++) + for (U32 jm=0; jm<mJointMotionList->getNumJointMotions(); jm++) { - if (!mJointStates[jm].getJoint()) + if (!mJointStates[jm]->getJoint()) continue; - if (mJointStates[jm].getJoint()->getName() == std::string("mPelvis")) + if (mJointStates[jm]->getJoint()->getName() == std::string("mPelvis")) { - mPelvisStatep = &mJointStates[jm]; + mPelvisState = mJointStates[jm]; } } @@ -124,8 +124,11 @@ BOOL LLKeyframeFallMotion::onUpdate(F32 activeTime, U8* joint_mask) BOOL result = LLKeyframeMotion::onUpdate(activeTime, joint_mask); F32 slerp_amt = clamp_rescale(activeTime / getDuration(), 0.5f, 0.75f, 0.f, 1.f); - mPelvisStatep->setRotation(mPelvisStatep->getRotation() * slerp(slerp_amt, mRotationToGroundNormal, LLQuaternion())); - + if (mPelvisState.notNull()) + { + mPelvisState->setRotation(mPelvisState->getRotation() * slerp(slerp_amt, mRotationToGroundNormal, LLQuaternion())); + } + return result; } diff --git a/indra/llcharacter/llkeyframefallmotion.h b/indra/llcharacter/llkeyframefallmotion.h index 4307c51130..618a169324 100644 --- a/indra/llcharacter/llkeyframefallmotion.h +++ b/indra/llcharacter/llkeyframefallmotion.h @@ -75,7 +75,7 @@ protected: //------------------------------------------------------------------------- LLCharacter* mCharacter; F32 mVelocityZ; - LLJointState* mPelvisStatep; + LLPointer<LLJointState> mPelvisState; LLQuaternion mRotationToGroundNormal; }; diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index 6efe243a8f..44a2425b1b 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -71,24 +71,22 @@ static F32 MAX_CONSTRAINTS = 10; // JointMotionList //----------------------------------------------------------------------------- LLKeyframeMotion::JointMotionList::JointMotionList() - : mNumJointMotions(0), - mJointMotionArray(NULL) { } LLKeyframeMotion::JointMotionList::~JointMotionList() { for_each(mConstraints.begin(), mConstraints.end(), DeletePointer()); - delete [] mJointMotionArray; + for_each(mJointMotionArray.begin(), mJointMotionArray.end(), DeletePointer()); } U32 LLKeyframeMotion::JointMotionList::dumpDiagInfo() { S32 total_size = sizeof(JointMotionList); - for (U32 i = 0; i < mNumJointMotions; i++) + for (U32 i = 0; i < getNumJointMotions(); i++) { - LLKeyframeMotion::JointMotion* joint_motion_p = &mJointMotionArray[i]; + LLKeyframeMotion::JointMotion* joint_motion_p = mJointMotionArray[i]; llinfos << "\tJoint " << joint_motion_p->mJointName << llendl; if (joint_motion_p->mUsage & LLJointState::SCALE) @@ -385,10 +383,10 @@ void LLKeyframeMotion::JointMotion::update(LLJointState* joint_state, F32 time, { // this value being 0 is the cause of https://jira.lindenlab.com/browse/SL-22678 but I haven't // managed to get a stack to see how it got here. Testing for 0 here will stop the crash. - if ( joint_state == 0 ) + if ( joint_state == NULL ) { return; - }; + } U32 usage = joint_state->getUsage(); @@ -431,7 +429,6 @@ void LLKeyframeMotion::JointMotion::update(LLJointState* joint_state, F32 time, LLKeyframeMotion::LLKeyframeMotion(const LLUUID &id) : LLMotion(id), mJointMotionList(NULL), - mJointStates(NULL), mPelvisp(NULL), mLastSkeletonSerialNum(0), mLastUpdateTime(0.f), @@ -448,10 +445,6 @@ LLKeyframeMotion::LLKeyframeMotion(const LLUUID &id) //----------------------------------------------------------------------------- LLKeyframeMotion::~LLKeyframeMotion() { - if (mJointStates) - { - delete [] mJointStates; - } for_each(mConstraints.begin(), mConstraints.end(), DeletePointer()); } @@ -464,6 +457,26 @@ LLMotion *LLKeyframeMotion::create(const LLUUID &id) } //----------------------------------------------------------------------------- +// getJointState() +//----------------------------------------------------------------------------- +LLPointer<LLJointState>& LLKeyframeMotion::getJointState(U32 index) +{ + llassert_always (index < (S32)mJointStates.size()); + return mJointStates[index]; +} + +//----------------------------------------------------------------------------- +// getJoin() +//----------------------------------------------------------------------------- +LLJoint* LLKeyframeMotion::getJoint(U32 index) +{ + llassert_always (index < (S32)mJointStates.size()); + LLJoint* joint = mJointStates[index]->getJoint(); + llassert_always (joint); + return joint; +} + +//----------------------------------------------------------------------------- // LLKeyframeMotion::onInitialize(LLCharacter *character) //----------------------------------------------------------------------------- LLMotion::LLMotionInitStatus LLKeyframeMotion::onInitialize(LLCharacter *character) @@ -506,17 +519,20 @@ LLMotion::LLMotionInitStatus LLKeyframeMotion::onInitialize(LLCharacter *charact // motion already existed in cache, so grab it mJointMotionList = joint_motion_list; + mJointStates.reserve(mJointMotionList->getNumJointMotions()); + // don't forget to allocate joint states - mJointStates = new LLJointState[mJointMotionList->mNumJointMotions]; - // set up joint states to point to character joints - for(U32 i = 0; i < mJointMotionList->mNumJointMotions; i++) + for(U32 i = 0; i < mJointMotionList->getNumJointMotions(); i++) { - if (LLJoint *jointp = mCharacter->getJoint(mJointMotionList->mJointMotionArray[i].mJointName)) + JointMotion* joint_motion = mJointMotionList->getJointMotion(i); + if (LLJoint *joint = mCharacter->getJoint(joint_motion->mJointName)) { - mJointStates[i].setJoint(jointp); - mJointStates[i].setUsage(mJointMotionList->mJointMotionArray[i].mUsage); - mJointStates[i].setPriority(joint_motion_list->mJointMotionArray[i].mPriority); + LLPointer<LLJointState> joint_state = new LLJointState; + mJointStates.push_back(joint_state); + joint_state->setJoint(joint); + joint_state->setUsage(joint_motion->mUsage); + joint_state->setPriority(joint_motion->mPriority); } } mAssetStatus = ASSET_LOADED; @@ -587,11 +603,12 @@ LLMotion::LLMotionInitStatus LLKeyframeMotion::onInitialize(LLCharacter *charact BOOL LLKeyframeMotion::setupPose() { // add all valid joint states to the pose - for (U32 jm=0; jm<mJointMotionList->mNumJointMotions; jm++) + for (U32 jm=0; jm<mJointMotionList->getNumJointMotions(); jm++) { - if ( mJointStates[jm].getJoint() ) + LLPointer<LLJointState> joint_state = getJointState(jm); + if ( joint_state->getJoint() ) { - addJointState( &mJointStates[jm] ); + addJointState( joint_state ); } } @@ -692,13 +709,12 @@ BOOL LLKeyframeMotion::onUpdate(F32 time, U8* joint_mask) //----------------------------------------------------------------------------- void LLKeyframeMotion::applyKeyframes(F32 time) { - U32 i; - for (i=0; i<mJointMotionList->mNumJointMotions; i++) + llassert_always (mJointMotionList->getNumJointMotions() <= mJointStates.size()); + for (U32 i=0; i<mJointMotionList->getNumJointMotions(); i++) { - mJointMotionList->mJointMotionArray[i].update( - &mJointStates[i], - time, - mJointMotionList->mDuration ); + mJointMotionList->getJointMotion(i)->update(mJointStates[i], + time, + mJointMotionList->mDuration ); } LLJoint::JointPriority* pose_priority = (LLJoint::JointPriority* )mCharacter->getAnimationData("Hand Pose Priority"); @@ -793,7 +809,7 @@ void LLKeyframeMotion::initializeConstraint(JointConstraint* constraint) S32 joint_num; LLVector3 source_pos = mCharacter->getVolumePos(shared_data->mSourceConstraintVolume, shared_data->mSourceConstraintOffset); - LLJoint* cur_joint = mJointStates[shared_data->mJointStateIndices[0]].getJoint(); + LLJoint* cur_joint = getJoint(shared_data->mJointStateIndices[0]); F32 source_pos_offset = dist_vec(source_pos, cur_joint->getWorldPosition()); @@ -802,7 +818,7 @@ void LLKeyframeMotion::initializeConstraint(JointConstraint* constraint) // grab joint lengths for (joint_num = 1; joint_num < shared_data->mChainLength; joint_num++) { - cur_joint = mJointStates[shared_data->mJointStateIndices[joint_num]].getJoint(); + cur_joint = getJointState(shared_data->mJointStateIndices[joint_num])->getJoint(); if (!cur_joint) { return; @@ -844,7 +860,7 @@ void LLKeyframeMotion::activateConstraint(JointConstraint* constraint) for (joint_num = 1; joint_num < shared_data->mChainLength; joint_num++) { - LLJoint* cur_joint = mJointStates[shared_data->mJointStateIndices[joint_num]].getJoint(); + LLJoint* cur_joint = getJoint(shared_data->mJointStateIndices[joint_num]); constraint->mPositions[joint_num] = (cur_joint->getWorldPosition() - mPelvisp->getWorldPosition()) * ~mPelvisp->getWorldRotation(); } @@ -884,7 +900,6 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 LLVector3 velocities[MAX_CHAIN_LENGTH - 1]; LLQuaternion old_rots[MAX_CHAIN_LENGTH]; S32 joint_num; - LLJoint* cur_joint; if (time < shared_data->mEaseInStartTime) { @@ -905,7 +920,7 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 activateConstraint(constraint); } - LLJoint* root_joint = mJointStates[shared_data->mJointStateIndices[shared_data->mChainLength]].getJoint(); + LLJoint* root_joint = getJoint(shared_data->mJointStateIndices[shared_data->mChainLength]); LLVector3 root_pos = root_joint->getWorldPosition(); // LLQuaternion root_rot = root_joint->getParent()->getWorldRotation(); @@ -916,14 +931,14 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 //apply underlying keyframe animation to get nominal "kinematic" joint positions for (joint_num = 0; joint_num <= shared_data->mChainLength; joint_num++) { - cur_joint = mJointStates[shared_data->mJointStateIndices[joint_num]].getJoint(); + LLJoint* cur_joint = getJoint(shared_data->mJointStateIndices[joint_num]); if (joint_mask[cur_joint->getJointNum()] >= (0xff >> (7 - getPriority()))) { // skip constraint return; } old_rots[joint_num] = cur_joint->getRotation(); - cur_joint->setRotation(mJointStates[shared_data->mJointStateIndices[joint_num]].getRotation()); + cur_joint->setRotation(getJointState(shared_data->mJointStateIndices[joint_num])->getRotation()); } @@ -1007,7 +1022,7 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 if (shared_data->mChainLength) { - LLQuaternion end_rot = mJointStates[shared_data->mJointStateIndices[0]].getJoint()->getWorldRotation(); + LLQuaternion end_rot = getJoint(shared_data->mJointStateIndices[0])->getWorldRotation(); // slam start and end of chain to the proper positions (rest of chain stays put) positions[0] = lerp(keyframe_source_pos, target_pos, weight); @@ -1016,7 +1031,7 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 // grab keyframe-specified positions of joints for (joint_num = 1; joint_num < shared_data->mChainLength; joint_num++) { - LLVector3 kinematic_position = mJointStates[shared_data->mJointStateIndices[joint_num]].getJoint()->getWorldPosition() + + LLVector3 kinematic_position = getJoint(shared_data->mJointStateIndices[joint_num])->getWorldPosition() + (source_to_target * constraint->mJointLengthFractions[joint_num]); // convert intermediate joint positions to world coordinates @@ -1061,9 +1076,9 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 for (joint_num = shared_data->mChainLength; joint_num > 0; joint_num--) { - LLQuaternion parent_rot = mJointStates[shared_data->mJointStateIndices[joint_num]].getJoint()->getParent()->getWorldRotation(); - cur_joint = mJointStates[shared_data->mJointStateIndices[joint_num]].getJoint(); - LLJoint* child_joint = mJointStates[shared_data->mJointStateIndices[joint_num - 1]].getJoint(); + LLJoint* cur_joint = getJoint(shared_data->mJointStateIndices[joint_num]); + LLJoint* child_joint = getJoint(shared_data->mJointStateIndices[joint_num - 1]); + LLQuaternion parent_rot = cur_joint->getParent()->getWorldRotation(); LLQuaternion cur_rot = cur_joint->getWorldRotation(); LLQuaternion fixup_rot; @@ -1088,25 +1103,25 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 if (weight != 1.f) { - LLQuaternion cur_rot = mJointStates[shared_data->mJointStateIndices[joint_num]].getRotation(); + LLQuaternion cur_rot = getJointState(shared_data->mJointStateIndices[joint_num])->getRotation(); target_rot = nlerp(weight, cur_rot, target_rot); } - mJointStates[shared_data->mJointStateIndices[joint_num]].setRotation(target_rot); + getJointState(shared_data->mJointStateIndices[joint_num])->setRotation(target_rot); cur_joint->setRotation(target_rot); } - LLJoint* end_joint = mJointStates[shared_data->mJointStateIndices[0]].getJoint(); + LLJoint* end_joint = getJoint(shared_data->mJointStateIndices[0]); LLQuaternion end_local_rot = end_rot * ~end_joint->getParent()->getWorldRotation(); if (weight == 1.f) { - mJointStates[shared_data->mJointStateIndices[0]].setRotation(end_local_rot); + getJointState(shared_data->mJointStateIndices[0])->setRotation(end_local_rot); } else { - LLQuaternion cur_rot = mJointStates[shared_data->mJointStateIndices[0]].getRotation(); - mJointStates[shared_data->mJointStateIndices[0]].setRotation(nlerp(weight, cur_rot, end_local_rot)); + LLQuaternion cur_rot = getJointState(shared_data->mJointStateIndices[0])->getRotation(); + getJointState(shared_data->mJointStateIndices[0])->setRotation(nlerp(weight, cur_rot, end_local_rot)); } // save simulated positions in pelvis-space and calculate total fixup distance @@ -1124,17 +1139,17 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 //reset old joint rots for (joint_num = 0; joint_num <= shared_data->mChainLength; joint_num++) { - mJointStates[shared_data->mJointStateIndices[joint_num]].getJoint()->setRotation(old_rots[joint_num]); + getJoint(shared_data->mJointStateIndices[joint_num])->setRotation(old_rots[joint_num]); } } // simple positional constraint (pelvis only) - else if (mJointStates[shared_data->mJointStateIndices[0]].getUsage() & LLJointState::POS) + else if (getJointState(shared_data->mJointStateIndices[0])->getUsage() & LLJointState::POS) { LLVector3 delta = source_to_target * weight; - LLJointState* current_joint_statep = &mJointStates[shared_data->mJointStateIndices[0]]; - LLQuaternion parent_rot = current_joint_statep->getJoint()->getParent()->getWorldRotation(); + LLPointer<LLJointState> current_joint_state = getJointState(shared_data->mJointStateIndices[0]); + LLQuaternion parent_rot = current_joint_state->getJoint()->getParent()->getWorldRotation(); delta = delta * ~parent_rot; - current_joint_statep->setPosition(current_joint_statep->getJoint()->getPosition() + delta); + current_joint_state->setPosition(current_joint_state->getJoint()->getPosition() + delta); } } @@ -1145,7 +1160,6 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) { BOOL old_version = FALSE; mJointMotionList = new LLKeyframeMotion::JointMotionList; - mJointMotionList->mNumJointMotions = 0; //------------------------------------------------------------------------- // get base priority @@ -1261,40 +1275,38 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) //------------------------------------------------------------------------- // get number of joint motions //------------------------------------------------------------------------- - if (!dp.unpackU32(mJointMotionList->mNumJointMotions, "num_joints")) + U32 num_motions = 0; + if (!dp.unpackU32(num_motions, "num_joints")) { llwarns << "can't read number of joints" << llendl; return FALSE; } - if (mJointMotionList->mNumJointMotions == 0) + if (num_motions == 0) { llwarns << "no joints in animation" << llendl; return FALSE; } - else if (mJointMotionList->mNumJointMotions > LL_CHARACTER_MAX_JOINTS) + else if (num_motions > LL_CHARACTER_MAX_JOINTS) { llwarns << "too many joints in animation" << llendl; return FALSE; } - mJointMotionList->mJointMotionArray = new JointMotion[mJointMotionList->mNumJointMotions]; - mJointStates = new LLJointState[mJointMotionList->mNumJointMotions]; - - if (!mJointMotionList->mJointMotionArray) - { - mJointMotionList->mDuration = 0.0f; - mJointMotionList->mEaseInDuration = 0.0f; - mJointMotionList->mEaseOutDuration = 0.0f; - return FALSE; - } + mJointMotionList->mJointMotionArray.clear(); + mJointMotionList->mJointMotionArray.reserve(num_motions); + mJointStates.clear(); + mJointStates.reserve(num_motions); //------------------------------------------------------------------------- // initialize joint motions //------------------------------------------------------------------------- - S32 k; - for(U32 i=0; i<mJointMotionList->mNumJointMotions; ++i) + + for(U32 i=0; i<num_motions; ++i) { + JointMotion* joint_motion = new JointMotion; + mJointMotionList->mJointMotionArray.push_back(joint_motion); + std::string joint_name; if (!dp.unpackString(joint_name, "joint_name")) { @@ -1316,9 +1328,12 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) //return FALSE; } - mJointMotionList->mJointMotionArray[i].mJointName = joint_name; - mJointStates[i].setJoint( joint ); - mJointStates[i].setUsage( 0 ); + joint_motion->mJointName = joint_name; + + LLPointer<LLJointState> joint_state = new LLJointState; + mJointStates.push_back(joint_state); + joint_state->setJoint( joint ); + joint_state->setUsage( 0 ); //--------------------------------------------------------------------- // get joint priority @@ -1330,36 +1345,36 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) return FALSE; } - mJointMotionList->mJointMotionArray[i].mPriority = (LLJoint::JointPriority)joint_priority; + joint_motion->mPriority = (LLJoint::JointPriority)joint_priority; if (joint_priority != LLJoint::USE_MOTION_PRIORITY && joint_priority > mJointMotionList->mMaxPriority) { mJointMotionList->mMaxPriority = (LLJoint::JointPriority)joint_priority; } - mJointStates[i].setPriority((LLJoint::JointPriority)joint_priority); + joint_state->setPriority((LLJoint::JointPriority)joint_priority); //--------------------------------------------------------------------- // scan rotation curve header //--------------------------------------------------------------------- - if (!dp.unpackS32(mJointMotionList->mJointMotionArray[i].mRotationCurve.mNumKeys, "num_rot_keys")) + if (!dp.unpackS32(joint_motion->mRotationCurve.mNumKeys, "num_rot_keys")) { llwarns << "can't read number of rotation keys" << llendl; return FALSE; } - mJointMotionList->mJointMotionArray[i].mRotationCurve.mInterpolationType = IT_LINEAR; - if (mJointMotionList->mJointMotionArray[i].mRotationCurve.mNumKeys != 0) + joint_motion->mRotationCurve.mInterpolationType = IT_LINEAR; + if (joint_motion->mRotationCurve.mNumKeys != 0) { - mJointStates[i].setUsage(mJointStates[i].getUsage() | LLJointState::ROT ); + joint_state->setUsage(joint_state->getUsage() | LLJointState::ROT ); } //--------------------------------------------------------------------- // scan rotation curve keys //--------------------------------------------------------------------- - RotationCurve *rCurve = &mJointMotionList->mJointMotionArray[i].mRotationCurve; + RotationCurve *rCurve = &joint_motion->mRotationCurve; - for (k = 0; k < mJointMotionList->mJointMotionArray[i].mRotationCurve.mNumKeys; k++) + for (S32 k = 0; k < joint_motion->mRotationCurve.mNumKeys; k++) { F32 time; U16 time_short; @@ -1424,24 +1439,24 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) //--------------------------------------------------------------------- // scan position curve header //--------------------------------------------------------------------- - if (!dp.unpackS32(mJointMotionList->mJointMotionArray[i].mPositionCurve.mNumKeys, "num_pos_keys")) + if (!dp.unpackS32(joint_motion->mPositionCurve.mNumKeys, "num_pos_keys")) { llwarns << "can't read number of position keys" << llendl; return FALSE; } - mJointMotionList->mJointMotionArray[i].mPositionCurve.mInterpolationType = IT_LINEAR; - if (mJointMotionList->mJointMotionArray[i].mPositionCurve.mNumKeys != 0) + joint_motion->mPositionCurve.mInterpolationType = IT_LINEAR; + if (joint_motion->mPositionCurve.mNumKeys != 0) { - mJointStates[i].setUsage(mJointStates[i].getUsage() | LLJointState::POS ); + joint_state->setUsage(joint_state->getUsage() | LLJointState::POS ); } //--------------------------------------------------------------------- // scan position curve keys //--------------------------------------------------------------------- - PositionCurve *pCurve = &mJointMotionList->mJointMotionArray[i].mPositionCurve; - BOOL is_pelvis = mJointMotionList->mJointMotionArray[i].mJointName == "mPelvis"; - for (k = 0; k < mJointMotionList->mJointMotionArray[i].mPositionCurve.mNumKeys; k++) + PositionCurve *pCurve = &joint_motion->mPositionCurve; + BOOL is_pelvis = joint_motion->mJointName == "mPelvis"; + for (S32 k = 0; k < joint_motion->mPositionCurve.mNumKeys; k++) { U16 time_short; PositionKey* pos_key = new PositionKey; @@ -1501,7 +1516,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) } } - mJointMotionList->mJointMotionArray[i].mUsage = mJointStates[i].getUsage(); + joint_motion->mUsage = joint_state->getUsage(); } //------------------------------------------------------------------------- @@ -1655,9 +1670,9 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) } joint = parent; constraintp->mJointStateIndices[i] = -1; - for (U32 j = 0; j < mJointMotionList->mNumJointMotions; j++) + for (U32 j = 0; j < mJointMotionList->getNumJointMotions(); j++) { - if(mJointStates[j].getJoint() == joint) + if(getJoint(j) == joint) { constraintp->mJointStateIndices[i] = (S32)j; break; @@ -1695,11 +1710,11 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const success &= dp.packF32(mJointMotionList->mEaseInDuration, "ease_in_duration"); success &= dp.packF32(mJointMotionList->mEaseOutDuration, "ease_out_duration"); success &= dp.packU32(mJointMotionList->mHandPose, "hand_pose"); - success &= dp.packU32(mJointMotionList->mNumJointMotions, "num_joints"); + success &= dp.packU32(mJointMotionList->getNumJointMotions(), "num_joints"); - for (U32 i = 0; i < mJointMotionList->mNumJointMotions; i++) + for (U32 i = 0; i < mJointMotionList->getNumJointMotions(); i++) { - JointMotion* joint_motionp = &mJointMotionList->mJointMotionArray[i]; + JointMotion* joint_motionp = mJointMotionList->getJointMotion(i); success &= dp.packString(joint_motionp->mJointName.c_str(), "joint_name"); success &= dp.packS32(joint_motionp->mPriority, "joint_priority"); success &= dp.packS32(joint_motionp->mRotationCurve.mNumKeys, "num_rot_keys"); @@ -1806,13 +1821,14 @@ void LLKeyframeMotion::setPriority(S32 priority) mJointMotionList->mBasePriority = (LLJoint::JointPriority)priority; mJointMotionList->mMaxPriority = mJointMotionList->mBasePriority; - for (U32 i = 0; i < mJointMotionList->mNumJointMotions; i++) + for (U32 i = 0; i < mJointMotionList->getNumJointMotions(); i++) { - mJointMotionList->mJointMotionArray[i].mPriority = (LLJoint::JointPriority)llclamp( - (S32)mJointMotionList->mJointMotionArray[i].mPriority + priority_delta, + JointMotion* joint_motion = mJointMotionList->getJointMotion(i); + joint_motion->mPriority = (LLJoint::JointPriority)llclamp( + (S32)joint_motion->mPriority + priority_delta, (S32)LLJoint::LOW_PRIORITY, (S32)LLJoint::HIGHEST_PRIORITY); - mJointStates[i].setPriority(mJointMotionList->mJointMotionArray[i].mPriority); + getJointState(i)->setPriority(joint_motion->mPriority); } } } @@ -1888,11 +1904,13 @@ void LLKeyframeMotion::setLoopIn(F32 in_point) mJointMotionList->mLoopInPoint = in_point; // set up loop keys - for (U32 i = 0; i < mJointMotionList->mNumJointMotions; i++) + for (U32 i = 0; i < mJointMotionList->getNumJointMotions(); i++) { - PositionCurve* pos_curve = &mJointMotionList->mJointMotionArray[i].mPositionCurve; - RotationCurve* rot_curve = &mJointMotionList->mJointMotionArray[i].mRotationCurve; - ScaleCurve* scale_curve = &mJointMotionList->mJointMotionArray[i].mScaleCurve; + JointMotion* joint_motion = mJointMotionList->getJointMotion(i); + + PositionCurve* pos_curve = &joint_motion->mPositionCurve; + RotationCurve* rot_curve = &joint_motion->mRotationCurve; + ScaleCurve* scale_curve = &joint_motion->mScaleCurve; pos_curve->mLoopInKey.mTime = mJointMotionList->mLoopInPoint; rot_curve->mLoopInKey.mTime = mJointMotionList->mLoopInPoint; @@ -1915,11 +1933,13 @@ void LLKeyframeMotion::setLoopOut(F32 out_point) mJointMotionList->mLoopOutPoint = out_point; // set up loop keys - for (U32 i = 0; i < mJointMotionList->mNumJointMotions; i++) + for (U32 i = 0; i < mJointMotionList->getNumJointMotions(); i++) { - PositionCurve* pos_curve = &mJointMotionList->mJointMotionArray[i].mPositionCurve; - RotationCurve* rot_curve = &mJointMotionList->mJointMotionArray[i].mRotationCurve; - ScaleCurve* scale_curve = &mJointMotionList->mJointMotionArray[i].mScaleCurve; + JointMotion* joint_motion = mJointMotionList->getJointMotion(i); + + PositionCurve* pos_curve = &joint_motion->mPositionCurve; + RotationCurve* rot_curve = &joint_motion->mRotationCurve; + ScaleCurve* scale_curve = &joint_motion->mScaleCurve; pos_curve->mLoopOutKey.mTime = mJointMotionList->mLoopOutPoint; rot_curve->mLoopOutKey.mTime = mJointMotionList->mLoopOutPoint; @@ -2020,10 +2040,10 @@ void LLKeyframeMotion::writeCAL3D(apr_file_t* fp) // </TRACK> // </ANIMATION> - apr_file_printf(fp, "<ANIMATION VERSION=\"1000\" DURATION=\"%.5f\" NUMTRACKS=\"%d\">\n", getDuration(), mJointMotionList->mNumJointMotions); - for (U32 joint_index = 0; joint_index < mJointMotionList->mNumJointMotions; joint_index++) + apr_file_printf(fp, "<ANIMATION VERSION=\"1000\" DURATION=\"%.5f\" NUMTRACKS=\"%d\">\n", getDuration(), mJointMotionList->getNumJointMotions()); + for (U32 joint_index = 0; joint_index < mJointMotionList->getNumJointMotions(); joint_index++) { - JointMotion* joint_motionp = &mJointMotionList->mJointMotionArray[joint_index]; + JointMotion* joint_motionp = mJointMotionList->getJointMotion(joint_index); LLJoint* animated_joint = mCharacter->getJoint(joint_motionp->mJointName); S32 joint_num = animated_joint->mJointNum + 1; diff --git a/indra/llcharacter/llkeyframemotion.h b/indra/llcharacter/llkeyframemotion.h index 57123fadea..9cea7f3a59 100644 --- a/indra/llcharacter/llkeyframemotion.h +++ b/indra/llcharacter/llkeyframemotion.h @@ -73,6 +73,11 @@ public: // Destructor virtual ~LLKeyframeMotion(); +private: + // private helper functions to wrap some asserts + LLPointer<LLJointState>& getJointState(U32 index); + LLJoint* getJoint(U32 index); + public: //------------------------------------------------------------------------- // functions to support MotionController and MotionRegistry @@ -388,7 +393,7 @@ public: U32 mUsage; LLJoint::JointPriority mPriority; - void update(LLJointState *joint_state, F32 time, F32 duration); + void update(LLJointState* joint_state, F32 time, F32 duration); }; //------------------------------------------------------------------------- @@ -397,8 +402,7 @@ public: class JointMotionList { public: - U32 mNumJointMotions; - JointMotion* mJointMotionArray; + std::vector<JointMotion*> mJointMotionArray; F32 mDuration; BOOL mLoop; F32 mLoopInPoint; @@ -415,6 +419,8 @@ public: JointMotionList(); ~JointMotionList(); U32 dumpDiagInfo(); + JointMotion* getJointMotion(U32 index) const { llassert(index < mJointMotionArray.size()); return mJointMotionArray[index]; } + U32 getNumJointMotions() const { return mJointMotionArray.size(); } }; @@ -425,7 +431,7 @@ protected: // Member Data //------------------------------------------------------------------------- JointMotionList* mJointMotionList; - LLJointState* mJointStates; + std::vector<LLPointer<LLJointState> > mJointStates; LLJoint* mPelvisp; LLCharacter* mCharacter; std::string mEmoteName; diff --git a/indra/llcharacter/llkeyframemotionparam.cpp b/indra/llcharacter/llkeyframemotionparam.cpp index dd64ef2135..f54d1f4a83 100644 --- a/indra/llcharacter/llkeyframemotionparam.cpp +++ b/indra/llcharacter/llkeyframemotionparam.cpp @@ -61,7 +61,6 @@ BOOL LLKeyframeMotionParam::sortFunc(ParameterizedMotion *new_motion, Parameteri //----------------------------------------------------------------------------- LLKeyframeMotionParam::LLKeyframeMotionParam( const LLUUID &id) : LLMotion(id) { - mJointStates = NULL; mDefaultKeyframeMotion = NULL; mCharacter = NULL; diff --git a/indra/llcharacter/llkeyframemotionparam.h b/indra/llcharacter/llkeyframemotionparam.h index 204a475dd3..39a02aea25 100644 --- a/indra/llcharacter/llkeyframemotionparam.h +++ b/indra/llcharacter/llkeyframemotionparam.h @@ -145,7 +145,6 @@ protected: typedef LLLinkedList < ParameterizedMotion > motion_list_t; LLAssocList <std::string, motion_list_t* > mParameterizedMotions; - LLJointState* mJointStates; LLMotion* mDefaultKeyframeMotion; LLCharacter* mCharacter; LLPoseBlender mPoseBlender; diff --git a/indra/llcharacter/llkeyframestandmotion.h b/indra/llcharacter/llkeyframestandmotion.h index 48496af917..f98a7e6a84 100644 --- a/indra/llcharacter/llkeyframestandmotion.h +++ b/indra/llcharacter/llkeyframestandmotion.h @@ -78,15 +78,15 @@ public: BOOL mFlipFeet; - LLJointState *mPelvisState; + LLPointer<LLJointState> mPelvisState; - LLJointState *mHipLeftState; - LLJointState *mKneeLeftState; - LLJointState *mAnkleLeftState; + LLPointer<LLJointState> mHipLeftState; + LLPointer<LLJointState> mKneeLeftState; + LLPointer<LLJointState> mAnkleLeftState; - LLJointState *mHipRightState; - LLJointState *mKneeRightState; - LLJointState *mAnkleRightState; + LLPointer<LLJointState> mHipRightState; + LLPointer<LLJointState> mKneeRightState; + LLPointer<LLJointState> mAnkleRightState; LLJoint mPelvisJoint; diff --git a/indra/llcharacter/llkeyframewalkmotion.cpp b/indra/llcharacter/llkeyframewalkmotion.cpp index 9a49996ebd..0d7e34bb4f 100644 --- a/indra/llcharacter/llkeyframewalkmotion.cpp +++ b/indra/llcharacter/llkeyframewalkmotion.cpp @@ -143,6 +143,8 @@ LLWalkAdjustMotion::LLWalkAdjustMotion(const LLUUID &id) : LLMotion(id) { mLastTime = 0.f; mName = "walk_adjust"; + + mPelvisState = new LLJointState; } //----------------------------------------------------------------------------- @@ -155,15 +157,15 @@ LLMotion::LLMotionInitStatus LLWalkAdjustMotion::onInitialize(LLCharacter *chara mRightAnkleJoint = mCharacter->getJoint("mAnkleRight"); mPelvisJoint = mCharacter->getJoint("mPelvis"); - mPelvisState.setJoint( mPelvisJoint ); + mPelvisState->setJoint( mPelvisJoint ); if ( !mPelvisJoint ) { llwarns << getName() << ": Can't get pelvis joint." << llendl; return STATUS_FAILURE; } - mPelvisState.setUsage(LLJointState::POS); - addJointState( &mPelvisState ); + mPelvisState->setUsage(LLJointState::POS); + addJointState( mPelvisState ); return STATUS_SUCCESS; } @@ -178,7 +180,7 @@ BOOL LLWalkAdjustMotion::onActivate() mAnimSpeed = 0.f; mAvgSpeed = 0.f; mRelativeDir = 1.f; - mPelvisState.setPosition(LLVector3::zero); + mPelvisState->setPosition(LLVector3::zero); // store ankle positions for next frame mLastLeftAnklePos = mCharacter->getPosGlobalFromAgent(mLeftAnkleJoint->getWorldPosition()); mLastRightAnklePos = mCharacter->getPosGlobalFromAgent(mRightAnkleJoint->getWorldPosition()); @@ -271,7 +273,7 @@ BOOL LLWalkAdjustMotion::onUpdate(F32 time, U8* joint_mask) // calculate ideal pelvis offset so that foot is glued to ground and damp towards it // the amount of foot slippage this frame + the offset applied last frame - mPelvisOffset = mPelvisState.getPosition() + lerp(LLVector3::zero, footCorrection, LLCriticalDamp::getInterpolant(0.2f)); + mPelvisOffset = mPelvisState->getPosition() + lerp(LLVector3::zero, footCorrection, LLCriticalDamp::getInterpolant(0.2f)); // pelvis drift (along walk direction) mAvgCorrection = lerp(mAvgCorrection, footCorrection.mV[VX] * mRelativeDir, LLCriticalDamp::getInterpolant(0.1f)); @@ -319,7 +321,7 @@ BOOL LLWalkAdjustMotion::onUpdate(F32 time, U8* joint_mask) F32 drift_comp_max = llclamp(speed, 0.f, DRIFT_COMP_MAX_SPEED) / DRIFT_COMP_MAX_SPEED; drift_comp_max *= DRIFT_COMP_MAX_TOTAL; - LLVector3 currentPelvisPos = mPelvisState.getJoint()->getPosition(); + LLVector3 currentPelvisPos = mPelvisState->getJoint()->getPosition(); // NB: this is an ADDITIVE amount that is accumulated every frame, so clamping it alone won't do the trick // must clamp with absolute position of pelvis in mind @@ -328,7 +330,7 @@ BOOL LLWalkAdjustMotion::onUpdate(F32 time, U8* joint_mask) mPelvisOffset.mV[VZ] = 0.f; // set position - mPelvisState.setPosition(mPelvisOffset); + mPelvisState->setPosition(mPelvisOffset); mCharacter->setAnimationData("Pelvis Offset", &mPelvisOffset); @@ -344,6 +346,17 @@ void LLWalkAdjustMotion::onDeactivate() } //----------------------------------------------------------------------------- +// LLFlyAdjustMotion::LLFlyAdjustMotion() +//----------------------------------------------------------------------------- +LLFlyAdjustMotion::LLFlyAdjustMotion(const LLUUID &id) + : LLMotion(id) +{ + mName = "fly_adjust"; + + mPelvisState = new LLJointState; +} + +//----------------------------------------------------------------------------- // LLFlyAdjustMotion::onInitialize() //----------------------------------------------------------------------------- LLMotion::LLMotionInitStatus LLFlyAdjustMotion::onInitialize(LLCharacter *character) @@ -351,15 +364,15 @@ LLMotion::LLMotionInitStatus LLFlyAdjustMotion::onInitialize(LLCharacter *charac mCharacter = character; LLJoint* pelvisJoint = mCharacter->getJoint("mPelvis"); - mPelvisState.setJoint( pelvisJoint ); + mPelvisState->setJoint( pelvisJoint ); if ( !pelvisJoint ) { llwarns << getName() << ": Can't get pelvis joint." << llendl; return STATUS_FAILURE; } - mPelvisState.setUsage(LLJointState::POS | LLJointState::ROT); - addJointState( &mPelvisState ); + mPelvisState->setUsage(LLJointState::POS | LLJointState::ROT); + addJointState( mPelvisState ); return STATUS_SUCCESS; } @@ -369,8 +382,8 @@ LLMotion::LLMotionInitStatus LLFlyAdjustMotion::onInitialize(LLCharacter *charac //----------------------------------------------------------------------------- BOOL LLFlyAdjustMotion::onActivate() { - mPelvisState.setPosition(LLVector3::zero); - mPelvisState.setRotation(LLQuaternion::DEFAULT); + mPelvisState->setPosition(LLVector3::zero); + mPelvisState->setRotation(LLQuaternion::DEFAULT); mRoll = 0.f; return TRUE; } @@ -392,11 +405,11 @@ BOOL LLFlyAdjustMotion::onUpdate(F32 time, U8* joint_mask) // llinfos << mRoll << llendl; LLQuaternion roll(mRoll, LLVector3(0.f, 0.f, 1.f)); - mPelvisState.setRotation(roll); + mPelvisState->setRotation(roll); // F32 lerp_amt = LLCriticalDamp::getInterpolant(0.2f); // -// LLVector3 pelvis_correction = mPelvisState.getPosition() - lerp(LLVector3::zero, mPelvisState.getJoint()->getPosition() + mPelvisState.getPosition(), lerp_amt); -// mPelvisState.setPosition(pelvis_correction); +// LLVector3 pelvis_correction = mPelvisState->getPosition() - lerp(LLVector3::zero, mPelvisState->getJoint()->getPosition() + mPelvisState->getPosition(), lerp_amt); +// mPelvisState->setPosition(pelvis_correction); return TRUE; } diff --git a/indra/llcharacter/llkeyframewalkmotion.h b/indra/llcharacter/llkeyframewalkmotion.h index f52a8d6e33..bd30b5d11d 100644 --- a/indra/llcharacter/llkeyframewalkmotion.h +++ b/indra/llcharacter/llkeyframewalkmotion.h @@ -123,7 +123,7 @@ public: LLCharacter *mCharacter; LLJoint* mLeftAnkleJoint; LLJoint* mRightAnkleJoint; - LLJointState mPelvisState; + LLPointer<LLJointState> mPelvisState; LLJoint* mPelvisJoint; LLVector3d mLastLeftAnklePos; LLVector3d mLastRightAnklePos; @@ -141,7 +141,7 @@ class LLFlyAdjustMotion : public LLMotion { public: // Constructor - LLFlyAdjustMotion(const LLUUID &id) : LLMotion(id) {mName = "fly_adjust";} + LLFlyAdjustMotion(const LLUUID &id); public: //------------------------------------------------------------------------- @@ -173,7 +173,7 @@ protected: // Member Data //------------------------------------------------------------------------- LLCharacter *mCharacter; - LLJointState mPelvisState; + LLPointer<LLJointState> mPelvisState; F32 mRoll; }; diff --git a/indra/llcharacter/llmotion.cpp b/indra/llcharacter/llmotion.cpp index e674620d42..bf332ed838 100644 --- a/indra/llcharacter/llmotion.cpp +++ b/indra/llcharacter/llmotion.cpp @@ -106,7 +106,7 @@ void LLMotion::fadeIn() //----------------------------------------------------------------------------- // addJointState() //----------------------------------------------------------------------------- -void LLMotion::addJointState(LLJointState* jointState) +void LLMotion::addJointState(const LLPointer<LLJointState>& jointState) { mPose.addJointState(jointState); S32 priority = jointState->getPriority(); diff --git a/indra/llcharacter/llmotion.h b/indra/llcharacter/llmotion.h index 2b5c5aad5e..7669920339 100644 --- a/indra/llcharacter/llmotion.h +++ b/indra/llcharacter/llmotion.h @@ -163,7 +163,7 @@ protected: // it will be deactivated virtual BOOL onActivate() = 0; - void addJointState(LLJointState* jointState); + void addJointState(const LLPointer<LLJointState>& jointState); protected: LLPose mPose; diff --git a/indra/llcharacter/llpose.cpp b/indra/llcharacter/llpose.cpp index 1e637d7e33..557bbd2d56 100644 --- a/indra/llcharacter/llpose.cpp +++ b/indra/llcharacter/llpose.cpp @@ -54,7 +54,7 @@ LLPose::~LLPose() //----------------------------------------------------------------------------- // getFirstJointState() //----------------------------------------------------------------------------- -LLJointState *LLPose::getFirstJointState() +LLJointState* LLPose::getFirstJointState() { mListIter = mJointMap.begin(); if (mListIter == mJointMap.end()) @@ -86,7 +86,7 @@ LLJointState *LLPose::getNextJointState() //----------------------------------------------------------------------------- // addJointState() //----------------------------------------------------------------------------- -BOOL LLPose::addJointState(LLJointState *jointState) +BOOL LLPose::addJointState(const LLPointer<LLJointState>& jointState) { if (mJointMap.find(jointState->getJoint()->getName()) == mJointMap.end()) { @@ -98,7 +98,7 @@ BOOL LLPose::addJointState(LLJointState *jointState) //----------------------------------------------------------------------------- // removeJointState() //----------------------------------------------------------------------------- -BOOL LLPose::removeJointState(LLJointState *jointState) +BOOL LLPose::removeJointState(const LLPointer<LLJointState>& jointState) { mJointMap.erase(jointState->getJoint()->getName()); return TRUE; @@ -199,7 +199,7 @@ LLJointStateBlender::~LLJointStateBlender() //----------------------------------------------------------------------------- // addJointState() //----------------------------------------------------------------------------- -BOOL LLJointStateBlender::addJointState(LLJointState *joint_state, S32 priority, BOOL additive_blend) +BOOL LLJointStateBlender::addJointState(const LLPointer<LLJointState>& joint_state, S32 priority, BOOL additive_blend) { llassert(joint_state); @@ -209,7 +209,7 @@ BOOL LLJointStateBlender::addJointState(LLJointState *joint_state, S32 priority, for(S32 i = 0; i < JSB_NUM_JOINT_STATES; i++) { - if (NULL == mJointStates[i]) + if (mJointStates[i].isNull()) { mJointStates[i] = joint_state; mPriorities[i] = priority; @@ -246,7 +246,7 @@ void LLJointStateBlender::blendJointStates(BOOL apply_now) // we need at least one joint to blend // if there is one, it will be in slot zero according to insertion logic // instead of resetting joint state to default, just leave it unchanged from last frame - if (NULL == mJointStates[0]) + if (mJointStates[0].isNull()) { return; } @@ -275,7 +275,7 @@ void LLJointStateBlender::blendJointStates(BOOL apply_now) sum_weights[SCALE_WEIGHT] = 0.f; for(S32 joint_state_index = 0; - joint_state_index < JSB_NUM_JOINT_STATES && mJointStates[joint_state_index] != NULL; + joint_state_index < JSB_NUM_JOINT_STATES && mJointStates[joint_state_index].notNull(); joint_state_index++) { LLJointState* jsp = mJointStates[joint_state_index]; @@ -468,7 +468,7 @@ BOOL LLPoseBlender::addMotion(LLMotion* motion) { LLPose* pose = motion->getPose(); - for(LLJointState *jsp = pose->getFirstJointState(); jsp; jsp = pose->getNextJointState()) + for(LLJointState* jsp = pose->getFirstJointState(); jsp; jsp = pose->getNextJointState()) { LLJoint *jointp = jsp->getJoint(); LLJointStateBlender* joint_blender; diff --git a/indra/llcharacter/llpose.h b/indra/llcharacter/llpose.h index fe0a23887d..5ba579a167 100644 --- a/indra/llcharacter/llpose.h +++ b/indra/llcharacter/llpose.h @@ -52,7 +52,7 @@ class LLPose { friend class LLPoseBlender; protected: - typedef std::map<std::string, LLJointState*> joint_map; + typedef std::map<std::string, LLPointer<LLJointState> > joint_map; typedef joint_map::iterator joint_map_iterator; typedef joint_map::value_type joint_map_value_type; @@ -61,19 +61,19 @@ protected: joint_map_iterator mListIter; public: // Iterate through jointStates - LLJointState *getFirstJointState(); - LLJointState *getNextJointState(); - LLJointState *findJointState(LLJoint *joint); - LLJointState *findJointState(const std::string &name); + LLJointState* getFirstJointState(); + LLJointState* getNextJointState(); + LLJointState* findJointState(LLJoint *joint); + LLJointState* findJointState(const std::string &name); public: // Constructor LLPose() : mWeight(0.f) {} // Destructor ~LLPose(); // add a joint state in this pose - BOOL addJointState(LLJointState *jointState); + BOOL addJointState(const LLPointer<LLJointState>& jointState); // remove a joint state from this pose - BOOL removeJointState(LLJointState *jointState); + BOOL removeJointState(const LLPointer<LLJointState>& jointState); // removes all joint states from this pose BOOL removeAllJointStates(); // set weight for all joint states in this pose @@ -89,14 +89,14 @@ const S32 JSB_NUM_JOINT_STATES = 6; class LLJointStateBlender { protected: - LLJointState* mJointStates[JSB_NUM_JOINT_STATES]; + LLPointer<LLJointState> mJointStates[JSB_NUM_JOINT_STATES]; S32 mPriorities[JSB_NUM_JOINT_STATES]; BOOL mAdditiveBlends[JSB_NUM_JOINT_STATES]; public: LLJointStateBlender(); ~LLJointStateBlender(); void blendJointStates(BOOL apply_now = TRUE); - BOOL addJointState(LLJointState *joint_state, S32 priority, BOOL additive_blend); + BOOL addJointState(const LLPointer<LLJointState>& joint_state, S32 priority, BOOL additive_blend); void interpolate(F32 u); void clear(); void resetCachedJoint(); diff --git a/indra/llcharacter/lltargetingmotion.cpp b/indra/llcharacter/lltargetingmotion.cpp index d5fe65461b..c0ce11cb85 100644 --- a/indra/llcharacter/lltargetingmotion.cpp +++ b/indra/llcharacter/lltargetingmotion.cpp @@ -55,6 +55,8 @@ LLTargetingMotion::LLTargetingMotion(const LLUUID &id) : LLMotion(id) { mCharacter = NULL; mName = "targeting"; + + mTorsoState = new LLJointState; } @@ -87,11 +89,11 @@ LLMotion::LLMotionInitStatus LLTargetingMotion::onInitialize(LLCharacter *charac return STATUS_FAILURE; } - mTorsoState.setJoint( mTorsoJoint ); + mTorsoState->setJoint( mTorsoJoint ); // add joint states to the pose - mTorsoState.setUsage(LLJointState::ROT); - addJointState( &mTorsoState ); + mTorsoState->setUsage(LLJointState::ROT); + addJointState( mTorsoState ); return STATUS_SUCCESS; } @@ -127,7 +129,7 @@ BOOL LLTargetingMotion::onUpdate(F32 time, U8* joint_mask) } //LLVector3 target_plane_normal = LLVector3(1.f, 0.f, 0.f) * mPelvisJoint->getWorldRotation(); - //LLVector3 torso_dir = LLVector3(1.f, 0.f, 0.f) * (mTorsoJoint->getWorldRotation() * mTorsoState.getRotation()); + //LLVector3 torso_dir = LLVector3(1.f, 0.f, 0.f) * (mTorsoJoint->getWorldRotation() * mTorsoState->getRotation()); LLVector3 skyward(0.f, 0.f, 1.f); LLVector3 left(skyward % target); @@ -151,14 +153,14 @@ BOOL LLTargetingMotion::onUpdate(F32 time, U8* joint_mask) new_torso_rot = new_torso_rot * ~cur_torso_rot; // slerp from current additive rotation to ideal additive rotation - new_torso_rot = nlerp(slerp_amt, mTorsoState.getRotation(), new_torso_rot); + new_torso_rot = nlerp(slerp_amt, mTorsoState->getRotation(), new_torso_rot); // constraint overall torso rotation LLQuaternion total_rot = new_torso_rot * mTorsoJoint->getRotation(); total_rot.constrain(F_PI_BY_TWO * 0.8f); new_torso_rot = total_rot * ~mTorsoJoint->getRotation(); - mTorsoState.setRotation(new_torso_rot); + mTorsoState->setRotation(new_torso_rot); return result; } diff --git a/indra/llcharacter/lltargetingmotion.h b/indra/llcharacter/lltargetingmotion.h index 9877467e48..d72a8b11ec 100644 --- a/indra/llcharacter/lltargetingmotion.h +++ b/indra/llcharacter/lltargetingmotion.h @@ -111,7 +111,7 @@ public: public: LLCharacter *mCharacter; - LLJointState mTorsoState; + LLPointer<LLJointState> mTorsoState; LLJoint* mPelvisJoint; LLJoint* mTorsoJoint; LLJoint* mRightHandJoint; diff --git a/indra/llcommon/llversionviewer.h b/indra/llcommon/llversionviewer.h index 1df8a89908..f9f3bf2087 100644 --- a/indra/llcommon/llversionviewer.h +++ b/indra/llcommon/llversionviewer.h @@ -34,8 +34,8 @@ const S32 LL_VERSION_MAJOR = 1; const S32 LL_VERSION_MINOR = 18; -const S32 LL_VERSION_PATCH = 5; -const S32 LL_VERSION_BUILD = 3; +const S32 LL_VERSION_PATCH = 6; +const S32 LL_VERSION_BUILD = 0; const char * const LL_CHANNEL = "Second Life Release"; diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index ca1bc9c525..6d000f3e7f 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -1194,6 +1194,13 @@ struct LLLayoutStack::LLEmbeddedPanel } } + ~LLEmbeddedPanel() + { + // probably not necessary, but... + delete mResizeBar; + mResizeBar = NULL; + } + LLPanel* mPanel; S32 mMinWidth; S32 mMinHeight; @@ -1212,6 +1219,7 @@ LLLayoutStack::LLLayoutStack(eLayoutOrientation orientation) : LLLayoutStack::~LLLayoutStack() { + std::for_each(mPanels.begin(), mPanels.end(), DeletePointer()); } void LLLayoutStack::draw() diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index 9a3542d3fb..8ef7066a31 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -355,9 +355,6 @@ extern const char* gURLProtocolWhitelistHandler[]; // Loads a URL with the user's default browser void spawn_web_browser(const char* escaped_url); -// Opens a file with ShellExecute. Security risk! -void shell_open(const char* file_path); - void simpleEscapeString ( std::string& stringIn ); #endif // _LL_window_h_ diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 943b98e9d5..0a2f9cfb6c 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -70,7 +70,6 @@ const S32 MAX_NUM_RESOLUTIONS = 32; void show_window_creation_error(const char* title) { llwarns << title << llendl; - shell_open( "help/window_creation_error.html"); /* OSMessageBox( "Second Life is unable to run because it can't set up your display.\n" @@ -735,7 +734,6 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits if (check_for_card(RENDERER, CARD_LIST[i])) { close(); - shell_open( "help/unsupported_card.html" ); return FALSE; } } @@ -3200,46 +3198,6 @@ void spawn_web_browser(const char* escaped_url) } } -void shell_open( const char* file_path ) -{ - OSStatus result = noErr; - - llinfos << "Opening " << file_path << llendl; - CFURLRef urlRef = NULL; - - CFStringRef stringRef = CFStringCreateWithCString(NULL, file_path, kCFStringEncodingUTF8); - if (stringRef) - { - // This will succeed if the string is a full URL, including the http:// - // Note that URLs specified this way need to be properly percent-escaped. - urlRef = CFURLCreateWithString(NULL, stringRef, NULL); - - if(urlRef == NULL) - { - // This will succeed if the string is a full or partial posix path. - // This will work even if the path contains characters that would need to be percent-escaped - // in the URL (such as spaces). - urlRef = CFURLCreateWithFileSystemPath(NULL, stringRef, kCFURLPOSIXPathStyle, false); - } - - CFRelease(stringRef); - } - - if (urlRef) - { - result = LSOpenCFURLRef(urlRef, NULL); - - if (result != noErr) - { - llinfos << "Error " << result << " on open." << llendl; - } - CFRelease(urlRef); - } - else - { - llinfos << "Error: couldn't create URL." << llendl; - } -} BOOL LLWindowMacOSX::dialog_color_picker ( F32 *r, F32 *g, F32 *b) { diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 2a4cf97308..2fdf80ee82 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -218,6 +218,5 @@ private: S32 OSMessageBoxMacOSX(const char* text, const char* caption, U32 type); void load_url_external(const char* url); -void shell_open( const char* file_path ); #endif //LL_LLWINDOWMACOSX_H diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index ad39c84ac8..cbf4b7dc3a 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -2230,11 +2230,11 @@ static SDL_Cursor *makeSDLCursorFromBMP(const char *filename, int hotx, int hoty bmpsurface->w, bmpsurface->h, 32, - 0xFFU, - 0xFF00U, - 0xFF0000U, - 0xFF000000U); - SDL_FillRect(cursurface, NULL, 0x00000000U); + SDL_SwapLE32(0xFFU), + SDL_SwapLE32(0xFF00U), + SDL_SwapLE32(0xFF0000U), + SDL_SwapLE32(0xFF000000U)); + SDL_FillRect(cursurface, NULL, SDL_SwapLE32(0x00000000U)); // Blit the cursor pixel data onto a 32-bit RGBA surface so we // only have to cope with processing one type of pixel format. @@ -2253,13 +2253,13 @@ static SDL_Cursor *makeSDLCursorFromBMP(const char *filename, int hotx, int hoty // is inferred by color-keying against 200,200,200 for (i=0; i<cursurface->h; ++i) { for (j=0; j<cursurface->w; ++j) { - unsigned char *pixelp = - ((unsigned char *)cursurface->pixels) + U8 *pixelp = + ((U8*)cursurface->pixels) + cursurface->pitch * i + j*cursurface->format->BytesPerPixel; - unsigned char srcred = pixelp[0]; - unsigned char srcgreen = pixelp[1]; - unsigned char srcblue = pixelp[2]; + U8 srcred = pixelp[0]; + U8 srcgreen = pixelp[1]; + U8 srcblue = pixelp[2]; BOOL mask_bit = (srcred != 200) || (srcgreen != 200) || (srcblue != 200); @@ -2741,11 +2741,6 @@ void spawn_web_browser(const char* escaped_url) llinfos << "spawn_web_browser returning." << llendl; } -void shell_open( const char* file_path ) -{ - // *TODO: This function is deprecated and should probably go away. - llwarns << "Deprecated shell_open(): " << file_path << llendl; -} void *LLWindowSDL::getPlatformWindow() { diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h index aa331ed742..2c411e03fd 100644 --- a/indra/llwindow/llwindowsdl.h +++ b/indra/llwindow/llwindowsdl.h @@ -37,6 +37,7 @@ #include "llwindow.h" #include "SDL/SDL.h" +#include "SDL/SDL_endian.h" #if LL_X11 // get X11-specific headers for use in low-level stuff like copy-and-paste support @@ -222,7 +223,6 @@ public: S32 OSMessageBoxSDL(const char* text, const char* caption, U32 type); void load_url_external(const char* url); -void shell_open( const char* file_path ); #if LL_GTK // Lazily initialize and check the runtime GTK version for goodness. diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 4e4bed6485..b8fd9948e3 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -84,7 +84,6 @@ LLW32MsgCallback gAsyncMsgCallback = NULL; void show_window_creation_error(const char* title) { llwarns << title << llendl; - shell_open( "help/window_creation_error.html"); } //static @@ -3398,24 +3397,6 @@ void spawn_web_browser(const char* escaped_url ) } } -void shell_open( const char* file_path ) -{ - llinfos << "Opening " << file_path << llendl; - - WCHAR wstr[1024]; - mbstowcs(wstr, file_path, 1024); - - HWND our_window = NULL; - int retval = (int) ShellExecute(our_window, L"open", wstr, NULL, NULL, SW_SHOWNORMAL); /* Flawfinder: ignore */ - if (retval > 32) - { - llinfos << "ShellExecute success with " << retval << llendl; - } - else - { - llinfos << "ShellExecute failure with " << retval << llendl; - } -} BOOL LLWindowWin32::dialog_color_picker ( F32 *r, F32 *g, F32 *b ) { diff --git a/indra/newview/English.lproj/InfoPlist.strings b/indra/newview/English.lproj/InfoPlist.strings index da8951428a..85f7e2530f 100644 --- a/indra/newview/English.lproj/InfoPlist.strings +++ b/indra/newview/English.lproj/InfoPlist.strings @@ -1,5 +1,5 @@ /* Localized versions of Info.plist keys */ CFBundleName = "Second Life"; -CFBundleShortVersionString = "Second Life version 1.18.5.3"; -CFBundleGetInfoString = "Second Life version 1.18.5.3, Copyright 2004-2007 Linden Research, Inc."; +CFBundleShortVersionString = "Second Life version 1.18.6.0"; +CFBundleGetInfoString = "Second Life version 1.18.6.0, Copyright 2004-2007 Linden Research, Inc."; diff --git a/indra/newview/Info-SecondLife.plist b/indra/newview/Info-SecondLife.plist index 427651ccba..59822a1e4c 100644 --- a/indra/newview/Info-SecondLife.plist +++ b/indra/newview/Info-SecondLife.plist @@ -32,7 +32,7 @@ </dict> </array> <key>CFBundleVersion</key> - <string>1.18.5.3</string> + <string>1.18.6.0</string> <key>CSResourcesFileMapped</key> <true/> </dict> diff --git a/indra/newview/linux_tools/client-readme.txt b/indra/newview/linux_tools/client-readme.txt index 641705da53..832dff4209 100644 --- a/indra/newview/linux_tools/client-readme.txt +++ b/indra/newview/linux_tools/client-readme.txt @@ -50,15 +50,18 @@ Please enjoy! Minimum requirements: * Internet Connection: Cable or DSL - * Computer Processor: 800MHz Pentium III or Athlon, or better - * Computer Memory: 256MB or better (strongly recommend more!) + * Computer Processor: 800MHz Pentium III or Athlon or better + (recommended: 1.5GHz or more) + * Computer Memory: 512MB (recommended: 768MB or more) * Linux Operating System: A reasonably modern 32-bit Linux environment is required. If you are running a 64-bit Linux distribution then you will need its 32-bit compatibility environment installed. * Video/Graphics Card: - o nVidia GeForce 2, GeForce 4mx, or better + o nVidia GeForce 2, GeForce 4mx, or better (recommend one of the + following: 6700, 6800, 7600, 7800, 7900, 8400, 8500, 8600, + 8800, Go 7400, Go 7600, Go 7800, Go 7900) o OR ATI Radeon 8500, 9250, or better - (nVidia cards are strongly recommended for the Linux client) + (nVidia cards are recommended for the Linux client) **NOTE**: Second Life absolutely requires you to have recent, correctly- configured OpenGL 3D drivers for your hardware - the graphics drivers diff --git a/indra/newview/linux_tools/wrapper.sh b/indra/newview/linux_tools/wrapper.sh index 638a0f0b76..35efbc13b8 100755 --- a/indra/newview/linux_tools/wrapper.sh +++ b/indra/newview/linux_tools/wrapper.sh @@ -59,7 +59,8 @@ fi ## Nothing worth editing below this line. ##------------------------------------------------------------------- -RUN_PATH=`dirname "$0" || echo .` +SCRIPTSRC=`readlink -f "$0" || echo "$0"` +RUN_PATH=`dirname "${SCRIPTSRC}" || echo .` cd "${RUN_PATH}" # Re-register the secondlife:// protocol handler every launch, for now. diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 4a7760f15c..d7fc716c55 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -567,7 +567,15 @@ void LLDrawPoolWater::shade() LLCubeMap* skyMap = gSky.mVOSkyp->getCubeMap(); gWaterProgram.enableTexture(LLShaderMgr::ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB); - skyMap->bind(); + + if (skyMap) + { + skyMap->bind(); + } + else + { + llwarns << "NULL gSky.mVOSkyp->getCubeMap(), not binding." << llendl; + } //bind normal map S32 bumpTex = gWaterProgram.enableTexture(LLShaderMgr::BUMP_MAP); diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index 7f846c2791..bc297354f7 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -38,7 +38,6 @@ #include "llfontgl.h" #include "llmd5.h" #include "llsecondlifeurls.h" -#include "llwindow.h" // shell_open() #include "llversionviewer.h" #include "v4color.h" diff --git a/indra/newview/llpolymesh.cpp b/indra/newview/llpolymesh.cpp index 492e590173..dc67ff48ea 100644 --- a/indra/newview/llpolymesh.cpp +++ b/indra/newview/llpolymesh.cpp @@ -862,14 +862,6 @@ void LLPolyMesh::dumpDiagInfo() llinfos << buf << llendl; llinfos << "-----------------------------------------------------" << llendl; } - -//----------------------------------------------------------------------------- -// getCoords() -//----------------------------------------------------------------------------- -const LLVector3 *LLPolyMesh::getCoords() const -{ - return mCoords; -} //----------------------------------------------------------------------------- // getWritableCoords() @@ -985,14 +977,6 @@ void LLPolyMesh::deleteAllMorphData() } //----------------------------------------------------------------------------- -// getWeights() -//----------------------------------------------------------------------------- -const F32* LLPolyMesh::getWeights() const -{ - return mSharedData->mWeights; -} - -//----------------------------------------------------------------------------- // getWritableWeights() //----------------------------------------------------------------------------- F32* LLPolyMesh::getWritableWeights() const diff --git a/indra/newview/llpolymesh.h b/indra/newview/llpolymesh.h index 3cf4acb0fa..8003c4a89d 100644 --- a/indra/newview/llpolymesh.h +++ b/indra/newview/llpolymesh.h @@ -224,7 +224,9 @@ public: } // Get coords - const LLVector3 *getCoords() const; + const LLVector3 *getCoords() const{ + return mCoords; + } // non const version LLVector3 *getWritableCoords(); @@ -273,7 +275,10 @@ public: } // Get weights - const F32 *getWeights() const; + const F32 *getWeights() const { + llassert (mSharedData); + return mSharedData->mWeights; + } F32 *getWritableWeights() const; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 302291ab52..f12f5763ef 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -70,7 +70,6 @@ #include "lluserrelations.h" #include "llversionviewer.h" #include "llvfs.h" -#include "llwindow.h" // for shell_open #include "llxorcipher.h" // saved password, MAC address #include "message.h" #include "v3math.h" diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 7aa25266fe..2fccdcd153 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -60,7 +60,6 @@ #include "lltimer.h" #include "llvfile.h" #include "llvolumemgr.h" -#include "llwindow.h" // for shell_open() // newview includes #include "llagent.h" diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index fa92bfb217..ebb0da016f 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -59,7 +59,6 @@ #include "llteleportflags.h" #include "lltracker.h" #include "lltransactionflags.h" -#include "llwindow.h" // shell_open() #include "llxfermanager.h" #include "message.h" #include "sound_ids.h" @@ -1199,7 +1198,22 @@ void inventory_offer_handler(LLOfferInfo* info, BOOL from_task) LLString::format_map_t args; args["[OBJECTNAME]"] = info->mDesc; - args["[OBJECTTYPE]"] = LLAssetType::lookupHumanReadable(info->mType); + // must protect against a NULL return from lookupHumanReadable() + const char* typestr = LLAssetType::lookupHumanReadable(info->mType); + if (typestr) + { + args["[OBJECTTYPE]"] = typestr; + } + else + { + llwarns << "LLAssetType::lookupHumanReadable() returned NULL - probably bad asset type: " << info->mType << llendl; + args["[OBJECTTYPE]"] = ""; + + // This seems safest, rather than propagating bogosity + llwarns << "Forcing an inventory-decline for probably-bad asset type." << llendl; + inventory_offer_callback(IOR_DECLINE, info); + return; + } // Name cache callbacks don't store userdata, so can't save // off the LLOfferInfo. Argh. JC diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 7a225c8a12..fc159ddc48 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -311,7 +311,13 @@ class LLBodyNoiseMotion : { public: // Constructor - LLBodyNoiseMotion(const LLUUID &id) : LLMotion(id) {mName = "body_noise";} + LLBodyNoiseMotion(const LLUUID &id) + : LLMotion(id) + { + mName = "body_noise"; + + mTorsoState = new LLJointState; + } // Destructor virtual ~LLBodyNoiseMotion() { } @@ -354,14 +360,14 @@ public: // must return true to indicate success and be available for activation virtual LLMotionInitStatus onInitialize(LLCharacter *character) { - if( !mTorsoState.setJoint( character->getJoint("mTorso") )) + if( !mTorsoState->setJoint( character->getJoint("mTorso") )) { return STATUS_FAILURE; } - mTorsoState.setUsage(LLJointState::ROT); + mTorsoState->setUsage(LLJointState::ROT); - addJointState( &mTorsoState ); + addJointState( mTorsoState ); return STATUS_SUCCESS; } @@ -388,7 +394,7 @@ public: F32 ry = TORSO_NOISE_AMOUNT * DEG_TO_RAD * noiseY / 0.42f; LLQuaternion tQn; tQn.setQuat( rx, ry, 0.0f ); - mTorsoState.setRotation( tQn ); + mTorsoState->setRotation( tQn ); return TRUE; } @@ -400,7 +406,7 @@ public: //------------------------------------------------------------------------- // joint states to be animated //------------------------------------------------------------------------- - LLJointState mTorsoState; + LLPointer<LLJointState> mTorsoState; }; //----------------------------------------------------------------------------- @@ -417,6 +423,8 @@ public: mCharacter(NULL) { mName = "breathe_rot"; + + mChestState = new LLJointState; } // Destructor @@ -463,12 +471,12 @@ public: mCharacter = character; bool success = true; - if ( !mChestState.setJoint( character->getJoint( "mChest" ) ) ) { success = false; } + if ( !mChestState->setJoint( character->getJoint( "mChest" ) ) ) { success = false; } if ( success ) { - mChestState.setUsage(LLJointState::ROT); - addJointState( &mChestState ); + mChestState->setUsage(LLJointState::ROT); + addJointState( mChestState ); } if ( success ) @@ -495,7 +503,7 @@ public: F32 breathe_amt = (sinf(mBreatheRate * time) * BREATHE_ROT_MOTION_STRENGTH); - mChestState.setRotation(LLQuaternion(breathe_amt, LLVector3(0.f, 1.f, 0.f))); + mChestState->setRotation(LLQuaternion(breathe_amt, LLVector3(0.f, 1.f, 0.f))); return TRUE; } @@ -507,7 +515,7 @@ public: //------------------------------------------------------------------------- // joint states to be animated //------------------------------------------------------------------------- - LLJointState mChestState; + LLPointer<LLJointState> mChestState; F32 mBreatheRate; LLCharacter* mCharacter; }; @@ -520,7 +528,13 @@ class LLPelvisFixMotion : { public: // Constructor - LLPelvisFixMotion(const LLUUID &id) : LLMotion(id), mCharacter(NULL) {mName = "pelvis_fix";} + LLPelvisFixMotion(const LLUUID &id) + : LLMotion(id), mCharacter(NULL) + { + mName = "pelvis_fix"; + + mPelvisState = new LLJointState; + } // Destructor virtual ~LLPelvisFixMotion() { } @@ -565,14 +579,14 @@ public: { mCharacter = character; - if (!mPelvisState.setJoint( character->getJoint("mPelvis"))) + if (!mPelvisState->setJoint( character->getJoint("mPelvis"))) { return STATUS_FAILURE; } - mPelvisState.setUsage(LLJointState::POS); + mPelvisState->setUsage(LLJointState::POS); - addJointState( &mPelvisState ); + addJointState( mPelvisState ); return STATUS_SUCCESS; } @@ -586,7 +600,7 @@ public: // must return FALSE when the motion is completed. virtual BOOL onUpdate(F32 time, U8* joint_mask) { - mPelvisState.setPosition(LLVector3::zero); + mPelvisState->setPosition(LLVector3::zero); return TRUE; } @@ -598,7 +612,7 @@ public: //------------------------------------------------------------------------- // joint states to be animated //------------------------------------------------------------------------- - LLJointState mPelvisState; + LLPointer<LLJointState> mPelvisState; LLCharacter* mCharacter; }; diff --git a/indra/newview/macview_Prefix.h b/indra/newview/macview_Prefix.h index 4d982f1897..08c59bcedd 100644 --- a/indra/newview/macview_Prefix.h +++ b/indra/newview/macview_Prefix.h @@ -221,7 +221,7 @@ #include "indra_constants.h" // for key and mask constants #include "llfontgl.h" #include "v4color.h" -#include "llwindow_impl.h" // shell_open() +#include "llwindow_impl.h" #include "llbutton.h" #include "llcheckboxctrl.h" diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index e9faccb4da..b16a9fb02b 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3667,6 +3667,11 @@ void LLPipeline::clearRenderMap() void LLPipeline::resetVertexBuffers(LLDrawable* drawable) { + if (!drawable) + { + return; + } + for (S32 i = 0; i < drawable->getNumFaces(); i++) { LLFace* facep = drawable->getFace(i); |