From 58d76a9ecf83b49e42fabfada27ca20814f93cf3 Mon Sep 17 00:00:00 2001
From: Loren Shih <seraph@lindenlab.com>
Date: Mon, 29 Mar 2010 12:11:51 -0400
Subject: [PATCH] EXT-6536 : Make LLVOAvatarSelf a singleton

Superficial cleanup to replace all instances of "gAgentAvatar" with "gAgentAvatarp".
---
 indra/newview/llagent.cpp               | 140 ++++++++++----------
 indra/newview/llagentcamera.cpp         | 162 ++++++++++++------------
 indra/newview/llagentui.cpp             |   6 +-
 indra/newview/llagentwearables.cpp      |  40 +++---
 indra/newview/lldriverparam.cpp         |   6 +-
 indra/newview/llgesturemgr.cpp          |   8 +-
 indra/newview/llinventorybridge.cpp     |  16 +--
 indra/newview/llinventoryfunctions.cpp  |   2 +-
 indra/newview/llinventorymodel.cpp      |   2 +-
 indra/newview/llinventorypanel.cpp      |   4 +-
 indra/newview/llmaniptranslate.cpp      |   2 +-
 indra/newview/llmorphview.cpp           |  14 +-
 indra/newview/llmoveview.cpp            |   8 +-
 indra/newview/llpaneleditwearable.cpp   |   2 +-
 indra/newview/llpreview.cpp             |   2 +-
 indra/newview/llpreviewanim.cpp         |  16 +--
 indra/newview/llscrollingpanelparam.cpp |   4 +-
 indra/newview/llselectmgr.cpp           |  10 +-
 indra/newview/llsidepanelappearance.cpp |   4 +-
 indra/newview/llstartup.cpp             |   2 +-
 indra/newview/llstatusbar.cpp           |   2 +-
 indra/newview/lltexlayer.cpp            |  12 +-
 indra/newview/lltooldraganddrop.cpp     |  26 ++--
 indra/newview/lltoolfocus.cpp           |   4 +-
 indra/newview/lltoolgrab.cpp            |   2 +-
 indra/newview/lltoolmorph.cpp           |  36 +++---
 indra/newview/lltoolpie.cpp             |   6 +-
 indra/newview/lltoolplacer.cpp          |   2 +-
 indra/newview/lltoolselect.cpp          |   4 +-
 indra/newview/llviewerdisplay.cpp       |   6 +-
 indra/newview/llviewerkeyboard.cpp      |   2 +-
 indra/newview/llviewermedia.cpp         |   2 +-
 indra/newview/llviewermenu.cpp          |  40 +++---
 indra/newview/llviewermessage.cpp       |  12 +-
 indra/newview/llviewerobject.cpp        |  10 +-
 indra/newview/llviewerobjectlist.cpp    |   8 +-
 indra/newview/llviewerwindow.cpp        |   4 +-
 indra/newview/llvoavatar.cpp            |  12 +-
 indra/newview/llvoavatarself.cpp        |  22 ++--
 indra/newview/llvoavatarself.h          |   2 +-
 indra/newview/llvoiceclient.cpp         |   4 +-
 indra/newview/llwearable.cpp            |  54 ++++----
 indra/newview/pipeline.cpp              |  16 +--
 43 files changed, 369 insertions(+), 369 deletions(-)

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 645acca4aea..3eeaacf93b2 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -159,11 +159,11 @@ bool handleSlowMotionAnimation(const LLSD& newvalue)
 {
 	if (newvalue.asBoolean())
 	{
-		gAgentAvatar->setAnimTimeFactor(0.2f);
+		gAgentAvatarp->setAnimTimeFactor(0.2f);
 	}
 	else
 	{
-		gAgentAvatar->setAnimTimeFactor(1.0f);
+		gAgentAvatarp->setAnimTimeFactor(1.0f);
 	}
 	return true;
 }
@@ -325,9 +325,9 @@ void LLAgent::ageChat()
 	if (isAgentAvatarValid())
 	{
 		// get amount of time since I last chatted
-		F64 elapsed_time = (F64)gAgentAvatar->mChatTimer.getElapsedTimeF32();
+		F64 elapsed_time = (F64)gAgentAvatarp->mChatTimer.getElapsedTimeF32();
 		// add in frame time * 3 (so it ages 4x)
-		gAgentAvatar->mChatTimer.setAge(elapsed_time + (F64)gFrameDTClamped * (CHAT_AGE_FAST_RATE - 1.0));
+		gAgentAvatarp->mChatTimer.setAge(elapsed_time + (F64)gFrameDTClamped * (CHAT_AGE_FAST_RATE - 1.0));
 	}
 }
 
@@ -521,13 +521,13 @@ void LLAgent::setFlying(BOOL fly)
 		// it will be walking with flying mode "ON" indication. However we allow to switch
 		// the flying mode off if we get ANIM_AGENT_STANDUP signal. See process_avatar_animation().
 		// See EXT-2781.
-		if(fly && gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_STANDUP) != gAgentAvatar->mSignaledAnimations.end())
+		if(fly && gAgentAvatarp->mSignaledAnimations.find(ANIM_AGENT_STANDUP) != gAgentAvatarp->mSignaledAnimations.end())
 		{
 			return;
 		}
 
 		// don't allow taking off while sitting
-		if (fly && gAgentAvatar->isSitting())
+		if (fly && gAgentAvatarp->isSitting())
 		{
 			return;
 		}
@@ -582,7 +582,7 @@ bool LLAgent::enableFlying()
 	BOOL sitting = FALSE;
 	if (isAgentAvatarValid())
 	{
-		sitting = gAgentAvatar->isSitting();
+		sitting = gAgentAvatarp->isSitting();
 	}
 	return !sitting;
 }
@@ -754,7 +754,7 @@ LLVector3 LLAgent::getVelocity() const
 {
 	if (isAgentAvatarValid())
 	{
-		return gAgentAvatar->getVelocity();
+		return gAgentAvatarp->getVelocity();
 	}
 	else
 	{
@@ -773,13 +773,13 @@ void LLAgent::setPositionAgent(const LLVector3 &pos_agent)
 		llerrs << "setPositionAgent is not a number" << llendl;
 	}
 
-	if (isAgentAvatarValid() && gAgentAvatar->getParent())
+	if (isAgentAvatarValid() && gAgentAvatarp->getParent())
 	{
 		LLVector3 pos_agent_sitting;
 		LLVector3d pos_agent_d;
-		LLViewerObject *parent = (LLViewerObject*)gAgentAvatar->getParent();
+		LLViewerObject *parent = (LLViewerObject*)gAgentAvatarp->getParent();
 
-		pos_agent_sitting = gAgentAvatar->getPosition() * parent->getRotation() + parent->getPositionAgent();
+		pos_agent_sitting = gAgentAvatarp->getPosition() * parent->getRotation() + parent->getPositionAgent();
 		pos_agent_d.setVec(pos_agent_sitting);
 
 		mFrameAgent.setOrigin(pos_agent_sitting);
@@ -800,9 +800,9 @@ void LLAgent::setPositionAgent(const LLVector3 &pos_agent)
 //-----------------------------------------------------------------------------
 const LLVector3d &LLAgent::getPositionGlobal() const
 {
-	if (isAgentAvatarValid() && !gAgentAvatar->mDrawable.isNull())
+	if (isAgentAvatarValid() && !gAgentAvatarp->mDrawable.isNull())
 	{
-		mPositionGlobal = getPosGlobalFromAgent(gAgentAvatar->getRenderPosition());
+		mPositionGlobal = getPosGlobalFromAgent(gAgentAvatarp->getRenderPosition());
 	}
 	else
 	{
@@ -817,9 +817,9 @@ const LLVector3d &LLAgent::getPositionGlobal() const
 //-----------------------------------------------------------------------------
 const LLVector3 &LLAgent::getPositionAgent()
 {
-	if (isAgentAvatarValid() && !gAgentAvatar->mDrawable.isNull())
+	if (isAgentAvatarValid() && !gAgentAvatarp->mDrawable.isNull())
 	{
-		mFrameAgent.setOrigin(gAgentAvatar->getRenderPosition());	
+		mFrameAgent.setOrigin(gAgentAvatarp->getRenderPosition());	
 	}
 
 	return mFrameAgent.getOrigin();
@@ -946,20 +946,20 @@ LLVector3 LLAgent::getReferenceUpVector()
 	// this vector is in the coordinate frame of the avatar's parent object, or the world if none
 	LLVector3 up_vector = LLVector3::z_axis;
 	if (isAgentAvatarValid() && 
-		gAgentAvatar->getParent() &&
-		gAgentAvatar->mDrawable.notNull())
+		gAgentAvatarp->getParent() &&
+		gAgentAvatarp->mDrawable.notNull())
 	{
 		U32 camera_mode = gAgentCamera.getCameraAnimating() ? gAgentCamera.getLastCameraMode() : gAgentCamera.getCameraMode();
 		// and in third person...
 		if (camera_mode == CAMERA_MODE_THIRD_PERSON)
 		{
 			// make the up vector point to the absolute +z axis
-			up_vector = up_vector * ~((LLViewerObject*)gAgentAvatar->getParent())->getRenderRotation();
+			up_vector = up_vector * ~((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
 		}
 		else if (camera_mode == CAMERA_MODE_MOUSELOOK)
 		{
 			// make the up vector point to the avatar's +z axis
-			up_vector = up_vector * gAgentAvatar->mDrawable->getRotation();
+			up_vector = up_vector * gAgentAvatarp->mDrawable->getRotation();
 		}
 	}
 
@@ -995,7 +995,7 @@ F32 LLAgent::clampPitchToLimits(F32 angle)
 
 	F32 angle_from_skyward = acos( mFrameAgent.getAtAxis() * skyward );
 
-	if (isAgentAvatarValid() && gAgentAvatar->isSitting())
+	if (isAgentAvatarValid() && gAgentAvatarp->isSitting())
 	{
 		look_down_limit = 130.f * DEG_TO_RAD;
 	}
@@ -1170,7 +1170,7 @@ void LLAgent::clearAFK()
 	// without setting the appropriate control flag. JC
 	if (mControlFlags & AGENT_CONTROL_AWAY
 		|| (isAgentAvatarValid()
-			&& (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_AWAY) != gAgentAvatar->mSignaledAnimations.end())))
+			&& (gAgentAvatarp->mSignaledAnimations.find(ANIM_AGENT_AWAY) != gAgentAvatarp->mSignaledAnimations.end())))
 	{
 		sendAnimationRequest(ANIM_AGENT_AWAY, ANIM_REQUEST_STOP);
 		clearControlFlags(AGENT_CONTROL_AWAY);
@@ -1292,7 +1292,7 @@ void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::s
 	LLViewerObject *obj;
 
 	LLWorld::getInstance()->resolveStepHeightGlobal(NULL, target_global, traceEndPt, targetOnGround, groundNorm, &obj);
-	F64 target_height = llmax((F64)gAgentAvatar->getPelvisToFoot(), target_global.mdV[VZ] - targetOnGround.mdV[VZ]);
+	F64 target_height = llmax((F64)gAgentAvatarp->getPelvisToFoot(), target_global.mdV[VZ] - targetOnGround.mdV[VZ]);
 
 	// clamp z value of target to minimum height above ground
 	mAutoPilotTargetGlobal.mdV[VZ] = targetOnGround.mdV[VZ] + target_height;
@@ -1394,7 +1394,7 @@ void LLAgent::autoPilot(F32 *delta_yaw)
 		
 		if (!isAgentAvatarValid()) return;
 
-		if (gAgentAvatar->mInAir)
+		if (gAgentAvatarp->mInAir)
 		{
 			setFlying(TRUE);
 		}
@@ -1472,7 +1472,7 @@ void LLAgent::autoPilot(F32 *delta_yaw)
 		{
 			if (isAgentAvatarValid())
 			{
-				F64 current_height = gAgentAvatar->getPositionGlobal().mdV[VZ];
+				F64 current_height = gAgentAvatarp->getPositionGlobal().mdV[VZ];
 				F32 delta_z = (F32)(mAutoPilotTargetGlobal.mdV[VZ] - current_height);
 				F32 slope = delta_z / xy_distance;
 				if (slope > 0.45f && delta_z > 6.f)
@@ -1555,7 +1555,7 @@ void LLAgent::propagate(const F32 dt)
 	// handle auto-land behavior
 	if (isAgentAvatarValid())
 	{
-		BOOL in_air = gAgentAvatar->mInAir;
+		BOOL in_air = gAgentAvatarp->mInAir;
 		LLVector3 land_vel = getVelocity();
 		land_vel.mV[VZ] = 0.f;
 
@@ -1781,24 +1781,24 @@ void LLAgent::endAnimationUpdateUI()
 		// Disable mouselook-specific animations
 		if (isAgentAvatarValid())
 		{
-			if( gAgentAvatar->isAnyAnimationSignaled(AGENT_GUN_AIM_ANIMS, NUM_AGENT_GUN_AIM_ANIMS) )
+			if( gAgentAvatarp->isAnyAnimationSignaled(AGENT_GUN_AIM_ANIMS, NUM_AGENT_GUN_AIM_ANIMS) )
 			{
-				if (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_AIM_RIFLE_R) != gAgentAvatar->mSignaledAnimations.end())
+				if (gAgentAvatarp->mSignaledAnimations.find(ANIM_AGENT_AIM_RIFLE_R) != gAgentAvatarp->mSignaledAnimations.end())
 				{
 					sendAnimationRequest(ANIM_AGENT_AIM_RIFLE_R, ANIM_REQUEST_STOP);
 					sendAnimationRequest(ANIM_AGENT_HOLD_RIFLE_R, ANIM_REQUEST_START);
 				}
-				if (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_AIM_HANDGUN_R) != gAgentAvatar->mSignaledAnimations.end())
+				if (gAgentAvatarp->mSignaledAnimations.find(ANIM_AGENT_AIM_HANDGUN_R) != gAgentAvatarp->mSignaledAnimations.end())
 				{
 					sendAnimationRequest(ANIM_AGENT_AIM_HANDGUN_R, ANIM_REQUEST_STOP);
 					sendAnimationRequest(ANIM_AGENT_HOLD_HANDGUN_R, ANIM_REQUEST_START);
 				}
-				if (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_AIM_BAZOOKA_R) != gAgentAvatar->mSignaledAnimations.end())
+				if (gAgentAvatarp->mSignaledAnimations.find(ANIM_AGENT_AIM_BAZOOKA_R) != gAgentAvatarp->mSignaledAnimations.end())
 				{
 					sendAnimationRequest(ANIM_AGENT_AIM_BAZOOKA_R, ANIM_REQUEST_STOP);
 					sendAnimationRequest(ANIM_AGENT_HOLD_BAZOOKA_R, ANIM_REQUEST_START);
 				}
-				if (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_AIM_BOW_L) != gAgentAvatar->mSignaledAnimations.end())
+				if (gAgentAvatarp->mSignaledAnimations.find(ANIM_AGENT_AIM_BOW_L) != gAgentAvatarp->mSignaledAnimations.end())
 				{
 					sendAnimationRequest(ANIM_AGENT_AIM_BOW_L, ANIM_REQUEST_STOP);
 					sendAnimationRequest(ANIM_AGENT_HOLD_BOW_L, ANIM_REQUEST_START);
@@ -1880,40 +1880,40 @@ void LLAgent::endAnimationUpdateUI()
 		if (isAgentAvatarValid())
 		{
 			// Trigger mouselook-specific animations
-			if( gAgentAvatar->isAnyAnimationSignaled(AGENT_GUN_HOLD_ANIMS, NUM_AGENT_GUN_HOLD_ANIMS) )
+			if( gAgentAvatarp->isAnyAnimationSignaled(AGENT_GUN_HOLD_ANIMS, NUM_AGENT_GUN_HOLD_ANIMS) )
 			{
-				if (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_HOLD_RIFLE_R) != gAgentAvatar->mSignaledAnimations.end())
+				if (gAgentAvatarp->mSignaledAnimations.find(ANIM_AGENT_HOLD_RIFLE_R) != gAgentAvatarp->mSignaledAnimations.end())
 				{
 					sendAnimationRequest(ANIM_AGENT_HOLD_RIFLE_R, ANIM_REQUEST_STOP);
 					sendAnimationRequest(ANIM_AGENT_AIM_RIFLE_R, ANIM_REQUEST_START);
 				}
-				if (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_HOLD_HANDGUN_R) != gAgentAvatar->mSignaledAnimations.end())
+				if (gAgentAvatarp->mSignaledAnimations.find(ANIM_AGENT_HOLD_HANDGUN_R) != gAgentAvatarp->mSignaledAnimations.end())
 				{
 					sendAnimationRequest(ANIM_AGENT_HOLD_HANDGUN_R, ANIM_REQUEST_STOP);
 					sendAnimationRequest(ANIM_AGENT_AIM_HANDGUN_R, ANIM_REQUEST_START);
 				}
-				if (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_HOLD_BAZOOKA_R) != gAgentAvatar->mSignaledAnimations.end())
+				if (gAgentAvatarp->mSignaledAnimations.find(ANIM_AGENT_HOLD_BAZOOKA_R) != gAgentAvatarp->mSignaledAnimations.end())
 				{
 					sendAnimationRequest(ANIM_AGENT_HOLD_BAZOOKA_R, ANIM_REQUEST_STOP);
 					sendAnimationRequest(ANIM_AGENT_AIM_BAZOOKA_R, ANIM_REQUEST_START);
 				}
-				if (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_HOLD_BOW_L) != gAgentAvatar->mSignaledAnimations.end())
+				if (gAgentAvatarp->mSignaledAnimations.find(ANIM_AGENT_HOLD_BOW_L) != gAgentAvatarp->mSignaledAnimations.end())
 				{
 					sendAnimationRequest(ANIM_AGENT_HOLD_BOW_L, ANIM_REQUEST_STOP);
 					sendAnimationRequest(ANIM_AGENT_AIM_BOW_L, ANIM_REQUEST_START);
 				}
 			}
-			if (gAgentAvatar->getParent())
+			if (gAgentAvatarp->getParent())
 			{
 				LLVector3 at_axis = LLViewerCamera::getInstance()->getAtAxis();
-				LLViewerObject* root_object = (LLViewerObject*)gAgentAvatar->getRoot();
+				LLViewerObject* root_object = (LLViewerObject*)gAgentAvatarp->getRoot();
 				if (root_object->flagCameraDecoupled())
 				{
 					resetAxes(at_axis);
 				}
 				else
 				{
-					resetAxes(at_axis * ~((LLViewerObject*)gAgentAvatar->getParent())->getRenderRotation());
+					resetAxes(at_axis * ~((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation());
 				}
 			}
 		}
@@ -1931,13 +1931,13 @@ void LLAgent::endAnimationUpdateUI()
 		// freeze avatar
 		if (isAgentAvatarValid())
 		{
-			mPauseRequest = gAgentAvatar->requestPause();
+			mPauseRequest = gAgentAvatarp->requestPause();
 		}
 	}
 
 	if (isAgentAvatarValid())
 	{
-		gAgentAvatar->updateAttachmentVisibility(gAgentCamera.getCameraMode());
+		gAgentAvatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode());
 	}
 
 	gFloaterTools->dirty();
@@ -2016,7 +2016,7 @@ void LLAgent::setStartPosition( U32 location_id )
     if (isAgentAvatarValid())
     {
         // the z height is at the agent's feet
-        agent_pos.mV[VZ] -= 0.5f * gAgentAvatar->mBodySize.mV[VZ];
+        agent_pos.mV[VZ] -= 0.5f * gAgentAvatarp->mBodySize.mV[VZ];
     }
 
     agent_pos.mV[VX] = llclamp( agent_pos.mV[VX], INSET, REGION_WIDTH - INSET );
@@ -2123,7 +2123,7 @@ void LLAgent::onAnimStop(const LLUUID& id)
 		setControlFlags(AGENT_CONTROL_FINISH_ANIM);
 
 		// now trigger dusting self off animation
-		if (isAgentAvatarValid() && !gAgentAvatar->mBelowWater && rand() % 3 == 0)
+		if (isAgentAvatarValid() && !gAgentAvatarp->mBelowWater && rand() % 3 == 0)
 			sendAnimationRequest( ANIM_AGENT_BRUSH, ANIM_REQUEST_START );
 	}
 	else if (id == ANIM_AGENT_PRE_JUMP || id == ANIM_AGENT_LAND || id == ANIM_AGENT_MEDIUM_LAND)
@@ -2324,7 +2324,7 @@ void LLAgent::buildFullnameAndTitle(std::string& name) const
 
 	if (isAgentAvatarValid())
 	{
-		name += gAgentAvatar->getFullname();
+		name += gAgentAvatarp->getFullname();
 	}
 }
 
