summaryrefslogtreecommitdiff
path: root/indra/newview/llvoavatarself.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llvoavatarself.cpp')
-rw-r--r--indra/newview/llvoavatarself.cpp86
1 files changed, 55 insertions, 31 deletions
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 15be6b23b3..c15dbeb8c6 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -48,6 +48,7 @@
#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
@@ -67,6 +68,14 @@
#include <boost/lexical_cast.hpp>
+LLVOAvatarSelf *gAgentAvatarp = NULL;
+BOOL isAgentAvatarValid()
+{
+ return (gAgentAvatarp &&
+ (gAgentAvatarp->getRegion() != NULL) &&
+ (!gAgentAvatarp->isDead()));
+}
+
using namespace LLVOAvatarDefines;
/*********************************************************************************
@@ -78,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;
@@ -133,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;
@@ -511,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();
}
/**
@@ -611,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)
@@ -621,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)
{
@@ -631,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)
{
@@ -641,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);
@@ -777,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)
{
@@ -791,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();
}
@@ -1036,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;
@@ -1069,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;
@@ -1668,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;
}
@@ -1925,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.
@@ -1944,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);
}
@@ -1961,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();
}
}
@@ -2046,10 +2071,9 @@ void LLVOAvatarSelf::onCustomizeStart()
// static
void LLVOAvatarSelf::onCustomizeEnd()
{
- LLVOAvatarSelf *avatarp = gAgent.getAvatarObject();
- if (avatarp)
+ if (isAgentAvatarValid())
{
- avatarp->invalidateAll();
+ gAgentAvatarp->invalidateAll();
}
}