diff options
Diffstat (limited to 'indra/newview/llvoavatar.cpp')
-rw-r--r-- | indra/newview/llvoavatar.cpp | 412 |
1 files changed, 199 insertions, 213 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 0f339405be..868d26d5c6 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -110,7 +110,6 @@ #include "llsdutil.h" #include "llscenemonitor.h" #include "llsdserialize.h" -#include "llcallstack.h" #include "llrendersphere.h" #include "llskinningutil.h" @@ -769,6 +768,8 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, } mVisuallyMuteSetting = LLVOAvatar::VisualMuteSettings(LLRenderMuteList::getInstance()->getSavedVisualMuteSetting(getID())); + + sInstances.push_back(this); } std::string LLVOAvatar::avString() const @@ -816,6 +817,8 @@ void LLVOAvatar::debugAvatarRezTime(std::string notification_name, std::string c //------------------------------------------------------------------------ LLVOAvatar::~LLVOAvatar() { + sInstances.remove(this); + if (gSavedSettings.getBOOL("IMShowArrivalsDepartures")) { LLAvatarName av_name; @@ -973,26 +976,16 @@ void LLVOAvatar::deleteLayerSetCaches(bool clearAll) // static bool LLVOAvatar::areAllNearbyInstancesBaked(S32& grey_avatars) { - bool res = true; grey_avatars = 0; - for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*) *iter; - if( inst->isDead() ) + LLVOAvatar* inst = (LLVOAvatar*)character; + if (!inst->isDead() && inst->mHasGrey && !inst->isFullyBaked()) { - continue; - } - else if( !inst->isFullyBaked() ) - { - res = false; - if (inst->mHasGrey) - { - ++grey_avatars; - } + ++grey_avatars; } } - return res; + return !grey_avatars; } // static @@ -1003,11 +996,10 @@ void LLVOAvatar::getNearbyRezzedStats(std::vector<S32>& counts, F32& avg_cloud_t avg_cloud_time = 0; cloud_avatars = 0; S32 count_avg = 0; - for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*) *iter; - if (inst) + if (LLVOAvatar* inst = (LLVOAvatar*)character) { S32 rez_status = inst->getRezzedStatus(); counts[rez_status]++; @@ -1024,6 +1016,7 @@ void LLVOAvatar::getNearbyRezzedStats(std::vector<S32>& counts, F32& avg_cloud_t } } } + if (count_avg > 0) { avg_cloud_time /= count_avg; @@ -1033,11 +1026,19 @@ void LLVOAvatar::getNearbyRezzedStats(std::vector<S32>& counts, F32& avg_cloud_t // static std::string LLVOAvatar::rezStatusToString(S32 rez_status) { - if (rez_status==0) return "cloud"; - if (rez_status==1) return "gray"; - if (rez_status==2) return "downloading baked"; - if (rez_status==3) return "loading attachments"; - if (rez_status==4) return "full"; + switch (rez_status) + { + case 0: + return "cloud"; + case 1: + return "gray"; + case 2: + return "downloading baked"; + case 3: + return "loading attachments"; + case 4: + return "full"; + } return "unknown"; } @@ -1046,10 +1047,9 @@ void LLVOAvatar::dumpBakedStatus() { LLVector3d camera_pos_global = gAgentCamera.getCameraPositionGlobal(); - for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*) *iter; + LLVOAvatar* inst = (LLVOAvatar*)character; LL_INFOS() << "Avatar "; LLNameValue* firstname = inst->getNVPair("FirstName"); @@ -1144,10 +1144,9 @@ void LLVOAvatar::destroyGL() //static void LLVOAvatar::resetImpostors() { - for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* avatar = (LLVOAvatar*) *iter; + LLVOAvatar* avatar = (LLVOAvatar*)character; avatar->mImpostor.release(); avatar->mNeedsImpostorUpdate = true; avatar->mLastImpostorUpdateReason = 1; @@ -1159,11 +1158,9 @@ void LLVOAvatar::deleteCachedImages(bool clearAll) { if (LLViewerTexLayerSet::sHasCaches) { - for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*) *iter; - inst->deleteLayerSetCaches(clearAll); + ((LLVOAvatar*)character)->deleteLayerSetCaches(clearAll); } LLViewerTexLayerSet::sHasCaches = false; } @@ -1218,7 +1215,7 @@ void LLVOAvatar::initInstance() //------------------------------------------------------------------------- if (LLCharacter::sInstances.size() == 1) { - registerMotion( ANIM_AGENT_DO_NOT_DISTURB, LLNullMotion::create ); + registerMotion( ANIM_AGENT_DO_NOT_DISTURB, LLNullMotion::create ); registerMotion( ANIM_AGENT_CROUCH, LLKeyframeStandMotion::create ); registerMotion( ANIM_AGENT_CROUCHWALK, LLKeyframeWalkMotion::create ); registerMotion( ANIM_AGENT_EXPRESS_AFRAID, LLEmote::create ); @@ -2632,6 +2629,9 @@ void LLVOAvatar::idleUpdate(LLAgent &agent, const F64 &time) { LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; + if (LLApp::isExiting()) + return; + if (isDead()) { LL_INFOS() << "Warning! Idle on dead avatar" << LL_ENDL; @@ -2673,6 +2673,29 @@ void LLVOAvatar::idleUpdate(LLAgent &agent, const F64 &time) } // Update should be happening max once per frame. + static LLCachedControl<S32> refreshPeriod(gSavedSettings, "AvatarExtentRefreshPeriodBatch"); + static LLCachedControl<S32> refreshMaxPerPeriod(gSavedSettings, "AvatarExtentRefreshMaxPerBatch"); + static S32 upd_freq = refreshPeriod; // initialise to a reasonable default of 1 batch + static S32 lastRecalibrationFrame{ 0 }; + + const S32 thisFrame = LLDrawable::getCurrentFrame(); + if (thisFrame - lastRecalibrationFrame >= upd_freq) + { + // Only update at the start of a cycle. . + // update frequency = ((Num_Avatars -1 / NumberPerPeriod) + 1 ) * Periodicity + // Given NumberPerPeriod = 5 and Periodicity = 4 + // | NumAvatars | frequency | + // +-------------+-----------+ + // | 1 | 4 | + // | 2 | 4 | + // | 5 | 4 | + // | 10 | 8 | + // | 25 | 20 | + + upd_freq = (((gObjectList.getAvatarCount() - 1) / refreshMaxPerPeriod) + 1)*refreshPeriod; + lastRecalibrationFrame = thisFrame; + } + if ((mLastAnimExtents[0]==LLVector3())|| (mLastAnimExtents[1])==LLVector3()) { @@ -2680,12 +2703,11 @@ void LLVOAvatar::idleUpdate(LLAgent &agent, const F64 &time) } else { - const S32 upd_freq = 4; // force update every upd_freq frames. - mNeedsExtentUpdate = ((LLDrawable::getCurrentFrame()+mID.mData[0])%upd_freq==0); + // Update extent if necessary. + // if the frame counnter + the first byte of the UUID % upd_freq = 0 then update the extent. + mNeedsExtentUpdate = ((thisFrame + mID.mData[0]) % upd_freq == 0); } - LLScopedContextString str("avatar_idle_update " + getFullname()); - checkTextureLoading() ; // force immediate pixel area update on avatars using last frames data (before drawable or camera updates) @@ -3099,30 +3121,15 @@ void LLVOAvatar::idleUpdateAppearanceAnimation() } else { - F32 morph_amt = calcMorphAmount(); - LLVisualParam *param; - if (!isSelf()) { + F32 morph_amt = calcMorphAmount(); // animate only top level params for non-self avatars - for (param = getFirstVisualParam(); - param; - param = getNextVisualParam()) - { - if (param->isTweakable()) - { - param->animate(morph_amt); - } - } + animateTweakableVisualParams(morph_amt); } // apply all params - for (param = getFirstVisualParam(); - param; - param = getNextVisualParam()) - { - param->apply(avatar_sex); - } + applyAllVisualParams(avatar_sex); mLastAppearanceBlendTime = appearance_anim_time; } @@ -3130,7 +3137,7 @@ void LLVOAvatar::idleUpdateAppearanceAnimation() } } -F32 LLVOAvatar::calcMorphAmount() +F32 LLVOAvatar::calcMorphAmount() const { F32 appearance_anim_time = mAppearanceMorphTimer.getElapsedTimeF32(); F32 blend_frac = calc_bouncy_animation(appearance_anim_time / APPEARANCE_MORPH_TIME); @@ -3187,7 +3194,7 @@ void LLVOAvatar::idleUpdateLipSync(bool voice_enabled) void LLVOAvatar::idleUpdateLoadingEffect() { // update visibility when avatar is partially loaded - if (updateIsFullyLoaded()) // changed? + if (!mFullyLoaded && updateIsFullyLoaded()) // Avoid repeat calculations by checking if mFullyLoaded is true first. { if (isFullyLoaded()) { @@ -3437,7 +3444,7 @@ void LLVOAvatar::idleUpdateNameTagText(bool new_name) { is_muted = isInMuteList(); } - bool is_friend = LLAvatarTracker::instance().isBuddy(getID()); + bool is_friend = isBuddy(); bool is_cloud = getIsCloud(); if (is_appearance != mNameAppearance) @@ -3573,7 +3580,9 @@ void LLVOAvatar::idleUpdateNameTagText(bool new_name) std::deque<LLChat>::iterator chat_iter = mChats.begin(); mNameText->clearString(); - LLColor4 new_chat = LLUIColorTable::instance().getColor( isSelf() ? "UserChatColor" : "AgentChatColor" ); + static const LLUIColor user_chat_color = LLUIColorTable::instance().getColor("UserChatColor"); + static const LLUIColor agent_chat_color = LLUIColorTable::instance().getColor("AgentChatColor"); + const LLColor4& new_chat = isSelf() ? user_chat_color : agent_chat_color; LLColor4 normal_chat = lerp(new_chat, LLColor4(0.8f, 0.8f, 0.8f, 1.f), 0.7f); LLColor4 old_chat = lerp(normal_chat, LLColor4(0.6f, 0.6f, 0.6f, 1.f), 0.7f); if (mTyping && mChats.size() >= MAX_BUBBLE_CHAT_UTTERANCES) @@ -3668,29 +3677,28 @@ void LLVOAvatar::clearNameTag() mTimeVisible.reset(); } -//static +// static void LLVOAvatar::invalidateNameTag(const LLUUID& agent_id) { - LLViewerObject* obj = gObjectList.findObject(agent_id); - if (!obj) return; - - LLVOAvatar* avatar = dynamic_cast<LLVOAvatar*>(obj); - if (!avatar) return; - - avatar->clearNameTag(); + if (LLViewerObject* obj = gObjectList.findObject(agent_id)) + { + if (LLVOAvatar* avatar = dynamic_cast<LLVOAvatar*>(obj)) + { + avatar->clearNameTag(); + } + } } -//static +// static void LLVOAvatar::invalidateNameTags() { - std::vector<LLCharacter*>::iterator it = LLCharacter::sInstances.begin(); - for ( ; it != LLCharacter::sInstances.end(); ++it) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* avatar = dynamic_cast<LLVOAvatar*>(*it); - if (!avatar) continue; - if (avatar->isDead()) continue; - - avatar->clearNameTag(); + LLVOAvatar* avatar = (LLVOAvatar*)character; + if (!avatar->isDead()) + { + avatar->clearNameTag(); + } } } @@ -4110,12 +4118,14 @@ void LLVOAvatar::updateDebugText() { // Leave mDebugText uncleared here, in case a derived class has added some state first - if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + static LLCachedControl<bool> debug_av_appearance_message(gSavedSettings, "DebugAvatarAppearanceMessage"); + if (debug_av_appearance_message) { updateAppearanceMessageDebugText(); } - if (gSavedSettings.getBOOL("DebugAvatarCompositeBaked")) + static LLCachedControl<bool> debug_av_composite_baked(gSavedSettings, "DebugAvatarCompositeBaked"); + if (debug_av_composite_baked) { if (!mBakedTextureDebugText.empty()) addDebugText(mBakedTextureDebugText); @@ -4574,7 +4584,7 @@ void LLVOAvatar::updateRootPositionAndRotation(LLAgent& agent, F32 speed, bool w root_pos += LLVector3d(getHoverOffset()); if (getOverallAppearance() == AOA_JELLYDOLL) { - F32 offz = -0.5 * (getScale()[VZ] - mBodySize.mV[VZ]); + F32 offz = -0.5f * (getScale()[VZ] - mBodySize.mV[VZ]); root_pos[2] += offz; // if (!isSelf() && !isControlAvatar()) // { @@ -4719,10 +4729,6 @@ bool LLVOAvatar::updateCharacter(LLAgent &agent) is_attachment = cav && cav->mRootVolp && cav->mRootVolp->isAttachment(); // For attached animated objects } - LLScopedContextString str("updateCharacter " + getFullname() + " is_control_avatar " - + boost::lexical_cast<std::string>(is_control_avatar) - + " is_attachment " + boost::lexical_cast<std::string>(is_attachment)); - // For fading out the names above heads, only let the timer // run if we're visible. if (mDrawable.notNull() && !visible) @@ -4821,8 +4827,8 @@ bool LLVOAvatar::updateCharacter(LLAgent &agent) if (!getParent() && (isSitting() || was_sit_ground_constrained)) { - F32 off_z = LLVector3d(getHoverOffset()).mdV[VZ]; - if (off_z != 0.0) + F32 off_z = (F32)LLVector3d(getHoverOffset()).mdV[VZ]; + if (off_z != 0.0f) { LLVector3 pos = mRoot->getWorldPosition(); pos.mV[VZ] += off_z; @@ -6388,8 +6394,6 @@ bool LLVOAvatar::jointIsRiggedTo(const LLJoint *joint) const void LLVOAvatar::clearAttachmentOverrides() { - LLScopedContextString str("clearAttachmentOverrides " + getFullname()); - for (S32 i=0; i<LL_CHARACTER_MAX_ANIMATED_JOINTS; i++) { LLJoint *pJoint = getJoint(i); @@ -6420,10 +6424,7 @@ void LLVOAvatar::clearAttachmentOverrides() //----------------------------------------------------------------------------- void LLVOAvatar::rebuildAttachmentOverrides() { - LLScopedContextString str("rebuildAttachmentOverrides " + getFullname()); - LL_DEBUGS("AnimatedObjects") << "rebuilding" << LL_ENDL; - dumpStack("AnimatedObjectsStack"); clearAttachmentOverrides(); @@ -6471,10 +6472,7 @@ void LLVOAvatar::rebuildAttachmentOverrides() // ----------------------------------------------------------------------------- void LLVOAvatar::updateAttachmentOverrides() { - LLScopedContextString str("updateAttachmentOverrides " + getFullname()); - LL_DEBUGS("AnimatedObjects") << "updating" << LL_ENDL; - dumpStack("AnimatedObjectsStack"); std::set<LLUUID> meshes_seen; @@ -6603,15 +6601,12 @@ void LLVOAvatar::addAttachmentOverridesForObject(LLViewerObject *vo, std::set<LL return; } - LLScopedContextString str("addAttachmentOverridesForObject " + getFullname()); - if (getOverallAppearance() != AOA_NORMAL) { return; } LL_DEBUGS("AnimatedObjects") << "adding" << LL_ENDL; - dumpStack("AnimatedObjectsStack"); // Process all children if (recursive) @@ -7282,7 +7277,7 @@ void LLVOAvatar::updateGL() { if (mMeshTexturesDirty) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; updateMeshTextures(); mMeshTexturesDirty = false; } @@ -8299,15 +8294,13 @@ void LLVOAvatar::logPendingPhases() //static void LLVOAvatar::logPendingPhasesAllAvatars() { - for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*) *iter; - if( inst->isDead() ) + LLVOAvatar* avatar = (LLVOAvatar*)character; + if (!avatar->isDead()) { - continue; + avatar->logPendingPhases(); } - inst->logPendingPhases(); } } @@ -8495,7 +8488,7 @@ bool LLVOAvatar::isTooComplex() const { bool too_complex; static LLCachedControl<S32> compelxity_render_mode(gSavedSettings, "RenderAvatarComplexityMode"); - bool render_friend = (LLAvatarTracker::instance().isBuddy(getID()) && compelxity_render_mode > AV_RENDER_LIMIT_BY_COMPLEXITY); + bool render_friend = (isBuddy() && compelxity_render_mode > AV_RENDER_LIMIT_BY_COMPLEXITY); if (isSelf() || render_friend || mVisuallyMuteSetting == AV_ALWAYS_RENDER) { @@ -8531,7 +8524,7 @@ bool LLVOAvatar::isTooSlow() const static LLCachedControl<S32> compelxity_render_mode(gSavedSettings, "RenderAvatarComplexityMode"); static LLCachedControl<bool> friends_only(gSavedSettings, "RenderAvatarFriendsOnly", false); - bool is_friend = LLAvatarTracker::instance().isBuddy(getID()); + bool is_friend = isBuddy(); bool render_friend = is_friend && compelxity_render_mode > AV_RENDER_LIMIT_BY_COMPLEXITY; if (render_friend || mVisuallyMuteSetting == AV_ALWAYS_RENDER) @@ -8572,7 +8565,7 @@ void LLVOAvatar::updateTooSlow() auto it = std::find(sAVsIgnoringARTLimit.begin(), sAVsIgnoringARTLimit.end(), mID); if (it != sAVsIgnoringARTLimit.end()) { - S32 index = it - sAVsIgnoringARTLimit.begin(); + S32 index = (S32)(it - sAVsIgnoringARTLimit.begin()); ignore_tune = (index < (MIN_NONTUNED_AVS - sAvatarsNearby + 1 + LLPerfStats::tunedAvatars)); } } @@ -8588,7 +8581,7 @@ void LLVOAvatar::updateTooSlow() if(!mTooSlowWithoutShadows) // if we were not previously above the full impostor cap { bool always_render_friends = compelxity_render_mode > AV_RENDER_LIMIT_BY_COMPLEXITY; - bool render_friend_or_exception = (always_render_friends && LLAvatarTracker::instance().isBuddy( id ) ) || + bool render_friend_or_exception = (always_render_friends && isBuddy()) || ( getVisualMuteSettings() == LLVOAvatar::AV_ALWAYS_RENDER ); if( (!isSelf() || allowSelfImpostor) && !render_friend_or_exception) { @@ -8632,7 +8625,8 @@ LLMotion* LLVOAvatar::findMotion(const LLUUID& id) const // colorized if using deferred rendering. void LLVOAvatar::debugColorizeSubMeshes(U32 i, const LLColor4& color) { - if (gSavedSettings.getBOOL("DebugAvatarCompositeBaked")) + static LLCachedControl<bool> debug_av_composite_baked(gSavedSettings, "DebugAvatarCompositeBaked"); + if (debug_av_composite_baked) { avatar_joint_mesh_list_t::iterator iter = mBakedTextureDatas[i].mJointMeshes.begin(); avatar_joint_mesh_list_t::iterator end = mBakedTextureDatas[i].mJointMeshes.end(); @@ -8766,7 +8760,7 @@ void LLVOAvatar::updateMeshVisibility() // virtual void LLVOAvatar::updateMeshTextures() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; static S32 update_counter = 0; mBakedTextureDebugText.clear(); @@ -9548,7 +9542,7 @@ void LLVOAvatar::parseAppearanceMessage(LLMessageSystem* mesgsys, LLAppearanceMe std::vector<LLVisualParam*>::iterator it = std::find(contents.mParams.begin(), contents.mParams.end(),appearance_version_param); if (it != contents.mParams.end()) { - S32 index = it - contents.mParams.begin(); + S32 index = (S32)(it - contents.mParams.begin()); contents.mParamAppearanceVersion = ll_round(contents.mParamWeights[index]); //LL_DEBUGS("Avatar") << "appversion req by appearance_version param: " << contents.mParamAppearanceVersion << LL_ENDL; } @@ -10480,15 +10474,16 @@ void LLVOAvatar::setVisibilityRank(U32 rank) S32 LLVOAvatar::getUnbakedPixelAreaRank() { S32 rank = 1; - for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*) *iter; - if (inst == this) + if (character == this) { return rank; } - else if (!inst->isDead() && !inst->isFullyBaked()) + + LLVOAvatar* avatar = (LLVOAvatar*)character; + if (!avatar->isDead() && !avatar->isFullyBaked()) { rank++; } @@ -10498,49 +10493,37 @@ S32 LLVOAvatar::getUnbakedPixelAreaRank() return 0; } -struct CompareScreenAreaGreater -{ - bool operator()(const LLCharacter* const& lhs, const LLCharacter* const& rhs) - { - return lhs->getPixelArea() > rhs->getPixelArea(); - } -}; - // static void LLVOAvatar::cullAvatarsByPixelArea() { - std::sort(LLCharacter::sInstances.begin(), LLCharacter::sInstances.end(), CompareScreenAreaGreater()); + LLCharacter::sInstances.sort([](LLCharacter* lhs, LLCharacter* rhs) + { + return lhs->getPixelArea() > rhs->getPixelArea(); + }); // Update the avatars that have changed status - U32 rank = 2; //1 is reserved for self. - for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) { - LLVOAvatar* inst = (LLVOAvatar*) *iter; - bool culled; - if (inst->isSelf() || inst->isFullyBaked()) - { - culled = false; - } - else + U32 rank = 2; //1 is reserved for self. + for (LLCharacter* character : LLCharacter::sInstances) { - culled = true; - } + LLVOAvatar* inst = (LLVOAvatar*)character; + bool culled = !inst->isSelf() && !inst->isFullyBaked(); - if (inst->mCulled != culled) - { - inst->mCulled = culled; - LL_DEBUGS() << "avatar " << inst->getID() << (culled ? " start culled" : " start not culled" ) << LL_ENDL; - inst->updateMeshTextures(); - } + if (inst->mCulled != culled) + { + inst->mCulled = culled; + LL_DEBUGS() << "avatar " << inst->getID() << (culled ? " start culled" : " start not culled" ) << LL_ENDL; + inst->updateMeshTextures(); + } - if (inst->isSelf()) - { - inst->setVisibilityRank(1); - } - else if (inst->mDrawable.notNull() && inst->mDrawable->isVisible()) - { - inst->setVisibilityRank(rank++); + if (inst->isSelf()) + { + inst->setVisibilityRank(1); + } + else if (inst->mDrawable.notNull() && inst->mDrawable->isVisible()) + { + inst->setVisibilityRank(rank++); + } } } @@ -10676,18 +10659,19 @@ void showRigInfoTabExtents(LLVOAvatar *avatar, LLJointRiggingInfoTab& tab, S32& void LLVOAvatar::getAssociatedVolumes(std::vector<LLVOVolume*>& volumes) { LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; - for ( LLVOAvatar::attachment_map_t::iterator iter = mAttachmentPoints.begin(); iter != mAttachmentPoints.end(); ++iter ) + for (const auto& iter : mAttachmentPoints) { - LLViewerJointAttachment* attachment = iter->second; + LLViewerJointAttachment* attachment = iter.second; LLViewerJointAttachment::attachedobjs_vec_t::iterator attach_end = attachment->mAttachedObjects.end(); - for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attach_iter = attachment->mAttachedObjects.begin(); - attach_iter != attach_end; ++attach_iter) + for (LLViewerObject* attached_object : attachment->mAttachedObjects) { - LLViewerObject* attached_object = attach_iter->get(); - LLVOVolume *volume = dynamic_cast<LLVOVolume*>(attached_object); - if (volume) + if (attached_object->isDead()) + continue; + + if (attached_object->getPCode() == LL_PCODE_VOLUME) { + LLVOVolume* volume = (LLVOVolume*)attached_object; volumes.push_back(volume); if (volume->isAnimatedObject()) { @@ -10697,15 +10681,12 @@ void LLVOAvatar::getAssociatedVolumes(std::vector<LLVOVolume*>& volumes) continue; } } - LLViewerObject::const_child_list_t& children = attached_object->getChildren(); - for (LLViewerObject::const_child_list_t::const_iterator it = children.begin(); - it != children.end(); ++it) + + for (LLViewerObject* childp : attached_object->getChildren()) { - LLViewerObject *childp = *it; - LLVOVolume *volume = dynamic_cast<LLVOVolume*>(childp); - if (volume) + if (!childp->isDead() && childp->getPCode() == LL_PCODE_VOLUME) { - volumes.push_back(volume); + volumes.push_back((LLVOVolume*)childp); } } } @@ -10744,42 +10725,40 @@ void LLVOAvatar::updateRiggingInfo() getAssociatedVolumes(volumes); - std::map<LLUUID,S32> curr_rigging_info_key; + std::map<LLUUID, S32> curr_rigging_info_key; + + // Get current rigging info key + for (LLVOVolume* vol : volumes) { - // Get current rigging info key - for (std::vector<LLVOVolume*>::iterator it = volumes.begin(); it != volumes.end(); ++it) + if (vol->isMesh() && vol->getVolume()) { - LLVOVolume *vol = *it; - if (vol->isMesh() && vol->getVolume()) - { - const LLUUID& mesh_id = vol->getVolume()->getParams().getSculptID(); - S32 max_lod = llmax(vol->getLOD(), vol->mLastRiggingInfoLOD); - curr_rigging_info_key[mesh_id] = max_lod; - } + const LLUUID& mesh_id = vol->getVolume()->getParams().getSculptID(); + S32 max_lod = llmax(vol->getLOD(), vol->mLastRiggingInfoLOD); + curr_rigging_info_key[mesh_id] = max_lod; } + } - // Check for key change, which indicates some change in volume composition or LOD. - if (curr_rigging_info_key == mLastRiggingInfoKey) - { - return; - } + // Check for key change, which indicates some change in volume composition or LOD. + if (curr_rigging_info_key == mLastRiggingInfoKey) + { + return; } // Something changed. Update. mLastRiggingInfoKey = curr_rigging_info_key; mJointRiggingInfoTab.clear(); - for (std::vector<LLVOVolume*>::iterator it = volumes.begin(); it != volumes.end(); ++it) + for (LLVOVolume* vol : volumes) { - LLVOVolume *vol = *it; vol->updateRiggingInfo(); mJointRiggingInfoTab.merge(vol->mJointRiggingInfoTab); } //LL_INFOS() << "done update rig count is " << countRigInfoTab(mJointRiggingInfoTab) << LL_ENDL; - LL_DEBUGS("RigSpammish") << getFullname() << " after update rig tab:" << LL_ENDL; - S32 joint_count, box_count; - showRigInfoTabExtents(this, mJointRiggingInfoTab, joint_count, box_count); - LL_DEBUGS("RigSpammish") << "uses " << joint_count << " joints " << " nonzero boxes: " << box_count << LL_ENDL; + // Remove debug only stuff on hot path + // LL_DEBUGS("RigSpammish") << getFullname() << " after update rig tab:" << LL_ENDL; + // S32 joint_count, box_count; + // showRigInfoTabExtents(this, mJointRiggingInfoTab, joint_count, box_count); + // LL_DEBUGS("RigSpammish") << "uses " << joint_count << " joints " << " nonzero boxes: " << box_count << LL_ENDL; } // virtual @@ -10799,11 +10778,9 @@ void LLVOAvatar::updateImpostors() { LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; - std::vector<LLCharacter*> instances_copy = LLCharacter::sInstances; - for (std::vector<LLCharacter*>::iterator iter = instances_copy.begin(); - iter != instances_copy.end(); ++iter) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* avatar = (LLVOAvatar*) *iter; + LLVOAvatar* avatar = (LLVOAvatar*)character; if (!avatar->isDead() && avatar->isVisible() && avatar->isImpostor() @@ -10960,21 +10937,17 @@ void LLVOAvatar::updateNearbyAvatarCount() S32 avs_nearby = 0; static LLCachedControl<F32> render_far_clip(gSavedSettings, "RenderFarClip", 64); F32 radius = render_far_clip * render_far_clip; - std::vector<LLCharacter *>::iterator char_iter = LLCharacter::sInstances.begin(); - while (char_iter != LLCharacter::sInstances.end()) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar *avatar = dynamic_cast<LLVOAvatar *>(*char_iter); - if (avatar && !avatar->isDead() && !avatar->isControlAvatar()) + LLVOAvatar* avatar = (LLVOAvatar*)character; + if (!avatar->isDead() && !avatar->isControlAvatar()) { - if ((dist_vec_squared(avatar->getPositionGlobal(), gAgent.getPositionGlobal()) > radius) && - (dist_vec_squared(avatar->getPositionGlobal(), gAgentCamera.getCameraPositionGlobal()) > radius)) + if ((dist_vec_squared(avatar->getPositionGlobal(), gAgent.getPositionGlobal()) <= radius) || + (dist_vec_squared(avatar->getPositionGlobal(), gAgentCamera.getCameraPositionGlobal()) <= radius)) { - char_iter++; - continue; + avs_nearby++; } - avs_nearby++; } - char_iter++; } sAvatarsNearby = avs_nearby; agent_update_timer.reset(); @@ -11144,7 +11117,7 @@ void LLVOAvatar::accountRenderComplexityForObject( LLObjectComplexity object_complexity; object_complexity.objectName = attached_object->getAttachmentItemName(); object_complexity.objectId = attached_object->getAttachmentItemID(); - object_complexity.objectCost = attachment_total_cost; + object_complexity.objectCost = (U32)attachment_total_cost; object_complexity_list.push_back(object_complexity); } } @@ -11548,7 +11521,7 @@ void LLVOAvatar::calcMutedAVColor() new_color = LLColor4::grey4; change_msg = " not rendered: color is grey4"; } - else if (LLMuteList::getInstance()->isMuted(av_id)) // the user blocked them + else if (isInMuteList()) // the user blocked them { // blocked avatars are dark grey new_color = LLColor4::grey4; @@ -11761,10 +11734,9 @@ F32 LLVOAvatar::getTotalGPURenderTime() F32 ret = 0.f; - for (LLCharacter* iter : LLCharacter::sInstances) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*) iter; - ret += inst->getGPURenderTime(); + ret += ((LLVOAvatar*)character)->getGPURenderTime(); } return ret; @@ -11776,10 +11748,9 @@ F32 LLVOAvatar::getMaxGPURenderTime() F32 ret = 0.f; - for (LLCharacter* iter : LLCharacter::sInstances) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*)iter; - ret = llmax(inst->getGPURenderTime(), ret); + ret = llmax(((LLVOAvatar*)character)->getGPURenderTime(), ret); } return ret; @@ -11793,12 +11764,12 @@ F32 LLVOAvatar::getAverageGPURenderTime() S32 count = 0; - for (LLCharacter* iter : LLCharacter::sInstances) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*)iter; - if (!inst->isTooSlow()) + LLVOAvatar* avatar = (LLVOAvatar*)character; + if (!avatar->isTooSlow()) { - ret += inst->getGPURenderTime(); + ret += avatar->getGPURenderTime(); ++count; } } @@ -11810,8 +11781,23 @@ F32 LLVOAvatar::getAverageGPURenderTime() return ret; } + bool LLVOAvatar::isBuddy() const { - return LLAvatarTracker::instance().isBuddy(getID()); + bool is_friend = false; + F64 now = LLFrameTimer::getTotalSeconds(); + if (now < mCachedBuddyListUpdateTime) + { + is_friend = mCachedInBuddyList; + } + else + { + is_friend = LLAvatarTracker::instance().isBuddy(getID()); + + const F64 SECONDS_BETWEEN_BUDDY_UPDATES = 1; + mCachedBuddyListUpdateTime = now + SECONDS_BETWEEN_BUDDY_UPDATES; + mCachedInBuddyList = is_friend; + } + return is_friend; } |