@@ -2470,14 +2470,14 @@ BOOL LLAgent::canJoinGroups() const
 
 LLQuaternion LLAgent::getHeadRotation()
 {
-	if (!isAgentAvatarValid() || !gAgentAvatar->mPelvisp || !gAgentAvatar->mHeadp)
+	if (!isAgentAvatarValid() || !gAgentAvatarp->mPelvisp || !gAgentAvatarp->mHeadp)
 	{
 		return LLQuaternion::DEFAULT;
 	}
 
 	if (!gAgentCamera.cameraMouselook())
 	{
-		return gAgentAvatar->getRotation();
+		return gAgentAvatarp->getRotation();
 	}
 
 	// We must be in mouselook
@@ -2486,9 +2486,9 @@ LLQuaternion LLAgent::getHeadRotation()
 	LLVector3 left = up % look_dir;
 
 	LLQuaternion rot(look_dir, left, up);
-	if (gAgentAvatar->getParent())
+	if (gAgentAvatarp->getParent())
 	{
-		rot = rot * ~gAgentAvatar->getParent()->getRotation();
+		rot = rot * ~gAgentAvatarp->getParent()->getRotation();
 	}
 
 	return rot;
@@ -3111,7 +3111,7 @@ void LLAgent::processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void *
 {
 	gAgentQueryManager.mNumPendingQueries--;
 
-	if (!isAgentAvatarValid() || gAgentAvatar->isDead())
+	if (!isAgentAvatarValid() || gAgentAvatarp->isDead())
 	{
 		llwarns << "No avatar for user in cached texture update!" << llendl;
 		return;
@@ -3144,27 +3144,27 @@ void LLAgent::processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void *
 			if (texture_id.notNull())
 			{
 				//llinfos << "Received cached texture " << (U32)texture_index << ": " << texture_id << llendl;
-				gAgentAvatar->setCachedBakedTexture(LLVOAvatarDictionary::bakedToLocalTextureIndex((EBakedTextureIndex)texture_index), texture_id);
-				//gAgentAvatar->setTETexture( LLVOAvatar::sBakedTextureIndices[texture_index], texture_id );
+				gAgentAvatarp->setCachedBakedTexture(LLVOAvatarDictionary::bakedToLocalTextureIndex((EBakedTextureIndex)texture_index), texture_id);
+				//gAgentAvatarp->setTETexture( LLVOAvatar::sBakedTextureIndices[texture_index], texture_id );
 				gAgentQueryManager.mActiveCacheQueries[texture_index] = 0;
 				num_results++;
 			}
 			else
 			{
 				// no cache of this bake. request upload.
-				gAgentAvatar->requestLayerSetUpload((EBakedTextureIndex)texture_index);
+				gAgentAvatarp->requestLayerSetUpload((EBakedTextureIndex)texture_index);
 			}
 		}
 	}
 
 	llinfos << "Received cached texture response for " << num_results << " textures." << llendl;
 
-	gAgentAvatar->updateMeshTextures();
+	gAgentAvatarp->updateMeshTextures();
 
 	if (gAgentQueryManager.mNumPendingQueries == 0)
 	{
 		// RN: not sure why composites are disabled at this point
-		gAgentAvatar->setCompositeUpdatesEnabled(TRUE);
+		gAgentAvatarp->setCompositeUpdatesEnabled(TRUE);
 		gAgent.sendAgentSetAppearance();
 	}
 }
@@ -3219,8 +3219,8 @@ void LLAgent::clearVisualParams(void *data)
 {
 	if (isAgentAvatarValid())
 	{
-		gAgentAvatar->clearVisualParamWeights();
-		gAgentAvatar->updateVisualParams();
+		gAgentAvatarp->clearVisualParamWeights();
+		gAgentAvatarp->updateVisualParams();
 	}
 }
 
@@ -3246,13 +3246,13 @@ bool LLAgent::teleportCore(bool is_local)
 	// Stop all animation before actual teleporting 
         if (isAgentAvatarValid())
 	{
-		for ( LLVOAvatar::AnimIterator anim_it= gAgentAvatar->mPlayingAnimations.begin();
-		      anim_it != gAgentAvatar->mPlayingAnimations.end();
+		for ( LLVOAvatar::AnimIterator anim_it= gAgentAvatarp->mPlayingAnimations.begin();
+		      anim_it != gAgentAvatarp->mPlayingAnimations.end();
 		      ++anim_it)
                {
-                       gAgentAvatar->stopMotion(anim_it->first);
+                       gAgentAvatarp->stopMotion(anim_it->first);
                }
-               gAgentAvatar->processAnimationStateChanges();
+               gAgentAvatarp->processAnimationStateChanges();
        }
 #endif
 
@@ -3448,8 +3448,8 @@ void LLAgent::stopCurrentAnimations()
 	if (isAgentAvatarValid())
 	{
 		for ( LLVOAvatar::AnimIterator anim_it =
-			      gAgentAvatar->mPlayingAnimations.begin();
-		      anim_it != gAgentAvatar->mPlayingAnimations.end();
+			      gAgentAvatarp->mPlayingAnimations.begin();
+		      anim_it != gAgentAvatarp->mPlayingAnimations.end();
 		      anim_it++)
 		{
 			if (anim_it->first ==
@@ -3462,7 +3462,7 @@ void LLAgent::stopCurrentAnimations()
 			else
 			{
 				// stop this animation locally
-				gAgentAvatar->stopMotion(anim_it->first, TRUE);
+				gAgentAvatarp->stopMotion(anim_it->first, TRUE);
 				// ...and tell the server to tell everyone.
 				sendAnimationRequest(anim_it->first, ANIM_REQUEST_STOP);
 			}
@@ -3577,7 +3577,7 @@ void LLAgent::sendAgentSetAppearance()
 	}
 
 
-	llinfos << "TAT: Sent AgentSetAppearance: " << gAgentAvatar->getBakedStatusForPrintout() << llendl;
+	llinfos << "TAT: Sent AgentSetAppearance: " << gAgentAvatarp->getBakedStatusForPrintout() << llendl;
 	//dumpAvatarTEs( "sendAgentSetAppearance()" );
 
 	LLMessageSystem* msg = gMessageSystem;
@@ -3591,7 +3591,7 @@ void LLAgent::sendAgentSetAppearance()
 	// NOTE -- when we start correcting all of the other Havok geometry 
 	// to compensate for the COLLISION_TOLERANCE ugliness we will have 
 	// to tweak this number again
-	const LLVector3 body_size = gAgentAvatar->mBodySize;
+	const LLVector3 body_size = gAgentAvatarp->mBodySize;
 	msg->addVector3Fast(_PREHASH_Size, body_size);	
 
 	// To guard against out of order packets
@@ -3601,20 +3601,20 @@ void LLAgent::sendAgentSetAppearance()
 
 	// is texture data current relative to wearables?
 	// KLW - TAT this will probably need to check the local queue.
-	BOOL textures_current = gAgentAvatar->areTexturesCurrent();
+	BOOL textures_current = gAgentAvatarp->areTexturesCurrent();
 
 	for(U8 baked_index = 0; baked_index < BAKED_NUM_INDICES; baked_index++ )
 	{
 		const ETextureIndex texture_index = LLVOAvatarDictionary::bakedToLocalTextureIndex((EBakedTextureIndex)baked_index);
 
 		// if we're not wearing a skirt, we don't need the texture to be baked
-		if (texture_index == TEX_SKIRT_BAKED && !gAgentAvatar->isWearingWearableType(WT_SKIRT))
+		if (texture_index == TEX_SKIRT_BAKED && !gAgentAvatarp->isWearingWearableType(WT_SKIRT))
 		{
 			continue;
 		}
 
 		// IMG_DEFAULT_AVATAR means not baked. 0 index should be ignored for baked textures
-		if (!gAgentAvatar->isTextureDefined(texture_index, 0))
+		if (!gAgentAvatarp->isTextureDefined(texture_index, 0))
 		{
 			textures_current = FALSE;
 			break;
@@ -3652,7 +3652,7 @@ void LLAgent::sendAgentSetAppearance()
 			msg->addU8Fast(_PREHASH_TextureIndex, (U8)texture_index);
 		}
 		msg->nextBlockFast(_PREHASH_ObjectData);
-		gAgentAvatar->sendAppearanceMessage( gMessageSystem );
+		gAgentAvatarp->sendAppearanceMessage( gMessageSystem );
 	}
 	else
 	{
@@ -3665,9 +3665,9 @@ void LLAgent::sendAgentSetAppearance()
 
 
 	S32 transmitted_params = 0;
-	for (LLViewerVisualParam* param = (LLViewerVisualParam*)gAgentAvatar->getFirstVisualParam();
+	for (LLViewerVisualParam* param = (LLViewerVisualParam*)gAgentAvatarp->getFirstVisualParam();
 		 param;
-		 param = (LLViewerVisualParam*)gAgentAvatar->getNextVisualParam())
+		 param = (LLViewerVisualParam*)gAgentAvatarp->getNextVisualParam())
 	{
 		if (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE)
 		{
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 62f1746f28b..2dd523cb244 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -374,7 +374,7 @@ void LLAgentCamera::unlockView()
 	{
 		if (isAgentAvatarValid())
 		{
-			setFocusGlobal(LLVector3d::zero, gAgentAvatar->mID);
+			setFocusGlobal(LLVector3d::zero, gAgentAvatarp->mID);
 		}
 		setFocusOnAvatar(FALSE, FALSE);	// no animation
 	}
@@ -1093,23 +1093,23 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y)
 
 	if (!isAgentAvatarValid()) return;
 
-	LLQuaternion av_inv_rot = ~gAgentAvatar->mRoot.getWorldRotation();
-	LLVector3 root_at = LLVector3::x_axis * gAgentAvatar->mRoot.getWorldRotation();
+	LLQuaternion av_inv_rot = ~gAgentAvatarp->mRoot.getWorldRotation();
+	LLVector3 root_at = LLVector3::x_axis * gAgentAvatarp->mRoot.getWorldRotation();
 
 	if 	((gViewerWindow->getMouseVelocityStat()->getCurrent() < 0.01f) &&
 		 (root_at * last_at_axis > 0.95f))
 	{
-		LLVector3 vel = gAgentAvatar->getVelocity();
+		LLVector3 vel = gAgentAvatarp->getVelocity();
 		if (vel.magVecSquared() > 4.f)
 		{
-			setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatar, vel * av_inv_rot);
+			setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatarp, vel * av_inv_rot);
 		}
 		else
 		{
 			// *FIX: rotate mframeagent by sit object's rotation?
-			LLQuaternion look_rotation = gAgentAvatar->isSitting() ? gAgentAvatar->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); // use camera's current rotation
+			LLQuaternion look_rotation = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); // use camera's current rotation
 			LLVector3 look_offset = LLVector3(2.f, 0.f, 0.f) * look_rotation * av_inv_rot;
-			setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatar, look_offset);
+			setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatarp, look_offset);
 		}
 		last_at_axis = root_at;
 		return;
@@ -1119,7 +1119,7 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y)
 	
 	if (CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode())
 	{
-		setLookAt(LOOKAT_TARGET_NONE, gAgentAvatar, LLVector3(-2.f, 0.f, 0.f));	
+		setLookAt(LOOKAT_TARGET_NONE, gAgentAvatarp, LLVector3(-2.f, 0.f, 0.f));	
 	}
 	else
 	{
@@ -1148,7 +1148,7 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y)
 		headLookAxis = frameCamera.getAtAxis();
 		// RN: we use world-space offset for mouselook and freelook
 		//headLookAxis = headLookAxis * av_inv_rot;
-		setLookAt(lookAtType, gAgentAvatar, headLookAxis);
+		setLookAt(lookAtType, gAgentAvatarp, headLookAxis);
 	}
 }
 
@@ -1170,12 +1170,12 @@ void LLAgentCamera::updateCamera()
 	validateFocusObject();
 
 	if (isAgentAvatarValid() && 
-		gAgentAvatar->isSitting() &&
+		gAgentAvatarp->isSitting() &&
 		camera_mode == CAMERA_MODE_MOUSELOOK)
 	{
 		//Ventrella
 		//changed camera_skyward to the new global "mCameraUpVector"
-		mCameraUpVector = mCameraUpVector * gAgentAvatar->getRenderRotation();
+		mCameraUpVector = mCameraUpVector * gAgentAvatarp->getRenderRotation();
 		//end Ventrella
 	}
 
@@ -1291,13 +1291,13 @@ void LLAgentCamera::updateCamera()
 			// (2) focus, and (3) upvector. They can then be queried elsewhere in llAgent.
 			//--------------------------------------------------------------------------------
 			// *TODO: use combined rotation of frameagent and sit object
-			LLQuaternion avatarRotationForFollowCam = gAgentAvatar->isSitting() ? gAgentAvatar->getRenderRotation() : gAgent.getFrameAgent().getQuaternion();
+			LLQuaternion avatarRotationForFollowCam = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion();
 
 			LLFollowCamParams* current_cam = LLFollowCamMgr::getActiveFollowCamParams();
 			if (current_cam)
 			{
 				mFollowCam.copyParams(*current_cam);
-				mFollowCam.setSubjectPositionAndRotation( gAgentAvatar->getRenderPosition(), avatarRotationForFollowCam );
+				mFollowCam.setSubjectPositionAndRotation( gAgentAvatarp->getRenderPosition(), avatarRotationForFollowCam );
 				mFollowCam.update();
 				LLViewerJoystick::getInstance()->setCameraNeedsUpdate(true);
 			}
