diff options
Diffstat (limited to 'indra/llcharacter')
-rw-r--r-- | indra/llcharacter/llcharacter.cpp | 23 | ||||
-rw-r--r-- | indra/llcharacter/llcharacter.h | 20 | ||||
-rw-r--r-- | indra/llcharacter/llkeyframemotion.cpp | 25 | ||||
-rw-r--r-- | indra/llcharacter/llkeyframewalkmotion.cpp | 2 |
4 files changed, 39 insertions, 31 deletions
diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp index 264b9a0be1..ecbcdb3bf5 100644 --- a/indra/llcharacter/llcharacter.cpp +++ b/indra/llcharacter/llcharacter.cpp @@ -38,7 +38,7 @@ LLStringTable LLCharacter::sVisualParamNames(1024); -std::vector< LLCharacter* > LLCharacter::sInstances; +std::list< LLCharacter* > LLCharacter::sInstances; bool LLCharacter::sAllowInstancesChange = true ; //----------------------------------------------------------------------------- @@ -53,7 +53,6 @@ LLCharacter::LLCharacter() mSkeletonSerialNum( 0 ) { llassert_always(sAllowInstancesChange) ; - sInstances.push_back(this); mMotionController.setCharacter( this ); mPauseRequest = new LLPauseRequestHandle(); @@ -66,28 +65,12 @@ LLCharacter::LLCharacter() //----------------------------------------------------------------------------- LLCharacter::~LLCharacter() { - for (LLVisualParam *param = getFirstVisualParam(); - param; - param = getNextVisualParam()) + for (const auto& it : mVisualParamIndexMap) { - delete param; + delete it.second; } - size_t i ; - size_t size = sInstances.size() ; - for(i = 0 ; i < size ; i++) - { - if(sInstances[i] == this) - { - break ; - } - } - - llassert_always(i < size) ; - llassert_always(sAllowInstancesChange) ; - sInstances[i] = sInstances[size - 1] ; - sInstances.pop_back() ; } diff --git a/indra/llcharacter/llcharacter.h b/indra/llcharacter/llcharacter.h index b390960a75..6143ec8cd1 100644 --- a/indra/llcharacter/llcharacter.h +++ b/indra/llcharacter/llcharacter.h @@ -245,6 +245,24 @@ public: S32 getVisualParamCount() const { return (S32)mVisualParamIndexMap.size(); } LLVisualParam* getVisualParam(const char *name); + void animateTweakableVisualParams(F32 delta) + { + for (auto& it : mVisualParamIndexMap) + { + if (it.second->isTweakable()) + { + it.second->animate(delta); + } + } + } + + void applyAllVisualParams(ESex avatar_sex) + { + for (auto& it : mVisualParamIndexMap) + { + it.second->apply(avatar_sex); + } + } ESex getSex() const { return mSex; } void setSex( ESex sex ) { mSex = sex; } @@ -255,7 +273,7 @@ public: U32 getSkeletonSerialNum() const { return mSkeletonSerialNum; } void setSkeletonSerialNum( U32 num ) { mSkeletonSerialNum = num; } - static std::vector< LLCharacter* > sInstances; + static std::list< LLCharacter* > sInstances; static bool sAllowInstancesChange ; //debug use virtual void setHoverOffset(const LLVector3& hover_offset, bool send_update=true) { mHoverOffset = hover_offset; } diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index 12212efb66..6790f1ad56 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -2227,7 +2227,12 @@ bool LLKeyframeMotion::dumpToFile(const std::string& name) } S32 file_size = getFileSize(); - U8* buffer = new U8[file_size]; + U8* buffer = new(std::nothrow) U8[file_size]; + if (!buffer) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Bad memory allocation for buffer, file: " << name << " " << file_size << LL_ENDL; + } LL_DEBUGS("BVH") << "Dumping " << outfilename << LL_ENDL; LLDataPackerBinaryBuffer dp(buffer, file_size); @@ -2407,13 +2412,10 @@ void LLKeyframeMotion::onLoadComplete(const LLUUID& asset_uuid, { LLUUID* id = (LLUUID*)user_data; - std::vector<LLCharacter* >::iterator char_iter = LLCharacter::sInstances.begin(); - - while(char_iter != LLCharacter::sInstances.end() && - (*char_iter)->getID() != *id) - { - ++char_iter; - } + auto char_iter = std::find_if(LLCharacter::sInstances.begin(), LLCharacter::sInstances.end(), [&](LLCharacter* c) + { + return c->getID() == *id; + }); delete id; @@ -2438,7 +2440,12 @@ void LLKeyframeMotion::onLoadComplete(const LLUUID& asset_uuid, LLFileSystem file(asset_uuid, type, LLFileSystem::READ); S32 size = file.getSize(); - U8* buffer = new U8[size]; + U8* buffer = new(std::nothrow) U8[size]; + if (!buffer) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Bad memory allocation for buffer of size: " << size << LL_ENDL; + } file.read((U8*)buffer, size); /*Flawfinder: ignore*/ LL_DEBUGS("Animation") << "Loading keyframe data for: " << motionp->getName() << ":" << motionp->getID() << " (" << size << " bytes)" << LL_ENDL; diff --git a/indra/llcharacter/llkeyframewalkmotion.cpp b/indra/llcharacter/llkeyframewalkmotion.cpp index 605e15f442..f8691b5f59 100644 --- a/indra/llcharacter/llkeyframewalkmotion.cpp +++ b/indra/llcharacter/llkeyframewalkmotion.cpp @@ -383,7 +383,7 @@ bool LLFlyAdjustMotion::onUpdate(F32 time, U8* joint_mask) F32 target_roll = llclamp(ang_vel.mV[VZ], -4.f, 4.f) * roll_factor; // roll is critically damped interpolation between current roll and angular velocity-derived target roll - mRoll = LLSmoothInterpolation::lerp(mRoll, target_roll, U32Milliseconds(100)); + mRoll = LLSmoothInterpolation::lerp(mRoll, target_roll, F32Milliseconds(100.f)); LLQuaternion roll(mRoll, LLVector3(0.f, 0.f, 1.f)); mPelvisState->setRotation(roll); |