diff options
Diffstat (limited to 'indra/llcharacter')
-rw-r--r-- | indra/llcharacter/llcharacter.cpp | 28 | ||||
-rw-r--r-- | indra/llcharacter/llcharacter.h | 5 | ||||
-rw-r--r-- | indra/llcharacter/lljoint.cpp | 87 | ||||
-rw-r--r-- | indra/llcharacter/lljoint.h | 3 | ||||
-rw-r--r-- | indra/llcharacter/llkeyframemotion.cpp | 24 |
5 files changed, 89 insertions, 58 deletions
diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp index ecca9a2526..583f01cf91 100644 --- a/indra/llcharacter/llcharacter.cpp +++ b/indra/llcharacter/llcharacter.cpp @@ -19,13 +19,7 @@ LLStringTable LLCharacter::sVisualParamNames(1024); -// helper functions -BOOL larger_screen_area( LLCharacter* data_new, LLCharacter* data_tested ) -{ - return data_new->getPixelArea() > data_tested->getPixelArea(); -} - -LLLinkedList< LLCharacter > LLCharacter::sInstances( larger_screen_area ); +std::vector< LLCharacter* > LLCharacter::sInstances; //----------------------------------------------------------------------------- @@ -40,7 +34,7 @@ LLCharacter::LLCharacter() mSkeletonSerialNum( 0 ) { mMotionController.setCharacter( this ); - sInstances.addData(this); + sInstances.push_back(this); mPauseRequest = new LLPauseRequestHandle(); } @@ -57,7 +51,11 @@ LLCharacter::~LLCharacter() { delete param; } - sInstances.removeData(this); + std::vector<LLCharacter*>::iterator iter = std::find(sInstances.begin(), sInstances.end(), this); + if (iter != sInstances.end()) + { + sInstances.erase(iter); + } } @@ -66,7 +64,7 @@ LLCharacter::~LLCharacter() //----------------------------------------------------------------------------- LLJoint *LLCharacter::getJoint( const std::string &name ) { - LLJoint *joint = NULL; + LLJoint* joint = NULL; LLJoint *root = getRootJoint(); if (root) @@ -183,7 +181,7 @@ void LLCharacter::flushAllMotions() //----------------------------------------------------------------------------- // dumpCharacter() //----------------------------------------------------------------------------- -void LLCharacter::dumpCharacter( LLJoint *joint ) +void LLCharacter::dumpCharacter( LLJoint* joint ) { // handle top level entry into recursion if (joint == NULL) @@ -198,11 +196,11 @@ void LLCharacter::dumpCharacter( LLJoint *joint ) llinfos << "DEBUG: " << joint->getName() << " (" << (joint->getParent()?joint->getParent()->getName():std::string("ROOT")) << ")" << llendl; // recurse - for ( LLJoint *j = joint->mChildren.getFirstData(); - j != NULL; - j = joint->mChildren.getNextData() ) + for (LLJoint::child_list_t::iterator iter = joint->mChildren.begin(); + iter != joint->mChildren.end(); ++iter) { - dumpCharacter(j); + LLJoint* child_joint = *iter; + dumpCharacter(child_joint); } } diff --git a/indra/llcharacter/llcharacter.h b/indra/llcharacter/llcharacter.h index f2f106f360..0ed22f81f7 100644 --- a/indra/llcharacter/llcharacter.h +++ b/indra/llcharacter/llcharacter.h @@ -21,6 +21,7 @@ #include "linked_lists.h" #include "string_table.h" #include "llmemory.h" +#include "llthread.h" class LLPolyMesh; @@ -90,7 +91,7 @@ public: virtual F32 getTimeDilation() = 0; // gets current pixel area of this character - virtual F32 getPixelArea() = 0; + virtual F32 getPixelArea() const = 0; // gets the head mesh of the character virtual LLPolyMesh* getHeadMesh() = 0; @@ -223,7 +224,7 @@ public: U32 getSkeletonSerialNum() const { return mSkeletonSerialNum; } void setSkeletonSerialNum( U32 num ) { mSkeletonSerialNum = num; } - static LLLinkedList< LLCharacter > sInstances; + static std::vector< LLCharacter* > sInstances; protected: LLMotionController mMotionController; diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index 3924c06adc..3797b06aa1 100644 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -50,8 +50,9 @@ LLJoint::LLJoint(const std::string &name, LLJoint *parent) setName(name); if (parent) + { parent->addChild( this ); - + } touch(); } @@ -61,6 +62,10 @@ LLJoint::LLJoint(const std::string &name, LLJoint *parent) //----------------------------------------------------------------------------- LLJoint::~LLJoint() { + if (mParent) + { + mParent->removeChild( this ); + } removeAllChildren(); } @@ -72,7 +77,9 @@ void LLJoint::setup(const std::string &name, LLJoint *parent) { setName(name); if (parent) + { parent->addChild( this ); + } } //----------------------------------------------------------------------------- @@ -90,11 +97,11 @@ void LLJoint::touch(U32 flags) { child_flags |= POSITION_DIRTY; } - - for ( LLJoint *joint = mChildren.getFirstData(); - joint != NULL; - joint = mChildren.getNextData() ) + + for (child_list_t::iterator iter = mChildren.begin(); + iter != mChildren.end(); ++iter) { + LLJoint* joint = *iter; joint->touch(child_flags); } } @@ -121,13 +128,15 @@ LLJoint *LLJoint::findJoint( const std::string &name ) if (name == getName()) return this; - for ( LLJoint *j = mChildren.getFirstData(); - j != NULL; - j = mChildren.getNextData() ) + for (child_list_t::iterator iter = mChildren.begin(); + iter != mChildren.end(); ++iter) { - LLJoint *found = j->findJoint(name); + LLJoint* joint = *iter; + LLJoint *found = joint->findJoint(name); if (found) + { return found; + } } return NULL; @@ -137,12 +146,12 @@ LLJoint *LLJoint::findJoint( const std::string &name ) //-------------------------------------------------------------------- // addChild() //-------------------------------------------------------------------- -void LLJoint::addChild(LLJoint *joint) +void LLJoint::addChild(LLJoint* joint) { if (joint->mParent) joint->mParent->removeChild(joint); - mChildren.addDataAtEnd(joint); + mChildren.push_back(joint); joint->mXform.setParent(&mXform); joint->mParent = this; joint->touch(); @@ -152,9 +161,13 @@ void LLJoint::addChild(LLJoint *joint) //-------------------------------------------------------------------- // removeChild() //-------------------------------------------------------------------- -void LLJoint::removeChild(LLJoint *joint) +void LLJoint::removeChild(LLJoint* joint) { - this->mChildren.removeData(joint); + child_list_t::iterator iter = std::find(mChildren.begin(), mChildren.end(), joint); + if (iter != mChildren.end()) + { + this->mChildren.erase(iter); + } joint->mXform.setParent(NULL); joint->mParent = NULL; joint->touch(); @@ -166,11 +179,15 @@ void LLJoint::removeChild(LLJoint *joint) //-------------------------------------------------------------------- void LLJoint::removeAllChildren() { - for ( LLJoint *joint = mChildren.getFirstData(); - joint != NULL; - joint = mChildren.getNextData() ) + for (child_list_t::iterator iter = mChildren.begin(); + iter != mChildren.end();) { - removeChild(joint); + child_list_t::iterator curiter = iter++; + LLJoint* joint = *curiter; + mChildren.erase(curiter); + joint->mXform.setParent(NULL); + joint->mParent = NULL; + joint->touch(); } } @@ -189,8 +206,11 @@ const LLVector3& LLJoint::getPosition() //-------------------------------------------------------------------- void LLJoint::setPosition( const LLVector3& pos ) { - mXform.setPosition(pos); - touch(MATRIX_DIRTY | POSITION_DIRTY); +// if (mXform.getPosition() != pos) + { + mXform.setPosition(pos); + touch(MATRIX_DIRTY | POSITION_DIRTY); + } } @@ -257,8 +277,11 @@ void LLJoint::setRotation( const LLQuaternion& rot ) { if (rot.isFinite()) { - mXform.setRotation(rot); - touch(MATRIX_DIRTY | ROTATION_DIRTY); + // if (mXform.getRotation() != rot) + { + mXform.setRotation(rot); + touch(MATRIX_DIRTY | ROTATION_DIRTY); + } } } @@ -320,8 +343,12 @@ const LLVector3& LLJoint::getScale() //-------------------------------------------------------------------- void LLJoint::setScale( const LLVector3& scale ) { - mXform.setScale(scale); - touch(); +// if (mXform.getScale() != scale) + { + mXform.setScale(scale); + touch(); + } + } @@ -393,14 +420,18 @@ void LLJoint::updateWorldPRSParent() // updateWorldMatrixChildren() //----------------------------------------------------------------------------- void LLJoint::updateWorldMatrixChildren() -{ +{ + if (!this->mUpdateXform) return; + if (mDirtyFlags & MATRIX_DIRTY) { updateWorldMatrix(); } - for (LLJoint *child = mChildren.getFirstData(); child; child = mChildren.getNextData()) + for (child_list_t::iterator iter = mChildren.begin(); + iter != mChildren.end(); ++iter) { - child->updateWorldMatrixChildren(); + LLJoint* joint = *iter; + joint->updateWorldMatrixChildren(); } } @@ -475,8 +506,10 @@ void LLJoint::clampRotation(LLQuaternion old_rot, LLQuaternion new_rot) { LLVector3 main_axis(1.f, 0.f, 0.f); - for (LLJoint* joint = mChildren.getFirstData(); joint; joint = mChildren.getNextData()) + for (child_list_t::iterator iter = mChildren.begin(); + iter != mChildren.end(); ++iter) { + LLJoint* joint = *iter; if (joint->isAnimatable()) { main_axis = joint->getPosition(); diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index 2fc86e87df..6399d0a429 100644 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -76,7 +76,8 @@ public: LLDynamicArray<LLVector3> mConstraintSilhouette; // child joints - LLLinkedList<LLJoint> mChildren; + typedef std::list<LLJoint*> child_list_t; + child_list_t mChildren; // debug statics static S32 sNumTouches; diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index bfa4b637e1..ea77126aca 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -1892,28 +1892,26 @@ void LLKeyframeMotion::onLoadComplete(LLVFS *vfs, void* user_data, S32 status) { LLUUID* id = (LLUUID*)user_data; + + std::vector<LLCharacter* >::iterator char_iter = LLCharacter::sInstances.begin(); - LLCharacter* character = NULL; + while(char_iter != LLCharacter::sInstances.end() && + (*char_iter)->getID() != *id) + { + ++char_iter; + } - for(character = LLCharacter::sInstances.getFirstData(); - character; - character = LLCharacter::sInstances.getNextData()) - { - if (character->getID() == *id) - { - break; - } - } - delete id; - if (!character) + if (char_iter == LLCharacter::sInstances.end()) { return; } + LLCharacter* character = *char_iter; + // create an instance of this motion (it may or may not already exist) - LLKeyframeMotion* motionp = (LLKeyframeMotion*)character->createMotion(asset_uuid); + LLKeyframeMotion* motionp = (LLKeyframeMotion*) character->createMotion(asset_uuid); if (0 == status && motionp) { |