@@ -1374,7 +1374,7 @@ void LLAgentCamera::updateCamera()
 
 		if (isAgentAvatarValid() && (mCameraMode != CAMERA_MODE_MOUSELOOK))
 		{
-			gAgentAvatar->updateAttachmentVisibility(mCameraMode);
+			gAgentAvatarp->updateAttachmentVisibility(mCameraMode);
 		}
 	}
 	else 
@@ -1472,40 +1472,40 @@ void LLAgentCamera::updateCamera()
 	}
 	gAgent.setLastPositionGlobal(global_pos);
 	
-	if (LLVOAvatar::sVisibleInFirstPerson && isAgentAvatarValid() && !gAgentAvatar->isSitting() && cameraMouselook())
+	if (LLVOAvatar::sVisibleInFirstPerson && isAgentAvatarValid() && !gAgentAvatarp->isSitting() && cameraMouselook())
 	{
-		LLVector3 head_pos = gAgentAvatar->mHeadp->getWorldPosition() + 
-			LLVector3(0.08f, 0.f, 0.05f) * gAgentAvatar->mHeadp->getWorldRotation() + 
-			LLVector3(0.1f, 0.f, 0.f) * gAgentAvatar->mPelvisp->getWorldRotation();
+		LLVector3 head_pos = gAgentAvatarp->mHeadp->getWorldPosition() + 
+			LLVector3(0.08f, 0.f, 0.05f) * gAgentAvatarp->mHeadp->getWorldRotation() + 
+			LLVector3(0.1f, 0.f, 0.f) * gAgentAvatarp->mPelvisp->getWorldRotation();
 		LLVector3 diff = mCameraPositionAgent - head_pos;
-		diff = diff * ~gAgentAvatar->mRoot.getWorldRotation();
+		diff = diff * ~gAgentAvatarp->mRoot.getWorldRotation();
 
-		LLJoint* torso_joint = gAgentAvatar->mTorsop;
-		LLJoint* chest_joint = gAgentAvatar->mChestp;
+		LLJoint* torso_joint = gAgentAvatarp->mTorsop;
+		LLJoint* chest_joint = gAgentAvatarp->mChestp;
 		LLVector3 torso_scale = torso_joint->getScale();
 		LLVector3 chest_scale = chest_joint->getScale();
 
 		// shorten avatar skeleton to avoid foot interpenetration
-		if (!gAgentAvatar->mInAir)
+		if (!gAgentAvatarp->mInAir)
 		{
 			LLVector3 chest_offset = LLVector3(0.f, 0.f, chest_joint->getPosition().mV[VZ]) * torso_joint->getWorldRotation();
 			F32 z_compensate = llclamp(-diff.mV[VZ], -0.2f, 1.f);
 			F32 scale_factor = llclamp(1.f - ((z_compensate * 0.5f) / chest_offset.mV[VZ]), 0.5f, 1.2f);
 			torso_joint->setScale(LLVector3(1.f, 1.f, scale_factor));
 
-			LLJoint* neck_joint = gAgentAvatar->mNeckp;
+			LLJoint* neck_joint = gAgentAvatarp->mNeckp;
 			LLVector3 neck_offset = LLVector3(0.f, 0.f, neck_joint->getPosition().mV[VZ]) * chest_joint->getWorldRotation();
 			scale_factor = llclamp(1.f - ((z_compensate * 0.5f) / neck_offset.mV[VZ]), 0.5f, 1.2f);
 			chest_joint->setScale(LLVector3(1.f, 1.f, scale_factor));
 			diff.mV[VZ] = 0.f;
 		}
 
-		gAgentAvatar->mPelvisp->setPosition(gAgentAvatar->mPelvisp->getPosition() + diff);
+		gAgentAvatarp->mPelvisp->setPosition(gAgentAvatarp->mPelvisp->getPosition() + diff);
 
-		gAgentAvatar->mRoot.updateWorldMatrixChildren();
+		gAgentAvatarp->mRoot.updateWorldMatrixChildren();
 
-		for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); 
-			 iter != gAgentAvatar->mAttachmentPoints.end(); )
+		for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
+			 iter != gAgentAvatarp->mAttachmentPoints.end(); )
 		{
 			LLVOAvatar::attachment_map_t::iterator curiter = iter++;
 			LLViewerJointAttachment* attachment = curiter->second;
@@ -1607,12 +1607,12 @@ LLVector3d LLAgentCamera::calcFocusPositionTargetGlobal()
 	{
 		LLVector3d at_axis(1.0, 0.0, 0.0);
 		LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion();
-		if (isAgentAvatarValid() && gAgentAvatar->getParent())
+		if (isAgentAvatarValid() && gAgentAvatarp->getParent())
 		{
-			LLViewerObject* root_object = (LLViewerObject*)gAgentAvatar->getRoot();
+			LLViewerObject* root_object = (LLViewerObject*)gAgentAvatarp->getRoot();
 			if (!root_object->flagCameraDecoupled())
 			{
-				agent_rot *= ((LLViewerObject*)(gAgentAvatar->getParent()))->getRenderRotation();
+				agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation();
 			}
 		}
 		at_axis = at_axis * agent_rot;
@@ -1662,7 +1662,7 @@ LLVector3d LLAgentCamera::calcFocusPositionTargetGlobal()
 		}
 		return mFocusTargetGlobal;
 	}
-	else if (mSitCameraEnabled && isAgentAvatarValid() && gAgentAvatar->isSitting() && mSitCameraReferenceObject.notNull())
+	else if (mSitCameraEnabled && isAgentAvatarValid() && gAgentAvatarp->isSitting() && mSitCameraReferenceObject.notNull())
 	{
 		// sit camera
 		LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition();
@@ -1682,9 +1682,9 @@ LLVector3d LLAgentCamera::calcThirdPersonFocusOffset()
 	// ...offset from avatar
 	LLVector3d focus_offset;
 	LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion();
-	if (isAgentAvatarValid() && gAgentAvatar->getParent())
+	if (isAgentAvatarValid() && gAgentAvatarp->getParent())
 	{
-		agent_rot *= ((LLViewerObject*)(gAgentAvatar->getParent()))->getRenderRotation();
+		agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation();
 	}
 
 	focus_offset = mFocusOffsetInitial[mCameraPreset] * agent_rot;
@@ -1694,9 +1694,9 @@ LLVector3d LLAgentCamera::calcThirdPersonFocusOffset()
 void LLAgentCamera::setupSitCamera()
 {
 	// agent frame entering this function is in world coordinates
-	if (isAgentAvatarValid() && gAgentAvatar->getParent())
+	if (isAgentAvatarValid() && gAgentAvatarp->getParent())
 	{
-		LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatar->getParent())->getRenderRotation();
+		LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
 		// slam agent coordinate frame to proper parent local version
 		LLVector3 at_axis = gAgent.getFrameAgent().getAtAxis();
 		at_axis.mV[VZ] = 0.f;
@@ -1763,7 +1763,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 	F32			camera_land_height;
 	LLVector3d	frame_center_global = !isAgentAvatarValid() ? 
 		gAgent.getPositionGlobal() :
-		gAgent.getPosGlobalFromAgent(gAgentAvatar->mRoot.getWorldPosition());
+		gAgent.getPosGlobalFromAgent(gAgentAvatarp->mRoot.getWorldPosition());
 	
 	BOOL		isConstrained = FALSE;
 	LLVector3d	head_offset;
@@ -1778,32 +1778,32 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 	}// End Ventrella
 	else if (mCameraMode == CAMERA_MODE_MOUSELOOK)
 	{
-		if (!isAgentAvatarValid() || gAgentAvatar->mDrawable.isNull())
+		if (!isAgentAvatarValid() || gAgentAvatarp->mDrawable.isNull())
 		{
 			llwarns << "Null avatar drawable!" << llendl;
 			return LLVector3d::zero;
 		}
 		head_offset.clearVec();
-		if (gAgentAvatar->isSitting() && gAgentAvatar->getParent())
+		if (gAgentAvatarp->isSitting() && gAgentAvatarp->getParent())
 		{
-			gAgentAvatar->updateHeadOffset();
-			head_offset.mdV[VX] = gAgentAvatar->mHeadOffset.mV[VX];
-			head_offset.mdV[VY] = gAgentAvatar->mHeadOffset.mV[VY];
-			head_offset.mdV[VZ] = gAgentAvatar->mHeadOffset.mV[VZ] + 0.1f;
-			const LLMatrix4& mat = ((LLViewerObject*) gAgentAvatar->getParent())->getRenderMatrix();
+			gAgentAvatarp->updateHeadOffset();
+			head_offset.mdV[VX] = gAgentAvatarp->mHeadOffset.mV[VX];
+			head_offset.mdV[VY] = gAgentAvatarp->mHeadOffset.mV[VY];
+			head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ] + 0.1f;
+			const LLMatrix4& mat = ((LLViewerObject*) gAgentAvatarp->getParent())->getRenderMatrix();
 			camera_position_global = gAgent.getPosGlobalFromAgent
-								((gAgentAvatar->getPosition()+
-								 LLVector3(head_offset)*gAgentAvatar->getRotation()) * mat);
+								((gAgentAvatarp->getPosition()+
+								 LLVector3(head_offset)*gAgentAvatarp->getRotation()) * mat);
 		}
 		else
 		{
-			head_offset.mdV[VZ] = gAgentAvatar->mHeadOffset.mV[VZ];
-			if (gAgentAvatar->isSitting())
+			head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ];
+			if (gAgentAvatarp->isSitting())
 			{
 				head_offset.mdV[VZ] += 0.1;
 			}
-			camera_position_global = gAgent.getPosGlobalFromAgent(gAgentAvatar->getRenderPosition());//frame_center_global;
-			head_offset = head_offset * gAgentAvatar->getRenderRotation();
+			camera_position_global = gAgent.getPosGlobalFromAgent(gAgentAvatarp->getRenderPosition());//frame_center_global;
+			head_offset = head_offset * gAgentAvatarp->getRenderRotation();
 			camera_position_global = camera_position_global + head_offset;
 		}
 	}
@@ -1814,7 +1814,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 
 		if (mSitCameraEnabled 
 			&& isAgentAvatarValid() 
-			&& gAgentAvatar->isSitting() 
+			&& gAgentAvatarp->isSitting() 
 			&& mSitCameraReferenceObject.notNull())
 		{
 			// sit camera
@@ -1830,9 +1830,9 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 			local_camera_offset = mCameraZoomFraction * getCameraOffsetInitial() * gSavedSettings.getF32("CameraOffsetScale");
 			
 			// are we sitting down?
-			if (isAgentAvatarValid() && gAgentAvatar->getParent())
+			if (isAgentAvatarValid() && gAgentAvatarp->getParent())
 			{
-				LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatar->getParent())->getRenderRotation();
+				LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
 				// slam agent coordinate frame to proper parent local version
 				LLVector3 at_axis = gAgent.getFrameAgent().getAtAxis() * parent_rot;
 				at_axis.mV[VZ] = 0.f;
@@ -1846,7 +1846,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 				local_camera_offset = gAgent.getFrameAgent().rotateToAbsolute( local_camera_offset );
 			}
 
-			if (!mCameraCollidePlane.isExactlyZero() && (!isAgentAvatarValid() || !gAgentAvatar->isSitting()))
+			if (!mCameraCollidePlane.isExactlyZero() && (!isAgentAvatarValid() || !gAgentAvatarp->isSitting()))
 			{
 				LLVector3 plane_normal;
 				plane_normal.setVec(mCameraCollidePlane.mV);
@@ -1899,7 +1899,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 			// set the global camera position
 			LLVector3d camera_offset;
 			
-			LLVector3 av_pos = !isAgentAvatarValid() ? LLVector3::zero : gAgentAvatar->getRenderPosition();
+			LLVector3 av_pos = !isAgentAvatarValid() ? LLVector3::zero : gAgentAvatarp->getRenderPosition();
 			camera_offset.setVec( local_camera_offset );
 			camera_position_global = frame_center_global + head_offset + camera_offset;
 
@@ -1911,8 +1911,8 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 				LLVector3 vel = gAgent.getVelocity();
 
 				// lag by appropriate amount for flying
-				F32 time_in_air = gAgentAvatar->mTimeInAir.getElapsedTimeF32();
-				if(!mCameraAnimating && gAgentAvatar->mInAir && time_in_air > GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME)
+				F32 time_in_air = gAgentAvatarp->mTimeInAir.getElapsedTimeF32();
+				if(!mCameraAnimating && gAgentAvatarp->mInAir && time_in_air > GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME)
 				{
 					LLVector3 frame_at_axis = gAgent.getFrameAgent().getAtAxis();
 					frame_at_axis -= projected_vec(frame_at_axis, gAgent.getReferenceUpVector());
@@ -1924,7 +1924,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 
 					lag_interp *= u;
 
-					if (gViewerWindow->getLeftMouseDown() && gViewerWindow->getLastPick().mObjectID == gAgentAvatar->getID())
+					if (gViewerWindow->getLeftMouseDown() && gViewerWindow->getLastPick().mObjectID == gAgentAvatarp->getID())
 					{
 						// disable camera lag when using mouse-directed steering
 						target_lag.clearVec();
@@ -2135,8 +2135,8 @@ void LLAgentCamera::changeCameraToMouselook(BOOL animate)
 
 	if (isAgentAvatarValid())
 	{
-		gAgentAvatar->stopMotion(ANIM_AGENT_BODY_NOISE);
-		gAgentAvatar->stopMotion(ANIM_AGENT_BREATHE_ROT);
+		gAgentAvatarp->stopMotion(ANIM_AGENT_BODY_NOISE);
+		gAgentAvatarp->stopMotion(ANIM_AGENT_BREATHE_ROT);
 	}
 
 	//gViewerWindow->stopGrab();
@@ -2223,9 +2223,9 @@ void LLAgentCamera::changeCameraToFollow(BOOL animate)
 
 		if (isAgentAvatarValid())
 		{
-			gAgentAvatar->mPelvisp->setPosition(LLVector3::zero);
-			gAgentAvatar->startMotion( ANIM_AGENT_BODY_NOISE );
-			gAgentAvatar->startMotion( ANIM_AGENT_BREATHE_ROT );
+			gAgentAvatarp->mPelvisp->setPosition(LLVector3::zero);
+			gAgentAvatarp->startMotion( ANIM_AGENT_BODY_NOISE );
+			gAgentAvatarp->startMotion( ANIM_AGENT_BREATHE_ROT );
 		}
 
 		// unpause avatar animation
@@ -2266,12 +2266,12 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate)
 
 	if (isAgentAvatarValid())
 	{
-		if (!gAgentAvatar->isSitting())
+		if (!gAgentAvatarp->isSitting())
 		{
-			gAgentAvatar->mPelvisp->setPosition(LLVector3::zero);
+			gAgentAvatarp->mPelvisp->setPosition(LLVector3::zero);
 		}
-		gAgentAvatar->startMotion(ANIM_AGENT_BODY_NOISE);
-		gAgentAvatar->startMotion(ANIM_AGENT_BREATHE_ROT);
+		gAgentAvatarp->startMotion(ANIM_AGENT_BODY_NOISE);
+		gAgentAvatarp->startMotion(ANIM_AGENT_BREATHE_ROT);
 	}
 
 	LLVector3 at_axis;
@@ -2305,9 +2305,9 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate)
 	}
 
 	// Remove any pitch from the avatar
-	if (isAgentAvatarValid() && gAgentAvatar->getParent())
+	if (isAgentAvatarValid() && gAgentAvatarp->getParent())
 	{
-		LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatar->getParent())->getRenderRotation();
+		LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
 		at_axis = LLViewerCamera::getInstance()->getAtAxis();
 		at_axis.mV[VZ] = 0.f;
 		at_axis.normalize();
@@ -2391,8 +2391,8 @@ void LLAgentCamera::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL came
 
 			gAgent.sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_START);
 			gAgent.setCustomAnim(TRUE);
