diff options
Diffstat (limited to 'indra/newview/llvoavatarself.cpp')
-rw-r--r-- | indra/newview/llvoavatarself.cpp | 105 |
1 files changed, 65 insertions, 40 deletions
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 98ca76ed01..c15dbeb8c6 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -44,9 +44,11 @@ #include "pipeline.h" #include "llagent.h" // Get state values from here +#include "llagentcamera.h" #include "llagentwearables.h" #include "llhudeffecttrail.h" #include "llhudmanager.h" +#include "llinventoryfunctions.h" #include "llselectmgr.h" #include "lltoolgrab.h" // for needsRenderBeam #include "lltoolmgr.h" // for needsRenderBeam @@ -66,6 +68,14 @@ #include <boost/lexical_cast.hpp> +LLVOAvatarSelf *gAgentAvatarp = NULL; +BOOL isAgentAvatarValid() +{ + return (gAgentAvatarp && + (gAgentAvatarp->getRegion() != NULL) && + (!gAgentAvatarp->isDead())); +} + using namespace LLVOAvatarDefines; /********************************************************************************* @@ -77,14 +87,14 @@ using namespace LLVOAvatarDefines; struct LocalTextureData { LocalTextureData() : - mIsBakedReady(FALSE), + mIsBakedReady(false), mDiscard(MAX_DISCARD_LEVEL+1), mImage(NULL), mWearableID(IMG_DEFAULT_AVATAR), mTexEntry(NULL) {} LLPointer<LLViewerFetchedTexture> mImage; - BOOL mIsBakedReady; + bool mIsBakedReady; S32 mDiscard; LLUUID mWearableID; // UUID of the wearable that this texture belongs to, not of the image itself LLTextureEntry *mTexEntry; @@ -132,7 +142,6 @@ LLVOAvatarSelf::LLVOAvatarSelf(const LLUUID& id, mLastRegionHandle(0), mRegionCrossingCount(0) { - gAgent.setAvatarObject(this); gAgentWearables.setAvatarObject(this); lldebugs << "Marking avatar as self " << id << llendl; @@ -510,16 +519,17 @@ BOOL LLVOAvatarSelf::buildMenus() return TRUE; } +void LLVOAvatarSelf::cleanup() +{ + markDead(); + delete mScreenp; + mScreenp = NULL; + mRegionp = NULL; +} + LLVOAvatarSelf::~LLVOAvatarSelf() { - // gAgents pointer might have been set to a different Avatar Self, don't get rid of it if so. - if (gAgent.getAvatarObject() == this) - { - gAgent.setAvatarObject(NULL); - gAgentWearables.setAvatarObject(NULL); - } - delete mScreenp; - mScreenp = NULL; + cleanup(); } /** @@ -610,6 +620,17 @@ BOOL LLVOAvatarSelf::updateCharacter(LLAgent &agent) } // virtual +BOOL LLVOAvatarSelf::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) +{ + if (!isAgentAvatarValid()) + { + return TRUE; + } + LLVOAvatar::idleUpdate(agent, world, time); + return TRUE; +} + +// virtual LLJoint *LLVOAvatarSelf::getJoint(const std::string &name) { if (mScreenp) @@ -620,7 +641,8 @@ LLJoint *LLVOAvatarSelf::getJoint(const std::string &name) return LLVOAvatar::getJoint(name); } -/*virtual*/ BOOL LLVOAvatarSelf::setVisualParamWeight(LLVisualParam *which_param, F32 weight, BOOL upload_bake ) +// virtual +BOOL LLVOAvatarSelf::setVisualParamWeight(LLVisualParam *which_param, F32 weight, BOOL upload_bake ) { if (!which_param) { @@ -630,7 +652,8 @@ LLJoint *LLVOAvatarSelf::getJoint(const std::string &name) return setParamWeight(param,weight,upload_bake); } -/*virtual*/ BOOL LLVOAvatarSelf::setVisualParamWeight(const char* param_name, F32 weight, BOOL upload_bake ) +// virtual +BOOL LLVOAvatarSelf::setVisualParamWeight(const char* param_name, F32 weight, BOOL upload_bake ) { if (!param_name) { @@ -640,7 +663,8 @@ LLJoint *LLVOAvatarSelf::getJoint(const std::string &name) return setParamWeight(param,weight,upload_bake); } -/*virtual*/ BOOL LLVOAvatarSelf::setVisualParamWeight(S32 index, F32 weight, BOOL upload_bake ) +// virtual +BOOL LLVOAvatarSelf::setVisualParamWeight(S32 index, F32 weight, BOOL upload_bake ) { LLViewerVisualParam *param = (LLViewerVisualParam*) LLCharacter::getVisualParam(index); return setParamWeight(param,weight,upload_bake); @@ -776,7 +800,8 @@ void LLVOAvatarSelf::removeMissingBakedTextures() //virtual void LLVOAvatarSelf::updateRegion(LLViewerRegion *regionp) { - if (regionp->getHandle() != mLastRegionHandle) + setRegion(regionp); + if (!regionp || (regionp->getHandle() != mLastRegionHandle)) { if (mLastRegionHandle != 0) { @@ -790,7 +815,10 @@ void LLVOAvatarSelf::updateRegion(LLViewerRegion *regionp) max = llmax(delta, max); LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CROSSING_MAX, max); } - mLastRegionHandle = regionp->getHandle(); + if (regionp) + { + mLastRegionHandle = regionp->getHandle(); + } } mRegionCrossingTimer.reset(); } @@ -819,10 +847,10 @@ void LLVOAvatarSelf::idleUpdateTractorBeam() { LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); - if (gAgent.mPointAt.notNull()) + if (gAgentCamera.mPointAt.notNull()) { // get point from pointat effect - mBeam->setPositionGlobal(gAgent.mPointAt->getPointAtPosGlobal()); + mBeam->setPositionGlobal(gAgentCamera.mPointAt->getPointAtPosGlobal()); mBeam->triggerLocal(); } else if (selection->getFirstRootObject() && @@ -873,7 +901,7 @@ void LLVOAvatarSelf::restoreMeshData() //llinfos << "Restoring" << llendl; mMeshValid = TRUE; updateJointLODs(); - updateAttachmentVisibility(gAgent.getCameraMode()); + updateAttachmentVisibility(gAgentCamera.getCameraMode()); // force mesh update as LOD might not have changed to trigger this gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY, TRUE); @@ -938,7 +966,7 @@ void LLVOAvatarSelf::wearableUpdated( EWearableType type, BOOL upload_result ) // if we're editing our appearance, ensure that we're not using baked textures // The baked texture for alpha masks is set explicitly when you hit "save" - if (gAgent.cameraCustomizeAvatar()) + if (gAgentCamera.cameraCustomizeAvatar()) { setNewBakedTexture(index,IMG_DEFAULT_AVATAR); } @@ -1027,7 +1055,7 @@ const LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *view return 0; } - updateAttachmentVisibility(gAgent.getCameraMode()); + updateAttachmentVisibility(gAgentCamera.getCameraMode()); // Then make sure the inventory is in sync with the avatar. @@ -1035,7 +1063,7 @@ const LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *view if (attachment->isObjectAttached(viewer_object)) { const LLUUID& attachment_id = viewer_object->getItemID(); - LLAppearanceManager::instance().registerAttachment(attachment_id); + LLAppearanceMgr::instance().registerAttachment(attachment_id); } return attachment; @@ -1068,13 +1096,13 @@ BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object) // Make sure the inventory is in sync with the avatar. // Update COF contents, don't trigger appearance update. - if (gAgent.getAvatarObject() == NULL) + if (!isAgentAvatarValid()) { llinfos << "removeItemLinks skipped, avatar is under destruction" << llendl; } else { - LLAppearanceManager::instance().unregisterAttachment(attachment_id); + LLAppearanceMgr::instance().unregisterAttachment(attachment_id); } return TRUE; @@ -1115,11 +1143,11 @@ void LLVOAvatarSelf::localTextureLoaded(BOOL success, LLViewerFetchedTexture *sr discard_level < local_tex_obj->getDiscard()) { local_tex_obj->setDiscard(discard_level); - if (!gAgent.cameraCustomizeAvatar()) + if (!gAgentCamera.cameraCustomizeAvatar()) { requestLayerSetUpdate(index); } - else if (gAgent.cameraCustomizeAvatar()) + else if (gAgentCamera.cameraCustomizeAvatar()) { LLVisualParamHint::requestHintUpdates(); } @@ -1523,11 +1551,11 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te if (tex_discard >= 0 && tex_discard <= desired_discard) { local_tex_obj->setDiscard(tex_discard); - if (isSelf() && !gAgent.cameraCustomizeAvatar()) + if (isSelf() && !gAgentCamera.cameraCustomizeAvatar()) { requestLayerSetUpdate(type); } - else if (isSelf() && gAgent.cameraCustomizeAvatar()) + else if (isSelf() && gAgentCamera.cameraCustomizeAvatar()) { LLVisualParamHint::requestHintUpdates(); } @@ -1667,7 +1695,7 @@ void LLVOAvatarSelf::onLocalTextureLoaded(BOOL success, LLViewerFetchedTexture * void LLVOAvatarSelf::dumpTotalLocalTextureByteCount() { S32 gl_bytes = 0; - gAgent.getAvatarObject()->getLocalTextureByteCount(&gl_bytes); + gAgentAvatarp->getLocalTextureByteCount(&gl_bytes); llinfos << "Total Avatar LocTex GL:" << (gl_bytes/1024) << "KB" << llendl; } @@ -1924,9 +1952,7 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**) { LLUUID texture_id; msg->getUUID("TextureData", "TextureID", texture_id); - - LLVOAvatarSelf* self = gAgent.getAvatarObject(); - if (!self) return; + if (!isAgentAvatarValid()) return; // If this is a texture corresponding to one of our baked entries, // just rebake that layer set. @@ -1943,13 +1969,13 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**) const LLVOAvatarDictionary::TextureEntry *texture_dict = iter->second; if (texture_dict->mIsBakedTexture) { - if (texture_id == self->getTEImage(index)->getID()) + if (texture_id == gAgentAvatarp->getTEImage(index)->getID()) { - LLTexLayerSet* layer_set = self->getLayerSet(index); + LLTexLayerSet* layer_set = gAgentAvatarp->getLayerSet(index); if (layer_set) { llinfos << "TAT: rebake - matched entry " << (S32)index << llendl; - self->invalidateComposite(layer_set, TRUE); + gAgentAvatarp->invalidateComposite(layer_set, TRUE); found = TRUE; LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES); } @@ -1960,12 +1986,12 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**) // If texture not found, rebake all entries. if (!found) { - self->forceBakeAllTextures(); + gAgentAvatarp->forceBakeAllTextures(); } else { // Not sure if this is necessary, but forceBakeAllTextures() does it. - self->updateMeshTextures(); + gAgentAvatarp->updateMeshTextures(); } } @@ -2045,10 +2071,9 @@ void LLVOAvatarSelf::onCustomizeStart() // static void LLVOAvatarSelf::onCustomizeEnd() { - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { - avatarp->invalidateAll(); + gAgentAvatarp->invalidateAll(); } } |