-			gAgentAvatar->startMotion(ANIM_AGENT_CUSTOMIZE);
-			LLMotion* turn_motion = gAgentAvatar->findMotion(ANIM_AGENT_CUSTOMIZE);
+			gAgentAvatarp->startMotion(ANIM_AGENT_CUSTOMIZE);
+			LLMotion* turn_motion = gAgentAvatarp->findMotion(ANIM_AGENT_CUSTOMIZE);
 
 			if (turn_motion)
 			{
@@ -2503,7 +2503,7 @@ void LLAgentCamera::setFocusGlobal(const LLVector3d& focus, const LLUUID &object
 		{
 			if (isAgentAvatarValid())
 			{
-				mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatar->mHeadp->getWorldPosition());
+				mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mHeadp->getWorldPosition());
 			}
 			else
 			{
@@ -2548,7 +2548,7 @@ void LLAgentCamera::setFocusGlobal(const LLVector3d& focus, const LLUUID &object
 		{
 			if (isAgentAvatarValid())
 			{
-				mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatar->mHeadp->getWorldPosition());
+				mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mHeadp->getWorldPosition());
 			}
 			else
 			{
@@ -2685,9 +2685,9 @@ void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate)
 		if (mCameraMode == CAMERA_MODE_THIRD_PERSON)
 		{
 			LLVector3 at_axis;
-			if (isAgentAvatarValid() && gAgentAvatar->getParent())
+			if (isAgentAvatarValid() && gAgentAvatarp->getParent())
 			{
-				LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatar->getParent())->getRenderRotation();
+				LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
 				at_axis = LLViewerCamera::getInstance()->getAtAxis();
 				at_axis.mV[VZ] = 0.f;
 				at_axis.normalize();
@@ -2720,10 +2720,10 @@ BOOL LLAgentCamera::setLookAt(ELookAtType target_type, LLViewerObject *object, L
 		LLViewerObject* parent = object;
 		while(parent)
 		{
-			if (parent == gAgentAvatar)
+			if (parent == gAgentAvatarp)
 			{
 				// looking at an attachment on ourselves, which we don't want to do
-				object = gAgentAvatar;
+				object = gAgentAvatarp;
 				position.clearVec();
 			}
 			parent = (LLViewerObject*)parent->getParent();
@@ -2732,7 +2732,7 @@ BOOL LLAgentCamera::setLookAt(ELookAtType target_type, LLViewerObject *object, L
 	if(!mLookAt || mLookAt->isDead())
 	{
 		mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT);
-		mLookAt->setSourceObject(gAgentAvatar);
+		mLookAt->setSourceObject(gAgentAvatarp);
 	}
 
 	return mLookAt->setLookAt(target_type, object, position);
@@ -2761,7 +2761,7 @@ void LLAgentCamera::lookAtLastChat()
 		LLVOAvatar *chatter_av = (LLVOAvatar*)chatter;
 		if (isAgentAvatarValid() && chatter_av->mHeadp)
 		{
-			delta_pos = chatter_av->mHeadp->getWorldPosition() - gAgentAvatar->mHeadp->getWorldPosition();
+			delta_pos = chatter_av->mHeadp->getWorldPosition() - gAgentAvatarp->mHeadp->getWorldPosition();
 		}
 		else
 		{
@@ -2773,7 +2773,7 @@ void LLAgentCamera::lookAtLastChat()
 
 		changeCameraToThirdPerson();
 
-		LLVector3 new_camera_pos = gAgentAvatar->mHeadp->getWorldPosition();
+		LLVector3 new_camera_pos = gAgentAvatarp->mHeadp->getWorldPosition();
 		LLVector3 left = delta_pos % LLVector3::z_axis;
 		left.normalize();
 		LLVector3 up = left % delta_pos;
@@ -2802,7 +2802,7 @@ void LLAgentCamera::lookAtLastChat()
 
 		changeCameraToThirdPerson();
 
-		LLVector3 new_camera_pos = gAgentAvatar->mHeadp->getWorldPosition();
+		LLVector3 new_camera_pos = gAgentAvatarp->mHeadp->getWorldPosition();
 		LLVector3 left = delta_pos % LLVector3::z_axis;
 		left.normalize();
 		LLVector3 up = left % delta_pos;
@@ -2827,7 +2827,7 @@ BOOL LLAgentCamera::setPointAt(EPointAtType target_type, LLViewerObject *object,
 	if (!mPointAt || mPointAt->isDead())
 	{
 		mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT);
-		mPointAt->setSourceObject(gAgentAvatar);
+		mPointAt->setSourceObject(gAgentAvatarp);
 	}
 	return mPointAt->setPointAt(target_type, object, position);
 }
diff --git a/indra/newview/llagentui.cpp b/indra/newview/llagentui.cpp
index 452a11b01ed..c4597ad6f8d 100644
--- a/indra/newview/llagentui.cpp
+++ b/indra/newview/llagentui.cpp
@@ -51,8 +51,8 @@ void LLAgentUI::buildName(std::string& name)
 	name.clear();
 	if (isAgentAvatarValid())
 	{
-		LLNameValue *first_nv = gAgentAvatar->getNVPair("FirstName");
-		LLNameValue *last_nv = gAgentAvatar->getNVPair("LastName");
+		LLNameValue *first_nv = gAgentAvatarp->getNVPair("FirstName");
+		LLNameValue *last_nv = gAgentAvatarp->getNVPair("LastName");
 		if (first_nv && last_nv)
 		{
 			name = first_nv->printData() + " " + last_nv->printData();
@@ -72,7 +72,7 @@ void LLAgentUI::buildName(std::string& name)
 void LLAgentUI::buildFullname(std::string& name)
 {
 	if (isAgentAvatarValid())
-		name = gAgentAvatar->getFullname();
+		name = gAgentAvatarp->getFullname();
 }
 
 //static
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index 91552a7f5bb..62fc5544ab3 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -485,7 +485,7 @@ void LLAgentWearables::saveWearable(const EWearableType type, const U32 index, B
 			return;
 		}
 
-		gAgentAvatar->wearableUpdated( type, TRUE );
+		gAgentAvatarp->wearableUpdated( type, TRUE );
 
 		if (send_update)
 		{
@@ -783,7 +783,7 @@ U32 LLAgentWearables::pushWearable(const EWearableType type, LLWearable *wearabl
 
 void LLAgentWearables::wearableUpdated(LLWearable *wearable)
 {
-	gAgentAvatar->wearableUpdated(wearable->getType(), TRUE);
+	gAgentAvatarp->wearableUpdated(wearable->getType(), TRUE);
 	wearable->refreshName();
 	wearable->setLabelUpdated();
 
@@ -827,7 +827,7 @@ void LLAgentWearables::popWearable(const EWearableType type, U32 index)
 	if (wearable)
 	{
 		mWearableDatas[type].erase(mWearableDatas[type].begin() + index);
-		gAgentAvatar->wearableUpdated(wearable->getType(), TRUE);
+		gAgentAvatarp->wearableUpdated(wearable->getType(), TRUE);
 		wearable->setLabelUpdated();
 	}
 }
@@ -959,7 +959,7 @@ void LLAgentWearables::processAgentInitialWearablesUpdate(LLMessageSystem* mesgs
 	LLUUID agent_id;
 	gMessageSystem->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
 
-	if (isAgentAvatarValid() && (agent_id == gAgentAvatar->getID()))
+	if (isAgentAvatarValid() && (agent_id == gAgentAvatarp->getID()))
 	{
 		gMessageSystem->getU32Fast(_PREHASH_AgentData, _PREHASH_SerialNum, gAgentQueryManager.mUpdateSerialNum);
 		
@@ -1061,9 +1061,9 @@ void LLAgentWearables::onInitialWearableAssetArrived(LLWearable* wearable, void*
 		gAgentWearables.mItemsAwaitingWearableUpdate.erase(wear_data->mItemID);
 
 		// disable composites if initial textures are baked
-		gAgentAvatar->setupComposites();
+		gAgentAvatarp->setupComposites();
 
-		gAgentAvatar->setCompositeUpdatesEnabled(TRUE);
+		gAgentAvatarp->setCompositeUpdatesEnabled(TRUE);
 		gInventory.addChangedMask(LLInventoryObserver::LABEL, wearable->getItemID());
 	}
 	else
@@ -1092,7 +1092,7 @@ void LLAgentWearables::onInitialWearableAssetArrived(LLWearable* wearable, void*
 		// If there are any, schedule them to be uploaded as soon as the layer textures they depend on arrive.
 		if (gAgentCamera.cameraCustomizeAvatar())
 		{
-			gAgentAvatar->requestLayerSetUploads();
+			gAgentAvatarp->requestLayerSetUploads();
 		}
 	}
 }
@@ -1234,7 +1234,7 @@ void LLAgentWearables::createStandardWearables(BOOL female)
 
 	if (!isAgentAvatarValid()) return;
 
-	gAgentAvatar->setSex(female ? SEX_FEMALE : SEX_MALE);
+	gAgentAvatarp->setSex(female ? SEX_FEMALE : SEX_MALE);
 
 	const BOOL create[WT_COUNT] = 
 		{
@@ -1283,7 +1283,7 @@ void LLAgentWearables::createStandardWearablesDone(S32 type, U32 index)
 	llinfos << "type " << type << " index " << index << llendl;
 
 	if (!isAgentAvatarValid()) return;
-	gAgentAvatar->updateVisualParams();
+	gAgentAvatarp->updateVisualParams();
 }
 
 void LLAgentWearables::createStandardWearablesAllDone()
@@ -1298,7 +1298,7 @@ void LLAgentWearables::createStandardWearablesAllDone()
 	updateServer();
 
 	// Treat this as the first texture entry message, if none received yet
-	gAgentAvatar->onFirstTEMessageReceived();
+	gAgentAvatarp->onFirstTEMessageReceived();
 }
 
 // MULTI-WEARABLE: Properly handle multiwearables later.
@@ -1418,7 +1418,7 @@ void LLAgentWearables::makeNewOutfit(const std::string& new_folder_name,
 		for (S32 i = 0; i < attachments_to_include.count(); i++)
 		{
 			S32 attachment_pt = attachments_to_include[i];
-			LLViewerJointAttachment* attachment = get_if_there(gAgentAvatar->mAttachmentPoints, attachment_pt, (LLViewerJointAttachment*)NULL);
+			LLViewerJointAttachment* attachment = get_if_there(gAgentAvatarp->mAttachmentPoints, attachment_pt, (LLViewerJointAttachment*)NULL);
 			if (!attachment) continue;
 			for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
 				 attachment_iter != attachment->mAttachedObjects.end();
@@ -1762,9 +1762,9 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it
 
 	if (isAgentAvatarValid())
 	{
-		gAgentAvatar->setCompositeUpdatesEnabled(TRUE);
-		gAgentAvatar->updateVisualParams();
-		gAgentAvatar->invalidateAll();
+		gAgentAvatarp->setCompositeUpdatesEnabled(TRUE);
+		gAgentAvatarp->updateVisualParams();
+		gAgentAvatarp->invalidateAll();
 	}
 
 	// Start rendering & update the server
@@ -2023,8 +2023,8 @@ void LLAgentWearables::userUpdateAttachments(LLInventoryModel::item_array_t& obj
 
 	// Build up list of objects to be removed and items currently attached.
 	llvo_vec_t objects_to_remove;
-	for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); 
-		 iter != gAgentAvatar->mAttachmentPoints.end();)
+	for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
+		 iter != gAgentAvatarp->mAttachmentPoints.end();)
 	{
 		LLVOAvatar::attachment_map_t::iterator curiter = iter++;
 		LLViewerJointAttachment* attachment = curiter->second;
@@ -2107,8 +2107,8 @@ void LLAgentWearables::userRemoveAllAttachments()
 
 	llvo_vec_t objects_to_remove;
 	
-	for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); 
-		 iter != gAgentAvatar->mAttachmentPoints.end();)
+	for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
+		 iter != gAgentAvatarp->mAttachmentPoints.end();)
 	{
 		LLVOAvatar::attachment_map_t::iterator curiter = iter++;
 		LLViewerJointAttachment* attachment = curiter->second;
@@ -2676,8 +2676,8 @@ void LLInitialWearablesFetch::processWearablesMessage()
 		// Add all current attachments to the requested items as well.
 		if (isAgentAvatarValid())
 		{
-			for (LLVOAvatar::attachment_map_t::const_iterator iter = gAgentAvatar->mAttachmentPoints.begin(); 
-				 iter != gAgentAvatar->mAttachmentPoints.end(); ++iter)
+			for (LLVOAvatar::attachment_map_t::const_iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
+				 iter != gAgentAvatarp->mAttachmentPoints.end(); ++iter)
 			{
 				LLViewerJointAttachment* attachment = iter->second;
 				if (!attachment) continue;
diff --git a/indra/newview/lldriverparam.cpp b/indra/newview/lldriverparam.cpp
index 75d1c437c3b..ebd767d654a 100644
--- a/indra/newview/lldriverparam.cpp
+++ b/indra/newview/lldriverparam.cpp
@@ -123,7 +123,7 @@ void LLDriverParamInfo::toStream(std::ostream &out)
 		for (entry_info_list_t::iterator iter = mDrivenInfoList.begin(); iter != mDrivenInfoList.end(); iter++)
 		{
 			LLDrivenEntryInfo driven = *iter;
-			LLViewerVisualParam *param = (LLViewerVisualParam*)gAgentAvatar->getVisualParam(driven.mDrivenID);
+			LLViewerVisualParam *param = (LLViewerVisualParam*)gAgentAvatarp->getVisualParam(driven.mDrivenID);
 			if (param)
 			{
 				param->getInfo()->toStream(out);
@@ -145,7 +145,7 @@ void LLDriverParamInfo::toStream(std::ostream &out)
 			}
 			else
 			{
-				llwarns << "could not get parameter " << driven.mDrivenID << " from avatar " << gAgentAvatar << " for driver parameter " << getID() << llendl;
+				llwarns << "could not get parameter " << driven.mDrivenID << " from avatar " << gAgentAvatarp << " for driver parameter " << getID() << llendl;
 			}
 			out << std::endl;
 		}
@@ -631,7 +631,7 @@ void LLDriverParam::setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight, bo
 	   mWearablep->isOnTop())
 	{
 		// call setWeight through LLVOAvatarSelf so other wearables can be updated with the correct values
-		gAgentAvatar->setVisualParamWeight( (LLVisualParam*)driven->mParam, driven_weight, upload_bake );
+		gAgentAvatarp->setVisualParamWeight( (LLVisualParam*)driven->mParam, driven_weight, upload_bake );
 	}
 	else
 	{
diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp
index c9a950ed42e..1f8c42ad908 100644
--- a/indra/newview/llgesturemgr.cpp
+++ b/indra/newview/llgesturemgr.cpp
@@ -757,8 +757,8 @@ void LLGestureManager::stepGesture(LLMultiGesture* gesture)
 	{
 		// look in signaled animations (simulator's view of what is
 		// currently playing.
-		LLVOAvatar::AnimIterator play_it = gAgentAvatar->mSignaledAnimations.find(*gest_it);
-		if (play_it != gAgentAvatar->mSignaledAnimations.end())
+		LLVOAvatar::AnimIterator play_it = gAgentAvatarp->mSignaledAnimations.find(*gest_it);
+		if (play_it != gAgentAvatarp->mSignaledAnimations.end())
 		{
 			++gest_it;
 		}
@@ -776,8 +776,8 @@ void LLGestureManager::stepGesture(LLMultiGesture* gesture)
 		 gest_it != gesture->mRequestedAnimIDs.end();
 		 )
 	{
-	 LLVOAvatar::AnimIterator play_it = gAgentAvatar->mSignaledAnimations.find(*gest_it);
-		if (play_it != gAgentAvatar->mSignaledAnimations.end())
+	 LLVOAvatar::AnimIterator play_it = gAgentAvatarp->mSignaledAnimations.find(*gest_it);
+		if (play_it != gAgentAvatarp->mSignaledAnimations.end())
 		{
 			// Hooray, this animation has started playing!
 			// Copy into playing.
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index a62640c8130..bcd53023caa 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -4149,7 +4149,7 @@ std::string LLObjectBridge::getLabelSuffix() const
 {
 	if (get_is_item_worn(mUUID))
 	{
-		std::string attachment_point_name = gAgentAvatar->getAttachedPointName(mUUID);
+		std::string attachment_point_name = gAgentAvatarp->getAttachedPointName(mUUID);
 
 		// e.g. "(worn on ...)" / "(attached to ...)"
 		LLStringUtil::format_map_t args;
@@ -4170,8 +4170,8 @@ void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attach
 	S32 attach_pt = 0;
 	if (isAgentAvatarValid() && attachment)
 	{
-		for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin();
-			 iter != gAgentAvatar->mAttachmentPoints.end(); ++iter)
+		for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin();
+			 iter != gAgentAvatarp->mAttachmentPoints.end(); ++iter)
 		{
 			if (iter->second == attachment)
 			{
@@ -4197,7 +4197,7 @@ void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attach
 
 bool confirm_replace_attachment_rez(const LLSD& notification, const LLSD& response)
 {
-	if (!gAgentAvatar->canAttachMoreObjects())
+	if (!gAgentAvatarp->canAttachMoreObjects())
 	{
 		LLSD args;
 		args["MAX_ATTACHMENTS"] = llformat("%d", MAX_AGENT_ATTACHMENTS);
@@ -4275,7 +4275,7 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 				// commented out for DEV-32347
 				//items.push_back(std::string("Restore to Last Position"));
 
-				if (!gAgentAvatar->canAttachMoreObjects())
+				if (!gAgentAvatarp->canAttachMoreObjects())
 				{
 					disabled_items.push_back(std::string("Object Wear"));
 					disabled_items.push_back(std::string("Attach To"));
@@ -4289,8 +4289,8 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 					&& (attach_hud_menu->getChildCount() == 0)
 					&& isAgentAvatarValid())
 				{
-					for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin();
-						 iter != gAgentAvatar->mAttachmentPoints.end(); )
+					for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin();
+						 iter != gAgentAvatarp->mAttachmentPoints.end(); )
 					{
 						LLVOAvatar::attachment_map_t::iterator curiter = iter++;
 						LLViewerJointAttachment* attachment = curiter->second;
@@ -4342,7 +4342,7 @@ BOOL LLObjectBridge::renameItem(const std::string& new_name)
 
 		if (isAgentAvatarValid())
 		{
-			LLViewerObject* obj = gAgentAvatar->getWornAttachment( item->getUUID() );
+			LLViewerObject* obj = gAgentAvatarp->getWornAttachment( item->getUUID() );
 			if(obj)
 			{
 				LLSelectMgr::getInstance()->deselectAll();
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index f1b7806635e..1750dd79ac3 100644
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -352,7 +352,7 @@ BOOL get_is_item_worn(const LLUUID& id)
 	{
 		case LLAssetType::AT_OBJECT:
 		{
-			if (isAgentAvatarValid() && gAgentAvatar->isWearingAttachment(item->getLinkedUUID()))
+			if (isAgentAvatarValid() && gAgentAvatarp->isWearingAttachment(item->getLinkedUUID()))
 				return TRUE;
 			break;
 		}
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index 7c8fb4f9b9a..f88747c382b 100644
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -3782,7 +3782,7 @@ bool LLInventoryCollectFunctor::itemTransferCommonlyAllowed(LLInventoryItem* ite
 		break;
 		
 	case LLAssetType::AT_OBJECT:
-		if (isAgentAvatarValid() && !gAgentAvatar->isWearingAttachment(item->getUUID()))
+		if (isAgentAvatarValid() && !gAgentAvatarp->isWearingAttachment(item->getUUID()))
 		{
 			allowed = true;
 		}
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index 3520c7e0c0a..e2ace7db01e 100644
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -872,8 +872,8 @@ bool LLInventoryPanel::attachObject(const LLSD& userdata)
 
 	std::string joint_name = userdata.asString();
 	LLViewerJointAttachment* attachmentp = NULL;
-	for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); 
-		 iter != gAgentAvatar->mAttachmentPoints.end(); )
+	for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
+		 iter != gAgentAvatarp->mAttachmentPoints.end(); )
 	{
 		LLVOAvatar::attachment_map_t::iterator curiter = iter++;
 		LLViewerJointAttachment* attachment = curiter->second;
diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp
index 8d77ade2539..5f0c5e17951 100644
--- a/indra/newview/llmaniptranslate.cpp
+++ b/indra/newview/llmaniptranslate.cpp
@@ -714,7 +714,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 				// in position changes even when the mouse moves
 				object->setPosition(new_position_local);
 				rebuild(object);
-				gAgentAvatar->clampAttachmentPositions();
+				gAgentAvatarp->clampAttachmentPositions();
 				new_position_local = object->getPosition();
 
 				if (selectNode->mIndividualSelection)
diff --git a/indra/newview/llmorphview.cpp b/indra/newview/llmorphview.cpp
index 6334d54e336..d670eb6ffd6 100644
--- a/indra/newview/llmorphview.cpp
+++ b/indra/newview/llmorphview.cpp
@@ -89,14 +89,14 @@ void	LLMorphView::initialize()
 	mCameraYaw = 0.f;
 	mCameraDist = -1.f;
 
-	if (!isAgentAvatarValid() || gAgentAvatar->isDead())
+	if (!isAgentAvatarValid() || gAgentAvatarp->isDead())
 	{
 		gAgentCamera.changeCameraToDefault();
 		return;
 	}
 
-	gAgentAvatar->stopMotion( ANIM_AGENT_BODY_NOISE );
-	gAgentAvatar->mSpecialRenderMode = 3;
+	gAgentAvatarp->stopMotion( ANIM_AGENT_BODY_NOISE );
+	gAgentAvatarp->mSpecialRenderMode = 3;
 	
 	// set up camera for close look at avatar
 	mOldCameraNearClip = LLViewerCamera::getInstance()->getNear();
@@ -112,8 +112,8 @@ void	LLMorphView::shutdown()
 
 	if (isAgentAvatarValid())
 	{
-		gAgentAvatar->startMotion( ANIM_AGENT_BODY_NOISE );
-		gAgentAvatar->mSpecialRenderMode = 0;
+		gAgentAvatarp->startMotion( ANIM_AGENT_BODY_NOISE );
+		gAgentAvatarp->mSpecialRenderMode = 0;
 		// reset camera
 		LLViewerCamera::getInstance()->setNear(mOldCameraNearClip);
 	}
@@ -162,11 +162,11 @@ void LLMorphView::updateCamera()
 {
 	if (!mCameraTargetJoint)
 	{
-		setCameraTargetJoint(gAgentAvatar->getJoint("mHead"));
+		setCameraTargetJoint(gAgentAvatarp->getJoint("mHead"));
 	}	
 	if (!isAgentAvatarValid()) return;
 
-	LLJoint* root_joint = gAgentAvatar->getRootJoint();
+	LLJoint* root_joint = gAgentAvatarp->getRootJoint();
 	if( !root_joint )
 	{
 		return;
diff --git a/indra/newview/llmoveview.cpp b/indra/newview/llmoveview.cpp
index b47acefc768..0f22a500937 100644
--- a/indra/newview/llmoveview.cpp
+++ b/indra/newview/llmoveview.cpp
@@ -42,7 +42,7 @@
 
 #include "llagent.h"
 #include "llagentcamera.h"
-#include "llvoavatarself.h" // to check gAgentAvatar->isSitting()
+#include "llvoavatarself.h" // to check gAgentAvatarp->isSitting()
 #include "llbottomtray.h"
 #include "llbutton.h"
 #include "llfloaterreg.h"
@@ -332,7 +332,7 @@ void LLFloaterMove::setMovementMode(const EMovementMode mode)
 	updateButtonsWithMovementMode(mode);
 
 	bool bHideModeButtons = MM_FLY == mode
-		|| (isAgentAvatarValid() && gAgentAvatar->isSitting());
+		|| (isAgentAvatarValid() && gAgentAvatarp->isSitting());
 
 	showModeButtons(!bHideModeButtons);
 
@@ -390,7 +390,7 @@ void LLFloaterMove::initMovementMode()
 
 	if (isAgentAvatarValid())
 	{
-		setEnabled(!gAgentAvatar->isSitting());
+		setEnabled(!gAgentAvatarp->isSitting());
 	}
 }
 
@@ -491,7 +491,7 @@ void LLFloaterMove::onOpen(const LLSD& key)
 		showModeButtons(FALSE);
 	}
 
-	if (isAgentAvatarValid() && gAgentAvatar->isSitting())
+	if (isAgentAvatarValid() && gAgentAvatarp->isSitting())
 	{
 		setSittingMode(TRUE);
 		showModeButtons(FALSE);
diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index 89fd4715fcd..805016f0893 100644
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -602,7 +602,7 @@ LLPanel* LLPanelEditWearable::getPanel(EWearableType type)
 void LLPanelEditWearable::getSortedParams(value_map_t &sorted_params, const std::string &edit_group)
 {
 	LLWearable::visual_param_vec_t param_list;
-	ESex avatar_sex = gAgentAvatar->getSex();
+	ESex avatar_sex = gAgentAvatarp->getSex();
 
 	mWearablePtr->getVisualParams(param_list);
 
diff --git a/indra/newview/llpreview.cpp b/indra/newview/llpreview.cpp
index 87c7bdbfabd..d5ec3a36c3c 100644
--- a/indra/newview/llpreview.cpp
+++ b/indra/newview/llpreview.cpp
@@ -181,7 +181,7 @@ void LLPreview::onCommit()
 			{
 				if (isAgentAvatarValid())
 				{
-					LLViewerObject* obj = gAgentAvatar->getWornAttachment( item->getUUID() );
+					LLViewerObject* obj = gAgentAvatarp->getWornAttachment( item->getUUID() );
 					if( obj )
 					{
 						LLSelectMgr::getInstance()->deselectAll();
diff --git a/indra/newview/llpreviewanim.cpp b/indra/newview/llpreviewanim.cpp
index 9210f5b8b7a..262961b73b2 100644
--- a/indra/newview/llpreviewanim.cpp
+++ b/indra/newview/llpreviewanim.cpp
@@ -71,7 +71,7 @@ BOOL LLPreviewAnim::postBuild()
 	const LLInventoryItem* item = getItem();
 	if(item)
 	{
-		gAgentAvatar->createMotion(item->getAssetUUID()); // preload the animation
+		gAgentAvatarp->createMotion(item->getAssetUUID()); // preload the animation
 		childSetText("desc", item->getDescription());
 	}
 
@@ -125,7 +125,7 @@ void LLPreviewAnim::playAnim( void *userdata )
 		{
 			self->mPauseRequest = NULL;
 			gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_START);
-			LLMotion* motion = gAgentAvatar->findMotion(itemID);
+			LLMotion* motion = gAgentAvatarp->findMotion(itemID);
 			if (motion)
 			{
 				motion->setDeactivateCallback(&endAnimCallback, (void *)(new LLHandle<LLFloater>(self->getHandle())));
@@ -133,7 +133,7 @@ void LLPreviewAnim::playAnim( void *userdata )
 		}
 		else
 		{
-			gAgentAvatar->stopMotion(itemID);
+			gAgentAvatarp->stopMotion(itemID);
 			gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_STOP);
 		}
 	}
@@ -158,8 +158,8 @@ void LLPreviewAnim::auditionAnim( void *userdata )
 		if (self->childGetValue("Anim audition btn").asBoolean() ) 
 		{
 			self->mPauseRequest = NULL;
-			gAgentAvatar->startMotion(item->getAssetUUID());
-			LLMotion* motion = gAgentAvatar->findMotion(itemID);
+			gAgentAvatarp->startMotion(item->getAssetUUID());
+			LLMotion* motion = gAgentAvatarp->findMotion(itemID);
 			
 			if (motion)
 			{
@@ -168,7 +168,7 @@ void LLPreviewAnim::auditionAnim( void *userdata )
 		}
 		else
 		{
-			gAgentAvatar->stopMotion(itemID);
+			gAgentAvatarp->stopMotion(itemID);
 			gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_STOP);
 		}
 	}
@@ -181,9 +181,9 @@ void LLPreviewAnim::onClose(bool app_quitting)
 
 	if(item)
 	{
-		gAgentAvatar->stopMotion(item->getAssetUUID());
+		gAgentAvatarp->stopMotion(item->getAssetUUID());
 		gAgent.sendAnimationRequest(item->getAssetUUID(), ANIM_REQUEST_STOP);
-		LLMotion* motion = gAgentAvatar->findMotion(item->getAssetUUID());
+		LLMotion* motion = gAgentAvatarp->findMotion(item->getAssetUUID());
 		
 		if (motion)
 		{
diff --git a/indra/newview/llscrollingpanelparam.cpp b/indra/newview/llscrollingpanelparam.cpp
index b47b3843089..7980fe19459 100644
--- a/indra/newview/llscrollingpanelparam.cpp
+++ b/indra/newview/llscrollingpanelparam.cpp
@@ -209,7 +209,7 @@ void LLScrollingPanelParam::onSliderMoved(LLUICtrl* ctrl, void* userdata)
 	if (current_weight != new_weight )
 	{
 		self->mWearable->setVisualParamWeight( param->getID(), new_weight, FALSE );
-		gAgentAvatar->updateVisualParams();
+		gAgentAvatarp->updateVisualParams();
 	}
 }
 
@@ -298,7 +298,7 @@ void LLScrollingPanelParam::onHintHeldDown( LLVisualParamHint* hint )
 				&& new_percent < slider->getMaxValue())
 			{
 				mWearable->setVisualParamWeight( hint->getVisualParam()->getID(), new_weight, FALSE);
-				gAgentAvatar->updateVisualParams();
+				gAgentAvatarp->updateVisualParams();
 
 				slider->setValue( weightToPercent( new_weight ) );
 			}
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 26d1ec1d6cf..6969ae5e1ea 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -1475,7 +1475,7 @@ void LLSelectMgr::selectionSetImage(const LLUUID& imageid)
 				object->sendTEUpdate();
 				// 1 particle effect per object				
 				LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE);
-				effectp->setSourceObject(gAgentAvatar);
+				effectp->setSourceObject(gAgentAvatarp);
 				effectp->setTargetObject(object);
 				effectp->setDuration(LL_HUD_DUR_SHORT);
 				effectp->setColor(LLColor4U(gAgent.getEffectColor()));
@@ -3630,7 +3630,7 @@ void LLSelectMgr::sendAttach(U8 attachment_point)
 	BOOL build_mode = LLToolMgr::getInstance()->inEdit();
 	// Special case: Attach to default location for this object.
 	if (0 == attachment_point ||
-		get_if_there(gAgentAvatar->mAttachmentPoints, (S32)attachment_point, (LLViewerJointAttachment*)NULL))
+		get_if_there(gAgentAvatarp->mAttachmentPoints, (S32)attachment_point, (LLViewerJointAttachment*)NULL))
 	{
 		sendListToRegions(
 			"ObjectAttach",
@@ -4913,7 +4913,7 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud)
 
 	if (isAgentAvatarValid() && for_hud)
 	{
-		LLBBox hud_bbox = gAgentAvatar->getHUDBBox();
+		LLBBox hud_bbox = gAgentAvatarp->getHUDBBox();
 
 		F32 cur_zoom = gAgentCamera.mHUDCurZoom;
 
@@ -5610,7 +5610,7 @@ void LLSelectMgr::updateSelectionCenter()
 
 		if (mSelectedObjects->mSelectType == SELECT_TYPE_ATTACHMENT && isAgentAvatarValid())
 		{
-			mPauseRequest = gAgentAvatar->requestPause();
+			mPauseRequest = gAgentAvatarp->requestPause();
 		}
 		else
 		{
@@ -5643,7 +5643,7 @@ void LLSelectMgr::updateSelectionCenter()
 			
 			LLViewerObject *root = object->getRootEdit();
 			if (mSelectedObjects->mSelectType == SELECT_TYPE_WORLD && // not an attachment
-				!root->isChild(gAgentAvatar) && // not the object you're sitting on
+				!root->isChild(gAgentAvatarp) && // not the object you're sitting on
 				!object->isAvatar()) // not another avatar
 			{
 				mShowSelection = TRUE;
diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp
index e65da0022e9..587565bafd4 100644
--- a/indra/newview/llsidepanelappearance.cpp
+++ b/indra/newview/llsidepanelappearance.cpp
@@ -368,8 +368,8 @@ void LLSidepanelAppearance::fetchInventory()
 
 	if (isAgentAvatarValid())
 	{
-		for (LLVOAvatar::attachment_map_t::const_iterator iter = gAgentAvatar->mAttachmentPoints.begin(); 
-			 iter != gAgentAvatar->mAttachmentPoints.end(); ++iter)
+		for (LLVOAvatar::attachment_map_t::const_iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
+			 iter != gAgentAvatarp->mAttachmentPoints.end(); ++iter)
 		{
 			LLViewerJointAttachment* attachment = iter->second;
 			if (!attachment) continue;
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 7ed095c68e7..87ced0352b8 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -1926,7 +1926,7 @@ bool idle_startup()
 		{
 			// wait for avatar to be completely loaded
 			if (isAgentAvatarValid()
-				&& gAgentAvatar->isFullyLoaded())
+				&& gAgentAvatarp->isFullyLoaded())
 			{
 				//llinfos << "avatar fully loaded" << llendl;
 				LLStartUp::setStartupState( STATE_CLEANUP );
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index add1cea8ccf..58f64ff1f37 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -447,7 +447,7 @@ void LLStatusBar::setHealth(S32 health)
 		{
 			if (isAgentAvatarValid())
 			{
-				if (gAgentAvatar->getSex() == SEX_FEMALE)
+				if (gAgentAvatarp->getSex() == SEX_FEMALE)
 				{
 					make_ui_sound("UISndHealthReductionF");
 				}
diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp
index 6461ec82217..3f4dab4feac 100644
--- a/indra/newview/lltexlayer.cpp
+++ b/indra/newview/lltexlayer.cpp
@@ -350,7 +350,7 @@ void LLTexLayerSetBuffer::readBackAndUpload()
 			{
 				// baked_upload_data is owned by the responder and deleted after the request completes
 				LLBakedUploadData* baked_upload_data =
-					new LLBakedUploadData(gAgentAvatar, this->mTexLayerSet, asset_id);
+					new LLBakedUploadData(gAgentAvatarp, this->mTexLayerSet, asset_id);
 				mUploadID = asset_id;
 				
 				// upload the image
@@ -409,8 +409,8 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid,
 
 	if (0 == result &&
 		isAgentAvatarValid() &&
-		!gAgentAvatar->isDead() &&
-		baked_upload_data->mAvatar == gAgentAvatar && // Sanity check: only the user's avatar should be uploading textures.
+		!gAgentAvatarp->isDead() &&
+		baked_upload_data->mAvatar == gAgentAvatarp && // Sanity check: only the user's avatar should be uploading textures.
 		baked_upload_data->mTexLayerSet->hasComposite()
 		)
 	{
@@ -435,11 +435,11 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid,
 
 			if (result >= 0)
 			{
-				LLVOAvatarDefines::ETextureIndex baked_te = gAgentAvatar->getBakedTE(layerset_buffer->mTexLayerSet);
+				LLVOAvatarDefines::ETextureIndex baked_te = gAgentAvatarp->getBakedTE(layerset_buffer->mTexLayerSet);
 				// Update baked texture info with the new UUID
 				U64 now = LLFrameTimer::getTotalTime();		// Record starting time
 				llinfos << "Baked texture upload took " << (S32)((now - baked_upload_data->mStartTime) / 1000) << " ms" << llendl;
-				gAgentAvatar->setNewBakedTexture(baked_te, uuid);
+				gAgentAvatarp->setNewBakedTexture(baked_te, uuid);
 			}
 			else
 			{	
@@ -453,7 +453,7 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid,
 			llinfos << "Received baked texture out of date, ignored." << llendl;
 		}
 
-		gAgentAvatar->dirtyMesh();
+		gAgentAvatarp->dirtyMesh();
 	}
 	else
 	{
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index f9d0c7c307c..c3aba4e5914 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -1174,7 +1174,7 @@ void LLToolDragAndDrop::dropScript(LLViewerObject* hit_obj,
 
 		// VEFFECT: SetScript
 		LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE);
-		effectp->setSourceObject(gAgentAvatar);
+		effectp->setSourceObject(gAgentAvatarp);
 		effectp->setTargetObject(hit_obj);
 		effectp->setDuration(LL_HUD_DUR_SHORT);
 		effectp->setColor(LLColor4U(gAgent.getEffectColor()));
@@ -1335,7 +1335,7 @@ void LLToolDragAndDrop::dropObject(LLViewerObject* raycast_target,
 
 	// VEFFECT: DropObject
 	LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE);
-	effectp->setSourceObject(gAgentAvatar);
+	effectp->setSourceObject(gAgentAvatarp);
 	effectp->setPositionGlobal(mLastHitPos);
 	effectp->setDuration(LL_HUD_DUR_SHORT);
 	effectp->setColor(LLColor4U(gAgent.getEffectColor()));
@@ -1398,7 +1398,7 @@ void LLToolDragAndDrop::dropInventory(LLViewerObject* hit_obj,
 
 	// VEFFECT: AddToInventory
 	LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE);
-	effectp->setSourceObject(gAgentAvatar);
+	effectp->setSourceObject(gAgentAvatarp);
 	effectp->setTargetObject(hit_obj);
 	effectp->setDuration(LL_HUD_DUR_SHORT);
 	effectp->setColor(LLColor4U(gAgent.getEffectColor()));
@@ -1496,7 +1496,7 @@ void LLToolDragAndDrop::commitGiveInventoryItem(const LLUUID& to_agent,
 
 	// VEFFECT: giveInventory
 	LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE);
-	effectp->setSourceObject(gAgentAvatar);
+	effectp->setSourceObject(gAgentAvatarp);
 	effectp->setTargetObject(gObjectList.findObject(to_agent));
 	effectp->setDuration(LL_HUD_DUR_SHORT);
 	effectp->setColor(LLColor4U(gAgent.getEffectColor()));
@@ -1735,7 +1735,7 @@ void LLToolDragAndDrop::commitGiveInventoryCategory(const LLUUID& to_agent,
 
 		// VEFFECT: giveInventoryCategory
 		LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE);
-		effectp->setSourceObject(gAgentAvatar);
+		effectp->setSourceObject(gAgentAvatarp);
 		effectp->setTargetObject(gObjectList.findObject(to_agent));
 		effectp->setDuration(LL_HUD_DUR_SHORT);
 		effectp->setColor(LLColor4U(gAgent.getEffectColor()));
@@ -1767,7 +1767,7 @@ BOOL LLToolDragAndDrop::isInventoryGiveAcceptable(LLInventoryItem* item)
 	switch(item->getType())
 	{
 	case LLAssetType::AT_OBJECT:
-		if (gAgentAvatar->isWearingAttachment(item->getUUID()))
+		if (gAgentAvatarp->isWearingAttachment(item->getUUID()))
 		{
 			acceptable = FALSE;
 		}
@@ -1810,7 +1810,7 @@ BOOL LLToolDragAndDrop::isInventoryGroupGiveAcceptable(LLInventoryItem* item)
 	switch(item->getType())
 	{
 	case LLAssetType::AT_OBJECT:
-		if (gAgentAvatar->isWearingAttachment(item->getUUID()))
+		if (gAgentAvatarp->isWearingAttachment(item->getUUID()))
 		{
 			acceptable = FALSE;
 		}
@@ -1848,7 +1848,7 @@ EAcceptance LLToolDragAndDrop::willObjectAcceptInventory(LLViewerObject* obj, LL
 	switch(item->getType())
 	{
 	case LLAssetType::AT_OBJECT:
-		if (isAgentAvatarValid() && gAgentAvatar->isWearingAttachment(item->getUUID()))
+		if (isAgentAvatarValid() && gAgentAvatarp->isWearingAttachment(item->getUUID()))
 		{
 				worn = TRUE;
 		}
@@ -1999,7 +1999,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezAttachmentFromInv(
 	}
 
 	// must not be already wearing it
-	if (!isAgentAvatarValid() || gAgentAvatar->isWearingAttachment(item->getUUID()))
+	if (!isAgentAvatarValid() || gAgentAvatarp->isWearingAttachment(item->getUUID()))
 	{
 		return ACCEPT_NO;
 	}
@@ -2040,7 +2040,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezObjectOnLand(
 	locateInventory(item, cat);
 	if (!item || !item->isComplete()) return ACCEPT_NO;
 
-	if (!isAgentAvatarValid() || gAgentAvatar->isWearingAttachment(item->getUUID()))
+	if (!isAgentAvatarValid() || gAgentAvatarp->isWearingAttachment(item->getUUID()))
 	{
 		return ACCEPT_NO;
 	}
@@ -2101,7 +2101,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezObjectOnObject(
 	LLViewerInventoryCategory* cat;
 	locateInventory(item, cat);
 	if (!item || !item->isComplete()) return ACCEPT_NO;
-	if (!isAgentAvatarValid() || gAgentAvatar->isWearingAttachment(item->getUUID()))
+	if (!isAgentAvatarValid() || gAgentAvatarp->isWearingAttachment(item->getUUID()))
 	{
 		return ACCEPT_NO;
 	}
@@ -2250,7 +2250,7 @@ EAcceptance LLToolDragAndDrop::dad3dTextureObject(
 		
 		// VEFFECT: SetTexture
 		LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE);
-		effectp->setSourceObject(gAgentAvatar);
+		effectp->setSourceObject(gAgentAvatarp);
 		effectp->setTargetObject(obj);
 		effectp->setDuration(LL_HUD_DUR_SHORT);
 		effectp->setColor(LLColor4U(gAgent.getEffectColor()));
@@ -2610,7 +2610,7 @@ EAcceptance LLToolDragAndDrop::dad3dGiveInventoryObject(
 		// cannot give away no-transfer objects
 		return ACCEPT_NO;
 	}
-	if (isAgentAvatarValid() && gAgentAvatar->isWearingAttachment(item->getUUID()))
+	if (isAgentAvatarValid() && gAgentAvatarp->isWearingAttachment(item->getUUID()))
 	{
 		// You can't give objects that are attached to you
 		return ACCEPT_NO;
diff --git a/indra/newview/lltoolfocus.cpp b/indra/newview/lltoolfocus.cpp
index b362d564df0..032714cabfd 100644
--- a/indra/newview/lltoolfocus.cpp
+++ b/indra/newview/lltoolfocus.cpp
@@ -173,7 +173,7 @@ void LLToolCamera::pickCallback(const LLPickInfo& pick_info)
 		BOOL good_customize_avatar_hit = FALSE;
 		if( hit_obj )
 		{
-			if (isAgentAvatarValid() && (hit_obj == gAgentAvatar))
+			if (isAgentAvatarValid() && (hit_obj == gAgentAvatarp))
 			{
 				// It's you
 				good_customize_avatar_hit = TRUE;
@@ -221,7 +221,7 @@ void LLToolCamera::pickCallback(const LLPickInfo& pick_info)
 			gAgentCamera.cameraThirdPerson() &&
 			gViewerWindow->getLeftMouseDown() && 
 			!gSavedSettings.getBOOL("FreezeTime") &&
-			(hit_obj == gAgentAvatar || 
+			(hit_obj == gAgentAvatarp || 
 			 (hit_obj && hit_obj->isAttachment() && LLVOAvatar::findAvatarFromAttachment(hit_obj)->isSelf())))
 		{
 			LLToolCamera::getInstance()->mMouseSteering = TRUE;
diff --git a/indra/newview/lltoolgrab.cpp b/indra/newview/lltoolgrab.cpp
index 982d55914da..04d873f91bd 100644
--- a/indra/newview/lltoolgrab.cpp
+++ b/indra/newview/lltoolgrab.cpp
@@ -708,7 +708,7 @@ void LLToolGrab::handleHoverActive(S32 x, S32 y, MASK mask)
 	{
 		if (!gAgentCamera.cameraMouselook() && 
 			!objectp->isHUDAttachment() && 
-			objectp->getRoot() == gAgentAvatar->getRoot())
+			objectp->getRoot() == gAgentAvatarp->getRoot())
 		{
 			// force focus to point in space where we were looking previously
 			gAgentCamera.setFocusGlobal(gAgentCamera.calcFocusPositionTargetGlobal(), LLUUID::null);
diff --git a/indra/newview/lltoolmorph.cpp b/indra/newview/lltoolmorph.cpp
index 67d696d7d74..969049ee657 100644
--- a/indra/newview/lltoolmorph.cpp
+++ b/indra/newview/lltoolmorph.cpp
@@ -139,20 +139,20 @@ void LLVisualParamHint::requestHintUpdates( LLVisualParamHint* exception1, LLVis
 
 BOOL LLVisualParamHint::needsRender()
 {
-	return mNeedsUpdate && mDelayFrames-- <= 0 && !gAgentAvatar->mAppearanceAnimating && mAllowsUpdates;
+	return mNeedsUpdate && mDelayFrames-- <= 0 && !gAgentAvatarp->mAppearanceAnimating && mAllowsUpdates;
 }
 
 void LLVisualParamHint::preRender(BOOL clear_depth)
 {
 	mLastParamWeight = mVisualParam->getWeight();
 	mVisualParam->setWeight(mVisualParamWeight, FALSE);
-	gAgentAvatar->setVisualParamWeight(mVisualParam->getID(), mVisualParamWeight, FALSE);
-	gAgentAvatar->setVisualParamWeight("Blink_Left", 0.f);
-	gAgentAvatar->setVisualParamWeight("Blink_Right", 0.f);
-	gAgentAvatar->updateComposites();
-	gAgentAvatar->updateVisualParams();
-	gAgentAvatar->updateGeometry(gAgentAvatar->mDrawable);
-	gAgentAvatar->updateLOD();
+	gAgentAvatarp->setVisualParamWeight(mVisualParam->getID(), mVisualParamWeight, FALSE);
+	gAgentAvatarp->setVisualParamWeight("Blink_Left", 0.f);
+	gAgentAvatarp->setVisualParamWeight("Blink_Right", 0.f);
+	gAgentAvatarp->updateComposites();
+	gAgentAvatarp->updateVisualParams();
+	gAgentAvatarp->updateGeometry(gAgentAvatarp->mDrawable);
+	gAgentAvatarp->updateLOD();
 
 	LLViewerDynamicTexture::preRender(clear_depth);
 }
@@ -193,7 +193,7 @@ BOOL LLVisualParamHint::render()
 	const std::string& cam_target_mesh_name = mVisualParam->getCameraTargetName();
 	if( !cam_target_mesh_name.empty() )
 	{
-		cam_target_joint = (LLViewerJointMesh*)gAgentAvatar->getJoint( cam_target_mesh_name );
+		cam_target_joint = (LLViewerJointMesh*)gAgentAvatarp->getJoint( cam_target_mesh_name );
 	}
 	if( !cam_target_joint )
 	{
@@ -201,11 +201,11 @@ BOOL LLVisualParamHint::render()
 	}
 	if( !cam_target_joint )
 	{
-		cam_target_joint = (LLViewerJointMesh*)gAgentAvatar->getJoint("mHead");
+		cam_target_joint = (LLViewerJointMesh*)gAgentAvatarp->getJoint("mHead");
 	}
 
 	LLQuaternion avatar_rotation;
-	LLJoint* root_joint = gAgentAvatar->getRootJoint();
+	LLJoint* root_joint = gAgentAvatarp->getRootJoint();
 	if( root_joint )
 	{
 		avatar_rotation = root_joint->getWorldRotation();
@@ -233,17 +233,17 @@ BOOL LLVisualParamHint::render()
 
 	LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, FALSE);
 
-	if (gAgentAvatar->mDrawable.notNull())
+	if (gAgentAvatarp->mDrawable.notNull())
 	{
-		LLDrawPoolAvatar *avatarPoolp = (LLDrawPoolAvatar *)gAgentAvatar->mDrawable->getFace(0)->getPool();
+		LLDrawPoolAvatar *avatarPoolp = (LLDrawPoolAvatar *)gAgentAvatarp->mDrawable->getFace(0)->getPool();
 		LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE);
 		gGL.setAlphaRejectSettings(LLRender::CF_ALWAYS);
 		gGL.setSceneBlendType(LLRender::BT_REPLACE);
-		avatarPoolp->renderAvatars(gAgentAvatar);  // renders only one avatar
+		avatarPoolp->renderAvatars(gAgentAvatarp);  // renders only one avatar
 		gGL.setSceneBlendType(LLRender::BT_ALPHA);
 		gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
 	}
-	gAgentAvatar->setVisualParamWeight(mVisualParam->getID(), mLastParamWeight);
+	gAgentAvatarp->setVisualParamWeight(mVisualParam->getID(), mLastParamWeight);
 	mVisualParam->setWeight(mLastParamWeight, FALSE);
 	gGL.color4f(1,1,1,1);
 	mGLTexturep->setGLTextureCreated(true);
@@ -294,9 +294,9 @@ BOOL LLVisualParamReset::render()
 {
 	if (sDirty)
 	{
-		gAgentAvatar->updateComposites();
-		gAgentAvatar->updateVisualParams();
-		gAgentAvatar->updateGeometry(gAgentAvatar->mDrawable);
+		gAgentAvatarp->updateComposites();
+		gAgentAvatarp->updateVisualParams();
+		gAgentAvatarp->updateGeometry(gAgentAvatarp->mDrawable);
 		sDirty = FALSE;
 	}
 
diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp
index 580b483b6b3..322da2e3432 100644
--- a/indra/newview/lltoolpie.cpp
+++ b/indra/newview/lltoolpie.cpp
@@ -206,7 +206,7 @@ BOOL LLToolPie::pickLeftMouseDownCallback()
 			break;
 		case CLICK_ACTION_SIT:
 			{
-				if (isAgentAvatarValid() && !gAgentAvatar->isSitting()) // agent not already sitting
+				if (isAgentAvatarValid() && !gAgentAvatarp->isSitting()) // agent not already sitting
 				{
 					handle_object_sit_or_stand();
 					// put focus in world when sitting on an object
@@ -330,7 +330,7 @@ BOOL LLToolPie::pickLeftMouseDownCallback()
 			}
 			object = (LLViewerObject*)object->getParent();
 		}
-		if (object && object == gAgentAvatar)
+		if (object && object == gAgentAvatarp)
 		{
 			// we left clicked on avatar, switch to focus mode
 			LLToolMgr::getInstance()->setTransientTool(LLToolCamera::getInstance());
@@ -412,7 +412,7 @@ ECursorType cursor_from_object(LLViewerObject* object)
 	{
 	case CLICK_ACTION_SIT:
 		{
-			if (isAgentAvatarValid() && !gAgentAvatar->isSitting()) // not already sitting?
+			if (isAgentAvatarValid() && !gAgentAvatarp->isSitting()) // not already sitting?
 			{
 				cursor = UI_CURSOR_TOOLSIT;
 			}
diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp
index 847852f8af0..91f01f0b362 100644
--- a/indra/newview/lltoolplacer.cpp
+++ b/indra/newview/lltoolplacer.cpp
@@ -434,7 +434,7 @@ BOOL LLToolPlacer::addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics )
 
 	// VEFFECT: AddObject
 	LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE);
-	effectp->setSourceObject((LLViewerObject*)gAgentAvatar);
+	effectp->setSourceObject((LLViewerObject*)gAgentAvatarp);
 	effectp->setPositionGlobal(regionp->getPosGlobalFromRegion(ray_end_region));
 	effectp->setDuration(LL_HUD_DUR_SHORT);
 	effectp->setColor(LLColor4U(gAgent.getEffectColor()));
diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp
index a45bb2a4ded..2065ba17912 100644
--- a/indra/newview/lltoolselect.cpp
+++ b/indra/newview/lltoolselect.cpp
@@ -169,8 +169,8 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi
 		}
 
 		if (!gAgentCamera.getFocusOnAvatar() &&										// if camera not glued to avatar
-			LLVOAvatar::findAvatarFromAttachment(object) != gAgentAvatar &&	// and it's not one of your attachments
-			object != gAgentAvatar)									// and it's not you
+			LLVOAvatar::findAvatarFromAttachment(object) != gAgentAvatarp &&	// and it's not one of your attachments
+			object != gAgentAvatarp)									// and it's not you
 		{
 			// have avatar turn to face the selected object(s)
 			LLVector3d selection_center = LLSelectMgr::getInstance()->getSelectionCenterGlobal();
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index f0f911b9963..823466e33ed 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -347,7 +347,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 		S32 attach_count = 0;
 		if (isAgentAvatarValid())
 		{
-			attach_count = gAgentAvatar->getAttachmentCount();
+			attach_count = gAgentAvatarp->getAttachmentCount();
 		}
 		F32 teleport_save_time = TELEPORT_EXPIRY + TELEPORT_EXPIRY_PER_ATTACHMENT * attach_count;
 		F32 teleport_elapsed = gTeleportDisplayTimer.getElapsedTimeF32();
@@ -1032,10 +1032,10 @@ LLRect get_whole_screen_region()
 
 bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::matrix4f &model)
 {
-	if (isAgentAvatarValid() && gAgentAvatar->hasHUDAttachment())
+	if (isAgentAvatarValid() && gAgentAvatarp->hasHUDAttachment())
 	{
 		F32 zoom_level = gAgentCamera.mHUDCurZoom;
-		LLBBox hud_bbox = gAgentAvatar->getHUDBBox();
+		LLBBox hud_bbox = gAgentAvatarp->getHUDBBox();
 		
 		F32 hud_depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f);
 		proj = gl_ortho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, hud_depth);
diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp
index d899c72e0e1..dd7390a907b 100644
--- a/indra/newview/llviewerkeyboard.cpp
+++ b/indra/newview/llviewerkeyboard.cpp
@@ -877,7 +877,7 @@ EKeyboardMode LLViewerKeyboard::getMode()
 	{
 		return MODE_EDIT_AVATAR;
 	}
-	else if (isAgentAvatarValid() && gAgentAvatar->isSitting())
+	else if (isAgentAvatarValid() && gAgentAvatarp->isSitting())
 	{
 		return MODE_SITTING;
 	}
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 49a3ed14dcc..9bf2a5fad2f 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -3025,7 +3025,7 @@ bool LLViewerMediaImpl::isObjectAttachedToAnotherAvatar(LLVOVolume *obj)
 		if (NULL != object)
 		{
 			LLVOAvatar *avatar = object->asAvatar();
-			if ((NULL != avatar) && (avatar != gAgentAvatar))
+			if ((NULL != avatar) && (avatar != gAgentAvatarp))
 			{
 				result = true;
 				break;
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index f838d1436dc..8d3bf4deab3 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -2694,8 +2694,8 @@ class LLSelfEnableRemoveAllAttachments : public view_listener_t
 		bool new_value = false;
 		if (isAgentAvatarValid())
 		{
-			for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); 
-				 iter != gAgentAvatar->mAttachmentPoints.end(); )
+			for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
+				 iter != gAgentAvatarp->mAttachmentPoints.end(); )
 			{
 				LLVOAvatar::attachment_map_t::iterator curiter = iter++;
 				LLViewerJointAttachment* attachment = curiter->second;
@@ -2825,7 +2825,7 @@ bool handle_go_to()
 
 	if (isAgentAvatarValid() && !gSavedSettings.getBOOL("AutoPilotLocksCamera"))
 	{
-		gAgentCamera.setFocusGlobal(gAgentCamera.getFocusTargetGlobal(), gAgentAvatar->getID());
+		gAgentCamera.setFocusGlobal(gAgentCamera.getFocusTargetGlobal(), gAgentAvatarp->getID());
 	}
 	else 
 	{
@@ -3364,7 +3364,7 @@ class LLSelfStandUp : public view_listener_t
 
 bool enable_standup_self()
 {
-	bool new_value = isAgentAvatarValid() && gAgentAvatar->isSitting();
+	bool new_value = isAgentAvatarValid() && gAgentAvatarp->isSitting();
 	return new_value;
 }
 
@@ -3695,7 +3695,7 @@ class LLLandSit : public view_listener_t
 		LLQuaternion target_rot;
 		if (isAgentAvatarValid())
 		{
-			target_rot = gAgentAvatar->getRotation();
+			target_rot = gAgentAvatarp->getRotation();
 		}
 		else
 		{
@@ -4588,7 +4588,7 @@ BOOL sitting_on_selection()
 	// Need to determine if avatar is sitting on this object
 	if (!isAgentAvatarValid()) return FALSE;
 
-	return (gAgentAvatar->isSitting() && gAgentAvatar->getRoot() == root_object);
+	return (gAgentAvatarp->isSitting() && gAgentAvatarp->getRoot() == root_object);
 }
 
 class LLToolsSaveToInventory : public view_listener_t
@@ -5841,7 +5841,7 @@ class LLObjectAttachToAvatar : public view_listener_t
 			S32 index = userdata.asInteger();
 			LLViewerJointAttachment* attachment_point = NULL;
 			if (index > 0)
-				attachment_point = get_if_there(gAgentAvatar->mAttachmentPoints, index, (LLViewerJointAttachment*)NULL);
+				attachment_point = get_if_there(gAgentAvatarp->mAttachmentPoints, index, (LLViewerJointAttachment*)NULL);
 			confirm_replace_attachment(0, attachment_point);
 		}
 		return true;
@@ -5862,8 +5862,8 @@ void near_attach_object(BOOL success, void *user_data)
 		U8 attachment_id = 0;
 		if (attachment)
 		{
-			for (LLVOAvatar::attachment_map_t::const_iterator iter = gAgentAvatar->mAttachmentPoints.begin();
-				 iter != gAgentAvatar->mAttachmentPoints.end(); ++iter)
+			for (LLVOAvatar::attachment_map_t::const_iterator iter = gAgentAvatarp->mAttachmentPoints.begin();
+				 iter != gAgentAvatarp->mAttachmentPoints.end(); ++iter)
 			{
 				if (iter->second == attachment)
 				{
@@ -5988,7 +5988,7 @@ class LLAttachmentDetachFromPoint : public view_listener_t
 {
 	bool handleEvent(const LLSD& user_data)
 	{
-		const LLViewerJointAttachment *attachment = get_if_there(gAgentAvatar->mAttachmentPoints, user_data.asInteger(), (LLViewerJointAttachment*)NULL);
+		const LLViewerJointAttachment *attachment = get_if_there(gAgentAvatarp->mAttachmentPoints, user_data.asInteger(), (LLViewerJointAttachment*)NULL);
 		if (attachment->getNumObjects() > 0)
 		{
 			gMessageSystem->newMessage("ObjectDetach");
@@ -6016,7 +6016,7 @@ static bool onEnableAttachmentLabel(LLUICtrl* ctrl, const LLSD& data)
 	LLMenuItemGL* menu = dynamic_cast<LLMenuItemGL*>(ctrl);
 	if (menu)
 	{
-		const LLViewerJointAttachment *attachment = get_if_there(gAgentAvatar->mAttachmentPoints, data["index"].asInteger(), (LLViewerJointAttachment*)NULL);
+		const LLViewerJointAttachment *attachment = get_if_there(gAgentAvatarp->mAttachmentPoints, data["index"].asInteger(), (LLViewerJointAttachment*)NULL);
 		if (attachment)
 		{
 			label = data["label"].asString();
@@ -6134,7 +6134,7 @@ class LLAttachmentEnableDrop : public view_listener_t
 		if (object && LLSelectMgr::getInstance()->getSelection()->contains(object,SELECT_ALL_TES ))
 		{
     		S32 attachmentID  = ATTACHMENT_ID_FROM_STATE(object->getState());
-			attachment = get_if_there(gAgentAvatar->mAttachmentPoints, attachmentID, (LLViewerJointAttachment*)NULL);
+			attachment = get_if_there(gAgentAvatarp->mAttachmentPoints, attachmentID, (LLViewerJointAttachment*)NULL);
 
 			if (attachment)
 			{
@@ -6266,8 +6266,8 @@ class LLAttachmentPointFilled : public view_listener_t
 	bool handleEvent(const LLSD& user_data)
 	{
 		bool enable = false;
-		LLVOAvatar::attachment_map_t::iterator found_it = gAgentAvatar->mAttachmentPoints.find(user_data.asInteger());
-		if (found_it != gAgentAvatar->mAttachmentPoints.end())
+		LLVOAvatar::attachment_map_t::iterator found_it = gAgentAvatarp->mAttachmentPoints.find(user_data.asInteger());
+		if (found_it != gAgentAvatarp->mAttachmentPoints.end())
 		{
 			enable = found_it->second->getNumObjects() > 0;
 		}
@@ -6486,8 +6486,8 @@ void handle_dump_attachments(void*)
 {
 	if(!isAgentAvatarValid()) return;
 
-	for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); 
-		 iter != gAgentAvatar->mAttachmentPoints.end(); )
+	for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
+		 iter != gAgentAvatarp->mAttachmentPoints.end(); )
 	{
 		LLVOAvatar::attachment_map_t::iterator curiter = iter++;
 		LLViewerJointAttachment* attachment = curiter->second;
@@ -6907,7 +6907,7 @@ void reload_vertex_shader(void *)
 
 void handle_dump_avatar_local_textures(void*)
 {
-	gAgentAvatar->dumpLocalTextures();
+	gAgentAvatarp->dumpLocalTextures();
 }
 
 void handle_dump_timers()
@@ -6930,7 +6930,7 @@ void handle_grab_texture(void* data)
 	if (!isAgentAvatarValid()) return;
 
 	// MULTI-WEARABLE: change to support an index
-	const LLUUID& asset_id = gAgentAvatar->grabLocalTexture(tex_index, 0);
+	const LLUUID& asset_id = gAgentAvatarp->grabLocalTexture(tex_index, 0);
 	LL_INFOS("texture") << "Adding baked texture " << asset_id << " to inventory." << llendl;
 	LLAssetType::EType asset_type = LLAssetType::AT_TEXTURE;
 	LLInventoryType::EType inv_type = LLInventoryType::IT_TEXTURE;
@@ -7003,7 +7003,7 @@ BOOL enable_grab_texture(void* data)
 	if (isAgentAvatarValid())
 	{
 		// MULTI-WEARABLE:
-		return gAgentAvatar->canGrabLocalTexture(index,0);
+		return gAgentAvatarp->canGrabLocalTexture(index,0);
 	}
 	return FALSE;
 }
@@ -7218,7 +7218,7 @@ void handle_rebake_textures(void*)
 
 	// Slam pending upload count to "unstick" things
 	bool slam_for_debug = true;
-	gAgentAvatar->forceBakeAllTextures(slam_for_debug);
+	gAgentAvatarp->forceBakeAllTextures(slam_for_debug);
 }
 
 void toggle_visibility(void* user_data)
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 96bb687bbb3..85f501b2a16 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -3004,7 +3004,7 @@ void process_teleport_finish(LLMessageSystem* msg, void**)
 
 	if (isAgentAvatarValid())
 	{
-		gAgentAvatar->clearChatText();
+		gAgentAvatarp->clearChatText();
 		gAgentCamera.slamLookAt(look_at);
 	}
 	gAgent.setPositionAgent(pos);
@@ -3151,9 +3151,9 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**)
 			LLNotificationsUtil::add("SystemMessageTip", args);
 
 			// Set the new position
-			gAgentAvatar->setPositionAgent(agent_pos);
-			gAgentAvatar->clearChat();
-			gAgentAvatar->slamPosition();
+			gAgentAvatarp->setPositionAgent(agent_pos);
+			gAgentAvatarp->clearChat();
+			gAgentAvatarp->slamPosition();
 		}
 	}
 	else
@@ -3215,7 +3215,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**)
 
 	if (isAgentAvatarValid())
 	{
-		gAgentAvatar->mFootPlane.clearVec();
+		gAgentAvatarp->mFootPlane.clearVec();
 	}
 	
 	// send walk-vs-run status
@@ -4175,7 +4175,7 @@ void process_avatar_sit_response(LLMessageSystem *mesgsys, void **user_data)
 	if (object)
 	{
 		LLVector3 sit_spot = object->getPositionAgent() + (sitPosition * object->getRotation());
-		if (!use_autopilot || isAgentAvatarValid() && gAgentAvatar->isSitting() && gAgentAvatar->getRoot() == object->getRoot())
+		if (!use_autopilot || isAgentAvatarValid() && gAgentAvatarp->isSitting() && gAgentAvatarp->getRoot() == object->getRoot())
 		{
 			//we're already sitting on this object, so don't autopilot
 		}
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index f3eb75bcd0b..8860b734bba 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -134,15 +134,15 @@ LLViewerObject *LLViewerObject::createObject(const LLUUID &id, const LLPCode pco
 	{
 		if (id == gAgentID)
 		{
-			if (!gAgentAvatar)
+			if (!gAgentAvatarp)
 			{
-				gAgentAvatar = new LLVOAvatarSelf(id, pcode, regionp);
+				gAgentAvatarp = new LLVOAvatarSelf(id, pcode, regionp);
 			}
 			else 
 			{
-				gAgentAvatar->updateRegion(regionp);
+				gAgentAvatarp->updateRegion(regionp);
 			}
-			res = gAgentAvatar;
+			res = gAgentAvatarp;
 		}
 		else
 		{
@@ -388,7 +388,7 @@ void LLViewerObject::markDead()
 			if (isAgentAvatarValid())
 			{
 				// stop motions associated with this object
-				gAgentAvatar->stopMotionFromSource(mID);
+				gAgentAvatarp->stopMotionFromSource(mID);
 			}
 		}
 
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index eb966a15359..5e0bd5b811b 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -894,8 +894,8 @@ void LLViewerObjectList::removeDrawable(LLDrawable* drawablep)
 
 BOOL LLViewerObjectList::killObject(LLViewerObject *objectp)
 {
-	// Don't ever kill gAgentAvatar, just mark it as null region instead.
-	if (objectp == gAgentAvatar)
+	// Don't ever kill gAgentAvatarp, just mark it as null region instead.
+	if (objectp == gAgentAvatarp)
 	{
 		objectp->setRegion(NULL);
 		return FALSE;
@@ -1218,8 +1218,8 @@ void LLViewerObjectList::generatePickList(LLCamera &camera)
 		// add all hud objects to pick list
 		if (isAgentAvatarValid())
 		{
-			for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); 
-				 iter != gAgentAvatar->mAttachmentPoints.end(); )
+			for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
+				 iter != gAgentAvatarp->mAttachmentPoints.end(); )
 			{
 				LLVOAvatar::attachment_map_t::iterator curiter = iter++;
 				LLViewerJointAttachment* attachment = curiter->second;
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 4b6ac07a947..f3ef4b38e90 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -367,7 +367,7 @@ class LLDebugText
 
 			if (isAgentAvatarValid())
 			{
-				tvector = gAgent.getPosGlobalFromAgent(gAgentAvatar->mRoot.getWorldPosition());
+				tvector = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mRoot.getWorldPosition());
 				agent_root_center_text = llformat("AgentRootCenter %f %f %f",
 												  (F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ]));
 			}
@@ -3150,7 +3150,7 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls,
 		// setup HUD render
 		if (selection->getSelectType() == SELECT_TYPE_HUD && LLSelectMgr::getInstance()->getSelection()->getObjectCount())
 		{
-			LLBBox hud_bbox = gAgentAvatar->getHUDBBox();
+			LLBBox hud_bbox = gAgentAvatarp->getHUDBBox();
 
 			// set up transform to encompass bounding box of HUD
 			glMatrixMode(GL_PROJECTION);
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 8e9e15352a1..e82a988ed22 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -962,12 +962,12 @@ void LLVOAvatar::restoreGL()
 {
 	if (!isAgentAvatarValid()) return;
 
-	gAgentAvatar->setCompositeUpdatesEnabled(TRUE);
-	for (U32 i = 0; i < gAgentAvatar->mBakedTextureDatas.size(); i++)
+	gAgentAvatarp->setCompositeUpdatesEnabled(TRUE);
+	for (U32 i = 0; i < gAgentAvatarp->mBakedTextureDatas.size(); i++)
 	{
-		gAgentAvatar->invalidateComposite(gAgentAvatar->mBakedTextureDatas[i].mTexLayerSet, FALSE);
+		gAgentAvatarp->invalidateComposite(gAgentAvatarp->mBakedTextureDatas[i].mTexLayerSet, FALSE);
 	}
-	gAgentAvatar->updateMeshTextures();
+	gAgentAvatarp->updateMeshTextures();
 }
 
 //static
@@ -6871,7 +6871,7 @@ void LLVOAvatar::dumpArchetypeXML( void* )
 		const std::string& wearable_name = LLWearableDictionary::getTypeName((EWearableType)type);
 		apr_file_printf( file, "\n\t\t<!-- wearable: %s -->\n", wearable_name.c_str() );
 
-		for (LLVisualParam* param = gAgentAvatar->getFirstVisualParam(); param; param = gAgentAvatar->getNextVisualParam())
+		for (LLVisualParam* param = gAgentAvatarp->getFirstVisualParam(); param; param = gAgentAvatarp->getNextVisualParam())
 		{
 			LLViewerVisualParam* viewer_param = (LLViewerVisualParam*)param;
 			if( (viewer_param->getWearableType() == type) && 
@@ -6887,7 +6887,7 @@ void LLVOAvatar::dumpArchetypeXML( void* )
 			if (LLVOAvatarDictionary::getTEWearableType((ETextureIndex)te) == type)
 			{
 				// MULTIPLE_WEARABLES: extend to multiple wearables?
-				LLViewerTexture* te_image = ((LLVOAvatar *)(gAgentAvatar))->getImage((ETextureIndex)te, 0);
+				LLViewerTexture* te_image = ((LLVOAvatar *)(gAgentAvatarp))->getImage((ETextureIndex)te, 0);
 				if( te_image )
 				{
 					std::string uuid_str;
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 0183061c0e4..74ee6a05d9f 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -67,12 +67,12 @@
 
 #include <boost/lexical_cast.hpp>
 
-LLVOAvatarSelf *gAgentAvatar = NULL;
+LLVOAvatarSelf *gAgentAvatarp = NULL;
 BOOL isAgentAvatarValid()
 {
-	return (gAgentAvatar &&
-			(gAgentAvatar->getRegion() != NULL) &&
-			(!gAgentAvatar->isDead()));
+	return (gAgentAvatarp &&
+			(gAgentAvatarp->getRegion() != NULL) &&
+			(!gAgentAvatarp->isDead()));
 }
 
 using namespace LLVOAvatarDefines;
@@ -1687,7 +1687,7 @@ void LLVOAvatarSelf::onLocalTextureLoaded(BOOL success, LLViewerFetchedTexture *
 void LLVOAvatarSelf::dumpTotalLocalTextureByteCount()
 {
 	S32 gl_bytes = 0;
-	gAgentAvatar->getLocalTextureByteCount(&gl_bytes);
+	gAgentAvatarp->getLocalTextureByteCount(&gl_bytes);
 	llinfos << "Total Avatar LocTex GL:" << (gl_bytes/1024) << "KB" << llendl;
 }
 
@@ -1961,13 +1961,13 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**)
 		const LLVOAvatarDictionary::TextureEntry *texture_dict = iter->second;
 		if (texture_dict->mIsBakedTexture)
 		{
-			if (texture_id == gAgentAvatar->getTEImage(index)->getID())
+			if (texture_id == gAgentAvatarp->getTEImage(index)->getID())
 			{
-				LLTexLayerSet* layer_set = gAgentAvatar->getLayerSet(index);
+				LLTexLayerSet* layer_set = gAgentAvatarp->getLayerSet(index);
 				if (layer_set)
 				{
 					llinfos << "TAT: rebake - matched entry " << (S32)index << llendl;
-					gAgentAvatar->invalidateComposite(layer_set, TRUE);
+					gAgentAvatarp->invalidateComposite(layer_set, TRUE);
 					found = TRUE;
 					LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES);
 				}
@@ -1978,12 +1978,12 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**)
 	// If texture not found, rebake all entries.
 	if (!found)
 	{
-		gAgentAvatar->forceBakeAllTextures();
+		gAgentAvatarp->forceBakeAllTextures();
 	}
 	else
 	{
 		// Not sure if this is necessary, but forceBakeAllTextures() does it.
-		gAgentAvatar->updateMeshTextures();
+		gAgentAvatarp->updateMeshTextures();
 	}
 }
 
@@ -2065,7 +2065,7 @@ void LLVOAvatarSelf::onCustomizeEnd()
 {
 	if (isAgentAvatarValid())
 	{
-		gAgentAvatar->invalidateAll();
+		gAgentAvatarp->invalidateAll();
 	}
 }
 
diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h
index 706a02c088b..3c7ec04fabb 100644
--- a/indra/newview/llvoavatarself.h
+++ b/indra/newview/llvoavatarself.h
@@ -334,7 +334,7 @@ class LLVOAvatarSelf :
 
 };
 
-extern LLVOAvatarSelf *gAgentAvatar;
+extern LLVOAvatarSelf *gAgentAvatarp;
 
 BOOL isAgentAvatarValid();
 
diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp
index 710348ac4be..e8fdccf30e0 100644
--- a/indra/newview/llvoiceclient.cpp
+++ b/indra/newview/llvoiceclient.cpp
@@ -5893,9 +5893,9 @@ void LLVoiceClient::updatePosition(void)
 					rot);				// rotation matrix
 					
 			// Send the current avatar position to the voice code
-			rot = gAgentAvatar->getRootJoint()->getWorldRotation().getMatrix3();
+			rot = gAgentAvatarp->getRootJoint()->getWorldRotation().getMatrix3();
 	
-			pos = gAgentAvatar->getPositionGlobal();
+			pos = gAgentAvatarp->getPositionGlobal();
 			// TODO: Can we get the head offset from outside the LLVOAvatar?
 //			pos += LLVector3d(mHeadOffset);
 			pos += LLVector3d(0.f, 0.f, 1.f);
diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp
index 23a14c07ab7..63f99273fe1 100644
--- a/indra/newview/llwearable.cpp
+++ b/indra/newview/llwearable.cpp
@@ -65,9 +65,9 @@ class LLOverrideBakedTextureUpdate
 		U32 num_bakes = (U32) LLVOAvatarDefines::BAKED_NUM_INDICES;
 		for( U32 index = 0; index < num_bakes; ++index )
 		{
-			composite_enabled[index] = gAgentAvatar->isCompositeUpdateEnabled(index);
+			composite_enabled[index] = gAgentAvatarp->isCompositeUpdateEnabled(index);
 		}
-		gAgentAvatar->setCompositeUpdatesEnabled(temp_state);
+		gAgentAvatarp->setCompositeUpdatesEnabled(temp_state);
 	}
 
 	~LLOverrideBakedTextureUpdate()
@@ -75,7 +75,7 @@ class LLOverrideBakedTextureUpdate
 		U32 num_bakes = (U32)LLVOAvatarDefines::BAKED_NUM_INDICES;		
 		for( U32 index = 0; index < num_bakes; ++index )
 		{
-			gAgentAvatar->setCompositeUpdatesEnabled(index, composite_enabled[index]);
+			gAgentAvatarp->setCompositeUpdatesEnabled(index, composite_enabled[index]);
 		}
 	}
 private:
@@ -202,9 +202,9 @@ BOOL LLWearable::exportFile(LLFILE* file) const
 
 void LLWearable::createVisualParams()
 {
-	for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatar->getFirstVisualParam(); 
+	for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam(); 
 		 param;
-		 param = (LLViewerVisualParam*) gAgentAvatar->getNextVisualParam())
+		 param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam())
 	{
 		if (param->getWearableType() == mType)
 		{
@@ -224,7 +224,7 @@ void LLWearable::createVisualParams()
 		param->resetDrivenParams();
 		if(!param->linkDrivenParams(boost::bind(wearable_function,(LLWearable*)this, _1), false))
 		{
-			if( !param->linkDrivenParams(boost::bind(avatar_function,gAgentAvatar,_1 ), true))
+			if( !param->linkDrivenParams(boost::bind(avatar_function,gAgentAvatarp,_1 ), true))
 			{
 				llwarns << "could not link driven params for wearable " << getName() << " id: " << param->getID() << llendl;
 				continue;
@@ -474,9 +474,9 @@ BOOL LLWearable::isOldVersion() const
 	}
 
 	S32 param_count = 0;
-	for( LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatar->getFirstVisualParam(); 
+	for( LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam(); 
 		param;
-		param = (LLViewerVisualParam*) gAgentAvatar->getNextVisualParam() )
+		param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam() )
 	{
 		if( (param->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) )
 		{
@@ -524,9 +524,9 @@ BOOL LLWearable::isDirty() const
 {
 	if (!isAgentAvatarValid()) return FALSE;
 
-	for( LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatar->getFirstVisualParam(); 
+	for( LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam(); 
 		param;
-		param = (LLViewerVisualParam*) gAgentAvatar->getNextVisualParam() )
+		param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam() )
 	{
 		if( (param->getWearableType() == mType) 
 			&& (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) 
@@ -589,7 +589,7 @@ void LLWearable::setParamsToDefaults()
 {
 	if (!isAgentAvatarValid()) return;
 
-	for( LLVisualParam* param = gAgentAvatar->getFirstVisualParam(); param; param = gAgentAvatar->getNextVisualParam() )
+	for( LLVisualParam* param = gAgentAvatarp->getFirstVisualParam(); param; param = gAgentAvatarp->getNextVisualParam() )
 	{
 		if( (((LLViewerVisualParam*)param)->getWearableType() == mType ) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) )
 		{
@@ -627,10 +627,10 @@ void LLWearable::writeToAvatar()
 {
 	if (!isAgentAvatarValid()) return;
 
-	ESex old_sex = gAgentAvatar->getSex();
+	ESex old_sex = gAgentAvatarp->getSex();
 
 	// Pull params
-	for( LLVisualParam* param = gAgentAvatar->getFirstVisualParam(); param; param = gAgentAvatar->getNextVisualParam() )
+	for( LLVisualParam* param = gAgentAvatarp->getFirstVisualParam(); param; param = gAgentAvatarp->getNextVisualParam() )
 	{
 		// cross-wearable parameters are not authoritative, as they are driven by a different wearable. So don't copy the values to the
 		// avatar object if cross wearable. Cross wearable params get their values from the avatar, they shouldn't write the other way.
@@ -639,7 +639,7 @@ void LLWearable::writeToAvatar()
 			S32 param_id = param->getID();
 			F32 weight = getVisualParamWeight(param_id);
 
-			gAgentAvatar->setVisualParamWeight( param_id, weight, FALSE );
+			gAgentAvatarp->setVisualParamWeight( param_id, weight, FALSE );
 		}
 	}
 
@@ -660,14 +660,14 @@ void LLWearable::writeToAvatar()
 			}
 			LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture( image_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE );
 			// MULTI-WEARABLE: replace hard-coded 0
-			gAgentAvatar->setLocalTextureTE(te, image, 0);
+			gAgentAvatarp->setLocalTextureTE(te, image, 0);
 		}
 	}
 
-	ESex new_sex = gAgentAvatar->getSex();
+	ESex new_sex = gAgentAvatarp->getSex();
 	if( old_sex != new_sex )
 	{
-		gAgentAvatar->updateSexDependentLayerSets( FALSE );
+		gAgentAvatarp->updateSexDependentLayerSets( FALSE );
 	}	
 	
 //	if( upload_bake )
@@ -693,12 +693,12 @@ void LLWearable::removeFromAvatar( EWearableType type, BOOL upload_bake )
 	}
 
 	// Pull params
-	for( LLVisualParam* param = gAgentAvatar->getFirstVisualParam(); param; param = gAgentAvatar->getNextVisualParam() )
+	for( LLVisualParam* param = gAgentAvatarp->getFirstVisualParam(); param; param = gAgentAvatarp->getNextVisualParam() )
 	{
 		if( (((LLViewerVisualParam*)param)->getWearableType() == type) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) )
 		{
 			S32 param_id = param->getID();
-			gAgentAvatar->setVisualParamWeight( param_id, param->getDefaultWeight(), upload_bake );
+			gAgentAvatarp->setVisualParamWeight( param_id, param->getDefaultWeight(), upload_bake );
 		}
 	}
 
@@ -707,8 +707,8 @@ void LLWearable::removeFromAvatar( EWearableType type, BOOL upload_bake )
 		gFloaterCustomize->setWearable(type, NULL, PERM_ALL, TRUE);
 	}
 
-	gAgentAvatar->updateVisualParams();
-	gAgentAvatar->wearableUpdated(type, TRUE);
+	gAgentAvatarp->updateVisualParams();
+	gAgentAvatarp->wearableUpdated(type, TRUE);
 
 //	if( upload_bake )
 //	{
@@ -733,9 +733,9 @@ void LLWearable::copyDataFrom(const LLWearable* src)
 
 	mSavedVisualParamMap.clear();
 	// Deep copy of mVisualParamMap (copies only those params that are current, filling in defaults where needed)
-	for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatar->getFirstVisualParam(); 
+	for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam(); 
 		param;
-		param = (LLViewerVisualParam*) gAgentAvatar->getNextVisualParam() )
+		param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam() )
 	{
 		if( (param->getWearableType() == mType) )
 		{
@@ -845,7 +845,7 @@ void LLWearable::setVisualParams()
 		S32 id = iter->first;
 		LLVisualParam *wearable_param = iter->second;
 		F32 value = wearable_param->getWeight();
-		gAgentAvatar->setVisualParamWeight(id, value, FALSE);
+		gAgentAvatarp->setVisualParamWeight(id, value, FALSE);
 	}
 }
 
@@ -986,7 +986,7 @@ BOOL LLWearable::isOnTop() const
 
 void LLWearable::createLayers(S32 te)
 {
-	LLTexLayerSet *layer_set = gAgentAvatar->getLayerSet((ETextureIndex)te);
+	LLTexLayerSet *layer_set = gAgentAvatarp->getLayerSet((ETextureIndex)te);
 	if (layer_set)
 	{
 		layer_set->cloneTemplates(mTEMap[te], (ETextureIndex)te, this);
@@ -1084,9 +1084,9 @@ void LLWearable::destroyTextures()
 void LLWearable::pullCrossWearableValues()
 {
 	// scan through all of the avatar's visual parameters
-	for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatar->getFirstVisualParam(); 
+	for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatarp->getFirstVisualParam(); 
 		 param;
-		 param = (LLViewerVisualParam*) gAgentAvatar->getNextVisualParam())
+		 param = (LLViewerVisualParam*) gAgentAvatarp->getNextVisualParam())
 	{
 		if( param )
 		{
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index fda89fae608..4ca251af3e2 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -3862,8 +3862,8 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects, BOOL render
 		glh::matrix4f save_model(glh_get_current_modelview());
 
 		setup_hud_matrices(screen_rect);
-		for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); 
-			 iter != gAgentAvatar->mAttachmentPoints.end(); )
+		for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
+			 iter != gAgentAvatarp->mAttachmentPoints.end(); )
 		{
 			LLVOAvatar::attachment_map_t::iterator curiter = iter++;
 			LLViewerJointAttachment* attachment = curiter->second;
@@ -3965,7 +3965,7 @@ void LLPipeline::rebuildPools()
 
 	if (isAgentAvatarValid())
 	{
-		gAgentAvatar->rebuildHUD();
+		gAgentAvatarp->rebuildHUD();
 	}
 }
 
@@ -4598,7 +4598,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 	}
 
 	if (isAgentAvatarValid() &&
-		gAgentAvatar->mSpecialRenderMode == 3)
+		gAgentAvatarp->mSpecialRenderMode == 3)
 	{
 		LLColor4  light_color = LLColor4::white;
 		light_color.mV[3] = 0.0f;
@@ -4709,11 +4709,11 @@ void LLPipeline::enableLightsDynamic()
 
 	if (isAgentAvatarValid() && getLightingDetail() <= 0)
 	{
-		if (gAgentAvatar->mSpecialRenderMode == 0) // normal
+		if (gAgentAvatarp->mSpecialRenderMode == 0) // normal
 		{
 			gPipeline.enableLightsAvatar();
 		}
-		else if (gAgentAvatar->mSpecialRenderMode >= 1)  // anim preview
+		else if (gAgentAvatarp->mSpecialRenderMode >= 1)  // anim preview
 		{
 			gPipeline.enableLightsAvatarEdit(LLColor4(0.7f, 0.6f, 0.3f, 1.f));
 		}
@@ -7106,7 +7106,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 
 		if (!skip_avatar_update)
 		{
-			gAgentAvatar->updateAttachmentVisibility(CAMERA_MODE_THIRD_PERSON);
+			gAgentAvatarp->updateAttachmentVisibility(CAMERA_MODE_THIRD_PERSON);
 		}
 		LLVertexBuffer::unbind();
 
@@ -7332,7 +7332,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
 
 		if (!skip_avatar_update)
 		{
-			gAgentAvatar->updateAttachmentVisibility(gAgentCamera.getCameraMode());
+			gAgentAvatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode());
 		}
 	}
 }
-- 
GitLab