From fc49539b36adfd4c87d7824db5d94a7858683f3d Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Tue, 23 Mar 2010 15:59:52 -0400 Subject: EXT-2959 : Full out camera functions from llagent to llagentcamera First check-in; only compiles, nothing more. --- indra/newview/llviewerkeyboard.cpp | 43 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'indra/newview/llviewerkeyboard.cpp') diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp index f757155b94..4034d8c57d 100644 --- a/indra/newview/llviewerkeyboard.cpp +++ b/indra/newview/llviewerkeyboard.cpp @@ -36,6 +36,7 @@ #include "llviewerkeyboard.h" #include "llmath.h" #include "llagent.h" +#include "llagentcamera.h" #include "llnearbychatbar.h" #include "llviewercontrol.h" #include "llfocusmgr.h" @@ -279,7 +280,7 @@ F32 get_orbit_rate() void camera_spin_around_ccw( EKeystate s ) { if( KEYSTATE_UP == s ) return; - gAgent.unlockView(); + gAgentCamera.unlockView(); gAgent.setOrbitLeftKey( get_orbit_rate() ); } @@ -287,14 +288,14 @@ void camera_spin_around_ccw( EKeystate s ) void camera_spin_around_cw( EKeystate s ) { if( KEYSTATE_UP == s ) return; - gAgent.unlockView(); + gAgentCamera.unlockView(); gAgent.setOrbitRightKey( get_orbit_rate() ); } void camera_spin_around_ccw_sitting( EKeystate s ) { if( KEYSTATE_UP == s ) return; - if (gAgent.rotateGrabbed() || gAgent.sitCameraEnabled()) + if (gAgent.rotateGrabbed() || gAgentCamera.sitCameraEnabled()) { //send keystrokes, but do not change camera agent_turn_right(s); @@ -310,7 +311,7 @@ void camera_spin_around_ccw_sitting( EKeystate s ) void camera_spin_around_cw_sitting( EKeystate s ) { if( KEYSTATE_UP == s ) return; - if (gAgent.rotateGrabbed() || gAgent.sitCameraEnabled()) + if (gAgent.rotateGrabbed() || gAgentCamera.sitCameraEnabled()) { //send keystrokes, but do not change camera agent_turn_left(s); @@ -326,7 +327,7 @@ void camera_spin_around_cw_sitting( EKeystate s ) void camera_spin_over( EKeystate s ) { if( KEYSTATE_UP == s ) return; - gAgent.unlockView(); + gAgentCamera.unlockView(); gAgent.setOrbitUpKey( get_orbit_rate() ); } @@ -334,14 +335,14 @@ void camera_spin_over( EKeystate s ) void camera_spin_under( EKeystate s ) { if( KEYSTATE_UP == s ) return; - gAgent.unlockView(); + gAgentCamera.unlockView(); gAgent.setOrbitDownKey( get_orbit_rate() ); } void camera_spin_over_sitting( EKeystate s ) { if( KEYSTATE_UP == s ) return; - if (gAgent.upGrabbed() || gAgent.sitCameraEnabled()) + if (gAgent.upGrabbed() || gAgentCamera.sitCameraEnabled()) { //send keystrokes, but do not change camera agent_jump(s); @@ -357,7 +358,7 @@ void camera_spin_over_sitting( EKeystate s ) void camera_spin_under_sitting( EKeystate s ) { if( KEYSTATE_UP == s ) return; - if (gAgent.downGrabbed() || gAgent.sitCameraEnabled()) + if (gAgent.downGrabbed() || gAgentCamera.sitCameraEnabled()) { //send keystrokes, but do not change camera agent_push_down(s); @@ -372,7 +373,7 @@ void camera_spin_under_sitting( EKeystate s ) void camera_move_forward( EKeystate s ) { if( KEYSTATE_UP == s ) return; - gAgent.unlockView(); + gAgentCamera.unlockView(); gAgent.setOrbitInKey( get_orbit_rate() ); } @@ -380,14 +381,14 @@ void camera_move_forward( EKeystate s ) void camera_move_backward( EKeystate s ) { if( KEYSTATE_UP == s ) return; - gAgent.unlockView(); + gAgentCamera.unlockView(); gAgent.setOrbitOutKey( get_orbit_rate() ); } void camera_move_forward_sitting( EKeystate s ) { if( KEYSTATE_UP == s ) return; - if (gAgent.forwardGrabbed() || gAgent.sitCameraEnabled()) + if (gAgent.forwardGrabbed() || gAgentCamera.sitCameraEnabled()) { agent_push_forward(s); } @@ -402,7 +403,7 @@ void camera_move_backward_sitting( EKeystate s ) { if( KEYSTATE_UP == s ) return; - if (gAgent.backwardGrabbed() || gAgent.sitCameraEnabled()) + if (gAgent.backwardGrabbed() || gAgentCamera.sitCameraEnabled()) { agent_push_backward(s); } @@ -415,56 +416,56 @@ void camera_move_backward_sitting( EKeystate s ) void camera_pan_up( EKeystate s ) { if( KEYSTATE_UP == s ) return; - gAgent.unlockView(); + gAgentCamera.unlockView(); gAgent.setPanUpKey( get_orbit_rate() ); } void camera_pan_down( EKeystate s ) { if( KEYSTATE_UP == s ) return; - gAgent.unlockView(); + gAgentCamera.unlockView(); gAgent.setPanDownKey( get_orbit_rate() ); } void camera_pan_left( EKeystate s ) { if( KEYSTATE_UP == s ) return; - gAgent.unlockView(); + gAgentCamera.unlockView(); gAgent.setPanLeftKey( get_orbit_rate() ); } void camera_pan_right( EKeystate s ) { if( KEYSTATE_UP == s ) return; - gAgent.unlockView(); + gAgentCamera.unlockView(); gAgent.setPanRightKey( get_orbit_rate() ); } void camera_pan_in( EKeystate s ) { if( KEYSTATE_UP == s ) return; - gAgent.unlockView(); + gAgentCamera.unlockView(); gAgent.setPanInKey( get_orbit_rate() ); } void camera_pan_out( EKeystate s ) { if( KEYSTATE_UP == s ) return; - gAgent.unlockView(); + gAgentCamera.unlockView(); gAgent.setPanOutKey( get_orbit_rate() ); } void camera_move_forward_fast( EKeystate s ) { if( KEYSTATE_UP == s ) return; - gAgent.unlockView(); + gAgentCamera.unlockView(); gAgent.setOrbitInKey(2.5f); } void camera_move_backward_fast( EKeystate s ) { if( KEYSTATE_UP == s ) return; - gAgent.unlockView(); + gAgentCamera.unlockView(); gAgent.setOrbitOutKey(2.5f); } @@ -868,7 +869,7 @@ S32 LLViewerKeyboard::loadBindings(const std::string& filename) EKeyboardMode LLViewerKeyboard::getMode() { - if ( gAgent.cameraMouselook() ) + if ( gAgentCamera.cameraMouselook() ) { return MODE_FIRST_PERSON; } -- cgit v1.3 From cc4a9b5640f4295c8af78efd4271a251434e39c6 Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Wed, 24 Mar 2010 16:12:01 -0400 Subject: EXT-2959 : Pull out camera functions from llagent to llagentcamera #2 checkin. Superficial cleanup and some bug fixing (e.g. took out duplicate mDrawDistance from llagent, took out gAgentCameraHACK and gAgentHACK). --- indra/newview/llagent.cpp | 3933 +++++++----------------------------- indra/newview/llagent.h | 296 +-- indra/newview/llagentcamera.cpp | 412 ++-- indra/newview/llagentcamera.h | 10 +- indra/newview/llappviewer.cpp | 4 +- indra/newview/lljoystickbutton.cpp | 16 +- indra/newview/llstartup.cpp | 2 +- indra/newview/llviewercamera.cpp | 3 +- indra/newview/llviewercontrol.cpp | 3 +- indra/newview/llviewerdisplay.cpp | 2 +- indra/newview/llviewerkeyboard.cpp | 52 +- indra/newview/llviewermessage.cpp | 2 +- indra/newview/llviewerwindow.cpp | 2 +- 13 files changed, 921 insertions(+), 3816 deletions(-) (limited to 'indra/newview/llviewerkeyboard.cpp') diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 5ee026f021..5dd4215206 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -82,8 +82,6 @@ #include "llworld.h" #include "llworldmap.h" -LLAgentCamera gAgentCameraHACK; // Seraph delete - using namespace LLVOAvatarDefines; extern LLMenuBarGL* gMenuBarView; @@ -110,65 +108,20 @@ const F32 AUTOPILOT_MAX_TIME_NO_PROGRESS = 1.5f; // seconds const LLVector3d FACE_EDIT_CAMERA_OFFSET(0.4f, -0.05f, 0.07f); const LLVector3d FACE_EDIT_TARGET_OFFSET(0.f, 0.f, 0.05f); -/* -// Mousewheel camera zoom -const F32 MIN_ZOOM_FRACTION = 0.25f; -const F32 INITIAL_ZOOM_FRACTION = 1.f; -const F32 MAX_ZOOM_FRACTION = 8.f; -*/ - const F32 METERS_PER_WHEEL_CLICK = 1.f; const F32 MAX_TIME_DELTA = 1.f; -/* -const F32 CAMERA_ZOOM_HALF_LIFE = 0.07f; // seconds -const F32 FOV_ZOOM_HALF_LIFE = 0.07f; // seconds - -const F32 CAMERA_FOCUS_HALF_LIFE = 0.f;//0.02f; -const F32 CAMERA_LAG_HALF_LIFE = 0.25f; -const F32 MIN_CAMERA_LAG = 0.5f; -const F32 MAX_CAMERA_LAG = 5.f; - -const F32 CAMERA_COLLIDE_EPSILON = 0.1f; -const F32 MIN_CAMERA_DISTANCE = 0.1f; -const F32 AVATAR_ZOOM_MIN_X_FACTOR = 0.55f; -const F32 AVATAR_ZOOM_MIN_Y_FACTOR = 0.7f; -const F32 AVATAR_ZOOM_MIN_Z_FACTOR = 1.15f; - -const F32 MAX_CAMERA_DISTANCE_FROM_AGENT = 50.f; - -const F32 MAX_CAMERA_SMOOTH_DISTANCE = 50.0f; - -const F32 HEAD_BUFFER_SIZE = 0.3f; -const F32 CUSTOMIZE_AVATAR_CAMERA_ANIM_SLOP = 0.2f; - -const F32 LAND_MIN_ZOOM = 0.15f; -const F32 AVATAR_MIN_ZOOM = 0.5f; -const F32 OBJECT_MIN_ZOOM = 0.02f; - -const F32 APPEARANCE_MIN_ZOOM = 0.39f; -const F32 APPEARANCE_MAX_ZOOM = 8.f; -*/ - // fidget constants const F32 MIN_FIDGET_TIME = 8.f; // seconds const F32 MAX_FIDGET_TIME = 20.f; // seconds const S32 MAX_NUM_CHAT_POSITIONS = 10; -/* -const F32 GROUND_TO_AIR_CAMERA_TRANSITION_TIME = 0.5f; -const F32 GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME = 0.5f; -*/ const F32 MAX_VELOCITY_AUTO_LAND_SQUARED = 4.f * 4.f; const F32 MAX_FOCUS_OFFSET = 20.f; -/* -const F32 OBJECT_EXTENTS_PADDING = 0.5f; -*/ - const F32 MIN_RADIUS_ALPHA_SIZZLE = 0.5f; const F64 CHAT_AGE_FAST_RATE = 3.0; @@ -231,20 +184,12 @@ bool handleSlowMotionAnimation(const LLSD& newvalue) // LLAgent() //----------------------------------------------------------------------------- LLAgent::LLAgent() : - mDrawDistance( DEFAULT_FAR_PLANE ), - mGroupPowers(0), mHideGroupTitle(FALSE), mGroupID(), -//// mLookAt(NULL), -//// mPointAt(NULL), - -//// mHUDTargetZoom(1.f), -//// mHUDCurZoom(1.f), mInitialized(FALSE), mListener(), -//// mForceMouselook(FALSE), mDoubleTapRunTimer(), mDoubleTapRunMode(DOUBLETAP_NONE), @@ -267,48 +212,10 @@ LLAgent::LLAgent() : mRenderState(0), mTypingTimer(), -//// mCameraMode( CAMERA_MODE_THIRD_PERSON ), -//// mLastCameraMode( CAMERA_MODE_THIRD_PERSON ), mViewsPushed(FALSE), -//// mCameraPreset(CAMERA_PRESET_REAR_VIEW), - mCustomAnim(FALSE), mShowAvatar(TRUE), -//// mCameraAnimating( FALSE ), -//// mAnimationCameraStartGlobal(), -//// mAnimationFocusStartGlobal(), -//// mAnimationTimer(), -//// mAnimationDuration(0.33f), - -//// mCameraFOVZoomFactor(0.f), -//// mCameraCurrentFOVZoomFactor(0.f), -//// mCameraFocusOffset(), -//// mCameraFOVDefault(DEFAULT_FIELD_OF_VIEW), - -//// mCameraCollidePlane(), - -//// mCurrentCameraDistance(2.f), // meters, set in init() -//// mTargetCameraDistance(2.f), -//// mCameraZoomFraction(1.f), // deprecated -//// mThirdPersonHeadOffset(0.f, 0.f, 1.f), -//// mSitCameraEnabled(FALSE), -//// mCameraSmoothingLastPositionGlobal(), -//// mCameraSmoothingLastPositionAgent(), -//// mCameraSmoothingStop(FALSE), - -//// mCameraUpVector(LLVector3::z_axis), // default is straight up - -//// mFocusOnAvatar(TRUE), -//// mFocusGlobal(), -//// mFocusTargetGlobal(), -//// mFocusObject(NULL), -//// mFocusObjectDist(0.f), -//// mFocusObjectOffset(), -//// mFocusDotRadius( 0.1f ), // meters -//// mTrackFocusObject(TRUE), -// mUIOffset(0.f), - mFrameAgent(), mIsBusy(FALSE), @@ -320,20 +227,6 @@ LLAgent::LLAgent() : mYawKey(0.f), mPitchKey(0.f), - mOrbitLeftKey(0.f), - mOrbitRightKey(0.f), - mOrbitUpKey(0.f), - mOrbitDownKey(0.f), - mOrbitInKey(0.f), - mOrbitOutKey(0.f), - - mPanUpKey(0.f), - mPanDownKey(0.f), - mPanLeftKey(0.f), - mPanRightKey(0.f), - mPanInKey(0.f), - mPanOutKey(0.f), - mControlFlags(0x00000000), mbFlagsDirty(FALSE), mbFlagsNeedReset(FALSE), @@ -371,7 +264,6 @@ LLAgent::LLAgent() : mControlsTakenPassedOnCount[i] = 0; } -//// mFollowCam.setMaxCameraDistantFromSubject( MAX_CAMERA_DISTANCE_FROM_AGENT ); mListener.reset(new LLAgentListener(*this)); } @@ -385,39 +277,10 @@ void LLAgent::init() gSavedSettings.declareBOOL("SlowMotionAnimation", FALSE, "Declared in code", FALSE); gSavedSettings.getControl("SlowMotionAnimation")->getSignal()->connect(boost::bind(&handleSlowMotionAnimation, _2)); - mDrawDistance = gSavedSettings.getF32("RenderFarClip"); - // *Note: this is where LLViewerCamera::getInstance() used to be constructed. setFlying( gSavedSettings.getBOOL("FlyingAtExit") ); -/* - LLViewerCamera::getInstance()->setView(DEFAULT_FIELD_OF_VIEW); - // Leave at 0.1 meters until we have real near clip management - LLViewerCamera::getInstance()->setNear(0.1f); - LLViewerCamera::getInstance()->setFar(mDrawDistance); // if you want to change camera settings, do so in camera.h - LLViewerCamera::getInstance()->setAspect( gViewerWindow->getWorldViewAspectRatio() ); // default, overridden in LLViewerWindow::reshape - LLViewerCamera::getInstance()->setViewHeightInPixels(768); // default, overridden in LLViewerWindow::reshape - -//// mCameraFocusOffsetTarget = LLVector4(gSavedSettings.getVector3("CameraOffsetBuild")); - -//// mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPreset"); - -//// mCameraOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getVector3("CameraOffsetRearView"); -//// mCameraOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getVector3("CameraOffsetFrontView"); -//// mCameraOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getVector3("CameraOffsetGroupView"); - -//// mFocusOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getVector3d("FocusOffsetRearView"); -//// mFocusOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getVector3d("FocusOffsetFrontView"); -//// mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getVector3d("FocusOffsetGroupView"); - -//// mCameraCollidePlane.clearVec(); -//// mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale"); -//// mTargetCameraDistance = mCurrentCameraDistance; -//// mCameraZoomFraction = 1.f; -//// mTrackFocusObject = gSavedSettings.getBOOL("TrackFocusObject"); -*/ - mEffectColor = LLUIColorTable::instance().getColor("EffectColor"); gSavedSettings.getControl("PreferredMaturity")->getValidateSignal()->connect(boost::bind(&LLAgent::validateMaturity, this, _2)); @@ -433,7 +296,7 @@ void LLAgent::cleanup() { mAvatarObject = NULL; mRegionp = NULL; - gAgentCameraHACK.cleanup(); + gAgentCamera.cleanup(); } //----------------------------------------------------------------------------- @@ -446,85 +309,6 @@ LLAgent::~LLAgent() // *Note: this is where LLViewerCamera::getInstance() used to be deleted. } -/* -// Change camera back to third person, stop the autopilot, -// deselect stuff, etc. -//----------------------------------------------------------------------------- -// resetView() -//----------------------------------------------------------------------------- -void LLAgent::resetView(BOOL reset_camera, BOOL change_camera) -{ - if (mAutoPilot) - { - stopAutoPilot(TRUE); - } - - if (!gNoRender) - { - LLSelectMgr::getInstance()->unhighlightAll(); - - // By popular request, keep land selection while walking around. JC - // LLViewerParcelMgr::getInstance()->deselectLand(); - - // force deselect when walking and attachment is selected - // this is so people don't wig out when their avatar moves without animating - if (LLSelectMgr::getInstance()->getSelection()->isAttachment()) - { - LLSelectMgr::getInstance()->deselectAll(); - } - - // Hide all popup menus - gMenuHolder->hideMenus(); - } - - if (change_camera && !gSavedSettings.getBOOL("FreezeTime")) - { - changeCameraToDefault(); - - if (LLViewerJoystick::getInstance()->getOverrideCamera()) - { - handle_toggle_flycam(); - } - - // reset avatar mode from eventual residual motion - if (LLToolMgr::getInstance()->inBuildMode()) - { - LLViewerJoystick::getInstance()->moveAvatar(true); - } - - //Camera Tool is needed for Free Camera Control Mode - if (!LLFloaterCamera::inFreeCameraMode()) - { - LLFloaterReg::hideInstance("build"); - - // Switch back to basic toolset - LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); - } - - gViewerWindow->showCursor(); - } - - - if (reset_camera && !gSavedSettings.getBOOL("FreezeTime")) - { - if (!gViewerWindow->getLeftMouseDown() && cameraThirdPerson()) - { - // leaving mouse-steer mode - LLVector3 agent_at_axis = getAtAxis(); - agent_at_axis -= projected_vec(agent_at_axis, getReferenceUpVector()); - agent_at_axis.normalize(); - gAgent.resetAxes(lerp(getAtAxis(), agent_at_axis, LLCriticalDamp::getInterpolant(0.3f))); - } - - setFocusOnAvatar(TRUE, ANIMATE); - - mCameraFOVZoomFactor = 0.f; - } - - mHUDTargetZoom = 1.f; -} -*/ - // Handle any actions that need to be performed when the main app gains focus // (such as through alt-tab). //----------------------------------------------------------------------------- @@ -532,9 +316,9 @@ void LLAgent::resetView(BOOL reset_camera, BOOL change_camera) //----------------------------------------------------------------------------- void LLAgent::onAppFocusGained() { - if (CAMERA_MODE_MOUSELOOK == gAgentCameraHACK.mCameraMode) + if (CAMERA_MODE_MOUSELOOK == gAgentCamera.mCameraMode) { - gAgentCameraHACK.changeCameraToDefault(); + gAgentCamera.changeCameraToDefault(); LLToolMgr::getInstance()->clearSavedTool(); } } @@ -551,24 +335,6 @@ void LLAgent::ageChat() } } -/* -// Allow camera to be moved somewhere other than behind avatar. -//----------------------------------------------------------------------------- -// unlockView() -//----------------------------------------------------------------------------- -void LLAgent::unlockView() -{ - if (getFocusOnAvatar()) - { - if (mAvatarObject.notNull()) - { - setFocusGlobal( LLVector3d::zero, mAvatarObject->mID ); - } - setFocusOnAvatar(FALSE, FALSE); // no animation - } -} -*/ - //----------------------------------------------------------------------------- // moveAt() //----------------------------------------------------------------------------- @@ -590,7 +356,7 @@ void LLAgent::moveAt(S32 direction, bool reset) if (reset) { - gAgentCameraHACK.resetView(); + gAgentCamera.resetView(); } } @@ -613,7 +379,7 @@ void LLAgent::moveAtNudge(S32 direction) setControlFlags(AGENT_CONTROL_NUDGE_AT_NEG); } - gAgentCameraHACK.resetView(); + gAgentCamera.resetView(); } //----------------------------------------------------------------------------- @@ -635,7 +401,7 @@ void LLAgent::moveLeft(S32 direction) setControlFlags(AGENT_CONTROL_LEFT_NEG | AGENT_CONTROL_FAST_LEFT); } - gAgentCameraHACK.resetView(); + gAgentCamera.resetView(); } //----------------------------------------------------------------------------- @@ -657,7 +423,7 @@ void LLAgent::moveLeftNudge(S32 direction) setControlFlags(AGENT_CONTROL_NUDGE_LEFT_NEG); } - gAgentCameraHACK.resetView(); + gAgentCamera.resetView(); } //----------------------------------------------------------------------------- @@ -679,7 +445,7 @@ void LLAgent::moveUp(S32 direction) setControlFlags(AGENT_CONTROL_UP_NEG | AGENT_CONTROL_FAST_UP); } - gAgentCameraHACK.resetView(); + gAgentCamera.resetView(); } //----------------------------------------------------------------------------- @@ -700,7 +466,7 @@ void LLAgent::moveYaw(F32 mag, bool reset_view) if (reset_view) { - gAgentCameraHACK.resetView(); + gAgentCamera.resetView(); } } @@ -811,7 +577,7 @@ void LLAgent::toggleFlying() BOOL fly = !gAgent.getFlying(); gAgent.setFlying( fly ); - gAgentCameraHACK.resetView(); + gAgentCamera.resetView(); } // static @@ -883,8 +649,7 @@ void LLAgent::setRegion(LLViewerRegion *regionp) LLVector3 delta; delta.setVec(regionp->getOriginGlobal()); - setPositionAgent -(getPositionAgent() - delta); + setPositionAgent(getPositionAgent() - delta); LLVector3 camera_position_agent = LLViewerCamera::getInstance()->getOrigin(); LLViewerCamera::getInstance()->setOrigin(camera_position_agent - delta); @@ -1034,19 +799,6 @@ void LLAgent::setPositionAgent(const LLVector3 &pos_agent) } } -/* -//----------------------------------------------------------------------------- -// slamLookAt() -//----------------------------------------------------------------------------- -void LLAgent::slamLookAt(const LLVector3 &look_at) -{ - LLVector3 look_at_norm = look_at; - look_at_norm.mV[VZ] = 0.f; - look_at_norm.normalize(); - resetAxes(look_at_norm); -} -*/ - //----------------------------------------------------------------------------- // getPositionGlobal() //----------------------------------------------------------------------------- @@ -1201,7 +953,7 @@ LLVector3 LLAgent::getReferenceUpVector() mAvatarObject->getParent() && mAvatarObject->mDrawable.notNull()) { - U32 camera_mode = gAgentCameraHACK.mCameraAnimating ? gAgentCameraHACK.mLastCameraMode : gAgentCameraHACK.mCameraMode; + U32 camera_mode = gAgentCamera.mCameraAnimating ? gAgentCamera.mLastCameraMode : gAgentCamera.mCameraMode; // and in third person... if (camera_mode == CAMERA_MODE_THIRD_PERSON) { @@ -1300,3290 +1052,959 @@ LLQuaternion LLAgent::getQuat() const return mFrameAgent.getQuaternion(); } -/* //----------------------------------------------------------------------------- -// calcFocusOffset() +// setKey() //----------------------------------------------------------------------------- -LLVector3 LLAgent::calcFocusOffset(LLViewerObject *object, LLVector3 original_focus_point, S32 x, S32 y) +void LLAgent::setKey(const S32 direction, S32 &key) { - LLMatrix4 obj_matrix = object->getRenderMatrix(); - LLQuaternion obj_rot = object->getRenderRotation(); - LLVector3 obj_pos = object->getRenderPosition(); - - BOOL is_avatar = object->isAvatar(); - // if is avatar - don't do any funk heuristics to position the focal point - // see DEV-30589 - if (is_avatar) + if (direction > 0) { - return original_focus_point - obj_pos; + key = 1; + } + else if (direction < 0) + { + key = -1; } - - - LLQuaternion inv_obj_rot = ~obj_rot; // get inverse of rotation - LLVector3 object_extents = object->getScale(); - // make sure they object extents are non-zero - object_extents.clamp(0.001f, F32_MAX); - - // obj_to_cam_ray is unit vector pointing from object center to camera, in the coordinate frame of the object - LLVector3 obj_to_cam_ray = obj_pos - LLViewerCamera::getInstance()->getOrigin(); - obj_to_cam_ray.rotVec(inv_obj_rot); - obj_to_cam_ray.normalize(); - - // obj_to_cam_ray_proportions are the (positive) ratios of - // the obj_to_cam_ray x,y,z components with the x,y,z object dimensions. - LLVector3 obj_to_cam_ray_proportions; - obj_to_cam_ray_proportions.mV[VX] = llabs(obj_to_cam_ray.mV[VX] / object_extents.mV[VX]); - obj_to_cam_ray_proportions.mV[VY] = llabs(obj_to_cam_ray.mV[VY] / object_extents.mV[VY]); - obj_to_cam_ray_proportions.mV[VZ] = llabs(obj_to_cam_ray.mV[VZ] / object_extents.mV[VZ]); - - // find the largest ratio stored in obj_to_cam_ray_proportions - // this corresponds to the object's local axial plane (XY, YZ, XZ) that is *most* facing the camera - LLVector3 longest_object_axis; - // is x-axis longest? - if (obj_to_cam_ray_proportions.mV[VX] > obj_to_cam_ray_proportions.mV[VY] - && obj_to_cam_ray_proportions.mV[VX] > obj_to_cam_ray_proportions.mV[VZ]) - { - // then grab it - longest_object_axis.setVec(obj_matrix.getFwdRow4()); - } - // is y-axis longest? - else if (obj_to_cam_ray_proportions.mV[VY] > obj_to_cam_ray_proportions.mV[VZ]) - { - // then grab it - longest_object_axis.setVec(obj_matrix.getLeftRow4()); - } - // otherwise, use z axis else { - longest_object_axis.setVec(obj_matrix.getUpRow4()); + key = 0; } +} - // Use this axis as the normal to project mouse click on to plane with that normal, at the object center. - // This generates a point behind the mouse cursor that is approximately in the middle of the object in - // terms of depth. - // We do this to allow the camera rotation tool to "tumble" the object by rotating the camera. - // If the focus point were the object surface under the mouse, camera rotation would introduce an undesirable - // eccentricity to the object orientation - LLVector3 focus_plane_normal(longest_object_axis); - focus_plane_normal.normalize(); - - LLVector3d focus_pt_global; - gViewerWindow->mousePointOnPlaneGlobal(focus_pt_global, x, y, gAgent.getPosGlobalFromAgent(obj_pos), focus_plane_normal); - LLVector3 focus_pt = gAgent.getPosAgentFromGlobal(focus_pt_global); - - // find vector from camera to focus point in object space - LLVector3 camera_to_focus_vec = focus_pt - LLViewerCamera::getInstance()->getOrigin(); - camera_to_focus_vec.rotVec(inv_obj_rot); - - // find vector from object origin to focus point in object coordinates - LLVector3 focus_offset_from_object_center = focus_pt - obj_pos; - // convert to object-local space - focus_offset_from_object_center.rotVec(inv_obj_rot); - - // We need to project the focus point back into the bounding box of the focused object. - // Do this by calculating the XYZ scale factors needed to get focus offset back in bounds along the camera_focus axis - LLVector3 clip_fraction; - // for each axis... - for (U32 axis = VX; axis <= VZ; axis++) +//----------------------------------------------------------------------------- +// getControlFlags() +//----------------------------------------------------------------------------- +U32 LLAgent::getControlFlags() +{ +/* + // HACK -- avoids maintenance of control flags when camera mode is turned on or off, + // only worries about it when the flags are measured + if (mCameraMode == CAMERA_MODE_MOUSELOOK) { - //...calculate distance that focus offset sits outside of bounding box along that axis... - //NOTE: dist_out_of_bounds keeps the sign of focus_offset_from_object_center - F32 dist_out_of_bounds; - if (focus_offset_from_object_center.mV[axis] > 0.f) - { - dist_out_of_bounds = llmax(0.f, focus_offset_from_object_center.mV[axis] - (object_extents.mV[axis] * 0.5f)); - } - else - { - dist_out_of_bounds = llmin(0.f, focus_offset_from_object_center.mV[axis] + (object_extents.mV[axis] * 0.5f)); - } - - //...then calculate the scale factor needed to push camera_to_focus_vec back in bounds along current axis - if (llabs(camera_to_focus_vec.mV[axis]) < 0.0001f) - { - // don't divide by very small number - clip_fraction.mV[axis] = 0.f; - } - else + if ( !(mControlFlags & AGENT_CONTROL_MOUSELOOK) ) { - clip_fraction.mV[axis] = dist_out_of_bounds / camera_to_focus_vec.mV[axis]; + mControlFlags |= AGENT_CONTROL_MOUSELOOK; } } +*/ + return mControlFlags; +} - LLVector3 abs_clip_fraction = clip_fraction; - abs_clip_fraction.abs(); - - // find axis of focus offset that is *most* outside the bounding box and use that to - // rescale focus offset to inside object extents - if (abs_clip_fraction.mV[VX] > abs_clip_fraction.mV[VY] - && abs_clip_fraction.mV[VX] > abs_clip_fraction.mV[VZ]) - { - focus_offset_from_object_center -= clip_fraction.mV[VX] * camera_to_focus_vec; - } - else if (abs_clip_fraction.mV[VY] > abs_clip_fraction.mV[VZ]) - { - focus_offset_from_object_center -= clip_fraction.mV[VY] * camera_to_focus_vec; - } - else - { - focus_offset_from_object_center -= clip_fraction.mV[VZ] * camera_to_focus_vec; - } - - // convert back to world space - focus_offset_from_object_center.rotVec(obj_rot); - - // now, based on distance of camera from object relative to object size - // push the focus point towards the near surface of the object when (relatively) close to the objcet - // or keep the focus point in the object middle when (relatively) far - // NOTE: leave focus point in middle of avatars, since the behavior you want when alt-zooming on avatars - // is almost always "tumble about middle" and not "spin around surface point" - if (!is_avatar) - { - LLVector3 obj_rel = original_focus_point - object->getRenderPosition(); - - //now that we have the object relative position, we should bias toward the center of the object - //based on the distance of the camera to the focus point vs. the distance of the camera to the focus - - F32 relDist = llabs(obj_rel * LLViewerCamera::getInstance()->getAtAxis()); - F32 viewDist = dist_vec(obj_pos + obj_rel, LLViewerCamera::getInstance()->getOrigin()); - - - LLBBox obj_bbox = object->getBoundingBoxAgent(); - F32 bias = 0.f; +//----------------------------------------------------------------------------- +// setControlFlags() +//----------------------------------------------------------------------------- +void LLAgent::setControlFlags(U32 mask) +{ + mControlFlags |= mask; + mbFlagsDirty = TRUE; +} - // virtual_camera_pos is the camera position we are simulating by backing the camera off - // and adjusting the FOV - LLVector3 virtual_camera_pos = gAgent.getPosAgentFromGlobal(mFocusTargetGlobal + (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor)); - // if the camera is inside the object (large, hollow objects, for example) - // leave focus point all the way to destination depth, away from object center - if(!obj_bbox.containsPointAgent(virtual_camera_pos)) - { - // perform magic number biasing of focus point towards surface vs. planar center - bias = clamp_rescale(relDist/viewDist, 0.1f, 0.7f, 0.0f, 1.0f); - obj_rel = lerp(focus_offset_from_object_center, obj_rel, bias); - } - - focus_offset_from_object_center = obj_rel; +//----------------------------------------------------------------------------- +// clearControlFlags() +//----------------------------------------------------------------------------- +void LLAgent::clearControlFlags(U32 mask) +{ + U32 old_flags = mControlFlags; + mControlFlags &= ~mask; + if (old_flags != mControlFlags) + { + mbFlagsDirty = TRUE; } +} - return focus_offset_from_object_center; +//----------------------------------------------------------------------------- +// controlFlagsDirty() +//----------------------------------------------------------------------------- +BOOL LLAgent::controlFlagsDirty() const +{ + return mbFlagsDirty; } //----------------------------------------------------------------------------- -// calcCameraMinDistance() +// enableControlFlagReset() //----------------------------------------------------------------------------- -BOOL LLAgent::calcCameraMinDistance(F32 &obj_min_distance) +void LLAgent::enableControlFlagReset() { - BOOL soft_limit = FALSE; // is the bounding box to be treated literally (volumes) or as an approximation (avatars) + mbFlagsNeedReset = TRUE; +} - if (!mFocusObject || mFocusObject->isDead()) +//----------------------------------------------------------------------------- +// resetControlFlags() +//----------------------------------------------------------------------------- +void LLAgent::resetControlFlags() +{ + if (mbFlagsNeedReset) { - obj_min_distance = 0.f; - return TRUE; + mbFlagsNeedReset = FALSE; + mbFlagsDirty = FALSE; + // reset all of the ephemeral flags + // some flags are managed elsewhere + mControlFlags &= AGENT_CONTROL_AWAY | AGENT_CONTROL_FLY | AGENT_CONTROL_MOUSELOOK; } +} - if (mFocusObject->mDrawable.isNull()) +//----------------------------------------------------------------------------- +// setAFK() +//----------------------------------------------------------------------------- +void LLAgent::setAFK() +{ + // Drones can't go AFK + if (gNoRender) { -#ifdef LL_RELEASE_FOR_DOWNLOAD - llwarns << "Focus object with no drawable!" << llendl; -#else - mFocusObject->dump(); - llerrs << "Focus object with no drawable!" << llendl; -#endif - obj_min_distance = 0.f; - return TRUE; + return; } - - LLQuaternion inv_object_rot = ~mFocusObject->getRenderRotation(); - LLVector3 target_offset_origin = mFocusObjectOffset; - LLVector3 camera_offset_target(getCameraPositionAgent() - getPosAgentFromGlobal(mFocusTargetGlobal)); - - // convert offsets into object local space - camera_offset_target.rotVec(inv_object_rot); - target_offset_origin.rotVec(inv_object_rot); - // push around object extents based on target offset - LLVector3 object_extents = mFocusObject->getScale(); - if (mFocusObject->isAvatar()) + if (!gAgent.getRegion()) { - // fudge factors that lets you zoom in on avatars a bit more (which don't do FOV zoom) - object_extents.mV[VX] *= AVATAR_ZOOM_MIN_X_FACTOR; - object_extents.mV[VY] *= AVATAR_ZOOM_MIN_Y_FACTOR; - object_extents.mV[VZ] *= AVATAR_ZOOM_MIN_Z_FACTOR; - soft_limit = TRUE; + // Don't set AFK if we're not talking to a region yet. + return; } - LLVector3 abs_target_offset = target_offset_origin; - abs_target_offset.abs(); - - LLVector3 target_offset_dir = target_offset_origin; - F32 object_radius = mFocusObject->getVObjRadius(); - BOOL target_outside_object_extents = FALSE; - - for (U32 i = VX; i <= VZ; i++) + if (!(mControlFlags & AGENT_CONTROL_AWAY)) { - if (abs_target_offset.mV[i] * 2.f > object_extents.mV[i] + OBJECT_EXTENTS_PADDING) - { - target_outside_object_extents = TRUE; - } - if (camera_offset_target.mV[i] > 0.f) - { - object_extents.mV[i] -= target_offset_origin.mV[i] * 2.f; - } - else + sendAnimationRequest(ANIM_AGENT_AWAY, ANIM_REQUEST_START); + setControlFlags(AGENT_CONTROL_AWAY | AGENT_CONTROL_STOP); + gAwayTimer.start(); + if (gAFKMenu) { - object_extents.mV[i] += target_offset_origin.mV[i] * 2.f; + gAFKMenu->setLabel(LLTrans::getString("AvatarSetNotAway")); } } +} - // don't shrink the object extents so far that the object inverts - object_extents.clamp(0.001f, F32_MAX); - - // move into first octant - LLVector3 camera_offset_target_abs_norm = camera_offset_target; - camera_offset_target_abs_norm.abs(); - // make sure offset is non-zero - camera_offset_target_abs_norm.clamp(0.001f, F32_MAX); - camera_offset_target_abs_norm.normalize(); - - // find camera position relative to normalized object extents - LLVector3 camera_offset_target_scaled = camera_offset_target_abs_norm; - camera_offset_target_scaled.mV[VX] /= object_extents.mV[VX]; - camera_offset_target_scaled.mV[VY] /= object_extents.mV[VY]; - camera_offset_target_scaled.mV[VZ] /= object_extents.mV[VZ]; +//----------------------------------------------------------------------------- +// clearAFK() +//----------------------------------------------------------------------------- +void LLAgent::clearAFK() +{ + gAwayTriggerTimer.reset(); - if (camera_offset_target_scaled.mV[VX] > camera_offset_target_scaled.mV[VY] && - camera_offset_target_scaled.mV[VX] > camera_offset_target_scaled.mV[VZ]) - { - if (camera_offset_target_abs_norm.mV[VX] < 0.001f) - { - obj_min_distance = object_extents.mV[VX] * 0.5f; - } - else - { - obj_min_distance = object_extents.mV[VX] * 0.5f / camera_offset_target_abs_norm.mV[VX]; - } - } - else if (camera_offset_target_scaled.mV[VY] > camera_offset_target_scaled.mV[VZ]) + // Gods can sometimes get into away state (via gestures) + // without setting the appropriate control flag. JC + LLVOAvatar* av = mAvatarObject; + if (mControlFlags & AGENT_CONTROL_AWAY + || (av + && (av->mSignaledAnimations.find(ANIM_AGENT_AWAY) != av->mSignaledAnimations.end()))) { - if (camera_offset_target_abs_norm.mV[VY] < 0.001f) - { - obj_min_distance = object_extents.mV[VY] * 0.5f; - } - else + sendAnimationRequest(ANIM_AGENT_AWAY, ANIM_REQUEST_STOP); + clearControlFlags(AGENT_CONTROL_AWAY); + if (gAFKMenu) { - obj_min_distance = object_extents.mV[VY] * 0.5f / camera_offset_target_abs_norm.mV[VY]; - } - } - else - { - if (camera_offset_target_abs_norm.mV[VZ] < 0.001f) - { - obj_min_distance = object_extents.mV[VZ] * 0.5f; - } - else - { - obj_min_distance = object_extents.mV[VZ] * 0.5f / camera_offset_target_abs_norm.mV[VZ]; + gAFKMenu->setLabel(LLTrans::getString("AvatarSetAway")); } } +} - LLVector3 object_split_axis; - LLVector3 target_offset_scaled = target_offset_origin; - target_offset_scaled.abs(); - target_offset_scaled.normalize(); - target_offset_scaled.mV[VX] /= object_extents.mV[VX]; - target_offset_scaled.mV[VY] /= object_extents.mV[VY]; - target_offset_scaled.mV[VZ] /= object_extents.mV[VZ]; +//----------------------------------------------------------------------------- +// getAFK() +//----------------------------------------------------------------------------- +BOOL LLAgent::getAFK() const +{ + return (mControlFlags & AGENT_CONTROL_AWAY) != 0; +} - if (target_offset_scaled.mV[VX] > target_offset_scaled.mV[VY] && - target_offset_scaled.mV[VX] > target_offset_scaled.mV[VZ]) - { - object_split_axis = LLVector3::x_axis; - } - else if (target_offset_scaled.mV[VY] > target_offset_scaled.mV[VZ]) +//----------------------------------------------------------------------------- +// setBusy() +//----------------------------------------------------------------------------- +void LLAgent::setBusy() +{ + sendAnimationRequest(ANIM_AGENT_BUSY, ANIM_REQUEST_START); + mIsBusy = TRUE; + if (gBusyMenu) { - object_split_axis = LLVector3::y_axis; + gBusyMenu->setLabel(LLTrans::getString("AvatarSetNotBusy")); } - else + LLNotificationsUI::LLChannelManager::getInstance()->muteAllChannels(true); +} + +//----------------------------------------------------------------------------- +// clearBusy() +//----------------------------------------------------------------------------- +void LLAgent::clearBusy() +{ + mIsBusy = FALSE; + sendAnimationRequest(ANIM_AGENT_BUSY, ANIM_REQUEST_STOP); + if (gBusyMenu) { - object_split_axis = LLVector3::z_axis; + gBusyMenu->setLabel(LLTrans::getString("AvatarSetBusy")); } + LLNotificationsUI::LLChannelManager::getInstance()->muteAllChannels(false); +} - LLVector3 camera_offset_object(getCameraPositionAgent() - mFocusObject->getPositionAgent()); +//----------------------------------------------------------------------------- +// getBusy() +//----------------------------------------------------------------------------- +BOOL LLAgent::getBusy() const +{ + return mIsBusy; +} - // length projected orthogonal to target offset - F32 camera_offset_dist = (camera_offset_object - target_offset_dir * (camera_offset_object * target_offset_dir)).magVec(); - // calculate whether the target point would be "visible" if it were outside the bounding box - // on the opposite of the splitting plane defined by object_split_axis; - BOOL exterior_target_visible = FALSE; - if (camera_offset_dist > object_radius) +//----------------------------------------------------------------------------- +// startAutoPilotGlobal() +//----------------------------------------------------------------------------- +void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::string& behavior_name, const LLQuaternion *target_rotation, void (*finish_callback)(BOOL, void *), void *callback_data, F32 stop_distance, F32 rot_threshold) +{ + if (!gAgent.getAvatarObject()) { - // target is visible from camera, so turn off fov zoom - exterior_target_visible = TRUE; + return; } + + mAutoPilotFinishedCallback = finish_callback; + mAutoPilotCallbackData = callback_data; + mAutoPilotRotationThreshold = rot_threshold; + mAutoPilotBehaviorName = behavior_name; - F32 camera_offset_clip = camera_offset_object * object_split_axis; - F32 target_offset_clip = target_offset_dir * object_split_axis; - - // target has moved outside of object extents - // check to see if camera and target are on same side - if (target_outside_object_extents) - { - if (camera_offset_clip > 0.f && target_offset_clip > 0.f) - { - return FALSE; - } - else if (camera_offset_clip < 0.f && target_offset_clip < 0.f) - { - return FALSE; - } - } + LLVector3d delta_pos( target_global ); + delta_pos -= getPositionGlobal(); + F64 distance = delta_pos.magVec(); + LLVector3d trace_target = target_global; - // clamp obj distance to diagonal of 10 by 10 cube - obj_min_distance = llmin(obj_min_distance, 10.f * F_SQRT3); + trace_target.mdV[VZ] -= 10.f; - obj_min_distance += LLViewerCamera::getInstance()->getNear() + (soft_limit ? 0.1f : 0.2f); - - return TRUE; -} + LLVector3d intersection; + LLVector3 normal; + LLViewerObject *hit_obj; + F32 heightDelta = LLWorld::getInstance()->resolveStepHeightGlobal(NULL, target_global, trace_target, intersection, normal, &hit_obj); -F32 LLAgent::getCameraZoomFraction() -{ - // 0.f -> camera zoomed all the way out - // 1.f -> camera zoomed all the way in - LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); - if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) - { - // already [0,1] - return mHUDTargetZoom; - } - else if (mFocusOnAvatar && cameraThirdPerson()) - { - return clamp_rescale(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION, 1.f, 0.f); - } - else if (cameraCustomizeAvatar()) + if (stop_distance > 0.f) { - F32 distance = (F32)mCameraFocusOffsetTarget.magVec(); - return clamp_rescale(distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM, 1.f, 0.f ); + mAutoPilotStopDistance = stop_distance; } else { - F32 min_zoom; - const F32 DIST_FUDGE = 16.f; // meters - F32 max_zoom = llmin(mDrawDistance - DIST_FUDGE, - LLWorld::getInstance()->getRegionWidthInMeters() - DIST_FUDGE, - MAX_CAMERA_DISTANCE_FROM_AGENT); - - F32 distance = (F32)mCameraFocusOffsetTarget.magVec(); - if (mFocusObject.notNull()) - { - if (mFocusObject->isAvatar()) - { - min_zoom = AVATAR_MIN_ZOOM; - } - else - { - min_zoom = OBJECT_MIN_ZOOM; - } - } - else + // Guess at a reasonable stop distance. + mAutoPilotStopDistance = fsqrtf( distance ); + if (mAutoPilotStopDistance < 0.5f) { - min_zoom = LAND_MIN_ZOOM; + mAutoPilotStopDistance = 0.5f; } - - return clamp_rescale(distance, min_zoom, max_zoom, 1.f, 0.f); } -} -void LLAgent::setCameraZoomFraction(F32 fraction) -{ - // 0.f -> camera zoomed all the way out - // 1.f -> camera zoomed all the way in - LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); + mAutoPilotFlyOnStop = getFlying(); - if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) - { - mHUDTargetZoom = fraction; - } - else if (mFocusOnAvatar && cameraThirdPerson()) + if (distance > 30.0) { - mCameraZoomFraction = rescale(fraction, 0.f, 1.f, MAX_ZOOM_FRACTION, MIN_ZOOM_FRACTION); + setFlying(TRUE); } - else if (cameraCustomizeAvatar()) + + if ( distance > 1.f && heightDelta > (sqrtf(mAutoPilotStopDistance) + 1.f)) { - LLVector3d camera_offset_dir = mCameraFocusOffsetTarget; - camera_offset_dir.normalize(); - mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, APPEARANCE_MAX_ZOOM, APPEARANCE_MIN_ZOOM); + setFlying(TRUE); + mAutoPilotFlyOnStop = TRUE; } - else - { - F32 min_zoom = LAND_MIN_ZOOM; - const F32 DIST_FUDGE = 16.f; // meters - F32 max_zoom = llmin(mDrawDistance - DIST_FUDGE, - LLWorld::getInstance()->getRegionWidthInMeters() - DIST_FUDGE, - MAX_CAMERA_DISTANCE_FROM_AGENT); - if (mFocusObject.notNull()) - { - if (mFocusObject.notNull()) - { - if (mFocusObject->isAvatar()) - { - min_zoom = AVATAR_MIN_ZOOM; - } - else - { - min_zoom = OBJECT_MIN_ZOOM; - } - } - } + mAutoPilot = TRUE; + mAutoPilotTargetGlobal = target_global; - LLVector3d camera_offset_dir = mCameraFocusOffsetTarget; - camera_offset_dir.normalize(); - mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, max_zoom, min_zoom); - } - startCameraAnimation(); -} + // trace ray down to find height of destination from ground + LLVector3d traceEndPt = target_global; + traceEndPt.mdV[VZ] -= 20.f; + + LLVector3d targetOnGround; + LLVector3 groundNorm; + LLViewerObject *obj; + LLWorld::getInstance()->resolveStepHeightGlobal(NULL, target_global, traceEndPt, targetOnGround, groundNorm, &obj); + F64 target_height = llmax((F64)gAgent.getAvatarObject()->getPelvisToFoot(), target_global.mdV[VZ] - targetOnGround.mdV[VZ]); -//----------------------------------------------------------------------------- -// cameraOrbitAround() -//----------------------------------------------------------------------------- -void LLAgent::cameraOrbitAround(const F32 radians) -{ - LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); - if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) - { - // do nothing for hud selection - } - else if (mFocusOnAvatar && (mCameraMode == CAMERA_MODE_THIRD_PERSON || mCameraMode == CAMERA_MODE_FOLLOW)) + // clamp z value of target to minimum height above ground + mAutoPilotTargetGlobal.mdV[VZ] = targetOnGround.mdV[VZ] + target_height; + mAutoPilotTargetDist = (F32)dist_vec(gAgent.getPositionGlobal(), mAutoPilotTargetGlobal); + if (target_rotation) { - mFrameAgent.rotate(radians, getReferenceUpVector()); + mAutoPilotUseRotation = TRUE; + mAutoPilotTargetFacing = LLVector3::x_axis * *target_rotation; + mAutoPilotTargetFacing.mV[VZ] = 0.f; + mAutoPilotTargetFacing.normalize(); } else { - mCameraFocusOffsetTarget.rotVec(radians, 0.f, 0.f, 1.f); - - cameraZoomIn(1.f); + mAutoPilotUseRotation = FALSE; } + + mAutoPilotNoProgressFrameCount = 0; } //----------------------------------------------------------------------------- -// cameraOrbitOver() +// startFollowPilot() //----------------------------------------------------------------------------- -void LLAgent::cameraOrbitOver(const F32 angle) +void LLAgent::startFollowPilot(const LLUUID &leader_id) { - LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); - if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) - { - // do nothing for hud selection - } - else if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON) - { - pitch(angle); - } - else - { - LLVector3 camera_offset_unit(mCameraFocusOffsetTarget); - camera_offset_unit.normalize(); - - F32 angle_from_up = acos( camera_offset_unit * getReferenceUpVector() ); - - LLVector3d left_axis; - left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis()); - F32 new_angle = llclamp(angle_from_up - angle, 1.f * DEG_TO_RAD, 179.f * DEG_TO_RAD); - mCameraFocusOffsetTarget.rotVec(angle_from_up - new_angle, left_axis); - - cameraZoomIn(1.f); - } -} + if (!mAutoPilot) return; -//----------------------------------------------------------------------------- -// cameraZoomIn() -//----------------------------------------------------------------------------- -void LLAgent::cameraZoomIn(const F32 fraction) -{ - if (gDisconnected) - { - return; - } + mLeaderID = leader_id; + if ( mLeaderID.isNull() ) return; - LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); - if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) + LLViewerObject* object = gObjectList.findObject(mLeaderID); + if (!object) { - // just update hud zoom level - mHUDTargetZoom /= fraction; + mLeaderID = LLUUID::null; return; } + startAutoPilotGlobal(object->getPositionGlobal()); +} - LLVector3d camera_offset(mCameraFocusOffsetTarget); - LLVector3d camera_offset_unit(mCameraFocusOffsetTarget); - F32 min_zoom = LAND_MIN_ZOOM; - F32 current_distance = (F32)camera_offset_unit.normalize(); - F32 new_distance = current_distance * fraction; - // Don't move through focus point - if (mFocusObject) +//----------------------------------------------------------------------------- +// stopAutoPilot() +//----------------------------------------------------------------------------- +void LLAgent::stopAutoPilot(BOOL user_cancel) +{ + if (mAutoPilot) { - LLVector3 camera_offset_dir((F32)camera_offset_unit.mdV[VX], (F32)camera_offset_unit.mdV[VY], (F32)camera_offset_unit.mdV[VZ]); - - if (mFocusObject->isAvatar()) + mAutoPilot = FALSE; + if (mAutoPilotUseRotation && !user_cancel) { - calcCameraMinDistance(min_zoom); + resetAxes(mAutoPilotTargetFacing); } - else + //NB: auto pilot can terminate for a reason other than reaching the destination + if (mAutoPilotFinishedCallback) { - min_zoom = OBJECT_MIN_ZOOM; + mAutoPilotFinishedCallback(!user_cancel && dist_vec(gAgent.getPositionGlobal(), mAutoPilotTargetGlobal) < mAutoPilotStopDistance, mAutoPilotCallbackData); } - } - - new_distance = llmax(new_distance, min_zoom); - - // Don't zoom too far back - const F32 DIST_FUDGE = 16.f; // meters - F32 max_distance = llmin(mDrawDistance - DIST_FUDGE, - LLWorld::getInstance()->getRegionWidthInMeters() - DIST_FUDGE ); - - if (new_distance > max_distance) - { - new_distance = max_distance; + mLeaderID = LLUUID::null; - // Unless camera is unlocked - //if (!LLViewerCamera::sDisableCameraConstraints) - //{ - // return; - //} - } + // If the user cancelled, don't change the fly state + if (!user_cancel) + { + setFlying(mAutoPilotFlyOnStop); + } + setControlFlags(AGENT_CONTROL_STOP); - if( cameraCustomizeAvatar() ) - { - new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM ); + if (user_cancel && !mAutoPilotBehaviorName.empty()) + { + if (mAutoPilotBehaviorName == "Sit") + LLNotificationsUtil::add("CancelledSit"); + else if (mAutoPilotBehaviorName == "Attach") + LLNotificationsUtil::add("CancelledAttach"); + else + LLNotificationsUtil::add("Cancelled"); + } } - - mCameraFocusOffsetTarget = new_distance * camera_offset_unit; } + +// Returns necessary agent pitch and yaw changes, radians. //----------------------------------------------------------------------------- -// cameraOrbitIn() +// autoPilot() //----------------------------------------------------------------------------- -void LLAgent::cameraOrbitIn(const F32 meters) +void LLAgent::autoPilot(F32 *delta_yaw) { - if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON) + if (mAutoPilot) { - F32 camera_offset_dist = llmax(0.001f, getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale")); - - mCameraZoomFraction = (mTargetCameraDistance - meters) / camera_offset_dist; - - if (!gSavedSettings.getBOOL("FreezeTime") && mCameraZoomFraction < MIN_ZOOM_FRACTION && meters > 0.f) + if (!mLeaderID.isNull()) { - // No need to animate, camera is already there. - changeCameraToMouselook(FALSE); + LLViewerObject* object = gObjectList.findObject(mLeaderID); + if (!object) + { + stopAutoPilot(); + return; + } + mAutoPilotTargetGlobal = object->getPositionGlobal(); } - - mCameraZoomFraction = llclamp(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION); - } - else - { - LLVector3d camera_offset(mCameraFocusOffsetTarget); - LLVector3d camera_offset_unit(mCameraFocusOffsetTarget); - F32 current_distance = (F32)camera_offset_unit.normalize(); - F32 new_distance = current_distance - meters; - F32 min_zoom = LAND_MIN_ZOOM; - // Don't move through focus point - if (mFocusObject.notNull()) + if (mAvatarObject.isNull()) { - if (mFocusObject->isAvatar()) - { - min_zoom = AVATAR_MIN_ZOOM; - } - else - { - min_zoom = OBJECT_MIN_ZOOM; - } + return; } - new_distance = llmax(new_distance, min_zoom); + if (mAvatarObject->mInAir) + { + setFlying(TRUE); + } + + LLVector3 at; + at.setVec(mFrameAgent.getAtAxis()); + LLVector3 target_agent = getPosAgentFromGlobal(mAutoPilotTargetGlobal); + LLVector3 direction = target_agent - getPositionAgent(); - // Don't zoom too far back - const F32 DIST_FUDGE = 16.f; // meters - F32 max_distance = llmin(mDrawDistance - DIST_FUDGE, - LLWorld::getInstance()->getRegionWidthInMeters() - DIST_FUDGE ); + F32 target_dist = direction.magVec(); - if (new_distance > max_distance) + if (target_dist >= mAutoPilotTargetDist) { - // Unless camera is unlocked - if (!gSavedSettings.getBOOL("DisableCameraConstraints")) + mAutoPilotNoProgressFrameCount++; + if (mAutoPilotNoProgressFrameCount > AUTOPILOT_MAX_TIME_NO_PROGRESS * gFPSClamped) { + stopAutoPilot(); return; } } - if( CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode() ) - { - new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM ); - } - - // Compute new camera offset - mCameraFocusOffsetTarget = new_distance * camera_offset_unit; - cameraZoomIn(1.f); - } -} - - -//----------------------------------------------------------------------------- -// cameraPanIn() -//----------------------------------------------------------------------------- -void LLAgent::cameraPanIn(F32 meters) -{ - LLVector3d at_axis; - at_axis.setVec(LLViewerCamera::getInstance()->getAtAxis()); - - mFocusTargetGlobal += meters * at_axis; - mFocusGlobal = mFocusTargetGlobal; - // don't enforce zoom constraints as this is the only way for users to get past them easily - updateFocusOffset(); - // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx - mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); -} - -//----------------------------------------------------------------------------- -// cameraPanLeft() -//----------------------------------------------------------------------------- -void LLAgent::cameraPanLeft(F32 meters) -{ - LLVector3d left_axis; - left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis()); - - mFocusTargetGlobal += meters * left_axis; - mFocusGlobal = mFocusTargetGlobal; - - // disable smoothing for camera pan, which causes some residents unhappiness - mCameraSmoothingStop = TRUE; - - cameraZoomIn(1.f); - updateFocusOffset(); - // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind - Nyx - mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); -} - -//----------------------------------------------------------------------------- -// cameraPanUp() -//----------------------------------------------------------------------------- -void LLAgent::cameraPanUp(F32 meters) -{ - LLVector3d up_axis; - up_axis.setVec(LLViewerCamera::getInstance()->getUpAxis()); - - mFocusTargetGlobal += meters * up_axis; - mFocusGlobal = mFocusTargetGlobal; - - // disable smoothing for camera pan, which causes some residents unhappiness - mCameraSmoothingStop = TRUE; - - cameraZoomIn(1.f); - updateFocusOffset(); - // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx - mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); -} -*/ - -//----------------------------------------------------------------------------- -// setKey() -//----------------------------------------------------------------------------- -void LLAgent::setKey(const S32 direction, S32 &key) -{ - if (direction > 0) - { - key = 1; - } - else if (direction < 0) - { - key = -1; - } - else - { - key = 0; - } -} - - -//----------------------------------------------------------------------------- -// getControlFlags() -//----------------------------------------------------------------------------- -U32 LLAgent::getControlFlags() -{ -/* - // HACK -- avoids maintenance of control flags when camera mode is turned on or off, - // only worries about it when the flags are measured - if (mCameraMode == CAMERA_MODE_MOUSELOOK) - { - if ( !(mControlFlags & AGENT_CONTROL_MOUSELOOK) ) - { - mControlFlags |= AGENT_CONTROL_MOUSELOOK; - } - } -*/ - return mControlFlags; -} - -//----------------------------------------------------------------------------- -// setControlFlags() -//----------------------------------------------------------------------------- -void LLAgent::setControlFlags(U32 mask) -{ - mControlFlags |= mask; - mbFlagsDirty = TRUE; -} - - -//----------------------------------------------------------------------------- -// clearControlFlags() -//----------------------------------------------------------------------------- -void LLAgent::clearControlFlags(U32 mask) -{ - U32 old_flags = mControlFlags; - mControlFlags &= ~mask; - if (old_flags != mControlFlags) - { - mbFlagsDirty = TRUE; - } -} - -//----------------------------------------------------------------------------- -// controlFlagsDirty() -//----------------------------------------------------------------------------- -BOOL LLAgent::controlFlagsDirty() const -{ - return mbFlagsDirty; -} - -//----------------------------------------------------------------------------- -// enableControlFlagReset() -//----------------------------------------------------------------------------- -void LLAgent::enableControlFlagReset() -{ - mbFlagsNeedReset = TRUE; -} - -//----------------------------------------------------------------------------- -// resetControlFlags() -//----------------------------------------------------------------------------- -void LLAgent::resetControlFlags() -{ - if (mbFlagsNeedReset) - { - mbFlagsNeedReset = FALSE; - mbFlagsDirty = FALSE; - // reset all of the ephemeral flags - // some flags are managed elsewhere - mControlFlags &= AGENT_CONTROL_AWAY | AGENT_CONTROL_FLY | AGENT_CONTROL_MOUSELOOK; - } -} - -//----------------------------------------------------------------------------- -// setAFK() -//----------------------------------------------------------------------------- -void LLAgent::setAFK() -{ - // Drones can't go AFK - if (gNoRender) - { - return; - } - - if (!gAgent.getRegion()) - { - // Don't set AFK if we're not talking to a region yet. - return; - } - - if (!(mControlFlags & AGENT_CONTROL_AWAY)) - { - sendAnimationRequest(ANIM_AGENT_AWAY, ANIM_REQUEST_START); - setControlFlags(AGENT_CONTROL_AWAY | AGENT_CONTROL_STOP); - gAwayTimer.start(); - if (gAFKMenu) - { - gAFKMenu->setLabel(LLTrans::getString("AvatarSetNotAway")); - } - } -} - -//----------------------------------------------------------------------------- -// clearAFK() -//----------------------------------------------------------------------------- -void LLAgent::clearAFK() -{ - gAwayTriggerTimer.reset(); - - // Gods can sometimes get into away state (via gestures) - // without setting the appropriate control flag. JC - LLVOAvatar* av = mAvatarObject; - if (mControlFlags & AGENT_CONTROL_AWAY - || (av - && (av->mSignaledAnimations.find(ANIM_AGENT_AWAY) != av->mSignaledAnimations.end()))) - { - sendAnimationRequest(ANIM_AGENT_AWAY, ANIM_REQUEST_STOP); - clearControlFlags(AGENT_CONTROL_AWAY); - if (gAFKMenu) - { - gAFKMenu->setLabel(LLTrans::getString("AvatarSetAway")); - } - } -} - -//----------------------------------------------------------------------------- -// getAFK() -//----------------------------------------------------------------------------- -BOOL LLAgent::getAFK() const -{ - return (mControlFlags & AGENT_CONTROL_AWAY) != 0; -} - -//----------------------------------------------------------------------------- -// setBusy() -//----------------------------------------------------------------------------- -void LLAgent::setBusy() -{ - sendAnimationRequest(ANIM_AGENT_BUSY, ANIM_REQUEST_START); - mIsBusy = TRUE; - if (gBusyMenu) - { - gBusyMenu->setLabel(LLTrans::getString("AvatarSetNotBusy")); - } - LLNotificationsUI::LLChannelManager::getInstance()->muteAllChannels(true); -} - -//----------------------------------------------------------------------------- -// clearBusy() -//----------------------------------------------------------------------------- -void LLAgent::clearBusy() -{ - mIsBusy = FALSE; - sendAnimationRequest(ANIM_AGENT_BUSY, ANIM_REQUEST_STOP); - if (gBusyMenu) - { - gBusyMenu->setLabel(LLTrans::getString("AvatarSetBusy")); - } - LLNotificationsUI::LLChannelManager::getInstance()->muteAllChannels(false); -} - -//----------------------------------------------------------------------------- -// getBusy() -//----------------------------------------------------------------------------- -BOOL LLAgent::getBusy() const -{ - return mIsBusy; -} - - -//----------------------------------------------------------------------------- -// startAutoPilotGlobal() -//----------------------------------------------------------------------------- -void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::string& behavior_name, const LLQuaternion *target_rotation, void (*finish_callback)(BOOL, void *), void *callback_data, F32 stop_distance, F32 rot_threshold) -{ - if (!gAgent.getAvatarObject()) - { - return; - } - - mAutoPilotFinishedCallback = finish_callback; - mAutoPilotCallbackData = callback_data; - mAutoPilotRotationThreshold = rot_threshold; - mAutoPilotBehaviorName = behavior_name; - - LLVector3d delta_pos( target_global ); - delta_pos -= getPositionGlobal(); - F64 distance = delta_pos.magVec(); - LLVector3d trace_target = target_global; - - trace_target.mdV[VZ] -= 10.f; - - LLVector3d intersection; - LLVector3 normal; - LLViewerObject *hit_obj; - F32 heightDelta = LLWorld::getInstance()->resolveStepHeightGlobal(NULL, target_global, trace_target, intersection, normal, &hit_obj); - - if (stop_distance > 0.f) - { - mAutoPilotStopDistance = stop_distance; - } - else - { - // Guess at a reasonable stop distance. - mAutoPilotStopDistance = fsqrtf( distance ); - if (mAutoPilotStopDistance < 0.5f) - { - mAutoPilotStopDistance = 0.5f; - } - } - - mAutoPilotFlyOnStop = getFlying(); - - if (distance > 30.0) - { - setFlying(TRUE); - } - - if ( distance > 1.f && heightDelta > (sqrtf(mAutoPilotStopDistance) + 1.f)) - { - setFlying(TRUE); - mAutoPilotFlyOnStop = TRUE; - } - - mAutoPilot = TRUE; - mAutoPilotTargetGlobal = target_global; - - // trace ray down to find height of destination from ground - LLVector3d traceEndPt = target_global; - traceEndPt.mdV[VZ] -= 20.f; - - LLVector3d targetOnGround; - LLVector3 groundNorm; - LLViewerObject *obj; - - LLWorld::getInstance()->resolveStepHeightGlobal(NULL, target_global, traceEndPt, targetOnGround, groundNorm, &obj); - F64 target_height = llmax((F64)gAgent.getAvatarObject()->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; - mAutoPilotTargetDist = (F32)dist_vec(gAgent.getPositionGlobal(), mAutoPilotTargetGlobal); - if (target_rotation) - { - mAutoPilotUseRotation = TRUE; - mAutoPilotTargetFacing = LLVector3::x_axis * *target_rotation; - mAutoPilotTargetFacing.mV[VZ] = 0.f; - mAutoPilotTargetFacing.normalize(); - } - else - { - mAutoPilotUseRotation = FALSE; - } - - mAutoPilotNoProgressFrameCount = 0; -} - - -//----------------------------------------------------------------------------- -// startFollowPilot() -//----------------------------------------------------------------------------- -void LLAgent::startFollowPilot(const LLUUID &leader_id) -{ - if (!mAutoPilot) return; - - mLeaderID = leader_id; - if ( mLeaderID.isNull() ) return; - - LLViewerObject* object = gObjectList.findObject(mLeaderID); - if (!object) - { - mLeaderID = LLUUID::null; - return; - } - - startAutoPilotGlobal(object->getPositionGlobal()); -} - - -//----------------------------------------------------------------------------- -// stopAutoPilot() -//----------------------------------------------------------------------------- -void LLAgent::stopAutoPilot(BOOL user_cancel) -{ - if (mAutoPilot) - { - mAutoPilot = FALSE; - if (mAutoPilotUseRotation && !user_cancel) - { - resetAxes(mAutoPilotTargetFacing); - } - //NB: auto pilot can terminate for a reason other than reaching the destination - if (mAutoPilotFinishedCallback) - { - mAutoPilotFinishedCallback(!user_cancel && dist_vec(gAgent.getPositionGlobal(), mAutoPilotTargetGlobal) < mAutoPilotStopDistance, mAutoPilotCallbackData); - } - mLeaderID = LLUUID::null; - - // If the user cancelled, don't change the fly state - if (!user_cancel) - { - setFlying(mAutoPilotFlyOnStop); - } - setControlFlags(AGENT_CONTROL_STOP); - - if (user_cancel && !mAutoPilotBehaviorName.empty()) - { - if (mAutoPilotBehaviorName == "Sit") - LLNotificationsUtil::add("CancelledSit"); - else if (mAutoPilotBehaviorName == "Attach") - LLNotificationsUtil::add("CancelledAttach"); - else - LLNotificationsUtil::add("Cancelled"); - } - } -} - - -// Returns necessary agent pitch and yaw changes, radians. -//----------------------------------------------------------------------------- -// autoPilot() -//----------------------------------------------------------------------------- -void LLAgent::autoPilot(F32 *delta_yaw) -{ - if (mAutoPilot) - { - if (!mLeaderID.isNull()) - { - LLViewerObject* object = gObjectList.findObject(mLeaderID); - if (!object) - { - stopAutoPilot(); - return; - } - mAutoPilotTargetGlobal = object->getPositionGlobal(); - } - - if (mAvatarObject.isNull()) - { - return; - } - - if (mAvatarObject->mInAir) - { - setFlying(TRUE); - } - - LLVector3 at; - at.setVec(mFrameAgent.getAtAxis()); - LLVector3 target_agent = getPosAgentFromGlobal(mAutoPilotTargetGlobal); - LLVector3 direction = target_agent - getPositionAgent(); - - F32 target_dist = direction.magVec(); - - if (target_dist >= mAutoPilotTargetDist) - { - mAutoPilotNoProgressFrameCount++; - if (mAutoPilotNoProgressFrameCount > AUTOPILOT_MAX_TIME_NO_PROGRESS * gFPSClamped) - { - stopAutoPilot(); - return; - } - } - - mAutoPilotTargetDist = target_dist; - - // Make this a two-dimensional solution - at.mV[VZ] = 0.f; - direction.mV[VZ] = 0.f; - - at.normalize(); - F32 xy_distance = direction.normalize(); - - F32 yaw = 0.f; - if (mAutoPilotTargetDist > mAutoPilotStopDistance) - { - yaw = angle_between(mFrameAgent.getAtAxis(), direction); - } - else if (mAutoPilotUseRotation) - { - // we're close now just aim at target facing - yaw = angle_between(at, mAutoPilotTargetFacing); - direction = mAutoPilotTargetFacing; - } - - yaw = 4.f * yaw / gFPSClamped; - - // figure out which direction to turn - LLVector3 scratch(at % direction); - - if (scratch.mV[VZ] > 0.f) - { - setControlFlags(AGENT_CONTROL_YAW_POS); - } - else - { - yaw = -yaw; - setControlFlags(AGENT_CONTROL_YAW_NEG); - } - - *delta_yaw = yaw; - - // Compute when to start slowing down and when to stop - F32 stop_distance = mAutoPilotStopDistance; - F32 slow_distance; - if (getFlying()) - { - slow_distance = llmax(6.f, mAutoPilotStopDistance + 5.f); - stop_distance = llmax(2.f, mAutoPilotStopDistance); - } - else - { - slow_distance = llmax(3.f, mAutoPilotStopDistance + 2.f); - } - - // If we're flying, handle autopilot points above or below you. - if (getFlying() && xy_distance < AUTOPILOT_HEIGHT_ADJUST_DISTANCE) - { - if (mAvatarObject.notNull()) - { - F64 current_height = mAvatarObject->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) - { - setControlFlags(AGENT_CONTROL_FAST_UP | AGENT_CONTROL_UP_POS); - } - else if (slope > 0.002f && delta_z > 0.5f) - { - setControlFlags(AGENT_CONTROL_UP_POS); - } - else if (slope < -0.45f && delta_z < -6.f && current_height > AUTOPILOT_MIN_TARGET_HEIGHT_OFF_GROUND) - { - setControlFlags(AGENT_CONTROL_FAST_UP | AGENT_CONTROL_UP_NEG); - } - else if (slope < -0.002f && delta_z < -0.5f && current_height > AUTOPILOT_MIN_TARGET_HEIGHT_OFF_GROUND) - { - setControlFlags(AGENT_CONTROL_UP_NEG); - } - } - } - - // calculate delta rotation to target heading - F32 delta_target_heading = angle_between(mFrameAgent.getAtAxis(), mAutoPilotTargetFacing); - - if (xy_distance > slow_distance && yaw < (F_PI / 10.f)) - { - // walking/flying fast - setControlFlags(AGENT_CONTROL_FAST_AT | AGENT_CONTROL_AT_POS); - } - else if (mAutoPilotTargetDist > mAutoPilotStopDistance) - { - // walking/flying slow - if (at * direction > 0.9f) - { - setControlFlags(AGENT_CONTROL_AT_POS); - } - else if (at * direction < -0.9f) - { - setControlFlags(AGENT_CONTROL_AT_NEG); - } - } - - // check to see if we need to keep rotating to target orientation - if (mAutoPilotTargetDist < mAutoPilotStopDistance) - { - setControlFlags(AGENT_CONTROL_STOP); - if(!mAutoPilotUseRotation || (delta_target_heading < mAutoPilotRotationThreshold)) - { - stopAutoPilot(); - } - } - } -} - - -//----------------------------------------------------------------------------- -// propagate() -//----------------------------------------------------------------------------- -void LLAgent::propagate(const F32 dt) -{ - // Update UI based on agent motion - LLFloaterMove *floater_move = LLFloaterReg::findTypedInstance("moveview"); - if (floater_move) - { - floater_move->mForwardButton ->setToggleState( mAtKey > 0 || mWalkKey > 0 ); - floater_move->mBackwardButton ->setToggleState( mAtKey < 0 || mWalkKey < 0 ); - floater_move->mTurnLeftButton ->setToggleState( mYawKey > 0.f ); - floater_move->mTurnRightButton ->setToggleState( mYawKey < 0.f ); - floater_move->mMoveUpButton ->setToggleState( mUpKey > 0 ); - floater_move->mMoveDownButton ->setToggleState( mUpKey < 0 ); - } - - // handle rotation based on keyboard levels - const F32 YAW_RATE = 90.f * DEG_TO_RAD; // radians per second - yaw(YAW_RATE * mYawKey * dt); - - const F32 PITCH_RATE = 90.f * DEG_TO_RAD; // radians per second - pitch(PITCH_RATE * mPitchKey * dt); - - // handle auto-land behavior - if (mAvatarObject.notNull()) - { - BOOL in_air = mAvatarObject->mInAir; - LLVector3 land_vel = getVelocity(); - land_vel.mV[VZ] = 0.f; - - if (!in_air - && mUpKey < 0 - && land_vel.magVecSquared() < MAX_VELOCITY_AUTO_LAND_SQUARED - && gSavedSettings.getBOOL("AutomaticFly")) - { - // land automatically - setFlying(FALSE); - } - } - - // clear keys - mAtKey = 0; - mWalkKey = 0; - mLeftKey = 0; - mUpKey = 0; - mYawKey = 0.f; - mPitchKey = 0.f; -} - -//----------------------------------------------------------------------------- -// updateAgentPosition() -//----------------------------------------------------------------------------- -void LLAgent::updateAgentPosition(const F32 dt, const F32 yaw_radians, const S32 mouse_x, const S32 mouse_y) -{ - propagate(dt); - - // static S32 cameraUpdateCount = 0; - - rotate(yaw_radians, 0, 0, 1); - - // - // Check for water and land collision, set underwater flag - // - - gAgentCameraHACK.updateLookAt(mouse_x, mouse_y); -} - -/* -//----------------------------------------------------------------------------- -// updateLookAt() -//----------------------------------------------------------------------------- -void LLAgent::updateLookAt(const S32 mouse_x, const S32 mouse_y) -{ - static LLVector3 last_at_axis; - - - if (mAvatarObject.isNull()) - { - return; - } - - LLQuaternion av_inv_rot = ~mAvatarObject->mRoot.getWorldRotation(); - LLVector3 root_at = LLVector3::x_axis * mAvatarObject->mRoot.getWorldRotation(); - - if ((gViewerWindow->getMouseVelocityStat()->getCurrent() < 0.01f) && - (root_at * last_at_axis > 0.95f )) - { - LLVector3 vel = mAvatarObject->getVelocity(); - if (vel.magVecSquared() > 4.f) - { - setLookAt(LOOKAT_TARGET_IDLE, mAvatarObject, vel * av_inv_rot); - } - else - { - // *FIX: rotate mframeagent by sit object's rotation? - LLQuaternion look_rotation = mAvatarObject->isSitting() ? mAvatarObject->getRenderRotation() : mFrameAgent.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, mAvatarObject, look_offset); - } - last_at_axis = root_at; - return; - } - - last_at_axis = root_at; - - if (CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode()) - { - setLookAt(LOOKAT_TARGET_NONE, mAvatarObject, LLVector3(-2.f, 0.f, 0.f)); - } - else - { - // Move head based on cursor position - ELookAtType lookAtType = LOOKAT_TARGET_NONE; - LLVector3 headLookAxis; - LLCoordFrame frameCamera = *((LLCoordFrame*)LLViewerCamera::getInstance()); - - if (cameraMouselook()) - { - lookAtType = LOOKAT_TARGET_MOUSELOOK; - } - else if (cameraThirdPerson()) - { - // range from -.5 to .5 - F32 x_from_center = - ((F32) mouse_x / (F32) gViewerWindow->getWindowWidthScaled() ) - 0.5f; - F32 y_from_center = - ((F32) mouse_y / (F32) gViewerWindow->getWindowHeightScaled() ) - 0.5f; - - frameCamera.yaw( - x_from_center * gSavedSettings.getF32("YawFromMousePosition") * DEG_TO_RAD); - frameCamera.pitch( - y_from_center * gSavedSettings.getF32("PitchFromMousePosition") * DEG_TO_RAD); - lookAtType = LOOKAT_TARGET_FREELOOK; - } - - headLookAxis = frameCamera.getAtAxis(); - // RN: we use world-space offset for mouselook and freelook - //headLookAxis = headLookAxis * av_inv_rot; - setLookAt(lookAtType, mAvatarObject, headLookAxis); - } -} -*/ - -// friends and operators - -std::ostream& operator<<(std::ostream &s, const LLAgent &agent) -{ - // This is unfinished, but might never be used. - // We'll just leave it for now; we can always delete it. - s << " { " - << " Frame = " << agent.mFrameAgent << "\n" - << " }"; - return s; -} - - -// ------------------- Beginning of legacy LLCamera hack ---------------------- -// This section is included for legacy LLCamera support until -// it is no longer needed. Some legacy code must exist in -// non-legacy functions, and is labeled with "// legacy" comments. - -//----------------------------------------------------------------------------- -// setAvatarObject() -//----------------------------------------------------------------------------- -void LLAgent::setAvatarObject(LLVOAvatarSelf *avatar) -{ - mAvatarObject = avatar; - - if (!avatar) - { - llinfos << "Setting LLAgent::mAvatarObject to NULL" << llendl; - return; - } - - if (!gAgentCameraHACK.mLookAt) - { - gAgentCameraHACK.mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT); - } - if (!gAgentCameraHACK.mPointAt) - { - gAgentCameraHACK.mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT); - } - - if (!gAgentCameraHACK.mLookAt.isNull()) - { - gAgentCameraHACK.mLookAt->setSourceObject(avatar); - } - if (!gAgentCameraHACK.mPointAt.isNull()) - { - gAgentCameraHACK.mPointAt->setSourceObject(avatar); - } -} - -// TRUE if your own avatar needs to be rendered. Usually only -// in third person and build. -//----------------------------------------------------------------------------- -// needsRenderAvatar() -//----------------------------------------------------------------------------- -BOOL LLAgent::needsRenderAvatar() -{ - if (gAgentCameraHACK.cameraMouselook() && !LLVOAvatar::sVisibleInFirstPerson) - { - return FALSE; - } - - return mShowAvatar && mGenderChosen; -} - -// TRUE if we need to render your own avatar's head. -BOOL LLAgent::needsRenderHead() -{ - return (LLVOAvatar::sVisibleInFirstPerson && LLPipeline::sReflectionRender) || (mShowAvatar && !gAgentCameraHACK.cameraMouselook()); -} - -//----------------------------------------------------------------------------- -// startTyping() -//----------------------------------------------------------------------------- -void LLAgent::startTyping() -{ - mTypingTimer.reset(); - - if (getRenderState() & AGENT_STATE_TYPING) - { - // already typing, don't trigger a different animation - return; - } - setRenderState(AGENT_STATE_TYPING); - - if (mChatTimer.getElapsedTimeF32() < 2.f) - { - LLViewerObject* chatter = gObjectList.findObject(mLastChatterID); - if (chatter && chatter->isAvatar()) - { - gAgentCameraHACK.setLookAt(LOOKAT_TARGET_RESPOND, chatter, LLVector3::zero); - } - } - - if (gSavedSettings.getBOOL("PlayTypingAnim")) - { - sendAnimationRequest(ANIM_AGENT_TYPE, ANIM_REQUEST_START); - } - LLNearbyChatBar::getInstance()->sendChatFromViewer("", CHAT_TYPE_START, FALSE); -} - -//----------------------------------------------------------------------------- -// stopTyping() -//----------------------------------------------------------------------------- -void LLAgent::stopTyping() -{ - if (mRenderState & AGENT_STATE_TYPING) - { - clearRenderState(AGENT_STATE_TYPING); - sendAnimationRequest(ANIM_AGENT_TYPE, ANIM_REQUEST_STOP); - LLNearbyChatBar::getInstance()->sendChatFromViewer("", CHAT_TYPE_STOP, FALSE); - } -} - -//----------------------------------------------------------------------------- -// setRenderState() -//----------------------------------------------------------------------------- -void LLAgent::setRenderState(U8 newstate) -{ - mRenderState |= newstate; -} - -//----------------------------------------------------------------------------- -// clearRenderState() -//----------------------------------------------------------------------------- -void LLAgent::clearRenderState(U8 clearstate) -{ - mRenderState &= ~clearstate; -} - - -//----------------------------------------------------------------------------- -// getRenderState() -//----------------------------------------------------------------------------- -U8 LLAgent::getRenderState() -{ - if (gNoRender || gKeyboard == NULL) - { - return 0; - } - - // *FIX: don't do stuff in a getter! This is infinite loop city! - if ((mTypingTimer.getElapsedTimeF32() > TYPING_TIMEOUT_SECS) - && (mRenderState & AGENT_STATE_TYPING)) - { - stopTyping(); - } - - if ((!LLSelectMgr::getInstance()->getSelection()->isEmpty() && LLSelectMgr::getInstance()->shouldShowSelection()) - || LLToolMgr::getInstance()->getCurrentTool()->isEditing() ) - { - setRenderState(AGENT_STATE_EDITING); - } - else - { - clearRenderState(AGENT_STATE_EDITING); - } - - return mRenderState; -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// endAnimationUpdateUI() -//----------------------------------------------------------------------------- -void LLAgent::endAnimationUpdateUI() -{ - if (gAgentCameraHACK.mCameraMode == gAgentCameraHACK.mLastCameraMode) - { - // We're already done endAnimationUpdateUI for this transition. - return; - } - - // clean up UI from mode we're leaving - if (gAgentCameraHACK.mLastCameraMode == CAMERA_MODE_MOUSELOOK ) - { - // show mouse cursor - gViewerWindow->showCursor(); - // show menus - gMenuBarView->setVisible(TRUE); - LLNavigationBar::getInstance()->setVisible(TRUE); - gStatusBar->setVisibleForMouselook(true); - - LLBottomTray::getInstance()->onMouselookModeOut(); - - LLSideTray::getInstance()->getButtonsPanel()->setVisible(TRUE); - LLSideTray::getInstance()->updateSidetrayVisibility(); - - LLPanelStandStopFlying::getInstance()->setVisible(TRUE); - - LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); - - LLFloaterCamera::onLeavingMouseLook(); - - // Only pop if we have pushed... - if (TRUE == mViewsPushed) - { -#if 0 // Use this once all floaters are registered - LLFloaterReg::restoreVisibleInstances(); -#else // Use this for now - LLFloaterView::skip_list_t skip_list; - if (LLFloaterReg::findInstance("mini_map")) - { - skip_list.insert(LLFloaterReg::findInstance("mini_map")); - } - - gFloaterView->popVisibleAll(skip_list); -#endif - mViewsPushed = FALSE; - } - - - gAgentCameraHACK.setLookAt(LOOKAT_TARGET_CLEAR); - if( gMorphView ) - { - gMorphView->setVisible( FALSE ); - } - - // Disable mouselook-specific animations - if (mAvatarObject.notNull()) - { - if( mAvatarObject->isAnyAnimationSignaled(AGENT_GUN_AIM_ANIMS, NUM_AGENT_GUN_AIM_ANIMS) ) - { - if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_AIM_RIFLE_R) != mAvatarObject->mSignaledAnimations.end()) - { - sendAnimationRequest(ANIM_AGENT_AIM_RIFLE_R, ANIM_REQUEST_STOP); - sendAnimationRequest(ANIM_AGENT_HOLD_RIFLE_R, ANIM_REQUEST_START); - } - if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_AIM_HANDGUN_R) != mAvatarObject->mSignaledAnimations.end()) - { - sendAnimationRequest(ANIM_AGENT_AIM_HANDGUN_R, ANIM_REQUEST_STOP); - sendAnimationRequest(ANIM_AGENT_HOLD_HANDGUN_R, ANIM_REQUEST_START); - } - if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_AIM_BAZOOKA_R) != mAvatarObject->mSignaledAnimations.end()) - { - sendAnimationRequest(ANIM_AGENT_AIM_BAZOOKA_R, ANIM_REQUEST_STOP); - sendAnimationRequest(ANIM_AGENT_HOLD_BAZOOKA_R, ANIM_REQUEST_START); - } - if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_AIM_BOW_L) != mAvatarObject->mSignaledAnimations.end()) - { - sendAnimationRequest(ANIM_AGENT_AIM_BOW_L, ANIM_REQUEST_STOP); - sendAnimationRequest(ANIM_AGENT_HOLD_BOW_L, ANIM_REQUEST_START); - } - } - } - } - else - if(gAgentCameraHACK.mLastCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR) - { - // make sure we ask to save changes - - LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); - - if( gMorphView ) - { - gMorphView->setVisible( FALSE ); - } - - if (mAvatarObject.notNull()) - { - if(mCustomAnim) - { - sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_STOP); - sendAnimationRequest(ANIM_AGENT_CUSTOMIZE_DONE, ANIM_REQUEST_START); - - mCustomAnim = FALSE ; - } - - } - gAgentCameraHACK.setLookAt(LOOKAT_TARGET_CLEAR); - } - - //--------------------------------------------------------------------- - // Set up UI for mode we're entering - //--------------------------------------------------------------------- - if (gAgentCameraHACK.mCameraMode == CAMERA_MODE_MOUSELOOK) - { - // hide menus - gMenuBarView->setVisible(FALSE); - LLNavigationBar::getInstance()->setVisible(FALSE); - gStatusBar->setVisibleForMouselook(false); - - LLBottomTray::getInstance()->onMouselookModeIn(); - - LLSideTray::getInstance()->getButtonsPanel()->setVisible(FALSE); - LLSideTray::getInstance()->updateSidetrayVisibility(); - - LLPanelStandStopFlying::getInstance()->setVisible(FALSE); - - // clear out camera lag effect - gAgentCameraHACK.mCameraLag.clearVec(); - - // JC - Added for always chat in third person option - gFocusMgr.setKeyboardFocus(NULL); - - LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset); - - mViewsPushed = TRUE; - - // hide all floaters except the mini map - -#if 0 // Use this once all floaters are registered - std::set exceptions; - exceptions.insert("mini_map"); - LLFloaterReg::hideVisibleInstances(exceptions); -#else // Use this for now - LLFloaterView::skip_list_t skip_list; - skip_list.insert(LLFloaterReg::findInstance("mini_map")); - gFloaterView->pushVisibleAll(FALSE, skip_list); -#endif - - if( gMorphView ) - { - gMorphView->setVisible(FALSE); - } - - gConsole->setVisible( TRUE ); - - if (mAvatarObject.notNull()) - { - // Trigger mouselook-specific animations - if( mAvatarObject->isAnyAnimationSignaled(AGENT_GUN_HOLD_ANIMS, NUM_AGENT_GUN_HOLD_ANIMS) ) - { - if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_HOLD_RIFLE_R) != mAvatarObject->mSignaledAnimations.end()) - { - sendAnimationRequest(ANIM_AGENT_HOLD_RIFLE_R, ANIM_REQUEST_STOP); - sendAnimationRequest(ANIM_AGENT_AIM_RIFLE_R, ANIM_REQUEST_START); - } - if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_HOLD_HANDGUN_R) != mAvatarObject->mSignaledAnimations.end()) - { - sendAnimationRequest(ANIM_AGENT_HOLD_HANDGUN_R, ANIM_REQUEST_STOP); - sendAnimationRequest(ANIM_AGENT_AIM_HANDGUN_R, ANIM_REQUEST_START); - } - if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_HOLD_BAZOOKA_R) != mAvatarObject->mSignaledAnimations.end()) - { - sendAnimationRequest(ANIM_AGENT_HOLD_BAZOOKA_R, ANIM_REQUEST_STOP); - sendAnimationRequest(ANIM_AGENT_AIM_BAZOOKA_R, ANIM_REQUEST_START); - } - if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_HOLD_BOW_L) != mAvatarObject->mSignaledAnimations.end()) - { - sendAnimationRequest(ANIM_AGENT_HOLD_BOW_L, ANIM_REQUEST_STOP); - sendAnimationRequest(ANIM_AGENT_AIM_BOW_L, ANIM_REQUEST_START); - } - } - if (mAvatarObject->getParent()) - { - LLVector3 at_axis = LLViewerCamera::getInstance()->getAtAxis(); - LLViewerObject* root_object = (LLViewerObject*)mAvatarObject->getRoot(); - if (root_object->flagCameraDecoupled()) - { - resetAxes(at_axis); - } - else - { - resetAxes(at_axis * ~((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation()); - } - } - } - - } - else if (gAgentCameraHACK.mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR) - { - LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset); - - if( gMorphView ) - { - gMorphView->setVisible( TRUE ); - } - - // freeze avatar - if (mAvatarObject.notNull()) - { - mPauseRequest = mAvatarObject->requestPause(); - } - } - - if (getAvatarObject()) - { - getAvatarObject()->updateAttachmentVisibility(gAgentCameraHACK.mCameraMode); - } - - gFloaterTools->dirty(); - - // Don't let this be called more than once if the camera - // mode hasn't changed. --JC - gAgentCameraHACK.mLastCameraMode = gAgentCameraHACK.mCameraMode; - -} - -/* -//----------------------------------------------------------------------------- -// updateCamera() -//----------------------------------------------------------------------------- -void LLAgent::updateCamera() -{ - static LLFastTimer::DeclareTimer ftm("Camera"); - LLFastTimer t(ftm); - - //Ventrella - changed camera_skyward to the new global "mCameraUpVector" - mCameraUpVector = LLVector3::z_axis; - //LLVector3 camera_skyward(0.f, 0.f, 1.f); - //end Ventrella - - U32 camera_mode = mCameraAnimating ? mLastCameraMode : mCameraMode; - - validateFocusObject(); - - if (mAvatarObject.notNull() && - mAvatarObject->isSitting() && - camera_mode == CAMERA_MODE_MOUSELOOK) - { - //Ventrella - //changed camera_skyward to the new global "mCameraUpVector" - mCameraUpVector = mCameraUpVector * mAvatarObject->getRenderRotation(); - //end Ventrella - } - - if (cameraThirdPerson() && mFocusOnAvatar && LLFollowCamMgr::getActiveFollowCamParams()) - { - changeCameraToFollow(); - } - - //Ventrella - //NOTE - this needs to be integrated into a general upVector system here within llAgent. - if ( camera_mode == CAMERA_MODE_FOLLOW && mFocusOnAvatar ) - { - mCameraUpVector = mFollowCam.getUpVector(); - } - //end Ventrella - - if (mSitCameraEnabled) - { - if (mSitCameraReferenceObject->isDead()) - { - setSitCamera(LLUUID::null); - } - } - - // Update UI with our camera inputs - LLFloaterCamera* camera_floater = LLFloaterReg::findTypedInstance("camera"); - if (camera_floater) - { - camera_floater->mRotate->setToggleState( - mOrbitRightKey > 0.f, // left - mOrbitUpKey > 0.f, // top - mOrbitLeftKey > 0.f, // right - mOrbitDownKey > 0.f); // bottom - - camera_floater->mTrack->setToggleState( - mPanLeftKey > 0.f, // left - mPanUpKey > 0.f, // top - mPanRightKey > 0.f, // right - mPanDownKey > 0.f); // bottom - } - - // Handle camera movement based on keyboard. - const F32 ORBIT_OVER_RATE = 90.f * DEG_TO_RAD; // radians per second - const F32 ORBIT_AROUND_RATE = 90.f * DEG_TO_RAD; // radians per second - const F32 PAN_RATE = 5.f; // meters per second - - if( mOrbitUpKey || mOrbitDownKey ) - { - F32 input_rate = mOrbitUpKey - mOrbitDownKey; - cameraOrbitOver( input_rate * ORBIT_OVER_RATE / gFPSClamped ); - } - - if( mOrbitLeftKey || mOrbitRightKey) - { - F32 input_rate = mOrbitLeftKey - mOrbitRightKey; - cameraOrbitAround( input_rate * ORBIT_AROUND_RATE / gFPSClamped ); - } - - if( mOrbitInKey || mOrbitOutKey ) - { - F32 input_rate = mOrbitInKey - mOrbitOutKey; - - LLVector3d to_focus = gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()) - calcFocusPositionTargetGlobal(); - F32 distance_to_focus = (F32)to_focus.magVec(); - // Move at distance (in meters) meters per second - cameraOrbitIn( input_rate * distance_to_focus / gFPSClamped ); - } - - if( mPanInKey || mPanOutKey ) - { - F32 input_rate = mPanInKey - mPanOutKey; - cameraPanIn( input_rate * PAN_RATE / gFPSClamped ); - } - - if( mPanRightKey || mPanLeftKey ) - { - F32 input_rate = mPanRightKey - mPanLeftKey; - cameraPanLeft( input_rate * -PAN_RATE / gFPSClamped ); - } - - if( mPanUpKey || mPanDownKey ) - { - F32 input_rate = mPanUpKey - mPanDownKey; - cameraPanUp( input_rate * PAN_RATE / gFPSClamped ); - } - - // Clear camera keyboard keys. - mOrbitLeftKey = 0.f; - mOrbitRightKey = 0.f; - mOrbitUpKey = 0.f; - mOrbitDownKey = 0.f; - mOrbitInKey = 0.f; - mOrbitOutKey = 0.f; - - mPanRightKey = 0.f; - mPanLeftKey = 0.f; - mPanUpKey = 0.f; - mPanDownKey = 0.f; - mPanInKey = 0.f; - mPanOutKey = 0.f; - - // lerp camera focus offset - mCameraFocusOffset = lerp(mCameraFocusOffset, mCameraFocusOffsetTarget, LLCriticalDamp::getInterpolant(CAMERA_FOCUS_HALF_LIFE)); - - //Ventrella - if ( mCameraMode == CAMERA_MODE_FOLLOW ) - { - if ( mAvatarObject.notNull() ) - { - //-------------------------------------------------------------------------------- - // this is where the avatar's position and rotation are given to followCam, and - // where it is updated. All three of its attributes are updated: (1) position, - // (2) focus, and (3) upvector. They can then be queried elsewhere in llAgent. - //-------------------------------------------------------------------------------- - // *TODO: use combined rotation of frameagent and sit object - LLQuaternion avatarRotationForFollowCam = mAvatarObject->isSitting() ? mAvatarObject->getRenderRotation() : mFrameAgent.getQuaternion(); - - LLFollowCamParams* current_cam = LLFollowCamMgr::getActiveFollowCamParams(); - if (current_cam) - { - mFollowCam.copyParams(*current_cam); - mFollowCam.setSubjectPositionAndRotation( mAvatarObject->getRenderPosition(), avatarRotationForFollowCam ); - mFollowCam.update(); - LLViewerJoystick::getInstance()->setCameraNeedsUpdate(true); - } - else - { - changeCameraToThirdPerson(TRUE); - } - } - } - // end Ventrella - - BOOL hit_limit; - LLVector3d camera_pos_global; - LLVector3d camera_target_global = calcCameraPositionTargetGlobal(&hit_limit); - mCameraVirtualPositionAgent = getPosAgentFromGlobal(camera_target_global); - LLVector3d focus_target_global = calcFocusPositionTargetGlobal(); - - // perform field of view correction - mCameraFOVZoomFactor = calcCameraFOVZoomFactor(); - camera_target_global = focus_target_global + (camera_target_global - focus_target_global) * (1.f + mCameraFOVZoomFactor); - - mShowAvatar = TRUE; // can see avatar by default - - // Adjust position for animation - if (mCameraAnimating) - { - F32 time = mAnimationTimer.getElapsedTimeF32(); - - // yet another instance of critically damped motion, hooray! - // F32 fraction_of_animation = 1.f - pow(2.f, -time / CAMERA_ZOOM_HALF_LIFE); - - // linear interpolation - F32 fraction_of_animation = time / mAnimationDuration; - - BOOL isfirstPerson = mCameraMode == CAMERA_MODE_MOUSELOOK; - BOOL wasfirstPerson = mLastCameraMode == CAMERA_MODE_MOUSELOOK; - F32 fraction_animation_to_skip; - - if (mAnimationCameraStartGlobal == camera_target_global) - { - fraction_animation_to_skip = 0.f; - } - else - { - LLVector3d cam_delta = mAnimationCameraStartGlobal - camera_target_global; - fraction_animation_to_skip = HEAD_BUFFER_SIZE / (F32)cam_delta.magVec(); - } - F32 animation_start_fraction = (wasfirstPerson) ? fraction_animation_to_skip : 0.f; - F32 animation_finish_fraction = (isfirstPerson) ? (1.f - fraction_animation_to_skip) : 1.f; - - if (fraction_of_animation < animation_finish_fraction) - { - if (fraction_of_animation < animation_start_fraction || fraction_of_animation > animation_finish_fraction ) - { - mShowAvatar = FALSE; - } - - // ...adjust position for animation - F32 smooth_fraction_of_animation = llsmoothstep(0.0f, 1.0f, fraction_of_animation); - camera_pos_global = lerp(mAnimationCameraStartGlobal, camera_target_global, smooth_fraction_of_animation); - mFocusGlobal = lerp(mAnimationFocusStartGlobal, focus_target_global, smooth_fraction_of_animation); - } - else - { - // ...animation complete - mCameraAnimating = FALSE; - - camera_pos_global = camera_target_global; - mFocusGlobal = focus_target_global; - - endAnimationUpdateUI(); - mShowAvatar = TRUE; - } - - if (getAvatarObject() && mCameraMode != CAMERA_MODE_MOUSELOOK) - { - getAvatarObject()->updateAttachmentVisibility(mCameraMode); - } - } - else - { - camera_pos_global = camera_target_global; - mFocusGlobal = focus_target_global; - mShowAvatar = TRUE; - } - - // smoothing - if (TRUE) - { - LLVector3d agent_pos = getPositionGlobal(); - LLVector3d camera_pos_agent = camera_pos_global - agent_pos; - // Sitting on what you're manipulating can cause camera jitter with smoothing. - // This turns off smoothing while editing. -MG - mCameraSmoothingStop |= (BOOL)LLToolMgr::getInstance()->inBuildMode(); - - if (cameraThirdPerson() && !mCameraSmoothingStop) - { - const F32 SMOOTHING_HALF_LIFE = 0.02f; - - F32 smoothing = LLCriticalDamp::getInterpolant(gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE, FALSE); - - if (!mFocusObject) // we differentiate on avatar mode - { - // for avatar-relative focus, we smooth in avatar space - - // the avatar moves too jerkily w/r/t global space to smooth there. - - LLVector3d delta = camera_pos_agent - mCameraSmoothingLastPositionAgent; - if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE) // only smooth over short distances please - { - camera_pos_agent = lerp(mCameraSmoothingLastPositionAgent, camera_pos_agent, smoothing); - camera_pos_global = camera_pos_agent + agent_pos; - } - } - else - { - LLVector3d delta = camera_pos_global - mCameraSmoothingLastPositionGlobal; - if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE) // only smooth over short distances please - { - camera_pos_global = lerp(mCameraSmoothingLastPositionGlobal, camera_pos_global, smoothing); - } - } - } - - mCameraSmoothingLastPositionGlobal = camera_pos_global; - mCameraSmoothingLastPositionAgent = camera_pos_agent; - mCameraSmoothingStop = FALSE; - } - - - mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLCriticalDamp::getInterpolant(FOV_ZOOM_HALF_LIFE)); - -// llinfos << "Current FOV Zoom: " << mCameraCurrentFOVZoomFactor << " Target FOV Zoom: " << mCameraFOVZoomFactor << " Object penetration: " << mFocusObjectDist << llendl; - - F32 ui_offset = 0.f; - if( CAMERA_MODE_CUSTOMIZE_AVATAR == mCameraMode ) - { - ui_offset = calcCustomizeAvatarUIOffset( camera_pos_global ); - } - - - LLVector3 focus_agent = getPosAgentFromGlobal(mFocusGlobal); - - mCameraPositionAgent = getPosAgentFromGlobal(camera_pos_global); - - // Move the camera - - //Ventrella - LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, mCameraUpVector, focus_agent); - //LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, camera_skyward, focus_agent); - //end Ventrella - - //RN: translate UI offset after camera is oriented properly - LLViewerCamera::getInstance()->translate(LLViewerCamera::getInstance()->getLeftAxis() * ui_offset); - - // Change FOV - LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / (1.f + mCameraCurrentFOVZoomFactor)); - - // follow camera when in customize mode - if (cameraCustomizeAvatar()) - { - setLookAt(LOOKAT_TARGET_FOCUS, NULL, mCameraPositionAgent); - } - - // update the travel distance stat - // this isn't directly related to the camera - // but this seemed like the best place to do this - LLVector3d global_pos = getPositionGlobal(); - if (! mLastPositionGlobal.isExactlyZero()) - { - LLVector3d delta = global_pos - mLastPositionGlobal; - mDistanceTraveled += delta.magVec(); - } - mLastPositionGlobal = global_pos; - - if (LLVOAvatar::sVisibleInFirstPerson && mAvatarObject.notNull() && !mAvatarObject->isSitting() && cameraMouselook()) - { - LLVector3 head_pos = mAvatarObject->mHeadp->getWorldPosition() + - LLVector3(0.08f, 0.f, 0.05f) * mAvatarObject->mHeadp->getWorldRotation() + - LLVector3(0.1f, 0.f, 0.f) * mAvatarObject->mPelvisp->getWorldRotation(); - LLVector3 diff = mCameraPositionAgent - head_pos; - diff = diff * ~mAvatarObject->mRoot.getWorldRotation(); - - LLJoint* torso_joint = mAvatarObject->mTorsop; - LLJoint* chest_joint = mAvatarObject->mChestp; - LLVector3 torso_scale = torso_joint->getScale(); - LLVector3 chest_scale = chest_joint->getScale(); - - // shorten avatar skeleton to avoid foot interpenetration - if (!mAvatarObject->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 = mAvatarObject->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; - } - - mAvatarObject->mPelvisp->setPosition(mAvatarObject->mPelvisp->getPosition() + diff); - - mAvatarObject->mRoot.updateWorldMatrixChildren(); - - for (LLVOAvatar::attachment_map_t::iterator iter = mAvatarObject->mAttachmentPoints.begin(); - iter != mAvatarObject->mAttachmentPoints.end(); ) - { - LLVOAvatar::attachment_map_t::iterator curiter = iter++; - LLViewerJointAttachment* attachment = curiter->second; - for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); - attachment_iter != attachment->mAttachedObjects.end(); - ++attachment_iter) - { - LLViewerObject *attached_object = (*attachment_iter); - if (attached_object && !attached_object->isDead() && attached_object->mDrawable.notNull()) - { - // clear any existing "early" movements of attachment - attached_object->mDrawable->clearState(LLDrawable::EARLY_MOVE); - gPipeline.updateMoveNormalAsync(attached_object->mDrawable); - attached_object->updateText(); - } - } - } - - torso_joint->setScale(torso_scale); - chest_joint->setScale(chest_scale); - } -} - -void LLAgent::updateFocusOffset() -{ - validateFocusObject(); - if (mFocusObject.notNull()) - { - LLVector3d obj_pos = getPosGlobalFromAgent(mFocusObject->getRenderPosition()); - mFocusObjectOffset.setVec(mFocusTargetGlobal - obj_pos); - } -} - -void LLAgent::validateFocusObject() -{ - if (mFocusObject.notNull() && - (mFocusObject->isDead())) - { - mFocusObjectOffset.clearVec(); - clearFocusObject(); - mCameraFOVZoomFactor = 0.f; - } -} - -//----------------------------------------------------------------------------- -// calcCustomizeAvatarUIOffset() -//----------------------------------------------------------------------------- -F32 LLAgent::calcCustomizeAvatarUIOffset( const LLVector3d& camera_pos_global ) -{ - F32 ui_offset = 0.f; + mAutoPilotTargetDist = target_dist; - if( gFloaterCustomize ) - { - const LLRect& rect = gFloaterCustomize->getRect(); + // Make this a two-dimensional solution + at.mV[VZ] = 0.f; + direction.mV[VZ] = 0.f; - // Move the camera so that the avatar isn't covered up by this floater. - F32 fraction_of_fov = 0.5f - (0.5f * (1.f - llmin(1.f, ((F32)rect.getWidth() / (F32)gViewerWindow->getWindowWidthScaled())))); - F32 apparent_angle = fraction_of_fov * LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect(); // radians - F32 offset = tan(apparent_angle); + at.normalize(); + F32 xy_distance = direction.normalize(); - if( rect.mLeft < (gViewerWindow->getWindowWidthScaled() - rect.mRight) ) + F32 yaw = 0.f; + if (mAutoPilotTargetDist > mAutoPilotStopDistance) { - // Move the avatar to the right (camera to the left) - ui_offset = offset; + yaw = angle_between(mFrameAgent.getAtAxis(), direction); } - else + else if (mAutoPilotUseRotation) { - // Move the avatar to the left (camera to the right) - ui_offset = -offset; + // we're close now just aim at target facing + yaw = angle_between(at, mAutoPilotTargetFacing); + direction = mAutoPilotTargetFacing; } - } - F32 range = (F32)dist_vec(camera_pos_global, gAgentCamera.getFocusGlobal()); - gAgentCameraHACK.mUIOffset = lerp(mUIOffset, ui_offset, LLCriticalDamp::getInterpolant(0.05f)); - return mUIOffset * range; -} -//----------------------------------------------------------------------------- -// calcFocusPositionTargetGlobal() -//----------------------------------------------------------------------------- -LLVector3d LLAgent::calcFocusPositionTargetGlobal() -{ - if (mFocusObject.notNull() && mFocusObject->isDead()) - { - clearFocusObject(); - } + yaw = 4.f * yaw / gFPSClamped; - // Ventrella - if ( mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar ) - { - mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedFocus()); - return mFocusTargetGlobal; - }// End Ventrella - else if (mCameraMode == CAMERA_MODE_MOUSELOOK) - { - LLVector3d at_axis(1.0, 0.0, 0.0); - LLQuaternion agent_rot = mFrameAgent.getQuaternion(); - if (mAvatarObject.notNull() && mAvatarObject->getParent()) + // figure out which direction to turn + LLVector3 scratch(at % direction); + + if (scratch.mV[VZ] > 0.f) { - LLViewerObject* root_object = (LLViewerObject*)mAvatarObject->getRoot(); - if (!root_object->flagCameraDecoupled()) - { - agent_rot *= ((LLViewerObject*)(mAvatarObject->getParent()))->getRenderRotation(); - } + setControlFlags(AGENT_CONTROL_YAW_POS); } - at_axis = at_axis * agent_rot; - mFocusTargetGlobal = calcCameraPositionTargetGlobal() + at_axis; - return mFocusTargetGlobal; - } - else if (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR) - { - return mFocusTargetGlobal; - } - else if (!mFocusOnAvatar) - { - if (mFocusObject.notNull() && !mFocusObject->isDead() && mFocusObject->mDrawable.notNull()) + else { - LLDrawable* drawablep = mFocusObject->mDrawable; - - if (mTrackFocusObject && - drawablep && - drawablep->isActive()) - { - if (!mFocusObject->isAvatar()) - { - if (mFocusObject->isSelected()) - { - gPipeline.updateMoveNormalAsync(drawablep); - } - else - { - if (drawablep->isState(LLDrawable::MOVE_UNDAMPED)) - { - gPipeline.updateMoveNormalAsync(drawablep); - } - else - { - gPipeline.updateMoveDampedAsync(drawablep); - } - } - } - } - // if not tracking object, update offset based on new object position - else - { - updateFocusOffset(); - } - LLVector3 focus_agent = mFocusObject->getRenderPosition() + mFocusObjectOffset; - mFocusTargetGlobal.setVec(getPosGlobalFromAgent(focus_agent)); + yaw = -yaw; + setControlFlags(AGENT_CONTROL_YAW_NEG); } - return mFocusTargetGlobal; - } - else if (mSitCameraEnabled && mAvatarObject.notNull() && mAvatarObject->isSitting() && mSitCameraReferenceObject.notNull()) - { - // sit camera - LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition(); - LLQuaternion object_rot = mSitCameraReferenceObject->getRenderRotation(); - LLVector3 target_pos = object_pos + (mSitCameraFocus * object_rot); - return getPosGlobalFromAgent(target_pos); - } - else - { - return getPositionGlobal() + calcThirdPersonFocusOffset(); - } -} - -LLVector3d LLAgent::calcThirdPersonFocusOffset() -{ - // ...offset from avatar - LLVector3d focus_offset; - - LLQuaternion agent_rot = mFrameAgent.getQuaternion(); - if (!mAvatarObject.isNull() && mAvatarObject->getParent()) - { - agent_rot *= ((LLViewerObject*)(mAvatarObject->getParent()))->getRenderRotation(); - } - - focus_offset = mFocusOffsetInitial[mCameraPreset] * agent_rot; - return focus_offset; -} - -void LLAgent::setupSitCamera() -{ - // agent frame entering this function is in world coordinates - if (mAvatarObject.notNull() && mAvatarObject->getParent()) - { - LLQuaternion parent_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); - // slam agent coordinate frame to proper parent local version - LLVector3 at_axis = mFrameAgent.getAtAxis(); - at_axis.mV[VZ] = 0.f; - at_axis.normalize(); - resetAxes(at_axis * ~parent_rot); - } -} - -//----------------------------------------------------------------------------- -// getCameraPositionAgent() -//----------------------------------------------------------------------------- -const LLVector3 &LLAgent::getCameraPositionAgent() const -{ - return LLViewerCamera::getInstance()->getOrigin(); -} - -//----------------------------------------------------------------------------- -// getCameraPositionGlobal() -//----------------------------------------------------------------------------- -LLVector3d LLAgent::getCameraPositionGlobal() const -{ - return getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()); -} - -//----------------------------------------------------------------------------- -// calcCameraFOVZoomFactor() -//----------------------------------------------------------------------------- -F32 LLAgent::calcCameraFOVZoomFactor() -{ - LLVector3 camera_offset_dir; - camera_offset_dir.setVec(mCameraFocusOffset); - - if (mCameraMode == CAMERA_MODE_MOUSELOOK) - { - return 0.f; - } - else if (mFocusObject.notNull() && !mFocusObject->isAvatar() && !mFocusOnAvatar) - { - // don't FOV zoom on mostly transparent objects - LLVector3 focus_offset = mFocusObjectOffset; - F32 obj_min_dist = 0.f; - calcCameraMinDistance(obj_min_dist); - F32 current_distance = llmax(0.001f, camera_offset_dir.magVec()); - - mFocusObjectDist = obj_min_dist - current_distance; - - F32 new_fov_zoom = llclamp(mFocusObjectDist / current_distance, 0.f, 1000.f); - return new_fov_zoom; - } - else // focusing on land or avatar - { - // keep old field of view until user changes focus explicitly - return mCameraFOVZoomFactor; - //return 0.f; - } -} - -//----------------------------------------------------------------------------- -// calcCameraPositionTargetGlobal() -//----------------------------------------------------------------------------- -LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) -{ - // Compute base camera position and look-at points. - F32 camera_land_height; - LLVector3d frame_center_global = mAvatarObject.isNull() ? getPositionGlobal() - : getPosGlobalFromAgent(mAvatarObject->mRoot.getWorldPosition()); - - BOOL isConstrained = FALSE; - LLVector3d head_offset; - head_offset.setVec(mThirdPersonHeadOffset); - - LLVector3d camera_position_global; + *delta_yaw = yaw; - // Ventrella - if ( mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar ) - { - camera_position_global = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedPosition()); - }// End Ventrella - else if (mCameraMode == CAMERA_MODE_MOUSELOOK) - { - if (mAvatarObject.isNull() || mAvatarObject->mDrawable.isNull()) - { - llwarns << "Null avatar drawable!" << llendl; - return LLVector3d::zero; - } - head_offset.clearVec(); - if (mAvatarObject->isSitting() && mAvatarObject->getParent()) + // Compute when to start slowing down and when to stop + F32 stop_distance = mAutoPilotStopDistance; + F32 slow_distance; + if (getFlying()) { - mAvatarObject->updateHeadOffset(); - head_offset.mdV[VX] = mAvatarObject->mHeadOffset.mV[VX]; - head_offset.mdV[VY] = mAvatarObject->mHeadOffset.mV[VY]; - head_offset.mdV[VZ] = mAvatarObject->mHeadOffset.mV[VZ] + 0.1f; - const LLMatrix4& mat = ((LLViewerObject*) mAvatarObject->getParent())->getRenderMatrix(); - camera_position_global = getPosGlobalFromAgent - ((mAvatarObject->getPosition()+ - LLVector3(head_offset)*mAvatarObject->getRotation()) * mat); + slow_distance = llmax(6.f, mAutoPilotStopDistance + 5.f); + stop_distance = llmax(2.f, mAutoPilotStopDistance); } else { - head_offset.mdV[VZ] = mAvatarObject->mHeadOffset.mV[VZ]; - if (mAvatarObject->isSitting()) - { - head_offset.mdV[VZ] += 0.1; - } - camera_position_global = getPosGlobalFromAgent(mAvatarObject->getRenderPosition());//frame_center_global; - head_offset = head_offset * mAvatarObject->getRenderRotation(); - camera_position_global = camera_position_global + head_offset; + slow_distance = llmax(3.f, mAutoPilotStopDistance + 2.f); } - } - else if (mCameraMode == CAMERA_MODE_THIRD_PERSON && mFocusOnAvatar) - { - LLVector3 local_camera_offset; - F32 camera_distance = 0.f; - if (mSitCameraEnabled - && mAvatarObject.notNull() - && mAvatarObject->isSitting() - && mSitCameraReferenceObject.notNull()) - { - // sit camera - LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition(); - LLQuaternion object_rot = mSitCameraReferenceObject->getRenderRotation(); - - LLVector3 target_pos = object_pos + (mSitCameraPos * object_rot); - - camera_position_global = getPosGlobalFromAgent(target_pos); - } - else + // If we're flying, handle autopilot points above or below you. + if (getFlying() && xy_distance < AUTOPILOT_HEIGHT_ADJUST_DISTANCE) { - local_camera_offset = mCameraZoomFraction * getCameraOffsetInitial() * gSavedSettings.getF32("CameraOffsetScale"); - - // are we sitting down? - if (mAvatarObject.notNull() && mAvatarObject->getParent()) - { - LLQuaternion parent_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); - // slam agent coordinate frame to proper parent local version - LLVector3 at_axis = mFrameAgent.getAtAxis() * parent_rot; - at_axis.mV[VZ] = 0.f; - at_axis.normalize(); - resetAxes(at_axis * ~parent_rot); - - local_camera_offset = local_camera_offset * mFrameAgent.getQuaternion() * parent_rot; - } - else - { - local_camera_offset = mFrameAgent.rotateToAbsolute( local_camera_offset ); - } - - if (!mCameraCollidePlane.isExactlyZero() && (mAvatarObject.isNull() || !mAvatarObject->isSitting())) + if (mAvatarObject.notNull()) { - LLVector3 plane_normal; - plane_normal.setVec(mCameraCollidePlane.mV); - - F32 offset_dot_norm = local_camera_offset * plane_normal; - if (llabs(offset_dot_norm) < 0.001f) - { - offset_dot_norm = 0.001f; - } - - camera_distance = local_camera_offset.normalize(); - - F32 pos_dot_norm = getPosAgentFromGlobal(frame_center_global + head_offset) * plane_normal; - - // if agent is outside the colliding half-plane - if (pos_dot_norm > mCameraCollidePlane.mV[VW]) + F64 current_height = mAvatarObject->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) { - // check to see if camera is on the opposite side (inside) the half-plane - if (offset_dot_norm + pos_dot_norm < mCameraCollidePlane.mV[VW]) - { - // diminish offset by factor to push it back outside the half-plane - camera_distance *= (pos_dot_norm - mCameraCollidePlane.mV[VW] - CAMERA_COLLIDE_EPSILON) / -offset_dot_norm; - } + setControlFlags(AGENT_CONTROL_FAST_UP | AGENT_CONTROL_UP_POS); } - else + else if (slope > 0.002f && delta_z > 0.5f) { - if (offset_dot_norm + pos_dot_norm > mCameraCollidePlane.mV[VW]) - { - camera_distance *= (mCameraCollidePlane.mV[VW] - pos_dot_norm - CAMERA_COLLIDE_EPSILON) / offset_dot_norm; - } + setControlFlags(AGENT_CONTROL_UP_POS); } - } - else - { - camera_distance = local_camera_offset.normalize(); - } - - mTargetCameraDistance = llmax(camera_distance, MIN_CAMERA_DISTANCE); - - if (mTargetCameraDistance != mCurrentCameraDistance) - { - F32 camera_lerp_amt = LLCriticalDamp::getInterpolant(CAMERA_ZOOM_HALF_LIFE); - - mCurrentCameraDistance = lerp(mCurrentCameraDistance, mTargetCameraDistance, camera_lerp_amt); - } - - // Make the camera distance current - local_camera_offset *= mCurrentCameraDistance; - - // set the global camera position - LLVector3d camera_offset; - - LLVector3 av_pos = mAvatarObject.isNull() ? LLVector3::zero : mAvatarObject->getRenderPosition(); - camera_offset.setVec( local_camera_offset ); - camera_position_global = frame_center_global + head_offset + camera_offset; - - if (mAvatarObject.notNull()) - { - LLVector3d camera_lag_d; - F32 lag_interp = LLCriticalDamp::getInterpolant(CAMERA_LAG_HALF_LIFE); - LLVector3 target_lag; - LLVector3 vel = getVelocity(); - - // lag by appropriate amount for flying - F32 time_in_air = mAvatarObject->mTimeInAir.getElapsedTimeF32(); - if(!mCameraAnimating && mAvatarObject->mInAir && time_in_air > GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME) + else if (slope < -0.45f && delta_z < -6.f && current_height > AUTOPILOT_MIN_TARGET_HEIGHT_OFF_GROUND) { - LLVector3 frame_at_axis = mFrameAgent.getAtAxis(); - frame_at_axis -= projected_vec(frame_at_axis, getReferenceUpVector()); - frame_at_axis.normalize(); - - //transition smoothly in air mode, to avoid camera pop - F32 u = (time_in_air - GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME) / GROUND_TO_AIR_CAMERA_TRANSITION_TIME; - u = llclamp(u, 0.f, 1.f); - - lag_interp *= u; - - if (gViewerWindow->getLeftMouseDown() && gViewerWindow->getLastPick().mObjectID == mAvatarObject->getID()) - { - // disable camera lag when using mouse-directed steering - target_lag.clearVec(); - } - else - { - target_lag = vel * gSavedSettings.getF32("DynamicCameraStrength") / 30.f; - } - - mCameraLag = lerp(mCameraLag, target_lag, lag_interp); - - F32 lag_dist = mCameraLag.magVec(); - if (lag_dist > MAX_CAMERA_LAG) - { - mCameraLag = mCameraLag * MAX_CAMERA_LAG / lag_dist; - } - - // clamp camera lag so that avatar is always in front - F32 dot = (mCameraLag - (frame_at_axis * (MIN_CAMERA_LAG * u))) * frame_at_axis; - if (dot < -(MIN_CAMERA_LAG * u)) - { - mCameraLag -= (dot + (MIN_CAMERA_LAG * u)) * frame_at_axis; - } + setControlFlags(AGENT_CONTROL_FAST_UP | AGENT_CONTROL_UP_NEG); } - else + else if (slope < -0.002f && delta_z < -0.5f && current_height > AUTOPILOT_MIN_TARGET_HEIGHT_OFF_GROUND) { - mCameraLag = lerp(mCameraLag, LLVector3::zero, LLCriticalDamp::getInterpolant(0.15f)); + setControlFlags(AGENT_CONTROL_UP_NEG); } - - camera_lag_d.setVec(mCameraLag); - camera_position_global = camera_position_global - camera_lag_d; } } - } - else - { - LLVector3d focusPosGlobal = calcFocusPositionTargetGlobal(); - // camera gets pushed out later wrt mCameraFOVZoomFactor...this is "raw" value - camera_position_global = focusPosGlobal + mCameraFocusOffset; - } - - if (!gSavedSettings.getBOOL("DisableCameraConstraints") && !gAgent.isGodlike()) - { - LLViewerRegion* regionp = LLWorld::getInstance()->getRegionFromPosGlobal( - camera_position_global); - bool constrain = true; - if(regionp && regionp->canManageEstate()) - { - constrain = false; - } - if(constrain) - { - F32 max_dist = ( CAMERA_MODE_CUSTOMIZE_AVATAR == mCameraMode ) ? - APPEARANCE_MAX_ZOOM : mDrawDistance; - LLVector3d camera_offset = camera_position_global - - gAgent.getPositionGlobal(); - F32 camera_distance = (F32)camera_offset.magVec(); + // calculate delta rotation to target heading + F32 delta_target_heading = angle_between(mFrameAgent.getAtAxis(), mAutoPilotTargetFacing); - if(camera_distance > max_dist) - { - camera_position_global = gAgent.getPositionGlobal() + - (max_dist / camera_distance) * camera_offset; - isConstrained = TRUE; - } + if (xy_distance > slow_distance && yaw < (F_PI / 10.f)) + { + // walking/flying fast + setControlFlags(AGENT_CONTROL_FAST_AT | AGENT_CONTROL_AT_POS); } - -// JC - Could constrain camera based on parcel stuff here. -// LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global); -// -// if (regionp && !regionp->mParcelOverlay->isBuildCameraAllowed(regionp->getPosRegionFromGlobal(camera_position_global))) -// { -// camera_position_global = last_position_global; -// -// isConstrained = TRUE; -// } - } - - // Don't let camera go underground - F32 camera_min_off_ground = getCameraMinOffGround(); - - camera_land_height = LLWorld::getInstance()->resolveLandHeightGlobal(camera_position_global); - - if (camera_position_global.mdV[VZ] < camera_land_height + camera_min_off_ground) - { - camera_position_global.mdV[VZ] = camera_land_height + camera_min_off_ground; - isConstrained = TRUE; - } - - - if (hit_limit) - { - *hit_limit = isConstrained; - } - - return camera_position_global; -} - - -LLVector3 LLAgent::getCameraOffsetInitial() -{ - return mCameraOffsetInitial[mCameraPreset]; -} - -//----------------------------------------------------------------------------- -// handleScrollWheel() -//----------------------------------------------------------------------------- -void LLAgent::handleScrollWheel(S32 clicks) -{ - if ( mCameraMode == CAMERA_MODE_FOLLOW && gAgentCamera.getFocusOnAvatar()) - { - if ( ! mFollowCam.getPositionLocked() ) // not if the followCam position is locked in place + else if (mAutoPilotTargetDist > mAutoPilotStopDistance) { - mFollowCam.zoom( clicks ); - if ( mFollowCam.isZoomedToMinimumDistance() ) + // walking/flying slow + if (at * direction > 0.9f) { - changeCameraToMouselook(FALSE); + setControlFlags(AGENT_CONTROL_AT_POS); + } + else if (at * direction < -0.9f) + { + setControlFlags(AGENT_CONTROL_AT_NEG); } } - } - else - { - LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); - const F32 ROOT_ROOT_TWO = sqrt(F_SQRT2); - - // Block if camera is animating - if (mCameraAnimating) - { - return; - } - - if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) - { - F32 zoom_factor = (F32)pow(0.8, -clicks); - cameraZoomIn(zoom_factor); - } - else if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON) - { - F32 camera_offset_initial_mag = getCameraOffsetInitial().magVec(); - - F32 current_zoom_fraction = mTargetCameraDistance / (camera_offset_initial_mag * gSavedSettings.getF32("CameraOffsetScale")); - current_zoom_fraction *= 1.f - pow(ROOT_ROOT_TWO, clicks); - - cameraOrbitIn(current_zoom_fraction * camera_offset_initial_mag * gSavedSettings.getF32("CameraOffsetScale")); - } - else + + // check to see if we need to keep rotating to target orientation + if (mAutoPilotTargetDist < mAutoPilotStopDistance) { - F32 current_zoom_fraction = (F32)mCameraFocusOffsetTarget.magVec(); - cameraOrbitIn(current_zoom_fraction * (1.f - pow(ROOT_ROOT_TWO, clicks))); + setControlFlags(AGENT_CONTROL_STOP); + if(!mAutoPilotUseRotation || (delta_target_heading < mAutoPilotRotationThreshold)) + { + stopAutoPilot(); + } } } } + //----------------------------------------------------------------------------- -// getCameraMinOffGround() +// propagate() //----------------------------------------------------------------------------- -F32 LLAgent::getCameraMinOffGround() +void LLAgent::propagate(const F32 dt) { - if (mCameraMode == CAMERA_MODE_MOUSELOOK) + // Update UI based on agent motion + LLFloaterMove *floater_move = LLFloaterReg::findTypedInstance("moveview"); + if (floater_move) { - return 0.f; + floater_move->mForwardButton ->setToggleState( mAtKey > 0 || mWalkKey > 0 ); + floater_move->mBackwardButton ->setToggleState( mAtKey < 0 || mWalkKey < 0 ); + floater_move->mTurnLeftButton ->setToggleState( mYawKey > 0.f ); + floater_move->mTurnRightButton ->setToggleState( mYawKey < 0.f ); + floater_move->mMoveUpButton ->setToggleState( mUpKey > 0 ); + floater_move->mMoveDownButton ->setToggleState( mUpKey < 0 ); } - else + + // handle rotation based on keyboard levels + const F32 YAW_RATE = 90.f * DEG_TO_RAD; // radians per second + yaw(YAW_RATE * mYawKey * dt); + + const F32 PITCH_RATE = 90.f * DEG_TO_RAD; // radians per second + pitch(PITCH_RATE * mPitchKey * dt); + + // handle auto-land behavior + if (mAvatarObject.notNull()) { - if (gSavedSettings.getBOOL("DisableCameraConstraints")) - { - return -1000.f; - } - else + BOOL in_air = mAvatarObject->mInAir; + LLVector3 land_vel = getVelocity(); + land_vel.mV[VZ] = 0.f; + + if (!in_air + && mUpKey < 0 + && land_vel.magVecSquared() < MAX_VELOCITY_AUTO_LAND_SQUARED + && gSavedSettings.getBOOL("AutomaticFly")) { - return 0.5f; + // land automatically + setFlying(FALSE); } } -} - - -//----------------------------------------------------------------------------- -// resetCamera() -//----------------------------------------------------------------------------- -void LLAgent::resetCamera() -{ - // Remove any pitch from the avatar - LLVector3 at = mFrameAgent.getAtAxis(); - at.mV[VZ] = 0.f; - at.normalize(); - gAgent.resetAxes(at); - // have to explicitly clear field of view zoom now - mCameraFOVZoomFactor = 0.f; - updateCamera(); + // clear keys + mAtKey = 0; + mWalkKey = 0; + mLeftKey = 0; + mUpKey = 0; + mYawKey = 0.f; + mPitchKey = 0.f; } //----------------------------------------------------------------------------- -// changeCameraToMouselook() +// updateAgentPosition() //----------------------------------------------------------------------------- -void LLAgent::changeCameraToMouselook(BOOL animate) +void LLAgent::updateAgentPosition(const F32 dt, const F32 yaw_radians, const S32 mouse_x, const S32 mouse_y) { - if (LLViewerJoystick::getInstance()->getOverrideCamera()) - { - return; - } - - // visibility changes at end of animation - gViewerWindow->getWindow()->resetBusyCount(); - - // unpause avatar animation - mPauseRequest = NULL; + propagate(dt); - LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset); + // static S32 cameraUpdateCount = 0; - if (mAvatarObject.notNull()) - { - mAvatarObject->stopMotion( ANIM_AGENT_BODY_NOISE ); - mAvatarObject->stopMotion( ANIM_AGENT_BREATHE_ROT ); - } + rotate(yaw_radians, 0, 0, 1); + + // + // Check for water and land collision, set underwater flag + // - //gViewerWindow->stopGrab(); - LLSelectMgr::getInstance()->deselectAll(); - gViewerWindow->hideCursor(); - gViewerWindow->moveCursorToCenter(); + gAgentCamera.updateLookAt(mouse_x, mouse_y); +} - if( mCameraMode != CAMERA_MODE_MOUSELOOK ) - { - gFocusMgr.setKeyboardFocus( NULL ); - - mLastCameraMode = mCameraMode; - mCameraMode = CAMERA_MODE_MOUSELOOK; - U32 old_flags = mControlFlags; - setControlFlags(AGENT_CONTROL_MOUSELOOK); - if (old_flags != mControlFlags) - { - mbFlagsDirty = TRUE; - } +// friends and operators - if (animate) - { - startCameraAnimation(); - } - else - { - mCameraAnimating = FALSE; - endAnimationUpdateUI(); - } - } +std::ostream& operator<<(std::ostream &s, const LLAgent &agent) +{ + // This is unfinished, but might never be used. + // We'll just leave it for now; we can always delete it. + s << " { " + << " Frame = " << agent.mFrameAgent << "\n" + << " }"; + return s; } +// ------------------- Beginning of legacy LLCamera hack ---------------------- +// This section is included for legacy LLCamera support until +// it is no longer needed. Some legacy code must exist in +// non-legacy functions, and is labeled with "// legacy" comments. + //----------------------------------------------------------------------------- -// changeCameraToDefault() +// setAvatarObject() //----------------------------------------------------------------------------- -void LLAgent::changeCameraToDefault() -{ - if (LLViewerJoystick::getInstance()->getOverrideCamera()) +void LLAgent::setAvatarObject(LLVOAvatarSelf *avatar) +{ + mAvatarObject = avatar; + + if (!avatar) { + llinfos << "Setting LLAgent::mAvatarObject to NULL" << llendl; return; } - if (LLFollowCamMgr::getActiveFollowCamParams()) + if (!gAgentCamera.mLookAt) { - changeCameraToFollow(); + gAgentCamera.mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT); } - else + if (!gAgentCamera.mPointAt) { - changeCameraToThirdPerson(); + gAgentCamera.mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT); + } + + if (!gAgentCamera.mLookAt.isNull()) + { + gAgentCamera.mLookAt->setSourceObject(avatar); + } + if (!gAgentCamera.mPointAt.isNull()) + { + gAgentCamera.mPointAt->setSourceObject(avatar); } } - -// Ventrella +// TRUE if your own avatar needs to be rendered. Usually only +// in third person and build. //----------------------------------------------------------------------------- -// changeCameraToFollow() +// needsRenderAvatar() //----------------------------------------------------------------------------- -void LLAgent::changeCameraToFollow(BOOL animate) +BOOL LLAgent::needsRenderAvatar() { - if (LLViewerJoystick::getInstance()->getOverrideCamera()) + if (gAgentCamera.cameraMouselook() && !LLVOAvatar::sVisibleInFirstPerson) { - return; + return FALSE; } - if( mCameraMode != CAMERA_MODE_FOLLOW ) - { - if (mCameraMode == CAMERA_MODE_MOUSELOOK) - { - animate = FALSE; - } - startCameraAnimation(); - - mLastCameraMode = mCameraMode; - mCameraMode = CAMERA_MODE_FOLLOW; - - // bang-in the current focus, position, and up vector of the follow cam - mFollowCam.reset( mCameraPositionAgent, LLViewerCamera::getInstance()->getPointOfInterest(), LLVector3::z_axis ); - - if (gBasicToolset) - { - LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); - } - - if (mAvatarObject.notNull()) - { - mAvatarObject->mPelvisp->setPosition(LLVector3::zero); - mAvatarObject->startMotion( ANIM_AGENT_BODY_NOISE ); - mAvatarObject->startMotion( ANIM_AGENT_BREATHE_ROT ); - } - - // unpause avatar animation - mPauseRequest = NULL; - - U32 old_flags = mControlFlags; - clearControlFlags(AGENT_CONTROL_MOUSELOOK); - if (old_flags != mControlFlags) - { - mbFlagsDirty = TRUE; - } + return mShowAvatar && mGenderChosen; +} - if (animate) - { - startCameraAnimation(); - } - else - { - mCameraAnimating = FALSE; - endAnimationUpdateUI(); - } - } +// TRUE if we need to render your own avatar's head. +BOOL LLAgent::needsRenderHead() +{ + return (LLVOAvatar::sVisibleInFirstPerson && LLPipeline::sReflectionRender) || (mShowAvatar && !gAgentCamera.cameraMouselook()); } //----------------------------------------------------------------------------- -// changeCameraToThirdPerson() +// startTyping() //----------------------------------------------------------------------------- -void LLAgent::changeCameraToThirdPerson(BOOL animate) +void LLAgent::startTyping() { - if (LLViewerJoystick::getInstance()->getOverrideCamera()) - { - return; - } - - gViewerWindow->getWindow()->resetBusyCount(); - - mCameraZoomFraction = INITIAL_ZOOM_FRACTION; + mTypingTimer.reset(); - if (mAvatarObject.notNull()) + if (getRenderState() & AGENT_STATE_TYPING) { - if (!mAvatarObject->isSitting()) - { - mAvatarObject->mPelvisp->setPosition(LLVector3::zero); - } - mAvatarObject->startMotion( ANIM_AGENT_BODY_NOISE ); - mAvatarObject->startMotion( ANIM_AGENT_BREATHE_ROT ); + // already typing, don't trigger a different animation + return; } + setRenderState(AGENT_STATE_TYPING); - LLVector3 at_axis; - - // unpause avatar animation - mPauseRequest = NULL; - - if( mCameraMode != CAMERA_MODE_THIRD_PERSON ) + if (mChatTimer.getElapsedTimeF32() < 2.f) { - if (gBasicToolset) - { - LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); - } - - mCameraLag.clearVec(); - if (mCameraMode == CAMERA_MODE_MOUSELOOK) - { - mCurrentCameraDistance = MIN_CAMERA_DISTANCE; - mTargetCameraDistance = MIN_CAMERA_DISTANCE; - animate = FALSE; - } - mLastCameraMode = mCameraMode; - mCameraMode = CAMERA_MODE_THIRD_PERSON; - U32 old_flags = mControlFlags; - clearControlFlags(AGENT_CONTROL_MOUSELOOK); - if (old_flags != mControlFlags) + LLViewerObject* chatter = gObjectList.findObject(mLastChatterID); + if (chatter && chatter->isAvatar()) { - mbFlagsDirty = TRUE; + gAgentCamera.setLookAt(LOOKAT_TARGET_RESPOND, chatter, LLVector3::zero); } - } - // Remove any pitch from the avatar - if (mAvatarObject.notNull() && mAvatarObject->getParent()) - { - LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); - at_axis = LLViewerCamera::getInstance()->getAtAxis(); - at_axis.mV[VZ] = 0.f; - at_axis.normalize(); - resetAxes(at_axis * ~obj_rot); - } - else + if (gSavedSettings.getBOOL("PlayTypingAnim")) { - at_axis = mFrameAgent.getAtAxis(); - at_axis.mV[VZ] = 0.f; - at_axis.normalize(); - resetAxes(at_axis); + sendAnimationRequest(ANIM_AGENT_TYPE, ANIM_REQUEST_START); } + LLNearbyChatBar::getInstance()->sendChatFromViewer("", CHAT_TYPE_START, FALSE); +} - - if (animate) - { - startCameraAnimation(); - } - else +//----------------------------------------------------------------------------- +// stopTyping() +//----------------------------------------------------------------------------- +void LLAgent::stopTyping() +{ + if (mRenderState & AGENT_STATE_TYPING) { - mCameraAnimating = FALSE; - endAnimationUpdateUI(); + clearRenderState(AGENT_STATE_TYPING); + sendAnimationRequest(ANIM_AGENT_TYPE, ANIM_REQUEST_STOP); + LLNearbyChatBar::getInstance()->sendChatFromViewer("", CHAT_TYPE_STOP, FALSE); } } //----------------------------------------------------------------------------- -// changeCameraToCustomizeAvatar() +// setRenderState() //----------------------------------------------------------------------------- -void LLAgent::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL camera_animate) +void LLAgent::setRenderState(U8 newstate) { - if (LLViewerJoystick::getInstance()->getOverrideCamera()) - { - return; - } + mRenderState |= newstate; +} - standUp(); // force stand up - gViewerWindow->getWindow()->resetBusyCount(); +//----------------------------------------------------------------------------- +// clearRenderState() +//----------------------------------------------------------------------------- +void LLAgent::clearRenderState(U8 clearstate) +{ + mRenderState &= ~clearstate; +} - if (gFaceEditToolset) - { - LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset); - } - if (camera_animate) +//----------------------------------------------------------------------------- +// getRenderState() +//----------------------------------------------------------------------------- +U8 LLAgent::getRenderState() +{ + if (gNoRender || gKeyboard == NULL) { - startCameraAnimation(); + return 0; } - // Remove any pitch from the avatar - //LLVector3 at = mFrameAgent.getAtAxis(); - //at.mV[VZ] = 0.f; - //at.normalize(); - //gAgent.resetAxes(at); - - if( mCameraMode != CAMERA_MODE_CUSTOMIZE_AVATAR ) + // *FIX: don't do stuff in a getter! This is infinite loop city! + if ((mTypingTimer.getElapsedTimeF32() > TYPING_TIMEOUT_SECS) + && (mRenderState & AGENT_STATE_TYPING)) { - mLastCameraMode = mCameraMode; - mCameraMode = CAMERA_MODE_CUSTOMIZE_AVATAR; - U32 old_flags = mControlFlags; - clearControlFlags(AGENT_CONTROL_MOUSELOOK); - if (old_flags != mControlFlags) - { - mbFlagsDirty = TRUE; - } - - gFocusMgr.setKeyboardFocus( NULL ); - gFocusMgr.setMouseCapture( NULL ); - - LLVOAvatarSelf::onCustomizeStart(); + stopTyping(); } - - if (mAvatarObject.notNull()) + + if ((!LLSelectMgr::getInstance()->getSelection()->isEmpty() && LLSelectMgr::getInstance()->shouldShowSelection()) + || LLToolMgr::getInstance()->getCurrentTool()->isEditing() ) { - if(avatar_animate) - { - // Remove any pitch from the avatar - LLVector3 at = mFrameAgent.getAtAxis(); - at.mV[VZ] = 0.f; - at.normalize(); - gAgent.resetAxes(at); - - sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_START); - mCustomAnim = TRUE ; - mAvatarObject->startMotion(ANIM_AGENT_CUSTOMIZE); - LLMotion* turn_motion = mAvatarObject->findMotion(ANIM_AGENT_CUSTOMIZE); - - if (turn_motion) - { - mAnimationDuration = turn_motion->getDuration() + CUSTOMIZE_AVATAR_CAMERA_ANIM_SLOP; - - } - else - { - mAnimationDuration = gSavedSettings.getF32("ZoomTime"); - } - } - - - - gAgentCamera.setFocusGlobal(LLVector3d::zero); + setRenderState(AGENT_STATE_EDITING); } else { - mCameraAnimating = FALSE; - endAnimationUpdateUI(); - } - -} - - -void LLAgent::switchCameraPreset(ECameraPreset preset) -{ - //zoom is supposed to be reset for the front and group views - mCameraZoomFraction = 1.f; - - //focusing on avatar in that case means following him on movements - mFocusOnAvatar = TRUE; - - mCameraPreset = preset; + clearRenderState(AGENT_STATE_EDITING); + } - gSavedSettings.setU32("CameraPreset", mCameraPreset); + return mRenderState; } - -// -// Focus point management -// - //----------------------------------------------------------------------------- -// startCameraAnimation() //----------------------------------------------------------------------------- -void LLAgent::startCameraAnimation() -{ - mAnimationCameraStartGlobal = getCameraPositionGlobal(); - mAnimationFocusStartGlobal = mFocusGlobal; - mAnimationTimer.reset(); - mCameraAnimating = TRUE; - mAnimationDuration = gSavedSettings.getF32("ZoomTime"); -} //----------------------------------------------------------------------------- -// stopCameraAnimation() +// endAnimationUpdateUI() //----------------------------------------------------------------------------- -void LLAgent::stopCameraAnimation() -{ - mCameraAnimating = FALSE; -} - -void LLAgent::clearFocusObject() +void LLAgent::endAnimationUpdateUI() { - if (mFocusObject.notNull()) + if (gAgentCamera.mCameraMode == gAgentCamera.mLastCameraMode) { - startCameraAnimation(); - - setFocusObject(NULL); - mFocusObjectOffset.clearVec(); + // We're already done endAnimationUpdateUI for this transition. + return; } -} -void LLAgent::setFocusObject(LLViewerObject* object) -{ - mFocusObject = object; -} + // clean up UI from mode we're leaving + if (gAgentCamera.mLastCameraMode == CAMERA_MODE_MOUSELOOK ) + { + // show mouse cursor + gViewerWindow->showCursor(); + // show menus + gMenuBarView->setVisible(TRUE); + LLNavigationBar::getInstance()->setVisible(TRUE); + gStatusBar->setVisibleForMouselook(true); -// Focus on a point, but try to keep camera position stable. -//----------------------------------------------------------------------------- -// setFocusGlobal() -//----------------------------------------------------------------------------- -void LLAgent::setFocusGlobal(const LLPickInfo& pick) -{ - LLViewerObject* objectp = gObjectList.findObject(pick.mObjectID); + LLBottomTray::getInstance()->onMouselookModeOut(); - if (objectp) - { - // focus on object plus designated offset - // which may or may not be same as pick.mPosGlobal - setFocusGlobal(objectp->getPositionGlobal() + LLVector3d(pick.mObjectOffset), pick.mObjectID); - } - else - { - // focus directly on point where user clicked - setFocusGlobal(pick.mPosGlobal, pick.mObjectID); - } -} + LLSideTray::getInstance()->getButtonsPanel()->setVisible(TRUE); + LLSideTray::getInstance()->updateSidetrayVisibility(); + LLPanelStandStopFlying::getInstance()->setVisible(TRUE); -void LLAgent::setFocusGlobal(const LLVector3d& focus, const LLUUID &object_id) -{ - setFocusObject(gObjectList.findObject(object_id)); - LLVector3d old_focus = mFocusTargetGlobal; - LLViewerObject *focus_obj = mFocusObject; + LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); - // if focus has changed - if (old_focus != focus) - { - if (focus.isExactlyZero()) + LLFloaterCamera::onLeavingMouseLook(); + + // Only pop if we have pushed... + if (TRUE == mViewsPushed) { - if (mAvatarObject.notNull()) - { - mFocusTargetGlobal = getPosGlobalFromAgent(mAvatarObject->mHeadp->getWorldPosition()); - } - else +#if 0 // Use this once all floaters are registered + LLFloaterReg::restoreVisibleInstances(); +#else // Use this for now + LLFloaterView::skip_list_t skip_list; + if (LLFloaterReg::findInstance("mini_map")) { - mFocusTargetGlobal = getPositionGlobal(); + skip_list.insert(LLFloaterReg::findInstance("mini_map")); } - mCameraFocusOffsetTarget = getCameraPositionGlobal() - mFocusTargetGlobal; - mCameraFocusOffset = mCameraFocusOffsetTarget; - setLookAt(LOOKAT_TARGET_CLEAR); + + gFloaterView->popVisibleAll(skip_list); +#endif + mViewsPushed = FALSE; } - else - { - mFocusTargetGlobal = focus; - if (!focus_obj) - { - mCameraFOVZoomFactor = 0.f; - } - mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(mCameraVirtualPositionAgent) - mFocusTargetGlobal; - - startCameraAnimation(); + + gAgentCamera.setLookAt(LOOKAT_TARGET_CLEAR); + if( gMorphView ) + { + gMorphView->setVisible( FALSE ); + } - if (focus_obj) + // Disable mouselook-specific animations + if (mAvatarObject.notNull()) + { + if( mAvatarObject->isAnyAnimationSignaled(AGENT_GUN_AIM_ANIMS, NUM_AGENT_GUN_AIM_ANIMS) ) { - if (focus_obj->isAvatar()) + if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_AIM_RIFLE_R) != mAvatarObject->mSignaledAnimations.end()) { - setLookAt(LOOKAT_TARGET_FOCUS, focus_obj); + sendAnimationRequest(ANIM_AGENT_AIM_RIFLE_R, ANIM_REQUEST_STOP); + sendAnimationRequest(ANIM_AGENT_HOLD_RIFLE_R, ANIM_REQUEST_START); } - else + if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_AIM_HANDGUN_R) != mAvatarObject->mSignaledAnimations.end()) { - setLookAt(LOOKAT_TARGET_FOCUS, focus_obj, (getPosAgentFromGlobal(focus) - focus_obj->getRenderPosition()) * ~focus_obj->getRenderRotation()); + sendAnimationRequest(ANIM_AGENT_AIM_HANDGUN_R, ANIM_REQUEST_STOP); + sendAnimationRequest(ANIM_AGENT_HOLD_HANDGUN_R, ANIM_REQUEST_START); + } + if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_AIM_BAZOOKA_R) != mAvatarObject->mSignaledAnimations.end()) + { + sendAnimationRequest(ANIM_AGENT_AIM_BAZOOKA_R, ANIM_REQUEST_STOP); + sendAnimationRequest(ANIM_AGENT_HOLD_BAZOOKA_R, ANIM_REQUEST_START); + } + if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_AIM_BOW_L) != mAvatarObject->mSignaledAnimations.end()) + { + sendAnimationRequest(ANIM_AGENT_AIM_BOW_L, ANIM_REQUEST_STOP); + sendAnimationRequest(ANIM_AGENT_HOLD_BOW_L, ANIM_REQUEST_START); } - } - else - { - setLookAt(LOOKAT_TARGET_FOCUS, NULL, getPosAgentFromGlobal(mFocusTargetGlobal)); } } } - else // focus == mFocusTargetGlobal + else + if(gAgentCamera.mLastCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR) { - if (focus.isExactlyZero()) + // make sure we ask to save changes + + LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); + + if( gMorphView ) { - if (mAvatarObject.notNull()) - { - mFocusTargetGlobal = getPosGlobalFromAgent(mAvatarObject->mHeadp->getWorldPosition()); - } - else - { - mFocusTargetGlobal = getPositionGlobal(); - } + gMorphView->setVisible( FALSE ); } - mCameraFocusOffsetTarget = (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor);; - mCameraFocusOffset = mCameraFocusOffsetTarget; - } - if (mFocusObject.notNull()) - { - // for attachments, make offset relative to avatar, not the attachment - if (mFocusObject->isAttachment()) + if (mAvatarObject.notNull()) { - while (mFocusObject.notNull() // DEV-29123 - can crash with a messed-up attachment - && !mFocusObject->isAvatar()) + if(mCustomAnim) { - mFocusObject = (LLViewerObject*) mFocusObject->getParent(); + sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_STOP); + sendAnimationRequest(ANIM_AGENT_CUSTOMIZE_DONE, ANIM_REQUEST_START); + + mCustomAnim = FALSE ; } - setFocusObject((LLViewerObject*)mFocusObject); + } - updateFocusOffset(); + gAgentCamera.setLookAt(LOOKAT_TARGET_CLEAR); } -} - -// Used for avatar customization -//----------------------------------------------------------------------------- -// setCameraPosAndFocusGlobal() -//----------------------------------------------------------------------------- -void LLAgent::setCameraPosAndFocusGlobal(const LLVector3d& camera_pos, const LLVector3d& focus, const LLUUID &object_id) -{ - LLVector3d old_focus = mFocusTargetGlobal; - F64 focus_delta_squared = (old_focus - focus).magVecSquared(); - const F64 ANIM_EPSILON_SQUARED = 0.0001; - if( focus_delta_squared > ANIM_EPSILON_SQUARED ) + //--------------------------------------------------------------------- + // Set up UI for mode we're entering + //--------------------------------------------------------------------- + if (gAgentCamera.mCameraMode == CAMERA_MODE_MOUSELOOK) { - startCameraAnimation(); + // hide menus + gMenuBarView->setVisible(FALSE); + LLNavigationBar::getInstance()->setVisible(FALSE); + gStatusBar->setVisibleForMouselook(false); - if( CAMERA_MODE_CUSTOMIZE_AVATAR == mCameraMode ) - { - // Compensate for the fact that the camera has already been offset to make room for LLFloaterCustomize. - mAnimationCameraStartGlobal -= LLVector3d(LLViewerCamera::getInstance()->getLeftAxis() * calcCustomizeAvatarUIOffset( mAnimationCameraStartGlobal )); - } - } - - //LLViewerCamera::getInstance()->setOrigin( gAgent.getPosAgentFromGlobal( camera_pos ) ); - setFocusObject(gObjectList.findObject(object_id)); - mFocusTargetGlobal = focus; - mCameraFocusOffsetTarget = camera_pos - focus; - mCameraFocusOffset = mCameraFocusOffsetTarget; + LLBottomTray::getInstance()->onMouselookModeIn(); - if (mFocusObject) - { - if (mFocusObject->isAvatar()) - { - setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject); - } - else - { - setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject, (getPosAgentFromGlobal(focus) - mFocusObject->getRenderPosition()) * ~mFocusObject->getRenderRotation()); - } - } - else - { - setLookAt(LOOKAT_TARGET_FOCUS, NULL, getPosAgentFromGlobal(mFocusTargetGlobal)); - } + LLSideTray::getInstance()->getButtonsPanel()->setVisible(FALSE); + LLSideTray::getInstance()->updateSidetrayVisibility(); - if( mCameraAnimating ) - { - const F64 ANIM_METERS_PER_SECOND = 10.0; - const F64 MIN_ANIM_SECONDS = 0.5; - const F64 MAX_ANIM_SECONDS = 10.0; - F64 anim_duration = llmax( MIN_ANIM_SECONDS, sqrt(focus_delta_squared) / ANIM_METERS_PER_SECOND ); - anim_duration = llmin( anim_duration, MAX_ANIM_SECONDS ); - setAnimationDuration( (F32)anim_duration ); - } + LLPanelStandStopFlying::getInstance()->setVisible(FALSE); - updateFocusOffset(); -} + // clear out camera lag effect + gAgentCamera.mCameraLag.clearVec(); -//----------------------------------------------------------------------------- -// setSitCamera() -//----------------------------------------------------------------------------- -void LLAgent::setSitCamera(const LLUUID &object_id, const LLVector3 &camera_pos, const LLVector3 &camera_focus) -{ - BOOL camera_enabled = !object_id.isNull(); + // JC - Added for always chat in third person option + gFocusMgr.setKeyboardFocus(NULL); - if (camera_enabled) - { - LLViewerObject *reference_object = gObjectList.findObject(object_id); - if (reference_object) - { - //convert to root object relative? - mSitCameraPos = camera_pos; - mSitCameraFocus = camera_focus; - mSitCameraReferenceObject = reference_object; - mSitCameraEnabled = TRUE; - } - } - else - { - mSitCameraPos.clearVec(); - mSitCameraFocus.clearVec(); - mSitCameraReferenceObject = NULL; - mSitCameraEnabled = FALSE; - } -} + LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset); -//----------------------------------------------------------------------------- -// setFocusOnAvatar() -//----------------------------------------------------------------------------- -void LLAgent::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) -{ - if (focus_on_avatar != mFocusOnAvatar) - { - if (animate) - { - startCameraAnimation(); - } - else + mViewsPushed = TRUE; + + // hide all floaters except the mini map + +#if 0 // Use this once all floaters are registered + std::set exceptions; + exceptions.insert("mini_map"); + LLFloaterReg::hideVisibleInstances(exceptions); +#else // Use this for now + LLFloaterView::skip_list_t skip_list; + skip_list.insert(LLFloaterReg::findInstance("mini_map")); + gFloaterView->pushVisibleAll(FALSE, skip_list); +#endif + + if( gMorphView ) { - stopCameraAnimation(); + gMorphView->setVisible(FALSE); } - } - - //RN: when focused on the avatar, we're not "looking" at it - // looking implies intent while focusing on avatar means - // you're just walking around with a camera on you...eesh. - if (!mFocusOnAvatar && focus_on_avatar) - { - setFocusGlobal(LLVector3d::zero); - mCameraFOVZoomFactor = 0.f; - if (mCameraMode == CAMERA_MODE_THIRD_PERSON) + + gConsole->setVisible( TRUE ); + + if (mAvatarObject.notNull()) { - LLVector3 at_axis; - if (mAvatarObject.notNull() && mAvatarObject->getParent()) + // Trigger mouselook-specific animations + if( mAvatarObject->isAnyAnimationSignaled(AGENT_GUN_HOLD_ANIMS, NUM_AGENT_GUN_HOLD_ANIMS) ) { - LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); - at_axis = LLViewerCamera::getInstance()->getAtAxis(); - at_axis.mV[VZ] = 0.f; - at_axis.normalize(); - resetAxes(at_axis * ~obj_rot); + if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_HOLD_RIFLE_R) != mAvatarObject->mSignaledAnimations.end()) + { + sendAnimationRequest(ANIM_AGENT_HOLD_RIFLE_R, ANIM_REQUEST_STOP); + sendAnimationRequest(ANIM_AGENT_AIM_RIFLE_R, ANIM_REQUEST_START); + } + if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_HOLD_HANDGUN_R) != mAvatarObject->mSignaledAnimations.end()) + { + sendAnimationRequest(ANIM_AGENT_HOLD_HANDGUN_R, ANIM_REQUEST_STOP); + sendAnimationRequest(ANIM_AGENT_AIM_HANDGUN_R, ANIM_REQUEST_START); + } + if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_HOLD_BAZOOKA_R) != mAvatarObject->mSignaledAnimations.end()) + { + sendAnimationRequest(ANIM_AGENT_HOLD_BAZOOKA_R, ANIM_REQUEST_STOP); + sendAnimationRequest(ANIM_AGENT_AIM_BAZOOKA_R, ANIM_REQUEST_START); + } + if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_HOLD_BOW_L) != mAvatarObject->mSignaledAnimations.end()) + { + sendAnimationRequest(ANIM_AGENT_HOLD_BOW_L, ANIM_REQUEST_STOP); + sendAnimationRequest(ANIM_AGENT_AIM_BOW_L, ANIM_REQUEST_START); + } } - else + if (mAvatarObject->getParent()) { - at_axis = LLViewerCamera::getInstance()->getAtAxis(); - at_axis.mV[VZ] = 0.f; - at_axis.normalize(); - resetAxes(at_axis); + LLVector3 at_axis = LLViewerCamera::getInstance()->getAtAxis(); + LLViewerObject* root_object = (LLViewerObject*)mAvatarObject->getRoot(); + if (root_object->flagCameraDecoupled()) + { + resetAxes(at_axis); + } + else + { + resetAxes(at_axis * ~((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation()); + } } } + + } + else if (gAgentCamera.mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR) + { + LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset); + + if( gMorphView ) + { + gMorphView->setVisible( TRUE ); + } + + // freeze avatar + if (mAvatarObject.notNull()) + { + mPauseRequest = mAvatarObject->requestPause(); + } } - // unlocking camera from avatar - else if (mFocusOnAvatar && !focus_on_avatar) + + if (getAvatarObject()) { - // keep camera focus point consistent, even though it is now unlocked - setFocusGlobal(getPositionGlobal() + calcThirdPersonFocusOffset(), gAgent.getID()); + getAvatarObject()->updateAttachmentVisibility(gAgentCamera.mCameraMode); } - - mFocusOnAvatar = focus_on_avatar; + + gFloaterTools->dirty(); + + // Don't let this be called more than once if the camera + // mode hasn't changed. --JC + gAgentCamera.mLastCameraMode = gAgentCamera.mCameraMode; + } -*/ //----------------------------------------------------------------------------- // heardChat() @@ -4600,7 +2021,7 @@ void LLAgent::heardChat(const LLUUID& id) if (ll_rand(2) == 0) { LLViewerObject *chatter = gObjectList.findObject(mLastChatterID); - gAgentCameraHACK.setLookAt(LOOKAT_TARGET_AUTO_LISTEN, chatter, LLVector3::zero); + gAgentCamera.setLookAt(LOOKAT_TARGET_AUTO_LISTEN, chatter, LLVector3::zero); } mLastChatterID = id; @@ -4613,7 +2034,7 @@ void LLAgent::heardChat(const LLUUID& id) void LLAgent::lookAtLastChat() { // Block if camera is animating or not in normal third person camera mode - if (gAgentCameraHACK.mCameraAnimating || !gAgentCameraHACK.cameraThirdPerson()) + if (gAgentCamera.mCameraAnimating || !gAgentCamera.cameraThirdPerson()) { return; } @@ -4637,7 +2058,7 @@ void LLAgent::lookAtLastChat() setControlFlags(AGENT_CONTROL_STOP); - gAgentCameraHACK.changeCameraToThirdPerson(); + gAgentCamera.changeCameraToThirdPerson(); LLVector3 new_camera_pos = mAvatarObject->mHeadp->getWorldPosition(); LLVector3 left = delta_pos % LLVector3::z_axis; @@ -4649,15 +2070,15 @@ void LLAgent::lookAtLastChat() new_camera_pos += up * 0.2f; if (chatter_av->mHeadp) { - gAgentCameraHACK.setFocusGlobal(getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition()), mLastChatterID); - gAgentCameraHACK.mCameraFocusOffsetTarget = getPosGlobalFromAgent(new_camera_pos) - gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition()); + gAgentCamera.setFocusGlobal(getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition()), mLastChatterID); + gAgentCamera.mCameraFocusOffsetTarget = getPosGlobalFromAgent(new_camera_pos) - gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition()); } else { - gAgentCameraHACK.setFocusGlobal(chatter->getPositionGlobal(), mLastChatterID); - gAgentCameraHACK.mCameraFocusOffsetTarget = getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal(); + gAgentCamera.setFocusGlobal(chatter->getPositionGlobal(), mLastChatterID); + gAgentCamera.mCameraFocusOffsetTarget = getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal(); } - gAgentCameraHACK.setFocusOnAvatar(FALSE, TRUE); + gAgentCamera.setFocusOnAvatar(FALSE, TRUE); } else { @@ -4666,7 +2087,7 @@ void LLAgent::lookAtLastChat() setControlFlags(AGENT_CONTROL_STOP); - gAgentCameraHACK.changeCameraToThirdPerson(); + gAgentCamera.changeCameraToThirdPerson(); LLVector3 new_camera_pos = mAvatarObject->mHeadp->getWorldPosition(); LLVector3 left = delta_pos % LLVector3::z_axis; @@ -4677,9 +2098,9 @@ void LLAgent::lookAtLastChat() new_camera_pos += left * 0.3f; new_camera_pos += up * 0.2f; - gAgentCameraHACK.setFocusGlobal(chatter->getPositionGlobal(), mLastChatterID); - gAgentCameraHACK.mCameraFocusOffsetTarget = getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal(); - gAgentCameraHACK.setFocusOnAvatar(FALSE, TRUE); + gAgentCamera.setFocusGlobal(chatter->getPositionGlobal(), mLastChatterID); + gAgentCamera.mCameraFocusOffsetTarget = getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal(); + gAgentCamera.setFocusOnAvatar(FALSE, TRUE); } } } @@ -5190,7 +2611,7 @@ LLQuaternion LLAgent::getHeadRotation() return LLQuaternion::DEFAULT; } - if (!gAgentCameraHACK.cameraMouselook()) + if (!gAgentCamera.cameraMouselook()) { return mAvatarObject->getRotation(); } @@ -5361,7 +2782,7 @@ void LLAgent::initOriginGlobal(const LLVector3d &origin_global) BOOL LLAgent::leftButtonGrabbed() const { - const BOOL camera_mouse_look = gAgentCameraHACK.cameraMouselook(); + const BOOL camera_mouse_look = gAgentCamera.cameraMouselook(); return (!camera_mouse_look && mControlsTakenCount[CONTROL_LBUTTON_DOWN_INDEX] > 0) || (camera_mouse_look && mControlsTakenCount[CONTROL_ML_LBUTTON_DOWN_INDEX] > 0) || (!camera_mouse_look && mControlsTakenPassedOnCount[CONTROL_LBUTTON_DOWN_INDEX] > 0) @@ -5833,7 +3254,7 @@ void LLAgent::processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void * return; } - if (gAgentCameraHACK.cameraCustomizeAvatar()) + if (gAgentCamera.cameraCustomizeAvatar()) { // ignore baked textures when in customize mode return; @@ -5990,7 +3411,7 @@ bool LLAgent::teleportCore(bool is_local) // Close all pie menus, deselect land, etc. // Don't change the camera until we know teleport succeeded. JC - gAgentCameraHACK.resetView(FALSE); + gAgentCamera.resetView(FALSE); // local logic LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TELEPORT_COUNT); @@ -6291,7 +3712,7 @@ void LLAgent::sendAgentSetAppearance() { if (mAvatarObject.isNull()) return; - if (gAgentQueryManager.mNumPendingQueries > 0 && !gAgentCameraHACK.cameraCustomizeAvatar()) + if (gAgentQueryManager.mNumPendingQueries > 0 && !gAgentCamera.cameraCustomizeAvatar()) { return; } @@ -6540,9 +3961,7 @@ void LLAgent::renderAutoPilotTarget() } } -/******************************************************************************** - * - */ +/********************************************************************************/ LLAgentQueryManager gAgentQueryManager; diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index d196c1c1c1..1b378ef7b2 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -66,32 +66,6 @@ class LLAgentDropGroupViewerNode; //-------------------------------------------------------------------- // Types //-------------------------------------------------------------------- -//-------------------------------------------------------------------- -// Types -//-------------------------------------------------------------------- - -/* -enum ECameraMode -{ - CAMERA_MODE_THIRD_PERSON, - CAMERA_MODE_MOUSELOOK, - CAMERA_MODE_CUSTOMIZE_AVATAR, - CAMERA_MODE_FOLLOW -}; - -// Camera Presets for CAMERA_MODE_THIRD_PERSON -enum ECameraPreset -{ - // Default preset, what the Third Person Mode actually was - CAMERA_PRESET_REAR_VIEW, - - // "Looking at the Avatar from the front" - CAMERA_PRESET_FRONT_VIEW, - - // "Above and to the left, over the shoulder, pulled back a little on the zoom" - CAMERA_PRESET_GROUP_VIEW -}; -*/ enum EAnimRequest { @@ -146,11 +120,12 @@ public: void setFirstLogin(BOOL b) { mFirstLogin = b; } // Return TRUE if the database reported this login as the first for this particular user. BOOL isFirstLogin() const { return mFirstLogin; } + BOOL isInitialized() const { return mInitialized; } public: - BOOL mInitialized; - BOOL mFirstLogin; std::string mMOTD; // Message of the day private: + BOOL mInitialized; + BOOL mFirstLogin; boost::shared_ptr mListener; //-------------------------------------------------------------------- @@ -455,8 +430,6 @@ public: void sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request); void endAnimationUpdateUI(); private: - LLFrameTimer mAnimationTimer; // Seconds that transition animation has been active // SERAPH REMOVE - F32 mAnimationDuration; // In seconds // SERAPH REMOVE BOOL mCustomAnim; // Current animation is ANIM_AGENT_CUSTOMIZE ? LLAnimPauseRequest mPauseRequest; BOOL mViewsPushed; // Keep track of whether or not we have pushed views @@ -498,44 +471,6 @@ public: void moveYaw(F32 mag, bool reset_view = true); void movePitch(F32 mag); - // SERAPH Remove this whole section - //-------------------------------------------------------------------- - // Orbit - //-------------------------------------------------------------------- -public: - void setOrbitLeftKey(F32 mag) { mOrbitLeftKey = mag; } - void setOrbitRightKey(F32 mag) { mOrbitRightKey = mag; } - void setOrbitUpKey(F32 mag) { mOrbitUpKey = mag; } - void setOrbitDownKey(F32 mag) { mOrbitDownKey = mag; } - void setOrbitInKey(F32 mag) { mOrbitInKey = mag; } - void setOrbitOutKey(F32 mag) { mOrbitOutKey = mag; } -private: - F32 mOrbitLeftKey; - F32 mOrbitRightKey; - F32 mOrbitUpKey; - F32 mOrbitDownKey; - F32 mOrbitInKey; - F32 mOrbitOutKey; - - // SERAPH Remove this whole section - //-------------------------------------------------------------------- - // Pan - //-------------------------------------------------------------------- -public: - void setPanLeftKey(F32 mag) { mPanLeftKey = mag; } - void setPanRightKey(F32 mag) { mPanRightKey = mag; } - void setPanUpKey(F32 mag) { mPanUpKey = mag; } - void setPanDownKey(F32 mag) { mPanDownKey = mag; } - void setPanInKey(F32 mag) { mPanInKey = mag; } - void setPanOutKey(F32 mag) { mPanOutKey = mag; } -private: - F32 mPanUpKey; - F32 mPanDownKey; - F32 mPanLeftKey; - F32 mPanRightKey; - F32 mPanInKey; - F32 mPanOutKey; - //-------------------------------------------------------------------- // Move the avatar's frame //-------------------------------------------------------------------- @@ -647,220 +582,6 @@ private: ** ** *******************************************************************************/ -/******************************************************************************** - ** ** - ** CAMERA - **/ - -/* - //-------------------------------------------------------------------- - // Mode - //-------------------------------------------------------------------- -public: - void changeCameraToDefault(); - void changeCameraToMouselook(BOOL animate = TRUE); - void changeCameraToThirdPerson(BOOL animate = TRUE); - void changeCameraToCustomizeAvatar(BOOL avatar_animate = TRUE, BOOL camera_animate = TRUE); // Trigger transition animation - void changeCameraToFollow(BOOL animate = TRUE); // Ventrella - BOOL cameraThirdPerson() const { return (mCameraMode == CAMERA_MODE_THIRD_PERSON && mLastCameraMode == CAMERA_MODE_THIRD_PERSON); } - BOOL cameraMouselook() const { return (mCameraMode == CAMERA_MODE_MOUSELOOK && mLastCameraMode == CAMERA_MODE_MOUSELOOK); } - BOOL cameraCustomizeAvatar() const { return (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR); } - BOOL cameraFollow() const { return (mCameraMode == CAMERA_MODE_FOLLOW && mLastCameraMode == CAMERA_MODE_FOLLOW); } - ECameraMode getCameraMode() const { return mCameraMode; } - void updateCamera(); // Call once per frame to update camera location/orientation - void resetCamera(); // Slam camera into its default position -private: - ECameraMode mCameraMode; // Target mode after transition animation is done - ECameraMode mLastCameraMode; - - //-------------------------------------------------------------------- - // Preset - //-------------------------------------------------------------------- -public: - void switchCameraPreset(ECameraPreset preset); - -private: - - // Determines default camera offset depending on the current camera preset - LLVector3 getCameraOffsetInitial(); - - // Camera preset in Third Person Mode - ECameraPreset mCameraPreset; - - // Initial camera offsets - std::map mCameraOffsetInitial; - - // Initial focus offsets - std::map mFocusOffsetInitial; - - //-------------------------------------------------------------------- - // Position - //-------------------------------------------------------------------- -public: - LLVector3d getCameraPositionGlobal() const; - const LLVector3 &getCameraPositionAgent() const; - LLVector3d calcCameraPositionTargetGlobal(BOOL *hit_limit = NULL); // Calculate the camera position target - F32 getCameraMinOffGround(); // Minimum height off ground for this mode, meters - void setCameraCollidePlane(const LLVector4 &plane) { mCameraCollidePlane = plane; } - BOOL calcCameraMinDistance(F32 &obj_min_distance); - F32 calcCustomizeAvatarUIOffset(const LLVector3d& camera_pos_global); - F32 getCurrentCameraBuildOffset() { return (F32)mCameraFocusOffset.length(); } -private: - F32 mCurrentCameraDistance; // Current camera offset from avatar - F32 mTargetCameraDistance; // Target camera offset from avatar - F32 mCameraFOVZoomFactor; // Amount of fov zoom applied to camera when zeroing in on an object - F32 mCameraCurrentFOVZoomFactor; // Interpolated fov zoom - F32 mCameraFOVDefault; // Default field of view that is basis for FOV zoom effect - LLVector4 mCameraCollidePlane; // Colliding plane for camera - F32 mCameraZoomFraction; // Mousewheel driven fraction of zoom - LLVector3 mCameraPositionAgent; // Camera position in agent coordinates - LLVector3 mCameraVirtualPositionAgent; // Camera virtual position (target) before performing FOV zoom - LLVector3d mCameraSmoothingLastPositionGlobal; - LLVector3d mCameraSmoothingLastPositionAgent; - BOOL mCameraSmoothingStop; - LLVector3 mCameraLag; // Third person camera lag - LLVector3 mCameraUpVector; // Camera's up direction in world coordinates (determines the 'roll' of the view) - - //-------------------------------------------------------------------- - // Follow - //-------------------------------------------------------------------- -public: - void setUsingFollowCam(bool using_follow_cam); -private: - LLFollowCam mFollowCam; // Ventrella - - //-------------------------------------------------------------------- - // Sit - //-------------------------------------------------------------------- -public: - void setupSitCamera(); - BOOL sitCameraEnabled() { return mSitCameraEnabled; } - void setSitCamera(const LLUUID &object_id, - const LLVector3 &camera_pos = LLVector3::zero, const LLVector3 &camera_focus = LLVector3::zero); -private: - LLPointer mSitCameraReferenceObject; // Object to which camera is related when sitting - BOOL mSitCameraEnabled; // Use provided camera information when sitting? - LLVector3 mSitCameraPos; // Root relative camera pos when sitting - LLVector3 mSitCameraFocus; // Root relative camera target when sitting -#endif - - //-------------------------------------------------------------------- - // Animation - //-------------------------------------------------------------------- -public: - void setCameraAnimating(BOOL b) { mCameraAnimating = b; } - BOOL getCameraAnimating() { return mCameraAnimating; } - void setAnimationDuration(F32 seconds) { mAnimationDuration = seconds; } - void startCameraAnimation(); - void stopCameraAnimation(); -private: - BOOL mCameraAnimating; // Camera is transitioning from one mode to another - LLVector3d mAnimationCameraStartGlobal; // Camera start position, global coords - LLVector3d mAnimationFocusStartGlobal; // Camera focus point, global coords - - //-------------------------------------------------------------------- - // Focus - //-------------------------------------------------------------------- -public: - LLVector3d calcFocusPositionTargetGlobal(); - LLVector3 calcFocusOffset(LLViewerObject *object, LLVector3 pos_agent, S32 x, S32 y); - BOOL getFocusOnAvatar() const { return mFocusOnAvatar; } - LLPointer& getFocusObject() { return mFocusObject; } - F32 getFocusObjectDist() const { return mFocusObjectDist; } - void updateFocusOffset(); - void validateFocusObject(); - void setFocusGlobal(const LLPickInfo& pick); - void setFocusGlobal(const LLVector3d &focus, const LLUUID &object_id = LLUUID::null); - void setFocusOnAvatar(BOOL focus, BOOL animate); - void setCameraPosAndFocusGlobal(const LLVector3d& pos, const LLVector3d& focus, const LLUUID &object_id); - void clearFocusObject(); - void setFocusObject(LLViewerObject* object); - void setObjectTracking(BOOL track) { mTrackFocusObject = track; } - const LLVector3d &getFocusGlobal() const { return mFocusGlobal; } - const LLVector3d &getFocusTargetGlobal() const { return mFocusTargetGlobal; } -private: - LLVector3d mCameraFocusOffset; // Offset from focus point in build mode - LLVector3d mCameraFocusOffsetTarget; // Target towards which we are lerping the camera's focus offset - BOOL mFocusOnAvatar; - LLVector3d mFocusGlobal; - LLVector3d mFocusTargetGlobal; - LLPointer mFocusObject; - F32 mFocusObjectDist; - LLVector3 mFocusObjectOffset; - F32 mFocusDotRadius; // Meters - BOOL mTrackFocusObject; - F32 mUIOffset; - - //-------------------------------------------------------------------- - // Third person - //-------------------------------------------------------------------- -public: - LLVector3d calcThirdPersonFocusOffset(); - void setThirdPersonHeadOffset(LLVector3 offset) { mThirdPersonHeadOffset = offset; } -private: - LLVector3 mThirdPersonHeadOffset; // Head offset for third person camera position - - //-------------------------------------------------------------------- - // Orbit - //-------------------------------------------------------------------- -public: - void cameraOrbitAround(const F32 radians); // Rotate camera CCW radians about build focus point - void cameraOrbitOver(const F32 radians); // Rotate camera forward radians over build focus point - void cameraOrbitIn(const F32 meters); // Move camera in toward build focus point - - //-------------------------------------------------------------------- - // Zoom - //-------------------------------------------------------------------- -public: - void handleScrollWheel(S32 clicks); // Mousewheel driven zoom - void cameraZoomIn(const F32 factor); // Zoom in by fraction of current distance - F32 getCameraZoomFraction(); // Get camera zoom as fraction of minimum and maximum zoom - void setCameraZoomFraction(F32 fraction); // Set camera zoom as fraction of minimum and maximum zoom - F32 calcCameraFOVZoomFactor(); - - //-------------------------------------------------------------------- - // Pan - //-------------------------------------------------------------------- -public: - void cameraPanIn(const F32 meters); - void cameraPanLeft(const F32 meters); - void cameraPanUp(const F32 meters); - - //-------------------------------------------------------------------- - // View - //-------------------------------------------------------------------- -public: - // Called whenever the agent moves. Puts camera back in default position, deselects items, etc. - void resetView(BOOL reset_camera = TRUE, BOOL change_camera = FALSE); - // Called on camera movement. Unlocks camera from the default position behind the avatar. - void unlockView(); - - //-------------------------------------------------------------------- - // Mouselook - //-------------------------------------------------------------------- -public: - BOOL getForceMouselook() const { return mForceMouselook; } - void setForceMouselook(BOOL mouselook) { mForceMouselook = mouselook; } -private: - BOOL mForceMouselook; - -*/ - - //-------------------------------------------------------------------- - // HUD - //-------------------------------------------------------------------- -public: - const LLColor4 &getEffectColor(); - void setEffectColor(const LLColor4 &color); -private: - LLUIColor mEffectColor; - -/** Camera - ** ** - *******************************************************************************/ - - - /******************************************************************************** ** ** ** ACCESS @@ -935,8 +656,6 @@ public: LLQuaternion getHeadRotation(); BOOL needsRenderAvatar(); // TRUE when camera mode is such that your own avatar should draw BOOL needsRenderHead(); -public: - F32 mDrawDistance; // SERAPH REMOVE private: BOOL mShowAvatar; // Should we render the avatar? U32 mAppearanceSerialNum; @@ -951,6 +670,15 @@ public: private: U8 mRenderState; // Current behavior state of agent + //-------------------------------------------------------------------- + // HUD + //-------------------------------------------------------------------- +public: + const LLColor4 &getEffectColor(); + void setEffectColor(const LLColor4 &color); +private: + LLUIColor mEffectColor; + /** Rendering ** ** *******************************************************************************/ diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index f1422e2442..c51edbaf4b 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -80,47 +80,15 @@ #include "llworld.h" #include "llworldmap.h" -static LLAgent gAgentHACK = gAgent; - using namespace LLVOAvatarDefines; extern LLMenuBarGL* gMenuBarView; -/* -const BOOL ANIMATE = TRUE; -const U8 AGENT_STATE_TYPING = 0x04; -const U8 AGENT_STATE_EDITING = 0x10; - -//drone wandering constants -const F32 MAX_WANDER_TIME = 20.f; // seconds -const F32 MAX_HEADING_HALF_ERROR = 0.2f; // radians -const F32 WANDER_MAX_SLEW_RATE = 2.f * DEG_TO_RAD; // radians / frame -const F32 WANDER_TARGET_MIN_DISTANCE = 10.f; // meters - -// Autopilot constants -const F32 AUTOPILOT_HEADING_HALF_ERROR = 10.f * DEG_TO_RAD; // radians -const F32 AUTOPILOT_MAX_SLEW_RATE = 1.f * DEG_TO_RAD; // radians / frame -const F32 AUTOPILOT_STOP_DISTANCE = 2.f; // meters -const F32 AUTOPILOT_HEIGHT_ADJUST_DISTANCE = 8.f; // meters -const F32 AUTOPILOT_MIN_TARGET_HEIGHT_OFF_GROUND = 1.f; // meters -const F32 AUTOPILOT_MAX_TIME_NO_PROGRESS = 1.5f; // seconds - -// face editing constants -const LLVector3d FACE_EDIT_CAMERA_OFFSET(0.4f, -0.05f, 0.07f); -const LLVector3d FACE_EDIT_TARGET_OFFSET(0.f, 0.f, 0.05f); -*/ - // Mousewheel camera zoom const F32 MIN_ZOOM_FRACTION = 0.25f; const F32 INITIAL_ZOOM_FRACTION = 1.f; const F32 MAX_ZOOM_FRACTION = 8.f; -/* -const F32 METERS_PER_WHEEL_CLICK = 1.f; - -const F32 MAX_TIME_DELTA = 1.f; -*/ - const F32 CAMERA_ZOOM_HALF_LIFE = 0.07f; // seconds const F32 FOV_ZOOM_HALF_LIFE = 0.07f; // seconds @@ -152,28 +120,10 @@ const F32 OBJECT_MIN_ZOOM = 0.02f; const F32 APPEARANCE_MIN_ZOOM = 0.39f; const F32 APPEARANCE_MAX_ZOOM = 8.f; -/* -// fidget constants -const F32 MIN_FIDGET_TIME = 8.f; // seconds -const F32 MAX_FIDGET_TIME = 20.f; // seconds - -const S32 MAX_NUM_CHAT_POSITIONS = 10; -*/ - const F32 GROUND_TO_AIR_CAMERA_TRANSITION_TIME = 0.5f; const F32 GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME = 0.5f; -/* -const F32 MAX_VELOCITY_AUTO_LAND_SQUARED = 4.f * 4.f; - -const F32 MAX_FOCUS_OFFSET = 20.f; -*/ const F32 OBJECT_EXTENTS_PADDING = 0.5f; -/* -const F32 MIN_RADIUS_ALPHA_SIZZLE = 0.5f; - -const F64 CHAT_AGE_FAST_RATE = 3.0; -*/ // The agent instance. LLAgentCamera gAgentCamera; @@ -182,9 +132,16 @@ LLAgentCamera gAgentCamera; // LLAgentCamera() //----------------------------------------------------------------------------- LLAgentCamera::LLAgentCamera() : + mDrawDistance( DEFAULT_FAR_PLANE ), + mLookAt(NULL), mPointAt(NULL), + mHUDTargetZoom(1.f), + mHUDCurZoom(1.f), + + mForceMouselook(FALSE), + mCameraMode( CAMERA_MODE_THIRD_PERSON ), mLastCameraMode( CAMERA_MODE_THIRD_PERSON ), @@ -238,6 +195,7 @@ LLAgentCamera::LLAgentCamera() : mPanInKey(0.f), mPanOutKey(0.f) { + mFollowCam.setMaxCameraDistantFromSubject( MAX_CAMERA_DISTANCE_FROM_AGENT ); } // Requires gSavedSettings to be initialized. @@ -248,6 +206,8 @@ void LLAgentCamera::init() { // *Note: this is where LLViewerCamera::getInstance() used to be constructed. + mDrawDistance = gSavedSettings.getF32("RenderFarClip"); + LLViewerCamera::getInstance()->setView(DEFAULT_FIELD_OF_VIEW); // Leave at 0.1 meters until we have real near clip management LLViewerCamera::getInstance()->setNear(0.1f); @@ -313,9 +273,9 @@ LLAgentCamera::~LLAgentCamera() //----------------------------------------------------------------------------- void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera) { - if (gAgentHACK.mAutoPilot) + if (gAgent.mAutoPilot) { - gAgentHACK.stopAutoPilot(TRUE); + gAgent.stopAutoPilot(TRUE); } if (!gNoRender) @@ -369,10 +329,10 @@ void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera) if (!gViewerWindow->getLeftMouseDown() && cameraThirdPerson()) { // leaving mouse-steer mode - LLVector3 agent_at_axis = gAgentHACK.getAtAxis(); - agent_at_axis -= projected_vec(agent_at_axis, gAgentHACK.getReferenceUpVector()); + LLVector3 agent_at_axis = gAgent.getAtAxis(); + agent_at_axis -= projected_vec(agent_at_axis, gAgent.getReferenceUpVector()); agent_at_axis.normalize(); - gAgentHACK.resetAxes(lerp(gAgentHACK.getAtAxis(), agent_at_axis, LLCriticalDamp::getInterpolant(0.3f))); + gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLCriticalDamp::getInterpolant(0.3f))); } setFocusOnAvatar(TRUE, ANIMATE); @@ -391,9 +351,9 @@ void LLAgentCamera::unlockView() { if (getFocusOnAvatar()) { - if (gAgentHACK.mAvatarObject.notNull()) + if (gAgent.mAvatarObject.notNull()) { - setFocusGlobal( LLVector3d::zero, gAgentHACK.mAvatarObject->mID ); + setFocusGlobal( LLVector3d::zero, gAgent.mAvatarObject->mID ); } setFocusOnAvatar(FALSE, FALSE); // no animation } @@ -407,7 +367,7 @@ void LLAgentCamera::slamLookAt(const LLVector3 &look_at) LLVector3 look_at_norm = look_at; look_at_norm.mV[VZ] = 0.f; look_at_norm.normalize(); - gAgentHACK.resetAxes(look_at_norm); + gAgent.resetAxes(look_at_norm); } //----------------------------------------------------------------------------- @@ -607,7 +567,7 @@ BOOL LLAgentCamera::calcCameraMinDistance(F32 &obj_min_distance) LLQuaternion inv_object_rot = ~mFocusObject->getRenderRotation(); LLVector3 target_offset_origin = mFocusObjectOffset; - LLVector3 camera_offset_target(getCameraPositionAgent() - gAgentHACK.getPosAgentFromGlobal(mFocusTargetGlobal)); + LLVector3 camera_offset_target(getCameraPositionAgent() - gAgent.getPosAgentFromGlobal(mFocusTargetGlobal)); // convert offsets into object local space camera_offset_target.rotVec(inv_object_rot); @@ -870,7 +830,7 @@ void LLAgentCamera::cameraOrbitAround(const F32 radians) } else if (mFocusOnAvatar && (mCameraMode == CAMERA_MODE_THIRD_PERSON || mCameraMode == CAMERA_MODE_FOLLOW)) { - gAgentHACK.mFrameAgent.rotate(radians, gAgentHACK.getReferenceUpVector()); + gAgent.mFrameAgent.rotate(radians, gAgent.getReferenceUpVector()); } else { @@ -893,14 +853,14 @@ void LLAgentCamera::cameraOrbitOver(const F32 angle) } else if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON) { - gAgentHACK.pitch(angle); + gAgent.pitch(angle); } else { LLVector3 camera_offset_unit(mCameraFocusOffsetTarget); camera_offset_unit.normalize(); - F32 angle_from_up = acos( camera_offset_unit * gAgentHACK.getReferenceUpVector() ); + F32 angle_from_up = acos( camera_offset_unit * gAgent.getReferenceUpVector() ); LLVector3d left_axis; left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis()); @@ -1111,28 +1071,28 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y) static LLVector3 last_at_axis; - if (gAgentHACK.mAvatarObject.isNull()) + if (gAgent.mAvatarObject.isNull()) { return; } - LLQuaternion av_inv_rot = ~gAgentHACK.mAvatarObject->mRoot.getWorldRotation(); - LLVector3 root_at = LLVector3::x_axis * gAgentHACK.mAvatarObject->mRoot.getWorldRotation(); + LLQuaternion av_inv_rot = ~gAgent.mAvatarObject->mRoot.getWorldRotation(); + LLVector3 root_at = LLVector3::x_axis * gAgent.mAvatarObject->mRoot.getWorldRotation(); if ((gViewerWindow->getMouseVelocityStat()->getCurrent() < 0.01f) && (root_at * last_at_axis > 0.95f )) { - LLVector3 vel = gAgentHACK.mAvatarObject->getVelocity(); + LLVector3 vel = gAgent.mAvatarObject->getVelocity(); if (vel.magVecSquared() > 4.f) { - setLookAt(LOOKAT_TARGET_IDLE, gAgentHACK.mAvatarObject, vel * av_inv_rot); + setLookAt(LOOKAT_TARGET_IDLE, gAgent.mAvatarObject, vel * av_inv_rot); } else { // *FIX: rotate mframeagent by sit object's rotation? - LLQuaternion look_rotation = gAgentHACK.mAvatarObject->isSitting() ? gAgentHACK.mAvatarObject->getRenderRotation() : gAgentHACK.mFrameAgent.getQuaternion(); // use camera's current rotation + LLQuaternion look_rotation = gAgent.mAvatarObject->isSitting() ? gAgent.mAvatarObject->getRenderRotation() : gAgent.mFrameAgent.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, gAgentHACK.mAvatarObject, look_offset); + setLookAt(LOOKAT_TARGET_IDLE, gAgent.mAvatarObject, look_offset); } last_at_axis = root_at; return; @@ -1142,7 +1102,7 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y) if (CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode()) { - setLookAt(LOOKAT_TARGET_NONE, gAgentHACK.mAvatarObject, LLVector3(-2.f, 0.f, 0.f)); + setLookAt(LOOKAT_TARGET_NONE, gAgent.mAvatarObject, LLVector3(-2.f, 0.f, 0.f)); } else { @@ -1171,7 +1131,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, gAgentHACK.mAvatarObject, headLookAxis); + setLookAt(lookAtType, gAgent.mAvatarObject, headLookAxis); } } @@ -1192,13 +1152,13 @@ void LLAgentCamera::updateCamera() validateFocusObject(); - if (gAgentHACK.mAvatarObject.notNull() && - gAgentHACK.mAvatarObject->isSitting() && + if (gAgent.mAvatarObject.notNull() && + gAgent.mAvatarObject->isSitting() && camera_mode == CAMERA_MODE_MOUSELOOK) { //Ventrella //changed camera_skyward to the new global "mCameraUpVector" - mCameraUpVector = mCameraUpVector * gAgentHACK.mAvatarObject->getRenderRotation(); + mCameraUpVector = mCameraUpVector * gAgent.mAvatarObject->getRenderRotation(); //end Ventrella } @@ -1306,7 +1266,7 @@ void LLAgentCamera::updateCamera() //Ventrella if ( mCameraMode == CAMERA_MODE_FOLLOW ) { - if ( gAgentHACK.mAvatarObject.notNull() ) + if ( gAgent.mAvatarObject.notNull() ) { //-------------------------------------------------------------------------------- // this is where the avatar's position and rotation are given to followCam, and @@ -1314,13 +1274,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 = gAgentHACK.mAvatarObject->isSitting() ? gAgentHACK.mAvatarObject->getRenderRotation() : gAgentHACK.mFrameAgent.getQuaternion(); + LLQuaternion avatarRotationForFollowCam = gAgent.mAvatarObject->isSitting() ? gAgent.mAvatarObject->getRenderRotation() : gAgent.mFrameAgent.getQuaternion(); LLFollowCamParams* current_cam = LLFollowCamMgr::getActiveFollowCamParams(); if (current_cam) { mFollowCam.copyParams(*current_cam); - mFollowCam.setSubjectPositionAndRotation( gAgentHACK.mAvatarObject->getRenderPosition(), avatarRotationForFollowCam ); + mFollowCam.setSubjectPositionAndRotation( gAgent.mAvatarObject->getRenderPosition(), avatarRotationForFollowCam ); mFollowCam.update(); LLViewerJoystick::getInstance()->setCameraNeedsUpdate(true); } @@ -1335,14 +1295,14 @@ void LLAgentCamera::updateCamera() BOOL hit_limit; LLVector3d camera_pos_global; LLVector3d camera_target_global = calcCameraPositionTargetGlobal(&hit_limit); - mCameraVirtualPositionAgent = gAgentHACK.getPosAgentFromGlobal(camera_target_global); + mCameraVirtualPositionAgent = gAgent.getPosAgentFromGlobal(camera_target_global); LLVector3d focus_target_global = calcFocusPositionTargetGlobal(); // perform field of view correction mCameraFOVZoomFactor = calcCameraFOVZoomFactor(); camera_target_global = focus_target_global + (camera_target_global - focus_target_global) * (1.f + mCameraFOVZoomFactor); - gAgentHACK.mShowAvatar = TRUE; // can see avatar by default + gAgent.mShowAvatar = TRUE; // can see avatar by default // Adjust position for animation if (mCameraAnimating) @@ -1375,7 +1335,7 @@ void LLAgentCamera::updateCamera() { if (fraction_of_animation < animation_start_fraction || fraction_of_animation > animation_finish_fraction ) { - gAgentHACK.mShowAvatar = FALSE; + gAgent.mShowAvatar = FALSE; } // ...adjust position for animation @@ -1391,26 +1351,26 @@ void LLAgentCamera::updateCamera() camera_pos_global = camera_target_global; mFocusGlobal = focus_target_global; - gAgentHACK.endAnimationUpdateUI(); - gAgentHACK.mShowAvatar = TRUE; + gAgent.endAnimationUpdateUI(); + gAgent.mShowAvatar = TRUE; } - if (gAgentHACK.getAvatarObject() && mCameraMode != CAMERA_MODE_MOUSELOOK) + if (gAgent.getAvatarObject() && mCameraMode != CAMERA_MODE_MOUSELOOK) { - gAgentHACK.getAvatarObject()->updateAttachmentVisibility(mCameraMode); + gAgent.getAvatarObject()->updateAttachmentVisibility(mCameraMode); } } else { camera_pos_global = camera_target_global; mFocusGlobal = focus_target_global; - gAgentHACK.mShowAvatar = TRUE; + gAgent.mShowAvatar = TRUE; } // smoothing if (TRUE) { - LLVector3d agent_pos = gAgentHACK.getPositionGlobal(); + LLVector3d agent_pos = gAgent.getPositionGlobal(); LLVector3d camera_pos_agent = camera_pos_global - agent_pos; // Sitting on what you're manipulating can cause camera jitter with smoothing. // This turns off smoothing while editing. -MG @@ -1461,9 +1421,9 @@ void LLAgentCamera::updateCamera() } - LLVector3 focus_agent = gAgentHACK.getPosAgentFromGlobal(mFocusGlobal); + LLVector3 focus_agent = gAgent.getPosAgentFromGlobal(mFocusGlobal); - mCameraPositionAgent = gAgentHACK.getPosAgentFromGlobal(camera_pos_global); + mCameraPositionAgent = gAgent.getPosAgentFromGlobal(camera_pos_global); // Move the camera @@ -1487,48 +1447,48 @@ void LLAgentCamera::updateCamera() // update the travel distance stat // this isn't directly related to the camera // but this seemed like the best place to do this - LLVector3d global_pos = gAgentHACK.getPositionGlobal(); - if (! gAgentHACK.mLastPositionGlobal.isExactlyZero()) + LLVector3d global_pos = gAgent.getPositionGlobal(); + if (! gAgent.mLastPositionGlobal.isExactlyZero()) { - LLVector3d delta = global_pos - gAgentHACK.mLastPositionGlobal; - gAgentHACK.mDistanceTraveled += delta.magVec(); + LLVector3d delta = global_pos - gAgent.mLastPositionGlobal; + gAgent.mDistanceTraveled += delta.magVec(); } - gAgentHACK.mLastPositionGlobal = global_pos; + gAgent.mLastPositionGlobal = global_pos; - if (LLVOAvatar::sVisibleInFirstPerson && gAgentHACK.mAvatarObject.notNull() && !gAgentHACK.mAvatarObject->isSitting() && cameraMouselook()) + if (LLVOAvatar::sVisibleInFirstPerson && gAgent.mAvatarObject.notNull() && !gAgent.mAvatarObject->isSitting() && cameraMouselook()) { - LLVector3 head_pos = gAgentHACK.mAvatarObject->mHeadp->getWorldPosition() + - LLVector3(0.08f, 0.f, 0.05f) * gAgentHACK.mAvatarObject->mHeadp->getWorldRotation() + - LLVector3(0.1f, 0.f, 0.f) * gAgentHACK.mAvatarObject->mPelvisp->getWorldRotation(); + LLVector3 head_pos = gAgent.mAvatarObject->mHeadp->getWorldPosition() + + LLVector3(0.08f, 0.f, 0.05f) * gAgent.mAvatarObject->mHeadp->getWorldRotation() + + LLVector3(0.1f, 0.f, 0.f) * gAgent.mAvatarObject->mPelvisp->getWorldRotation(); LLVector3 diff = mCameraPositionAgent - head_pos; - diff = diff * ~gAgentHACK.mAvatarObject->mRoot.getWorldRotation(); + diff = diff * ~gAgent.mAvatarObject->mRoot.getWorldRotation(); - LLJoint* torso_joint = gAgentHACK.mAvatarObject->mTorsop; - LLJoint* chest_joint = gAgentHACK.mAvatarObject->mChestp; + LLJoint* torso_joint = gAgent.mAvatarObject->mTorsop; + LLJoint* chest_joint = gAgent.mAvatarObject->mChestp; LLVector3 torso_scale = torso_joint->getScale(); LLVector3 chest_scale = chest_joint->getScale(); // shorten avatar skeleton to avoid foot interpenetration - if (!gAgentHACK.mAvatarObject->mInAir) + if (!gAgent.mAvatarObject->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 = gAgentHACK.mAvatarObject->mNeckp; + LLJoint* neck_joint = gAgent.mAvatarObject->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; } - gAgentHACK.mAvatarObject->mPelvisp->setPosition(gAgentHACK.mAvatarObject->mPelvisp->getPosition() + diff); + gAgent.mAvatarObject->mPelvisp->setPosition(gAgent.mAvatarObject->mPelvisp->getPosition() + diff); - gAgentHACK.mAvatarObject->mRoot.updateWorldMatrixChildren(); + gAgent.mAvatarObject->mRoot.updateWorldMatrixChildren(); - for (LLVOAvatar::attachment_map_t::iterator iter = gAgentHACK.mAvatarObject->mAttachmentPoints.begin(); - iter != gAgentHACK.mAvatarObject->mAttachmentPoints.end(); ) + for (LLVOAvatar::attachment_map_t::iterator iter = gAgent.mAvatarObject->mAttachmentPoints.begin(); + iter != gAgent.mAvatarObject->mAttachmentPoints.end(); ) { LLVOAvatar::attachment_map_t::iterator curiter = iter++; LLViewerJointAttachment* attachment = curiter->second; @@ -1557,7 +1517,7 @@ void LLAgentCamera::updateFocusOffset() validateFocusObject(); if (mFocusObject.notNull()) { - LLVector3d obj_pos = gAgentHACK.getPosGlobalFromAgent(mFocusObject->getRenderPosition()); + LLVector3d obj_pos = gAgent.getPosGlobalFromAgent(mFocusObject->getRenderPosition()); mFocusObjectOffset.setVec(mFocusTargetGlobal - obj_pos); } } @@ -1624,13 +1584,13 @@ LLVector3d LLAgentCamera::calcFocusPositionTargetGlobal() else if (mCameraMode == CAMERA_MODE_MOUSELOOK) { LLVector3d at_axis(1.0, 0.0, 0.0); - LLQuaternion agent_rot = gAgentHACK.mFrameAgent.getQuaternion(); - if (gAgentHACK.mAvatarObject.notNull() && gAgentHACK.mAvatarObject->getParent()) + LLQuaternion agent_rot = gAgent.mFrameAgent.getQuaternion(); + if (gAgent.mAvatarObject.notNull() && gAgent.mAvatarObject->getParent()) { - LLViewerObject* root_object = (LLViewerObject*)gAgentHACK.mAvatarObject->getRoot(); + LLViewerObject* root_object = (LLViewerObject*)gAgent.mAvatarObject->getRoot(); if (!root_object->flagCameraDecoupled()) { - agent_rot *= ((LLViewerObject*)(gAgentHACK.mAvatarObject->getParent()))->getRenderRotation(); + agent_rot *= ((LLViewerObject*)(gAgent.mAvatarObject->getParent()))->getRenderRotation(); } } at_axis = at_axis * agent_rot; @@ -1676,22 +1636,22 @@ LLVector3d LLAgentCamera::calcFocusPositionTargetGlobal() updateFocusOffset(); } LLVector3 focus_agent = mFocusObject->getRenderPosition() + mFocusObjectOffset; - mFocusTargetGlobal.setVec(gAgentHACK.getPosGlobalFromAgent(focus_agent)); + mFocusTargetGlobal.setVec(gAgent.getPosGlobalFromAgent(focus_agent)); } return mFocusTargetGlobal; } - else if (mSitCameraEnabled && gAgentHACK.mAvatarObject.notNull() && gAgentHACK.mAvatarObject->isSitting() && mSitCameraReferenceObject.notNull()) + else if (mSitCameraEnabled && gAgent.mAvatarObject.notNull() && gAgent.mAvatarObject->isSitting() && mSitCameraReferenceObject.notNull()) { // sit camera LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition(); LLQuaternion object_rot = mSitCameraReferenceObject->getRenderRotation(); LLVector3 target_pos = object_pos + (mSitCameraFocus * object_rot); - return gAgentHACK.getPosGlobalFromAgent(target_pos); + return gAgent.getPosGlobalFromAgent(target_pos); } else { - return gAgentHACK.getPositionGlobal() + calcThirdPersonFocusOffset(); + return gAgent.getPositionGlobal() + calcThirdPersonFocusOffset(); } } @@ -1700,10 +1660,10 @@ LLVector3d LLAgentCamera::calcThirdPersonFocusOffset() // ...offset from avatar LLVector3d focus_offset; - LLQuaternion agent_rot = gAgentHACK.mFrameAgent.getQuaternion(); - if (!gAgentHACK.mAvatarObject.isNull() && gAgentHACK.mAvatarObject->getParent()) + LLQuaternion agent_rot = gAgent.mFrameAgent.getQuaternion(); + if (!gAgent.mAvatarObject.isNull() && gAgent.mAvatarObject->getParent()) { - agent_rot *= ((LLViewerObject*)(gAgentHACK.mAvatarObject->getParent()))->getRenderRotation(); + agent_rot *= ((LLViewerObject*)(gAgent.mAvatarObject->getParent()))->getRenderRotation(); } focus_offset = mFocusOffsetInitial[mCameraPreset] * agent_rot; @@ -1713,14 +1673,14 @@ LLVector3d LLAgentCamera::calcThirdPersonFocusOffset() void LLAgentCamera::setupSitCamera() { // agent frame entering this function is in world coordinates - if (gAgentHACK.mAvatarObject.notNull() && gAgentHACK.mAvatarObject->getParent()) + if (gAgent.mAvatarObject.notNull() && gAgent.mAvatarObject->getParent()) { - LLQuaternion parent_rot = ((LLViewerObject*)gAgentHACK.mAvatarObject->getParent())->getRenderRotation(); + LLQuaternion parent_rot = ((LLViewerObject*)gAgent.mAvatarObject->getParent())->getRenderRotation(); // slam agent coordinate frame to proper parent local version - LLVector3 at_axis = gAgentHACK.mFrameAgent.getAtAxis(); + LLVector3 at_axis = gAgent.mFrameAgent.getAtAxis(); at_axis.mV[VZ] = 0.f; at_axis.normalize(); - gAgentHACK.resetAxes(at_axis * ~parent_rot); + gAgent.resetAxes(at_axis * ~parent_rot); } } @@ -1737,7 +1697,7 @@ const LLVector3 &LLAgentCamera::getCameraPositionAgent() const //----------------------------------------------------------------------------- LLVector3d LLAgentCamera::getCameraPositionGlobal() const { - return gAgentHACK.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()); + return gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()); } //----------------------------------------------------------------------------- @@ -1780,8 +1740,8 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) { // Compute base camera position and look-at points. F32 camera_land_height; - LLVector3d frame_center_global = gAgentHACK.mAvatarObject.isNull() ? gAgentHACK.getPositionGlobal() - : gAgentHACK.getPosGlobalFromAgent(gAgentHACK.mAvatarObject->mRoot.getWorldPosition()); + LLVector3d frame_center_global = gAgent.mAvatarObject.isNull() ? gAgent.getPositionGlobal() + : gAgent.getPosGlobalFromAgent(gAgent.mAvatarObject->mRoot.getWorldPosition()); BOOL isConstrained = FALSE; LLVector3d head_offset; @@ -1796,32 +1756,32 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) }// End Ventrella else if (mCameraMode == CAMERA_MODE_MOUSELOOK) { - if (gAgentHACK.mAvatarObject.isNull() || gAgentHACK.mAvatarObject->mDrawable.isNull()) + if (gAgent.mAvatarObject.isNull() || gAgent.mAvatarObject->mDrawable.isNull()) { llwarns << "Null avatar drawable!" << llendl; return LLVector3d::zero; } head_offset.clearVec(); - if (gAgentHACK.mAvatarObject->isSitting() && gAgentHACK.mAvatarObject->getParent()) + if (gAgent.mAvatarObject->isSitting() && gAgent.mAvatarObject->getParent()) { - gAgentHACK.mAvatarObject->updateHeadOffset(); - head_offset.mdV[VX] = gAgentHACK.mAvatarObject->mHeadOffset.mV[VX]; - head_offset.mdV[VY] = gAgentHACK.mAvatarObject->mHeadOffset.mV[VY]; - head_offset.mdV[VZ] = gAgentHACK.mAvatarObject->mHeadOffset.mV[VZ] + 0.1f; - const LLMatrix4& mat = ((LLViewerObject*) gAgentHACK.mAvatarObject->getParent())->getRenderMatrix(); - camera_position_global = gAgentHACK.getPosGlobalFromAgent - ((gAgentHACK.mAvatarObject->getPosition()+ - LLVector3(head_offset)*gAgentHACK.mAvatarObject->getRotation()) * mat); + gAgent.mAvatarObject->updateHeadOffset(); + head_offset.mdV[VX] = gAgent.mAvatarObject->mHeadOffset.mV[VX]; + head_offset.mdV[VY] = gAgent.mAvatarObject->mHeadOffset.mV[VY]; + head_offset.mdV[VZ] = gAgent.mAvatarObject->mHeadOffset.mV[VZ] + 0.1f; + const LLMatrix4& mat = ((LLViewerObject*) gAgent.mAvatarObject->getParent())->getRenderMatrix(); + camera_position_global = gAgent.getPosGlobalFromAgent + ((gAgent.mAvatarObject->getPosition()+ + LLVector3(head_offset)*gAgent.mAvatarObject->getRotation()) * mat); } else { - head_offset.mdV[VZ] = gAgentHACK.mAvatarObject->mHeadOffset.mV[VZ]; - if (gAgentHACK.mAvatarObject->isSitting()) + head_offset.mdV[VZ] = gAgent.mAvatarObject->mHeadOffset.mV[VZ]; + if (gAgent.mAvatarObject->isSitting()) { head_offset.mdV[VZ] += 0.1; } - camera_position_global = gAgentHACK.getPosGlobalFromAgent(gAgentHACK.mAvatarObject->getRenderPosition());//frame_center_global; - head_offset = head_offset * gAgentHACK.mAvatarObject->getRenderRotation(); + camera_position_global = gAgent.getPosGlobalFromAgent(gAgent.mAvatarObject->getRenderPosition());//frame_center_global; + head_offset = head_offset * gAgent.mAvatarObject->getRenderRotation(); camera_position_global = camera_position_global + head_offset; } } @@ -1831,8 +1791,8 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) F32 camera_distance = 0.f; if (mSitCameraEnabled - && gAgentHACK.mAvatarObject.notNull() - && gAgentHACK.mAvatarObject->isSitting() + && gAgent.mAvatarObject.notNull() + && gAgent.mAvatarObject->isSitting() && mSitCameraReferenceObject.notNull()) { // sit camera @@ -1841,30 +1801,30 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) LLVector3 target_pos = object_pos + (mSitCameraPos * object_rot); - camera_position_global = gAgentHACK.getPosGlobalFromAgent(target_pos); + camera_position_global = gAgent.getPosGlobalFromAgent(target_pos); } else { local_camera_offset = mCameraZoomFraction * getCameraOffsetInitial() * gSavedSettings.getF32("CameraOffsetScale"); // are we sitting down? - if (gAgentHACK.mAvatarObject.notNull() && gAgentHACK.mAvatarObject->getParent()) + if (gAgent.mAvatarObject.notNull() && gAgent.mAvatarObject->getParent()) { - LLQuaternion parent_rot = ((LLViewerObject*)gAgentHACK.mAvatarObject->getParent())->getRenderRotation(); + LLQuaternion parent_rot = ((LLViewerObject*)gAgent.mAvatarObject->getParent())->getRenderRotation(); // slam agent coordinate frame to proper parent local version - LLVector3 at_axis = gAgentHACK.mFrameAgent.getAtAxis() * parent_rot; + LLVector3 at_axis = gAgent.mFrameAgent.getAtAxis() * parent_rot; at_axis.mV[VZ] = 0.f; at_axis.normalize(); - gAgentHACK.resetAxes(at_axis * ~parent_rot); + gAgent.resetAxes(at_axis * ~parent_rot); - local_camera_offset = local_camera_offset * gAgentHACK.mFrameAgent.getQuaternion() * parent_rot; + local_camera_offset = local_camera_offset * gAgent.mFrameAgent.getQuaternion() * parent_rot; } else { - local_camera_offset = gAgentHACK.mFrameAgent.rotateToAbsolute( local_camera_offset ); + local_camera_offset = gAgent.mFrameAgent.rotateToAbsolute( local_camera_offset ); } - if (!mCameraCollidePlane.isExactlyZero() && (gAgentHACK.mAvatarObject.isNull() || !gAgentHACK.mAvatarObject->isSitting())) + if (!mCameraCollidePlane.isExactlyZero() && (gAgent.mAvatarObject.isNull() || !gAgent.mAvatarObject->isSitting())) { LLVector3 plane_normal; plane_normal.setVec(mCameraCollidePlane.mV); @@ -1877,7 +1837,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) camera_distance = local_camera_offset.normalize(); - F32 pos_dot_norm = gAgentHACK.getPosAgentFromGlobal(frame_center_global + head_offset) * plane_normal; + F32 pos_dot_norm = gAgent.getPosAgentFromGlobal(frame_center_global + head_offset) * plane_normal; // if agent is outside the colliding half-plane if (pos_dot_norm > mCameraCollidePlane.mV[VW]) @@ -1917,23 +1877,23 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) // set the global camera position LLVector3d camera_offset; - LLVector3 av_pos = gAgentHACK.mAvatarObject.isNull() ? LLVector3::zero : gAgentHACK.mAvatarObject->getRenderPosition(); + LLVector3 av_pos = gAgent.mAvatarObject.isNull() ? LLVector3::zero : gAgent.mAvatarObject->getRenderPosition(); camera_offset.setVec( local_camera_offset ); camera_position_global = frame_center_global + head_offset + camera_offset; - if (gAgentHACK.mAvatarObject.notNull()) + if (gAgent.mAvatarObject.notNull()) { LLVector3d camera_lag_d; F32 lag_interp = LLCriticalDamp::getInterpolant(CAMERA_LAG_HALF_LIFE); LLVector3 target_lag; - LLVector3 vel = gAgentHACK.getVelocity(); + LLVector3 vel = gAgent.getVelocity(); // lag by appropriate amount for flying - F32 time_in_air = gAgentHACK.mAvatarObject->mTimeInAir.getElapsedTimeF32(); - if(!mCameraAnimating && gAgentHACK.mAvatarObject->mInAir && time_in_air > GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME) + F32 time_in_air = gAgent.mAvatarObject->mTimeInAir.getElapsedTimeF32(); + if(!mCameraAnimating && gAgent.mAvatarObject->mInAir && time_in_air > GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME) { - LLVector3 frame_at_axis = gAgentHACK.mFrameAgent.getAtAxis(); - frame_at_axis -= projected_vec(frame_at_axis, gAgentHACK.getReferenceUpVector()); + LLVector3 frame_at_axis = gAgent.mFrameAgent.getAtAxis(); + frame_at_axis -= projected_vec(frame_at_axis, gAgent.getReferenceUpVector()); frame_at_axis.normalize(); //transition smoothly in air mode, to avoid camera pop @@ -1942,7 +1902,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) lag_interp *= u; - if (gViewerWindow->getLeftMouseDown() && gViewerWindow->getLastPick().mObjectID == gAgentHACK.mAvatarObject->getID()) + if (gViewerWindow->getLeftMouseDown() && gViewerWindow->getLastPick().mObjectID == gAgent.mAvatarObject->getID()) { // disable camera lag when using mouse-directed steering target_lag.clearVec(); @@ -2127,7 +2087,7 @@ F32 LLAgentCamera::getCameraMinOffGround() void LLAgentCamera::resetCamera() { // Remove any pitch from the avatar - LLVector3 at = gAgentHACK.mFrameAgent.getAtAxis(); + LLVector3 at = gAgent.mFrameAgent.getAtAxis(); at.mV[VZ] = 0.f; at.normalize(); gAgent.resetAxes(at); @@ -2151,14 +2111,14 @@ void LLAgentCamera::changeCameraToMouselook(BOOL animate) gViewerWindow->getWindow()->resetBusyCount(); // unpause avatar animation - gAgentHACK.mPauseRequest = NULL; + gAgent.mPauseRequest = NULL; LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset); - if (gAgentHACK.mAvatarObject.notNull()) + if (gAgent.mAvatarObject.notNull()) { - gAgentHACK.mAvatarObject->stopMotion( ANIM_AGENT_BODY_NOISE ); - gAgentHACK.mAvatarObject->stopMotion( ANIM_AGENT_BREATHE_ROT ); + gAgent.mAvatarObject->stopMotion( ANIM_AGENT_BODY_NOISE ); + gAgent.mAvatarObject->stopMotion( ANIM_AGENT_BREATHE_ROT ); } //gViewerWindow->stopGrab(); @@ -2172,11 +2132,11 @@ void LLAgentCamera::changeCameraToMouselook(BOOL animate) mLastCameraMode = mCameraMode; mCameraMode = CAMERA_MODE_MOUSELOOK; - U32 old_flags = gAgentHACK.mControlFlags; - gAgentHACK.setControlFlags(AGENT_CONTROL_MOUSELOOK); - if (old_flags != gAgentHACK.mControlFlags) + U32 old_flags = gAgent.mControlFlags; + gAgent.setControlFlags(AGENT_CONTROL_MOUSELOOK); + if (old_flags != gAgent.mControlFlags) { - gAgentHACK.mbFlagsDirty = TRUE; + gAgent.mbFlagsDirty = TRUE; } if (animate) @@ -2186,7 +2146,7 @@ void LLAgentCamera::changeCameraToMouselook(BOOL animate) else { mCameraAnimating = FALSE; - gAgentHACK.endAnimationUpdateUI(); + gAgent.endAnimationUpdateUI(); } } } @@ -2243,21 +2203,21 @@ void LLAgentCamera::changeCameraToFollow(BOOL animate) LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); } - if (gAgentHACK.mAvatarObject.notNull()) + if (gAgent.mAvatarObject.notNull()) { - gAgentHACK.mAvatarObject->mPelvisp->setPosition(LLVector3::zero); - gAgentHACK.mAvatarObject->startMotion( ANIM_AGENT_BODY_NOISE ); - gAgentHACK.mAvatarObject->startMotion( ANIM_AGENT_BREATHE_ROT ); + gAgent.mAvatarObject->mPelvisp->setPosition(LLVector3::zero); + gAgent.mAvatarObject->startMotion( ANIM_AGENT_BODY_NOISE ); + gAgent.mAvatarObject->startMotion( ANIM_AGENT_BREATHE_ROT ); } // unpause avatar animation - gAgentHACK.mPauseRequest = NULL; + gAgent.mPauseRequest = NULL; - U32 old_flags = gAgentHACK.mControlFlags; - gAgentHACK.clearControlFlags(AGENT_CONTROL_MOUSELOOK); - if (old_flags != gAgentHACK.mControlFlags) + U32 old_flags = gAgent.mControlFlags; + gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK); + if (old_flags != gAgent.mControlFlags) { - gAgentHACK.mbFlagsDirty = TRUE; + gAgent.mbFlagsDirty = TRUE; } if (animate) @@ -2267,7 +2227,7 @@ void LLAgentCamera::changeCameraToFollow(BOOL animate) else { mCameraAnimating = FALSE; - gAgentHACK.endAnimationUpdateUI(); + gAgent.endAnimationUpdateUI(); } } } @@ -2286,20 +2246,20 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate) mCameraZoomFraction = INITIAL_ZOOM_FRACTION; - if (gAgentHACK.mAvatarObject.notNull()) + if (gAgent.mAvatarObject.notNull()) { - if (!gAgentHACK.mAvatarObject->isSitting()) + if (!gAgent.mAvatarObject->isSitting()) { - gAgentHACK.mAvatarObject->mPelvisp->setPosition(LLVector3::zero); + gAgent.mAvatarObject->mPelvisp->setPosition(LLVector3::zero); } - gAgentHACK.mAvatarObject->startMotion( ANIM_AGENT_BODY_NOISE ); - gAgentHACK.mAvatarObject->startMotion( ANIM_AGENT_BREATHE_ROT ); + gAgent.mAvatarObject->startMotion( ANIM_AGENT_BODY_NOISE ); + gAgent.mAvatarObject->startMotion( ANIM_AGENT_BREATHE_ROT ); } LLVector3 at_axis; // unpause avatar animation - gAgentHACK.mPauseRequest = NULL; + gAgent.mPauseRequest = NULL; if( mCameraMode != CAMERA_MODE_THIRD_PERSON ) { @@ -2317,30 +2277,30 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate) } mLastCameraMode = mCameraMode; mCameraMode = CAMERA_MODE_THIRD_PERSON; - U32 old_flags = gAgentHACK.mControlFlags; - gAgentHACK.clearControlFlags(AGENT_CONTROL_MOUSELOOK); - if (old_flags != gAgentHACK.mControlFlags) + U32 old_flags = gAgent.mControlFlags; + gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK); + if (old_flags != gAgent.mControlFlags) { - gAgentHACK.mbFlagsDirty = TRUE; + gAgent.mbFlagsDirty = TRUE; } } // Remove any pitch from the avatar - if (gAgentHACK.mAvatarObject.notNull() && gAgentHACK.mAvatarObject->getParent()) + if (gAgent.mAvatarObject.notNull() && gAgent.mAvatarObject->getParent()) { - LLQuaternion obj_rot = ((LLViewerObject*)gAgentHACK.mAvatarObject->getParent())->getRenderRotation(); + LLQuaternion obj_rot = ((LLViewerObject*)gAgent.mAvatarObject->getParent())->getRenderRotation(); at_axis = LLViewerCamera::getInstance()->getAtAxis(); at_axis.mV[VZ] = 0.f; at_axis.normalize(); - gAgentHACK.resetAxes(at_axis * ~obj_rot); + gAgent.resetAxes(at_axis * ~obj_rot); } else { - at_axis = gAgentHACK.mFrameAgent.getAtAxis(); + at_axis = gAgent.mFrameAgent.getAtAxis(); at_axis.mV[VZ] = 0.f; at_axis.normalize(); - gAgentHACK.resetAxes(at_axis); + gAgent.resetAxes(at_axis); } @@ -2351,7 +2311,7 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate) else { mCameraAnimating = FALSE; - gAgentHACK.endAnimationUpdateUI(); + gAgent.endAnimationUpdateUI(); } } @@ -2365,7 +2325,7 @@ void LLAgentCamera::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL came return; } - gAgentHACK.standUp(); // force stand up + gAgent.standUp(); // force stand up gViewerWindow->getWindow()->resetBusyCount(); if (gFaceEditToolset) @@ -2379,7 +2339,7 @@ void LLAgentCamera::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL came } // Remove any pitch from the avatar - //LLVector3 at = gAgentHACK.mFrameAgent.getAtAxis(); + //LLVector3 at = gAgent.mFrameAgent.getAtAxis(); //at.mV[VZ] = 0.f; //at.normalize(); //gAgent.resetAxes(at); @@ -2388,11 +2348,11 @@ void LLAgentCamera::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL came { mLastCameraMode = mCameraMode; mCameraMode = CAMERA_MODE_CUSTOMIZE_AVATAR; - U32 old_flags = gAgentHACK.mControlFlags; - gAgentHACK.clearControlFlags(AGENT_CONTROL_MOUSELOOK); - if (old_flags != gAgentHACK.mControlFlags) + U32 old_flags = gAgent.mControlFlags; + gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK); + if (old_flags != gAgent.mControlFlags) { - gAgentHACK.mbFlagsDirty = TRUE; + gAgent.mbFlagsDirty = TRUE; } gFocusMgr.setKeyboardFocus( NULL ); @@ -2401,20 +2361,20 @@ void LLAgentCamera::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL came LLVOAvatarSelf::onCustomizeStart(); } - if (gAgentHACK.mAvatarObject.notNull()) + if (gAgent.mAvatarObject.notNull()) { if(avatar_animate) { // Remove any pitch from the avatar - LLVector3 at = gAgentHACK.mFrameAgent.getAtAxis(); + LLVector3 at = gAgent.mFrameAgent.getAtAxis(); at.mV[VZ] = 0.f; at.normalize(); gAgent.resetAxes(at); - gAgentHACK.sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_START); - gAgentHACK.mCustomAnim = TRUE; - gAgentHACK.mAvatarObject->startMotion(ANIM_AGENT_CUSTOMIZE); - LLMotion* turn_motion = gAgentHACK.mAvatarObject->findMotion(ANIM_AGENT_CUSTOMIZE); + gAgent.sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_START); + gAgent.mCustomAnim = TRUE; + gAgent.mAvatarObject->startMotion(ANIM_AGENT_CUSTOMIZE); + LLMotion* turn_motion = gAgent.mAvatarObject->findMotion(ANIM_AGENT_CUSTOMIZE); if (turn_motion) { @@ -2434,7 +2394,7 @@ void LLAgentCamera::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL came else { mCameraAnimating = FALSE; - gAgentHACK.endAnimationUpdateUI(); + gAgent.endAnimationUpdateUI(); } } @@ -2527,13 +2487,13 @@ void LLAgentCamera::setFocusGlobal(const LLVector3d& focus, const LLUUID &object { if (focus.isExactlyZero()) { - if (gAgentHACK.mAvatarObject.notNull()) + if (gAgent.mAvatarObject.notNull()) { - mFocusTargetGlobal = gAgentHACK.getPosGlobalFromAgent(gAgentHACK.mAvatarObject->mHeadp->getWorldPosition()); + mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgent.mAvatarObject->mHeadp->getWorldPosition()); } else { - mFocusTargetGlobal = gAgentHACK.getPositionGlobal(); + mFocusTargetGlobal = gAgent.getPositionGlobal(); } mCameraFocusOffsetTarget = getCameraPositionGlobal() - mFocusTargetGlobal; mCameraFocusOffset = mCameraFocusOffsetTarget; @@ -2559,12 +2519,12 @@ void LLAgentCamera::setFocusGlobal(const LLVector3d& focus, const LLUUID &object } else { - setLookAt(LOOKAT_TARGET_FOCUS, focus_obj, (gAgentHACK.getPosAgentFromGlobal(focus) - focus_obj->getRenderPosition()) * ~focus_obj->getRenderRotation()); + setLookAt(LOOKAT_TARGET_FOCUS, focus_obj, (gAgent.getPosAgentFromGlobal(focus) - focus_obj->getRenderPosition()) * ~focus_obj->getRenderRotation()); } } else { - setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgentHACK.getPosAgentFromGlobal(mFocusTargetGlobal)); + setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgent.getPosAgentFromGlobal(mFocusTargetGlobal)); } } } @@ -2572,13 +2532,13 @@ void LLAgentCamera::setFocusGlobal(const LLVector3d& focus, const LLUUID &object { if (focus.isExactlyZero()) { - if (gAgentHACK.mAvatarObject.notNull()) + if (gAgent.mAvatarObject.notNull()) { - mFocusTargetGlobal = gAgentHACK.getPosGlobalFromAgent(gAgentHACK.mAvatarObject->mHeadp->getWorldPosition()); + mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgent.mAvatarObject->mHeadp->getWorldPosition()); } else { - mFocusTargetGlobal = gAgentHACK.getPositionGlobal(); + mFocusTargetGlobal = gAgent.getPositionGlobal(); } } mCameraFocusOffsetTarget = (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor);; @@ -2636,12 +2596,12 @@ void LLAgentCamera::setCameraPosAndFocusGlobal(const LLVector3d& camera_pos, con } else { - setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject, (gAgentHACK.getPosAgentFromGlobal(focus) - mFocusObject->getRenderPosition()) * ~mFocusObject->getRenderRotation()); + setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject, (gAgent.getPosAgentFromGlobal(focus) - mFocusObject->getRenderPosition()) * ~mFocusObject->getRenderRotation()); } } else { - setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgentHACK.getPosAgentFromGlobal(mFocusTargetGlobal)); + setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgent.getPosAgentFromGlobal(mFocusTargetGlobal)); } if( mCameraAnimating ) @@ -2712,20 +2672,20 @@ void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) if (mCameraMode == CAMERA_MODE_THIRD_PERSON) { LLVector3 at_axis; - if (gAgentHACK.mAvatarObject.notNull() && gAgentHACK.mAvatarObject->getParent()) + if (gAgent.mAvatarObject.notNull() && gAgent.mAvatarObject->getParent()) { - LLQuaternion obj_rot = ((LLViewerObject*)gAgentHACK.mAvatarObject->getParent())->getRenderRotation(); + LLQuaternion obj_rot = ((LLViewerObject*)gAgent.mAvatarObject->getParent())->getRenderRotation(); at_axis = LLViewerCamera::getInstance()->getAtAxis(); at_axis.mV[VZ] = 0.f; at_axis.normalize(); - gAgentHACK.resetAxes(at_axis * ~obj_rot); + gAgent.resetAxes(at_axis * ~obj_rot); } else { at_axis = LLViewerCamera::getInstance()->getAtAxis(); at_axis.mV[VZ] = 0.f; at_axis.normalize(); - gAgentHACK.resetAxes(at_axis); + gAgent.resetAxes(at_axis); } } } @@ -2733,7 +2693,7 @@ void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) else if (mFocusOnAvatar && !focus_on_avatar) { // keep camera focus point consistent, even though it is now unlocked - setFocusGlobal(gAgentHACK.getPositionGlobal() + calcThirdPersonFocusOffset(), gAgent.getID()); + setFocusGlobal(gAgent.getPositionGlobal() + calcThirdPersonFocusOffset(), gAgent.getID()); } mFocusOnAvatar = focus_on_avatar; @@ -2747,10 +2707,10 @@ BOOL LLAgentCamera::setLookAt(ELookAtType target_type, LLViewerObject *object, L LLViewerObject* parent = object; while(parent) { - if (parent == gAgentHACK.mAvatarObject) + if (parent == gAgent.mAvatarObject) { // looking at an attachment on ourselves, which we don't want to do - object = gAgentHACK.mAvatarObject; + object = gAgent.mAvatarObject; position.clearVec(); } parent = (LLViewerObject*)parent->getParent(); @@ -2759,7 +2719,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(gAgentHACK.mAvatarObject); + mLookAt->setSourceObject(gAgent.mAvatarObject); } return mLookAt->setLookAt(target_type, object, position); @@ -2776,7 +2736,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(gAgentHACK.mAvatarObject); + mPointAt->setSourceObject(gAgent.mAvatarObject); } return mPointAt->setPointAt(target_type, object, position); diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index 6a0e8d372e..0b55b917d0 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -99,10 +99,6 @@ public: ** INITIALIZATION **/ - // SERAPH UNFILED -public: - F32 mDrawDistance; - //-------------------------------------------------------------------- // Constructors / Destructors //-------------------------------------------------------------------- @@ -139,9 +135,7 @@ private: //-------------------------------------------------------------------- public: void switchCameraPreset(ECameraPreset preset); - private: - /** Determines default camera offset depending on the current camera preset */ LLVector3 getCameraOffsetInitial(); @@ -251,7 +245,7 @@ public: void startCameraAnimation(); void stopCameraAnimation(); private: - LLFrameTimer mAnimationTimer; // Seconds that transition animation has been active // SERAPH agentCamera + LLFrameTimer mAnimationTimer; // Seconds that transition animation has been active F32 mAnimationDuration; // In seconds BOOL mCameraAnimating; // Camera is transitioning from one mode to another LLVector3d mAnimationCameraStartGlobal; // Camera start position, global coords @@ -347,6 +341,8 @@ public: void resetView(BOOL reset_camera = TRUE, BOOL change_camera = FALSE); // Called on camera movement. Unlocks camera from the default position behind the avatar. void unlockView(); +public: + F32 mDrawDistance; //-------------------------------------------------------------------- // Mouselook diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index aaac36d557..80c32399ce 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2509,9 +2509,9 @@ void LLAppViewer::cleanupSavedSettings() gSavedSettings.setF32("MapScale", LLWorldMapView::sMapScale ); // Some things are cached in LLAgent. - if (gAgent.mInitialized) + if (gAgent.isInitialized()) { - gSavedSettings.setF32("RenderFarClip", gAgent.mDrawDistance); + gSavedSettings.setF32("RenderFarClip", gAgentCamera.mDrawDistance); } } diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp index 33f651284b..9e1dc3a4b0 100644 --- a/indra/newview/lljoystickbutton.cpp +++ b/indra/newview/lljoystickbutton.cpp @@ -627,24 +627,24 @@ void LLJoystickCameraTrack::onHeldDown() if (dx > mVertSlopNear) { gAgentCamera.unlockView(); - gAgent.setPanRightKey(getOrbitRate()); + gAgentCamera.setPanRightKey(getOrbitRate()); } else if (dx < -mVertSlopNear) { gAgentCamera.unlockView(); - gAgent.setPanLeftKey(getOrbitRate()); + gAgentCamera.setPanLeftKey(getOrbitRate()); } // over/under rotation if (dy > mVertSlopNear) { gAgentCamera.unlockView(); - gAgent.setPanUpKey(getOrbitRate()); + gAgentCamera.setPanUpKey(getOrbitRate()); } else if (dy < -mVertSlopNear) { gAgentCamera.unlockView(); - gAgent.setPanDownKey(getOrbitRate()); + gAgentCamera.setPanDownKey(getOrbitRate()); } } @@ -694,25 +694,25 @@ void LLJoystickCameraZoom::onHeldDown() { // Zoom in fast gAgentCamera.unlockView(); - gAgent.setOrbitInKey(FAST_RATE); + gAgentCamera.setOrbitInKey(FAST_RATE); } else if (dy > mVertSlopNear) { // Zoom in slow gAgentCamera.unlockView(); - gAgent.setOrbitInKey(getOrbitRate()); + gAgentCamera.setOrbitInKey(getOrbitRate()); } else if (dy < -mVertSlopFar) { // Zoom out fast gAgentCamera.unlockView(); - gAgent.setOrbitOutKey(FAST_RATE); + gAgentCamera.setOrbitOutKey(FAST_RATE); } else if (dy < -mVertSlopNear) { // Zoom out slow gAgentCamera.unlockView(); - gAgent.setOrbitOutKey(getOrbitRate()); + gAgentCamera.setOrbitOutKey(getOrbitRate()); } } diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 559cd624f7..c440a1b285 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1174,7 +1174,7 @@ bool idle_startup() // World initialization must be done after above window init // User might have overridden far clip - LLWorld::getInstance()->setLandFarClip( gAgent.mDrawDistance ); + LLWorld::getInstance()->setLandFarClip(gAgentCamera.mDrawDistance); // Before we create the first region, we need to set the agent's mOriginGlobal // This is necessary because creating objects before this is set will result in a diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp index 0051f46716..aa82c216d9 100644 --- a/indra/newview/llviewercamera.cpp +++ b/indra/newview/llviewercamera.cpp @@ -37,6 +37,7 @@ // Viewer includes #include "llagent.h" +#include "llagentcamera.h" #include "llviewercontrol.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" @@ -354,7 +355,7 @@ void LLViewerCamera::setPerspective(BOOL for_selection, } else { - z_far = gAgent.mDrawDistance; + z_far = gAgentCamera.mDrawDistance; } } else diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 5daea96123..23349ab916 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -41,6 +41,7 @@ // For Listeners #include "llaudioengine.h" #include "llagent.h" +#include "llagentcamera.h" #include "llconsole.h" #include "lldrawpoolterrain.h" #include "llflexibleobject.h" @@ -102,7 +103,7 @@ static bool handleRenderAvatarMouselookChanged(const LLSD& newvalue) static bool handleRenderFarClipChanged(const LLSD& newvalue) { F32 draw_distance = (F32) newvalue.asReal(); - gAgent.mDrawDistance = draw_distance; + gAgentCamera.mDrawDistance = draw_distance; LLWorld::getInstance()->setLandFarClip(draw_distance); return true; } diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 17816bc818..5a2b901bd7 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -175,7 +175,7 @@ void display_update_camera() // Cut draw distance in half when customizing avatar, // but on the viewer only. - F32 final_far = gAgent.mDrawDistance; + F32 final_far = gAgentCamera.mDrawDistance; if (CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode()) { final_far *= 0.5f; diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp index 4034d8c57d..cbec2c890f 100644 --- a/indra/newview/llviewerkeyboard.cpp +++ b/indra/newview/llviewerkeyboard.cpp @@ -281,7 +281,7 @@ void camera_spin_around_ccw( EKeystate s ) { if( KEYSTATE_UP == s ) return; gAgentCamera.unlockView(); - gAgent.setOrbitLeftKey( get_orbit_rate() ); + gAgentCamera.setOrbitLeftKey( get_orbit_rate() ); } @@ -289,7 +289,7 @@ void camera_spin_around_cw( EKeystate s ) { if( KEYSTATE_UP == s ) return; gAgentCamera.unlockView(); - gAgent.setOrbitRightKey( get_orbit_rate() ); + gAgentCamera.setOrbitRightKey( get_orbit_rate() ); } void camera_spin_around_ccw_sitting( EKeystate s ) @@ -303,7 +303,7 @@ void camera_spin_around_ccw_sitting( EKeystate s ) else { //change camera but do not send keystrokes - gAgent.setOrbitLeftKey( get_orbit_rate() ); + gAgentCamera.setOrbitLeftKey( get_orbit_rate() ); } } @@ -319,7 +319,7 @@ void camera_spin_around_cw_sitting( EKeystate s ) else { //change camera but do not send keystrokes - gAgent.setOrbitRightKey( get_orbit_rate() ); + gAgentCamera.setOrbitRightKey( get_orbit_rate() ); } } @@ -328,7 +328,7 @@ void camera_spin_over( EKeystate s ) { if( KEYSTATE_UP == s ) return; gAgentCamera.unlockView(); - gAgent.setOrbitUpKey( get_orbit_rate() ); + gAgentCamera.setOrbitUpKey( get_orbit_rate() ); } @@ -336,7 +336,7 @@ void camera_spin_under( EKeystate s ) { if( KEYSTATE_UP == s ) return; gAgentCamera.unlockView(); - gAgent.setOrbitDownKey( get_orbit_rate() ); + gAgentCamera.setOrbitDownKey( get_orbit_rate() ); } void camera_spin_over_sitting( EKeystate s ) @@ -350,7 +350,7 @@ void camera_spin_over_sitting( EKeystate s ) else { //change camera but do not send keystrokes - gAgent.setOrbitUpKey( get_orbit_rate() ); + gAgentCamera.setOrbitUpKey( get_orbit_rate() ); } } @@ -366,7 +366,7 @@ void camera_spin_under_sitting( EKeystate s ) else { //change camera but do not send keystrokes - gAgent.setOrbitDownKey( get_orbit_rate() ); + gAgentCamera.setOrbitDownKey( get_orbit_rate() ); } } @@ -374,7 +374,7 @@ void camera_move_forward( EKeystate s ) { if( KEYSTATE_UP == s ) return; gAgentCamera.unlockView(); - gAgent.setOrbitInKey( get_orbit_rate() ); + gAgentCamera.setOrbitInKey( get_orbit_rate() ); } @@ -382,7 +382,7 @@ void camera_move_backward( EKeystate s ) { if( KEYSTATE_UP == s ) return; gAgentCamera.unlockView(); - gAgent.setOrbitOutKey( get_orbit_rate() ); + gAgentCamera.setOrbitOutKey( get_orbit_rate() ); } void camera_move_forward_sitting( EKeystate s ) @@ -394,7 +394,7 @@ void camera_move_forward_sitting( EKeystate s ) } else { - gAgent.setOrbitInKey( get_orbit_rate() ); + gAgentCamera.setOrbitInKey( get_orbit_rate() ); } } @@ -409,7 +409,7 @@ void camera_move_backward_sitting( EKeystate s ) } else { - gAgent.setOrbitOutKey( get_orbit_rate() ); + gAgentCamera.setOrbitOutKey( get_orbit_rate() ); } } @@ -417,56 +417,56 @@ void camera_pan_up( EKeystate s ) { if( KEYSTATE_UP == s ) return; gAgentCamera.unlockView(); - gAgent.setPanUpKey( get_orbit_rate() ); + gAgentCamera.setPanUpKey( get_orbit_rate() ); } void camera_pan_down( EKeystate s ) { if( KEYSTATE_UP == s ) return; gAgentCamera.unlockView(); - gAgent.setPanDownKey( get_orbit_rate() ); + gAgentCamera.setPanDownKey( get_orbit_rate() ); } void camera_pan_left( EKeystate s ) { if( KEYSTATE_UP == s ) return; gAgentCamera.unlockView(); - gAgent.setPanLeftKey( get_orbit_rate() ); + gAgentCamera.setPanLeftKey( get_orbit_rate() ); } void camera_pan_right( EKeystate s ) { if( KEYSTATE_UP == s ) return; gAgentCamera.unlockView(); - gAgent.setPanRightKey( get_orbit_rate() ); + gAgentCamera.setPanRightKey( get_orbit_rate() ); } void camera_pan_in( EKeystate s ) { if( KEYSTATE_UP == s ) return; gAgentCamera.unlockView(); - gAgent.setPanInKey( get_orbit_rate() ); + gAgentCamera.setPanInKey( get_orbit_rate() ); } void camera_pan_out( EKeystate s ) { if( KEYSTATE_UP == s ) return; gAgentCamera.unlockView(); - gAgent.setPanOutKey( get_orbit_rate() ); + gAgentCamera.setPanOutKey( get_orbit_rate() ); } void camera_move_forward_fast( EKeystate s ) { if( KEYSTATE_UP == s ) return; gAgentCamera.unlockView(); - gAgent.setOrbitInKey(2.5f); + gAgentCamera.setOrbitInKey(2.5f); } void camera_move_backward_fast( EKeystate s ) { if( KEYSTATE_UP == s ) return; gAgentCamera.unlockView(); - gAgent.setOrbitOutKey(2.5f); + gAgentCamera.setOrbitOutKey(2.5f); } @@ -474,7 +474,7 @@ void edit_avatar_spin_ccw( EKeystate s ) { if( KEYSTATE_UP == s ) return; gMorphView->setCameraDrivenByKeys( TRUE ); - gAgent.setOrbitLeftKey( get_orbit_rate() ); + gAgentCamera.setOrbitLeftKey( get_orbit_rate() ); //gMorphView->orbitLeft( get_orbit_rate() ); } @@ -483,7 +483,7 @@ void edit_avatar_spin_cw( EKeystate s ) { if( KEYSTATE_UP == s ) return; gMorphView->setCameraDrivenByKeys( TRUE ); - gAgent.setOrbitRightKey( get_orbit_rate() ); + gAgentCamera.setOrbitRightKey( get_orbit_rate() ); //gMorphView->orbitRight( get_orbit_rate() ); } @@ -491,7 +491,7 @@ void edit_avatar_spin_over( EKeystate s ) { if( KEYSTATE_UP == s ) return; gMorphView->setCameraDrivenByKeys( TRUE ); - gAgent.setOrbitUpKey( get_orbit_rate() ); + gAgentCamera.setOrbitUpKey( get_orbit_rate() ); //gMorphView->orbitUp( get_orbit_rate() ); } @@ -500,7 +500,7 @@ void edit_avatar_spin_under( EKeystate s ) { if( KEYSTATE_UP == s ) return; gMorphView->setCameraDrivenByKeys( TRUE ); - gAgent.setOrbitDownKey( get_orbit_rate() ); + gAgentCamera.setOrbitDownKey( get_orbit_rate() ); //gMorphView->orbitDown( get_orbit_rate() ); } @@ -508,7 +508,7 @@ void edit_avatar_move_forward( EKeystate s ) { if( KEYSTATE_UP == s ) return; gMorphView->setCameraDrivenByKeys( TRUE ); - gAgent.setOrbitInKey( get_orbit_rate() ); + gAgentCamera.setOrbitInKey( get_orbit_rate() ); //gMorphView->orbitIn(); } @@ -517,7 +517,7 @@ void edit_avatar_move_backward( EKeystate s ) { if( KEYSTATE_UP == s ) return; gMorphView->setCameraDrivenByKeys( TRUE ); - gAgent.setOrbitOutKey( get_orbit_rate() ); + gAgentCamera.setOrbitOutKey( get_orbit_rate() ); //gMorphView->orbitOut(); } diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index ea80dee05c..05dffb8107 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -3458,7 +3458,7 @@ void send_agent_update(BOOL force_send, BOOL send_reliable) msg->addVector3Fast(_PREHASH_CameraAtAxis, LLViewerCamera::getInstance()->getAtAxis()); msg->addVector3Fast(_PREHASH_CameraLeftAxis, LLViewerCamera::getInstance()->getLeftAxis()); msg->addVector3Fast(_PREHASH_CameraUpAxis, LLViewerCamera::getInstance()->getUpAxis()); - msg->addF32Fast(_PREHASH_Far, gAgent.mDrawDistance); + msg->addF32Fast(_PREHASH_Far, gAgentCamera.mDrawDistance); msg->addU32Fast(_PREHASH_ControlFlags, control_flags); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 8c6571aaf7..00c89457de 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -3656,7 +3656,7 @@ BOOL LLViewerWindow::mousePointOnLandGlobal(const S32 x, const S32 y, LLVector3d LLVector3 probe_point_region; // walk forwards to find the point - for (mouse_dir_scale = FIRST_PASS_STEP; mouse_dir_scale < gAgent.mDrawDistance; mouse_dir_scale += FIRST_PASS_STEP) + for (mouse_dir_scale = FIRST_PASS_STEP; mouse_dir_scale < gAgentCamera.mDrawDistance; mouse_dir_scale += FIRST_PASS_STEP) { LLVector3d mouse_direction_global_d; mouse_direction_global_d.setVec(mouse_direction_global * mouse_dir_scale); -- cgit v1.3 From 46fe5d49caef6c8db3df9d88f0d0ec773ef28095 Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Fri, 26 Mar 2010 14:33:48 -0400 Subject: EXT-6536 : Make LLVOAvatarSelf a singleton Superficial cleanup so that all instances of gAgent.getAvatarObject() use "LLVOAvatarSelf *avatarp = gAgent.getAvatarObject". --- indra/newview/llagentui.cpp | 3 +- indra/newview/llagentwearables.cpp | 3 +- indra/newview/lldriverparam.cpp | 15 ++++---- indra/newview/llgesturemgr.cpp | 12 +++---- indra/newview/llinventorybridge.cpp | 9 ++--- indra/newview/llinventoryfunctions.cpp | 4 +-- indra/newview/llinventorymodel.cpp | 5 ++- indra/newview/llinventorypanel.cpp | 2 +- indra/newview/llmorphview.cpp | 10 +++--- indra/newview/llpreviewanim.cpp | 17 ++++----- indra/newview/llselectmgr.cpp | 15 ++++---- indra/newview/lltooldraganddrop.cpp | 2 +- indra/newview/lltoolfocus.cpp | 7 ++-- indra/newview/lltoolpie.cpp | 24 +++++++------ indra/newview/llviewerdisplay.cpp | 6 ++-- indra/newview/llviewerkeyboard.cpp | 3 +- indra/newview/llviewermenu.cpp | 14 ++++---- indra/newview/llviewermessage.cpp | 6 ++-- indra/newview/llvoavatar.cpp | 22 ++++++------ indra/newview/llvoavatarself.cpp | 14 ++++---- indra/newview/llwearable.cpp | 65 ++++++++++++++-------------------- 21 files changed, 126 insertions(+), 132 deletions(-) (limited to 'indra/newview/llviewerkeyboard.cpp') diff --git a/indra/newview/llagentui.cpp b/indra/newview/llagentui.cpp index 4601e3241b..97e956c082 100644 --- a/indra/newview/llagentui.cpp +++ b/indra/newview/llagentui.cpp @@ -73,7 +73,8 @@ void LLAgentUI::buildName(std::string& name) //static void LLAgentUI::buildFullname(std::string& name) { - if (gAgent.getAvatarObject()) name = gAgent.getAvatarObject()->getFullname(); + LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); + if (avatarp) name = avatarp->getFullname(); } //static diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index c673e82d5f..aec8c6e403 100644 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -485,7 +485,8 @@ void LLAgentWearables::saveWearable(const EWearableType type, const U32 index, B return; } - gAgent.getAvatarObject()->wearableUpdated( type, TRUE ); + LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); + avatarp->wearableUpdated( type, TRUE ); if (send_update) { diff --git a/indra/newview/lldriverparam.cpp b/indra/newview/lldriverparam.cpp index 830e975e8a..c22c9d3048 100644 --- a/indra/newview/lldriverparam.cpp +++ b/indra/newview/lldriverparam.cpp @@ -118,13 +118,13 @@ void LLDriverParamInfo::toStream(std::ostream &out) out << std::endl; - LLVOAvatarSelf *avatar = gAgent.getAvatarObject(); - if(avatar) + LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); + if(avatarp) { for (entry_info_list_t::iterator iter = mDrivenInfoList.begin(); iter != mDrivenInfoList.end(); iter++) { LLDrivenEntryInfo driven = *iter; - LLViewerVisualParam *param = (LLViewerVisualParam*)avatar->getVisualParam(driven.mDrivenID); + LLViewerVisualParam *param = (LLViewerVisualParam*)avatarp->getVisualParam(driven.mDrivenID); if (param) { param->getInfo()->toStream(out); @@ -146,7 +146,7 @@ void LLDriverParamInfo::toStream(std::ostream &out) } else { - llwarns << "could not get parameter " << driven.mDrivenID << " from avatar " << avatar << " for driver parameter " << getID() << llendl; + llwarns << "could not get parameter " << driven.mDrivenID << " from avatar " << avatarp << " for driver parameter " << getID() << llendl; } out << std::endl; } @@ -626,13 +626,14 @@ F32 LLDriverParam::getDrivenWeight(const LLDrivenEntry* driven, F32 input_weight void LLDriverParam::setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight, bool upload_bake) { - LLVOAvatarSelf *avatar_self = gAgent.getAvatarObject(); - if(mWearablep && + LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); + if(avatarp && + mWearablep && driven->mParam->getCrossWearable() && mWearablep->isOnTop()) { // call setWeight through LLVOAvatarSelf so other wearables can be updated with the correct values - avatar_self->setVisualParamWeight( (LLVisualParam*)driven->mParam, driven_weight, upload_bake ); + avatarp->setVisualParamWeight( (LLVisualParam*)driven->mParam, driven_weight, upload_bake ); } else { diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp index 0ba7bdf613..47a9961323 100644 --- a/indra/newview/llgesturemgr.cpp +++ b/indra/newview/llgesturemgr.cpp @@ -746,8 +746,8 @@ void LLGestureManager::stepGesture(LLMultiGesture* gesture) { return; } - LLVOAvatar* avatar = gAgent.getAvatarObject(); - if (!avatar) return; + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + if (!avatarp) return; // Of the ones that started playing, have any stopped? @@ -758,8 +758,8 @@ void LLGestureManager::stepGesture(LLMultiGesture* gesture) { // look in signaled animations (simulator's view of what is // currently playing. - LLVOAvatar::AnimIterator play_it = avatar->mSignaledAnimations.find(*gest_it); - if (play_it != avatar->mSignaledAnimations.end()) + LLVOAvatar::AnimIterator play_it = avatarp->mSignaledAnimations.find(*gest_it); + if (play_it != avatarp->mSignaledAnimations.end()) { ++gest_it; } @@ -777,8 +777,8 @@ void LLGestureManager::stepGesture(LLMultiGesture* gesture) gest_it != gesture->mRequestedAnimIDs.end(); ) { - LLVOAvatar::AnimIterator play_it = avatar->mSignaledAnimations.find(*gest_it); - if (play_it != avatar->mSignaledAnimations.end()) + LLVOAvatar::AnimIterator play_it = avatarp->mSignaledAnimations.find(*gest_it); + if (play_it != avatarp->mSignaledAnimations.end()) { // Hooray, this animation has started playing! // Copy into playing. diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 2d544f53f4..08734137b6 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -4177,8 +4177,9 @@ void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attach S32 attach_pt = 0; if (gAgent.getAvatarObject() && attachment) { - for (LLVOAvatar::attachment_map_t::iterator iter = gAgent.getAvatarObject()->mAttachmentPoints.begin(); - iter != gAgent.getAvatarObject()->mAttachmentPoints.end(); ++iter) + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); + iter != avatarp->mAttachmentPoints.end(); ++iter) { if (iter->second == attachment) { @@ -4204,7 +4205,7 @@ void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attach bool confirm_replace_attachment_rez(const LLSD& notification, const LLSD& response) { - LLVOAvatar *avatarp = gAgent.getAvatarObject(); + LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); if (!avatarp->canAttachMoreObjects()) { @@ -4296,7 +4297,7 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags) } LLMenuGL* attach_menu = menu.findChildMenuByName("Attach To", TRUE); LLMenuGL* attach_hud_menu = menu.findChildMenuByName("Attach To HUD", TRUE); - LLVOAvatar *avatarp = gAgent.getAvatarObject(); + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); if (attach_menu && (attach_menu->getChildCount() == 0) && attach_hud_menu diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 3553137f53..d3e2a2f555 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -352,8 +352,8 @@ BOOL get_is_item_worn(const LLUUID& id) { case LLAssetType::AT_OBJECT: { - const LLVOAvatarSelf* my_avatar = gAgent.getAvatarObject(); - if(my_avatar && my_avatar->isWearingAttachment(item->getLinkedUUID())) + const LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + if(avatarp && avatarp->isWearingAttachment(item->getLinkedUUID())) return TRUE; break; } diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 83a466a243..1f9840923c 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -3774,7 +3774,7 @@ bool LLInventoryCollectFunctor::itemTransferCommonlyAllowed(LLInventoryItem* ite return false; bool allowed = false; - LLVOAvatarSelf* my_avatar = NULL; + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); switch(item->getType()) { @@ -3783,8 +3783,7 @@ bool LLInventoryCollectFunctor::itemTransferCommonlyAllowed(LLInventoryItem* ite break; case LLAssetType::AT_OBJECT: - my_avatar = gAgent.getAvatarObject(); - if(my_avatar && !my_avatar->isWearingAttachment(item->getUUID())) + if(avatarp && !avatarp->isWearingAttachment(item->getUUID())) { allowed = true; } diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index d7720b735c..2a8306f232 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -871,7 +871,7 @@ bool LLInventoryPanel::attachObject(const LLSD& userdata) mFolders->getSelectionList(selected_items); std::string joint_name = userdata.asString(); - LLVOAvatar *avatarp = static_cast(gAgent.getAvatarObject()); + LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); LLViewerJointAttachment* attachmentp = NULL; for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); iter != avatarp->mAttachmentPoints.end(); ) diff --git a/indra/newview/llmorphview.cpp b/indra/newview/llmorphview.cpp index 28da9a2b90..cb48db15e4 100644 --- a/indra/newview/llmorphview.cpp +++ b/indra/newview/llmorphview.cpp @@ -89,7 +89,7 @@ void LLMorphView::initialize() mCameraYaw = 0.f; mCameraDist = -1.f; - LLVOAvatar *avatarp = gAgent.getAvatarObject(); + LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); if (!avatarp || avatarp->isDead()) { gAgentCamera.changeCameraToDefault(); @@ -111,7 +111,7 @@ void LLMorphView::shutdown() { LLVOAvatarSelf::onCustomizeEnd(); - LLVOAvatar *avatarp = gAgent.getAvatarObject(); + LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); if (avatarp && !avatarp->isDead()) { avatarp->startMotion( ANIM_AGENT_BODY_NOISE ); @@ -167,12 +167,12 @@ void LLMorphView::updateCamera() setCameraTargetJoint(gAgent.getAvatarObject()->getJoint("mHead")); } - LLVOAvatar* avatar = gAgent.getAvatarObject(); - if( !avatar ) + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + if (!avatarp) { return; } - LLJoint* root_joint = avatar->getRootJoint(); + LLJoint* root_joint = avatarp->getRootJoint(); if( !root_joint ) { return; diff --git a/indra/newview/llpreviewanim.cpp b/indra/newview/llpreviewanim.cpp index 0cc747f789..49b297f702 100644 --- a/indra/newview/llpreviewanim.cpp +++ b/indra/newview/llpreviewanim.cpp @@ -110,6 +110,7 @@ void LLPreviewAnim::playAnim( void *userdata ) { LLPreviewAnim* self = (LLPreviewAnim*) userdata; const LLInventoryItem *item = self->getItem(); + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); if(item) { @@ -125,10 +126,7 @@ void LLPreviewAnim::playAnim( void *userdata ) { self->mPauseRequest = NULL; gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_START); - - LLVOAvatar* avatar = gAgent.getAvatarObject(); - LLMotion* motion = avatar->findMotion(itemID); - + LLMotion* motion = avatarp->findMotion(itemID); if (motion) { motion->setDeactivateCallback(&endAnimCallback, (void *)(new LLHandle(self->getHandle()))); @@ -136,7 +134,7 @@ void LLPreviewAnim::playAnim( void *userdata ) } else { - gAgent.getAvatarObject()->stopMotion(itemID); + avatarp->stopMotion(itemID); gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_STOP); } } @@ -161,10 +159,9 @@ void LLPreviewAnim::auditionAnim( void *userdata ) if (self->childGetValue("Anim audition btn").asBoolean() ) { self->mPauseRequest = NULL; + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); gAgent.getAvatarObject()->startMotion(item->getAssetUUID()); - - LLVOAvatar* avatar = gAgent.getAvatarObject(); - LLMotion* motion = avatar->findMotion(itemID); + LLMotion* motion = avatarp->findMotion(itemID); if (motion) { @@ -189,8 +186,8 @@ void LLPreviewAnim::onClose(bool app_quitting) gAgent.getAvatarObject()->stopMotion(item->getAssetUUID()); gAgent.sendAnimationRequest(item->getAssetUUID(), ANIM_REQUEST_STOP); - LLVOAvatar* avatar = gAgent.getAvatarObject(); - LLMotion* motion = avatar->findMotion(item->getAssetUUID()); + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + LLMotion* motion = avatarp->findMotion(item->getAssetUUID()); if (motion) { diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index d744f097d5..69f9a7e6fa 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -4911,10 +4911,10 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud) LLGLEnable blend(GL_BLEND); LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - LLVOAvatar* avatar = gAgent.getAvatarObject(); - if (for_hud && avatar) + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + if (avatarp && for_hud) { - LLBBox hud_bbox = avatar->getHUDBBox(); + LLBBox hud_bbox = avatarp->getHUDBBox(); F32 cur_zoom = gAgentCamera.mHUDCurZoom; @@ -5023,7 +5023,7 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud) } } - if (for_hud && avatar) + if (avatarp && for_hud) { glMatrixMode(GL_PROJECTION); gGL.popMatrix(); @@ -5399,7 +5399,8 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color) if (volume) { F32 silhouette_thickness; - if (is_hud_object && gAgent.getAvatarObject()) + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + if (avatarp && is_hud_object) { silhouette_thickness = LLSelectMgr::sHighlightThickness / gAgentCamera.mHUDCurZoom; } @@ -5641,10 +5642,10 @@ void LLSelectMgr::updateSelectionCenter() LLViewerObject* object = node->getObject(); if (!object) continue; - LLViewerObject *myAvatar = gAgent.getAvatarObject(); + LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); LLViewerObject *root = object->getRootEdit(); if (mSelectedObjects->mSelectType == SELECT_TYPE_WORLD && // not an attachment - !root->isChild(myAvatar) && // not the object you're sitting on + !root->isChild(avatarp) && // not the object you're sitting on !object->isAvatar()) // not another avatar { mShowSelection = TRUE; diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 0aa6b8736b..1f6f840c45 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -1547,7 +1547,7 @@ void LLToolDragAndDrop::giveInventoryCategory(const LLUUID& to_agent, llinfos << "LLToolDragAndDrop::giveInventoryCategory() - " << cat->getUUID() << llendl; - LLVOAvatar* avatarp = gAgent.getAvatarObject(); + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); if (!avatarp) { return; diff --git a/indra/newview/lltoolfocus.cpp b/indra/newview/lltoolfocus.cpp index 1e2e7095d8..363df74379 100644 --- a/indra/newview/lltoolfocus.cpp +++ b/indra/newview/lltoolfocus.cpp @@ -173,14 +173,13 @@ void LLToolCamera::pickCallback(const LLPickInfo& pick_info) BOOL good_customize_avatar_hit = FALSE; if( hit_obj ) { - LLVOAvatar* avatar = gAgent.getAvatarObject(); - if( hit_obj == avatar) + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + if (avatarp &&(hit_obj == avatarp)) { // It's you good_customize_avatar_hit = TRUE; } - else - if( hit_obj->isAttachment() && hit_obj->permYouOwner() ) + else if (hit_obj->isAttachment() && hit_obj->permYouOwner()) { // It's an attachment that you're wearing good_customize_avatar_hit = TRUE; diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 8d4f0f9116..c80db89ef0 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -205,15 +205,16 @@ BOOL LLToolPie::pickLeftMouseDownCallback() // touch behavior down below... break; case CLICK_ACTION_SIT: - - if ((gAgent.getAvatarObject() != NULL) && (!gAgent.getAvatarObject()->isSitting())) // agent not already sitting { - handle_object_sit_or_stand(); - // put focus in world when sitting on an object - gFocusMgr.setKeyboardFocus(NULL); - return TRUE; - } // else nothing (fall through to touch) - + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + if (avatarp && !avatarp->isSitting()) // agent not already sitting + { + handle_object_sit_or_stand(); + // put focus in world when sitting on an object + gFocusMgr.setKeyboardFocus(NULL); + return TRUE; + } // else nothing (fall through to touch) + } case CLICK_ACTION_PAY: if ((object && object->flagTakesMoney()) || (parent && parent->flagTakesMoney())) @@ -411,9 +412,12 @@ ECursorType cursor_from_object(LLViewerObject* object) switch(click_action) { case CLICK_ACTION_SIT: - if ((gAgent.getAvatarObject() != NULL) && (!gAgent.getAvatarObject()->isSitting())) // not already sitting? { - cursor = UI_CURSOR_TOOLSIT; + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + if (avatarp && !avatarp->isSitting()) // not already sitting? + { + cursor = UI_CURSOR_TOOLSIT; + } } break; case CLICK_ACTION_BUY: diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 5a2b901bd7..7bbe40a486 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1032,11 +1032,11 @@ LLRect get_whole_screen_region() bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::matrix4f &model) { - LLVOAvatar* my_avatarp = gAgent.getAvatarObject(); - if (my_avatarp && my_avatarp->hasHUDAttachment()) + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + if (avatarp && avatarp->hasHUDAttachment()) { F32 zoom_level = gAgentCamera.mHUDCurZoom; - LLBBox hud_bbox = my_avatarp->getHUDBBox(); + LLBBox hud_bbox = avatarp->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 cbec2c890f..00046ed3dd 100644 --- a/indra/newview/llviewerkeyboard.cpp +++ b/indra/newview/llviewerkeyboard.cpp @@ -869,6 +869,7 @@ S32 LLViewerKeyboard::loadBindings(const std::string& filename) EKeyboardMode LLViewerKeyboard::getMode() { + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); if ( gAgentCamera.cameraMouselook() ) { return MODE_FIRST_PERSON; @@ -877,7 +878,7 @@ EKeyboardMode LLViewerKeyboard::getMode() { return MODE_EDIT_AVATAR; } - else if (gAgent.getAvatarObject() && gAgent.getAvatarObject()->isSitting()) + else if (avatarp && avatarp->isSitting()) { return MODE_SITTING; } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index d79cb85730..b8a3232c29 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -4587,13 +4587,13 @@ BOOL sitting_on_selection() } // Need to determine if avatar is sitting on this object - LLVOAvatar* avatar = gAgent.getAvatarObject(); - if (!avatar) + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + if (!avatarp) { return FALSE; } - return (avatar->isSitting() && avatar->getRoot() == root_object); + return (avatarp->isSitting() && avatarp->getRoot() == root_object); } class LLToolsSaveToInventory : public view_listener_t @@ -6489,15 +6489,15 @@ void handle_toggle_pg(void*) void handle_dump_attachments(void*) { - LLVOAvatar* avatar = gAgent.getAvatarObject(); - if( !avatar ) + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + if(!avatarp) { llinfos << "NO AVATAR" << llendl; return; } - for (LLVOAvatar::attachment_map_t::iterator iter = avatar->mAttachmentPoints.begin(); - iter != avatar->mAttachmentPoints.end(); ) + for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); + iter != avatarp->mAttachmentPoints.end(); ) { LLVOAvatar::attachment_map_t::iterator curiter = iter++; LLViewerJointAttachment* attachment = curiter->second; diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 7b52724e8e..1ead7bac10 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -4165,9 +4165,9 @@ void process_avatar_sit_response(LLMessageSystem *mesgsys, void **user_data) BOOL force_mouselook; mesgsys->getBOOLFast(_PREHASH_SitTransform, _PREHASH_ForceMouselook, force_mouselook); - LLVOAvatar* avatar = gAgent.getAvatarObject(); + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatar && dist_vec_squared(camera_eye, camera_at) > 0.0001f) + if (avatarp && dist_vec_squared(camera_eye, camera_at) > 0.0001f) { gAgentCamera.setSitCamera(sitObjectID, camera_eye, camera_at); } @@ -4178,7 +4178,7 @@ void process_avatar_sit_response(LLMessageSystem *mesgsys, void **user_data) if (object) { LLVector3 sit_spot = object->getPositionAgent() + (sitPosition * object->getRotation()); - if (!use_autopilot || (avatar && avatar->isSitting() && avatar->getRoot() == object->getRoot())) + if (!use_autopilot || (avatarp && avatarp->isSitting() && avatarp->getRoot() == object->getRoot())) { //we're already sitting on this object, so don't autopilot } diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 54379dece3..bb69622135 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -965,15 +965,15 @@ void LLVOAvatar::dumpBakedStatus() //static void LLVOAvatar::restoreGL() { - LLVOAvatar* self = gAgent.getAvatarObject(); - if (!self) - return; - self->setCompositeUpdatesEnabled(TRUE); - for (U32 i = 0; i < self->mBakedTextureDatas.size(); i++) + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + if (!avatarp) return; + + avatarp->setCompositeUpdatesEnabled(TRUE); + for (U32 i = 0; i < avatarp->mBakedTextureDatas.size(); i++) { - self->invalidateComposite(self->mBakedTextureDatas[i].mTexLayerSet, FALSE); + avatarp->invalidateComposite(avatarp->mBakedTextureDatas[i].mTexLayerSet, FALSE); } - self->updateMeshTextures(); + avatarp->updateMeshTextures(); } //static @@ -6859,8 +6859,8 @@ void LLVOAvatar::useBakedTexture( const LLUUID& id ) // static void LLVOAvatar::dumpArchetypeXML( void* ) { - LLVOAvatar* avatar = gAgent.getAvatarObject(); - LLAPRFile outfile ; + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + LLAPRFile outfile; outfile.open(gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,"new archetype.xml"), LL_APR_WB ); apr_file_t* file = outfile.getFileHandle() ; if (!file) @@ -6878,7 +6878,7 @@ void LLVOAvatar::dumpArchetypeXML( void* ) const std::string& wearable_name = LLWearableDictionary::getTypeName((EWearableType)type); apr_file_printf( file, "\n\t\t\n", wearable_name.c_str() ); - for (LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam()) + for (LLVisualParam* param = avatarp->getFirstVisualParam(); param; param = avatarp->getNextVisualParam()) { LLViewerVisualParam* viewer_param = (LLViewerVisualParam*)param; if( (viewer_param->getWearableType() == type) && @@ -6894,7 +6894,7 @@ void LLVOAvatar::dumpArchetypeXML( void* ) if (LLVOAvatarDictionary::getTEWearableType((ETextureIndex)te) == type) { // MULTIPLE_WEARABLES: extend to multiple wearables? - LLViewerTexture* te_image = avatar->getImage((ETextureIndex)te, 0); + LLViewerTexture* te_image = ((LLVOAvatar*)avatarp)->getImage((ETextureIndex)te, 0); if( te_image ) { std::string uuid_str; diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 0243130e12..e3583b4d6b 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -1930,8 +1930,8 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**) LLUUID texture_id; msg->getUUID("TextureData", "TextureID", texture_id); - LLVOAvatarSelf* self = gAgent.getAvatarObject(); - if (!self) return; + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + if (!avatarp) return; // If this is a texture corresponding to one of our baked entries, // just rebake that layer set. @@ -1948,13 +1948,13 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**) const LLVOAvatarDictionary::TextureEntry *texture_dict = iter->second; if (texture_dict->mIsBakedTexture) { - if (texture_id == self->getTEImage(index)->getID()) + if (texture_id == avatarp->getTEImage(index)->getID()) { - LLTexLayerSet* layer_set = self->getLayerSet(index); + LLTexLayerSet* layer_set = avatarp->getLayerSet(index); if (layer_set) { llinfos << "TAT: rebake - matched entry " << (S32)index << llendl; - self->invalidateComposite(layer_set, TRUE); + avatarp->invalidateComposite(layer_set, TRUE); found = TRUE; LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES); } @@ -1965,12 +1965,12 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**) // If texture not found, rebake all entries. if (!found) { - self->forceBakeAllTextures(); + avatarp->forceBakeAllTextures(); } else { // Not sure if this is necessary, but forceBakeAllTextures() does it. - self->updateMeshTextures(); + avatarp->updateMeshTextures(); } } diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp index de2d049382..c9fe032a24 100644 --- a/indra/newview/llwearable.cpp +++ b/indra/newview/llwearable.cpp @@ -62,27 +62,26 @@ class LLOverrideBakedTextureUpdate public: LLOverrideBakedTextureUpdate(bool temp_state) { - mAvatar = gAgent.getAvatarObject(); + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); U32 num_bakes = (U32) LLVOAvatarDefines::BAKED_NUM_INDICES; for( U32 index = 0; index < num_bakes; ++index ) { - composite_enabled[index] = mAvatar->isCompositeUpdateEnabled(index); + composite_enabled[index] = avatarp->isCompositeUpdateEnabled(index); } - mAvatar->setCompositeUpdatesEnabled(temp_state); + avatarp->setCompositeUpdatesEnabled(temp_state); } ~LLOverrideBakedTextureUpdate() { + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); U32 num_bakes = (U32)LLVOAvatarDefines::BAKED_NUM_INDICES; for( U32 index = 0; index < num_bakes; ++index ) { - mAvatar->setCompositeUpdatesEnabled(index, composite_enabled[index]); - } + avatarp->setCompositeUpdatesEnabled(index, composite_enabled[index]); + } } - private: bool composite_enabled[LLVOAvatarDefines::BAKED_NUM_INDICES]; - LLVOAvatarSelf *mAvatar; }; // Private local functions @@ -205,10 +204,10 @@ BOOL LLWearable::exportFile(LLFILE* file) const void LLWearable::createVisualParams() { - LLVOAvatar* avatar = gAgent.getAvatarObject(); - for (LLViewerVisualParam* param = (LLViewerVisualParam*) avatar->getFirstVisualParam(); + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + for (LLViewerVisualParam* param = (LLViewerVisualParam*) avatarp->getFirstVisualParam(); param; - param = (LLViewerVisualParam*) avatar->getNextVisualParam()) + param = (LLViewerVisualParam*) avatarp->getNextVisualParam()) { if (param->getWearableType() == mType) { @@ -228,7 +227,7 @@ void LLWearable::createVisualParams() param->resetDrivenParams(); if(!param->linkDrivenParams(boost::bind(wearable_function,(LLWearable*)this, _1), false)) { - if( !param->linkDrivenParams(boost::bind(avatar_function,(LLVOAvatarSelf*)avatar,_1 ), true)) + if( !param->linkDrivenParams(boost::bind(avatar_function,avatarp,_1 ), true)) { llwarns << "could not link driven params for wearable " << getName() << " id: " << param->getID() << llendl; continue; @@ -464,12 +463,9 @@ BOOL LLWearable::importFile( LLFILE* file ) // since this wearable was created. BOOL LLWearable::isOldVersion() const { - LLVOAvatar* avatar = gAgent.getAvatarObject(); - llassert( avatar ); - if( !avatar ) - { - return FALSE; - } + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + llassert(avatarp); + if(!avatarp) return FALSE; if( LLWearable::sCurrentDefinitionVersion < mDefinitionVersion ) { @@ -483,9 +479,9 @@ BOOL LLWearable::isOldVersion() const } S32 param_count = 0; - for( LLViewerVisualParam* param = (LLViewerVisualParam*) avatar->getFirstVisualParam(); + for( LLViewerVisualParam* param = (LLViewerVisualParam*) avatarp->getFirstVisualParam(); param; - param = (LLViewerVisualParam*) avatar->getNextVisualParam() ) + param = (LLViewerVisualParam*) avatarp->getNextVisualParam() ) { if( (param->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) { @@ -531,17 +527,13 @@ BOOL LLWearable::isOldVersion() const // only if those values are the same as the defaults. BOOL LLWearable::isDirty() const { - LLVOAvatar* avatar = gAgent.getAvatarObject(); - llassert( avatar ); - if( !avatar ) - { - return FALSE; - } - + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + llassert(avatarp); + if(!avatarp) return FALSE; - for( LLViewerVisualParam* param = (LLViewerVisualParam*) avatar->getFirstVisualParam(); + for( LLViewerVisualParam* param = (LLViewerVisualParam*) avatarp->getFirstVisualParam(); param; - param = (LLViewerVisualParam*) avatar->getNextVisualParam() ) + param = (LLViewerVisualParam*) avatarp->getNextVisualParam() ) { if( (param->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) @@ -602,14 +594,11 @@ BOOL LLWearable::isDirty() const void LLWearable::setParamsToDefaults() { - LLVOAvatar* avatar = gAgent.getAvatarObject(); - llassert( avatar ); - if( !avatar ) - { - return; - } + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + llassert(avatarp); + if (!avatarp) return; - for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() ) + for( LLVisualParam* param = avatarp->getFirstVisualParam(); param; param = avatarp->getNextVisualParam() ) { if( (((LLViewerVisualParam*)param)->getWearableType() == mType ) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) { @@ -1123,10 +1112,10 @@ void LLWearable::destroyTextures() void LLWearable::pullCrossWearableValues() { // scan through all of the avatar's visual parameters - LLVOAvatar* avatar = gAgent.getAvatarObject(); - for (LLViewerVisualParam* param = (LLViewerVisualParam*) avatar->getFirstVisualParam(); + LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + for (LLViewerVisualParam* param = (LLViewerVisualParam*) avatarp->getFirstVisualParam(); param; - param = (LLViewerVisualParam*) avatar->getNextVisualParam()) + param = (LLViewerVisualParam*) avatarp->getNextVisualParam()) { if( param ) { -- cgit v1.3 From 94e6e10739c8321b6fb651a109901380ef92975a Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Mon, 29 Mar 2010 12:00:26 -0400 Subject: EXT-6536 : Make LLVOAvatarSelf a singleton Superficial cleanup to replace all instances of "LLVOAvatarSelf *avatarp = gAgent.getAvatarObject" with "gAgentAvatar". --- indra/newview/llagent.cpp | 217 +++++++++++++------------------ indra/newview/llagent.h | 16 --- indra/newview/llagentcamera.cpp | 218 ++++++++++++++------------------ indra/newview/llagentui.cpp | 12 +- indra/newview/llagentwearables.cpp | 101 +++++---------- indra/newview/llappearancemgr.cpp | 3 +- indra/newview/llappviewer.cpp | 3 +- indra/newview/lldriverparam.cpp | 12 +- indra/newview/llgesturemgr.cpp | 11 +- indra/newview/llinventorybridge.cpp | 46 +++---- indra/newview/llinventoryfunctions.cpp | 3 +- indra/newview/llinventorymodel.cpp | 3 +- indra/newview/llinventorypanel.cpp | 5 +- indra/newview/llmaniprotate.cpp | 9 +- indra/newview/llmaniptranslate.cpp | 2 +- indra/newview/llmorphview.cpp | 28 ++-- indra/newview/llmoveview.cpp | 10 +- indra/newview/llpaneleditwearable.cpp | 2 +- indra/newview/llpreview.cpp | 5 +- indra/newview/llpreviewanim.cpp | 20 ++- indra/newview/llscrollingpanelparam.cpp | 7 +- indra/newview/llselectmgr.cpp | 26 ++-- indra/newview/llsidepanelappearance.cpp | 7 +- indra/newview/llstartup.cpp | 8 +- indra/newview/llstatusbar.cpp | 6 +- indra/newview/lltexlayer.cpp | 18 +-- indra/newview/lltooldraganddrop.cpp | 52 +++----- indra/newview/lltoolfocus.cpp | 7 +- indra/newview/lltoolgrab.cpp | 2 +- indra/newview/lltoolmorph.cpp | 40 +++--- indra/newview/lltoolpie.cpp | 8 +- indra/newview/lltoolplacer.cpp | 3 +- indra/newview/lltoolselect.cpp | 4 +- indra/newview/llviewerdisplay.cpp | 11 +- indra/newview/llviewerkeyboard.cpp | 3 +- indra/newview/llviewermedia.cpp | 2 +- indra/newview/llviewermenu.cpp | 198 ++++++++++++++--------------- indra/newview/llviewermessage.cpp | 27 ++-- indra/newview/llviewerobject.cpp | 20 ++- indra/newview/llviewerobjectlist.cpp | 15 ++- indra/newview/llviewerwindow.cpp | 6 +- indra/newview/llvoavatar.cpp | 23 ++-- indra/newview/llvoavatarself.cpp | 58 +++++---- indra/newview/llvoavatarself.h | 7 +- indra/newview/llvoiceclient.cpp | 8 +- indra/newview/llwearable.cpp | 95 +++++--------- indra/newview/pipeline.cpp | 35 +++-- 47 files changed, 602 insertions(+), 820 deletions(-) (limited to 'indra/newview/llviewerkeyboard.cpp') diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index a1b2a9fc44..645acca4ae 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -159,11 +159,11 @@ bool handleSlowMotionAnimation(const LLSD& newvalue) { if (newvalue.asBoolean()) { - gAgent.getAvatarObject()->setAnimTimeFactor(0.2f); + gAgentAvatar->setAnimTimeFactor(0.2f); } else { - gAgent.getAvatarObject()->setAnimTimeFactor(1.0f); + gAgentAvatar->setAnimTimeFactor(1.0f); } return true; } @@ -207,8 +207,6 @@ LLAgent::LLAgent() : mDistanceTraveled(0.F), mLastPositionGlobal(LLVector3d::zero), - mAvatarObject(NULL), - mRenderState(0), mTypingTimer(), @@ -294,7 +292,6 @@ void LLAgent::init() //----------------------------------------------------------------------------- void LLAgent::cleanup() { - mAvatarObject = NULL; mRegionp = NULL; } @@ -325,12 +322,12 @@ void LLAgent::onAppFocusGained() void LLAgent::ageChat() { - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { // get amount of time since I last chatted - F64 elapsed_time = (F64)mAvatarObject->mChatTimer.getElapsedTimeF32(); + F64 elapsed_time = (F64)gAgentAvatar->mChatTimer.getElapsedTimeF32(); // add in frame time * 3 (so it ages 4x) - mAvatarObject->mChatTimer.setAge(elapsed_time + (F64)gFrameDTClamped * (CHAT_AGE_FAST_RATE - 1.0)); + gAgentAvatar->mChatTimer.setAge(elapsed_time + (F64)gFrameDTClamped * (CHAT_AGE_FAST_RATE - 1.0)); } } @@ -517,20 +514,20 @@ BOOL LLAgent::getFlying() const //----------------------------------------------------------------------------- void LLAgent::setFlying(BOOL fly) { - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { // *HACK: Don't allow to start the flying mode if we got ANIM_AGENT_STANDUP signal // because in this case we won't get a signal to start avatar flying animation and // 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 && mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_STANDUP) != mAvatarObject->mSignaledAnimations.end()) + if(fly && gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_STANDUP) != gAgentAvatar->mSignaledAnimations.end()) { return; } // don't allow taking off while sitting - if (fly && mAvatarObject->isSitting()) + if (fly && gAgentAvatar->isSitting()) { return; } @@ -583,9 +580,9 @@ void LLAgent::toggleFlying() bool LLAgent::enableFlying() { BOOL sitting = FALSE; - if (gAgent.getAvatarObject()) + if (isAgentAvatarValid()) { - sitting = gAgent.getAvatarObject()->isSitting(); + sitting = gAgentAvatar->isSitting(); } return !sitting; } @@ -755,9 +752,9 @@ void LLAgent::sendReliableMessage() //----------------------------------------------------------------------------- LLVector3 LLAgent::getVelocity() const { - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { - return mAvatarObject->getVelocity(); + return gAgentAvatar->getVelocity(); } else { @@ -776,13 +773,13 @@ void LLAgent::setPositionAgent(const LLVector3 &pos_agent) llerrs << "setPositionAgent is not a number" << llendl; } - if (mAvatarObject.notNull() && mAvatarObject->getParent()) + if (isAgentAvatarValid() && gAgentAvatar->getParent()) { LLVector3 pos_agent_sitting; LLVector3d pos_agent_d; - LLViewerObject *parent = (LLViewerObject*)mAvatarObject->getParent(); + LLViewerObject *parent = (LLViewerObject*)gAgentAvatar->getParent(); - pos_agent_sitting = mAvatarObject->getPosition() * parent->getRotation() + parent->getPositionAgent(); + pos_agent_sitting = gAgentAvatar->getPosition() * parent->getRotation() + parent->getPositionAgent(); pos_agent_d.setVec(pos_agent_sitting); mFrameAgent.setOrigin(pos_agent_sitting); @@ -803,9 +800,9 @@ void LLAgent::setPositionAgent(const LLVector3 &pos_agent) //----------------------------------------------------------------------------- const LLVector3d &LLAgent::getPositionGlobal() const { - if (mAvatarObject.notNull() && !mAvatarObject->mDrawable.isNull()) + if (isAgentAvatarValid() && !gAgentAvatar->mDrawable.isNull()) { - mPositionGlobal = getPosGlobalFromAgent(mAvatarObject->getRenderPosition()); + mPositionGlobal = getPosGlobalFromAgent(gAgentAvatar->getRenderPosition()); } else { @@ -820,9 +817,9 @@ const LLVector3d &LLAgent::getPositionGlobal() const //----------------------------------------------------------------------------- const LLVector3 &LLAgent::getPositionAgent() { - if(mAvatarObject.notNull() && !mAvatarObject->mDrawable.isNull()) + if (isAgentAvatarValid() && !gAgentAvatar->mDrawable.isNull()) { - mFrameAgent.setOrigin(mAvatarObject->getRenderPosition()); + mFrameAgent.setOrigin(gAgentAvatar->getRenderPosition()); } return mFrameAgent.getOrigin(); @@ -948,21 +945,21 @@ 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 (mAvatarObject.notNull() && - mAvatarObject->getParent() && - mAvatarObject->mDrawable.notNull()) + if (isAgentAvatarValid() && + gAgentAvatar->getParent() && + gAgentAvatar->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*)mAvatarObject->getParent())->getRenderRotation(); + up_vector = up_vector * ~((LLViewerObject*)gAgentAvatar->getParent())->getRenderRotation(); } else if (camera_mode == CAMERA_MODE_MOUSELOOK) { // make the up vector point to the avatar's +z axis - up_vector = up_vector * mAvatarObject->mDrawable->getRotation(); + up_vector = up_vector * gAgentAvatar->mDrawable->getRotation(); } } @@ -998,7 +995,7 @@ F32 LLAgent::clampPitchToLimits(F32 angle) F32 angle_from_skyward = acos( mFrameAgent.getAtAxis() * skyward ); - if (mAvatarObject.notNull() && mAvatarObject->isSitting()) + if (isAgentAvatarValid() && gAgentAvatar->isSitting()) { look_down_limit = 130.f * DEG_TO_RAD; } @@ -1171,10 +1168,9 @@ void LLAgent::clearAFK() // Gods can sometimes get into away state (via gestures) // without setting the appropriate control flag. JC - LLVOAvatar* av = mAvatarObject; if (mControlFlags & AGENT_CONTROL_AWAY - || (av - && (av->mSignaledAnimations.find(ANIM_AGENT_AWAY) != av->mSignaledAnimations.end()))) + || (isAgentAvatarValid() + && (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_AWAY) != gAgentAvatar->mSignaledAnimations.end()))) { sendAnimationRequest(ANIM_AGENT_AWAY, ANIM_REQUEST_STOP); clearControlFlags(AGENT_CONTROL_AWAY); @@ -1235,7 +1231,7 @@ BOOL LLAgent::getBusy() const //----------------------------------------------------------------------------- void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::string& behavior_name, const LLQuaternion *target_rotation, void (*finish_callback)(BOOL, void *), void *callback_data, F32 stop_distance, F32 rot_threshold) { - if (!gAgent.getAvatarObject()) + if (!isAgentAvatarValid()) { return; } @@ -1296,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)gAgent.getAvatarObject()->getPelvisToFoot(), target_global.mdV[VZ] - targetOnGround.mdV[VZ]); + F64 target_height = llmax((F64)gAgentAvatar->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; @@ -1396,12 +1392,9 @@ void LLAgent::autoPilot(F32 *delta_yaw) mAutoPilotTargetGlobal = object->getPositionGlobal(); } - if (mAvatarObject.isNull()) - { - return; - } + if (!isAgentAvatarValid()) return; - if (mAvatarObject->mInAir) + if (gAgentAvatar->mInAir) { setFlying(TRUE); } @@ -1477,9 +1470,9 @@ void LLAgent::autoPilot(F32 *delta_yaw) // If we're flying, handle autopilot points above or below you. if (getFlying() && xy_distance < AUTOPILOT_HEIGHT_ADJUST_DISTANCE) { - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { - F64 current_height = mAvatarObject->getPositionGlobal().mdV[VZ]; + F64 current_height = gAgentAvatar->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) @@ -1560,9 +1553,9 @@ void LLAgent::propagate(const F32 dt) pitch(PITCH_RATE * mPitchKey * dt); // handle auto-land behavior - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { - BOOL in_air = mAvatarObject->mInAir; + BOOL in_air = gAgentAvatar->mInAir; LLVector3 land_vel = getVelocity(); land_vel.mV[VZ] = 0.f; @@ -1615,29 +1608,6 @@ std::ostream& operator<<(std::ostream &s, const LLAgent &agent) return s; } - -// ------------------- Beginning of legacy LLCamera hack ---------------------- -// This section is included for legacy LLCamera support until -// it is no longer needed. Some legacy code must exist in -// non-legacy functions, and is labeled with "// legacy" comments. - -//----------------------------------------------------------------------------- -// setAvatarObject() -//----------------------------------------------------------------------------- -void LLAgent::setAvatarObject(LLVOAvatarSelf *avatar) -{ - mAvatarObject = avatar; - - if (!avatar) - { - llinfos << "Setting LLAgent::mAvatarObject to NULL" << llendl; - return; - } - - gAgentCamera.setAvatarObject(avatar); - gAgentWearables.setAvatarObject(avatar); -} - // TRUE if your own avatar needs to be rendered. Usually only // in third person and build. //----------------------------------------------------------------------------- @@ -1809,26 +1779,26 @@ void LLAgent::endAnimationUpdateUI() } // Disable mouselook-specific animations - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { - if( mAvatarObject->isAnyAnimationSignaled(AGENT_GUN_AIM_ANIMS, NUM_AGENT_GUN_AIM_ANIMS) ) + if( gAgentAvatar->isAnyAnimationSignaled(AGENT_GUN_AIM_ANIMS, NUM_AGENT_GUN_AIM_ANIMS) ) { - if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_AIM_RIFLE_R) != mAvatarObject->mSignaledAnimations.end()) + if (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_AIM_RIFLE_R) != gAgentAvatar->mSignaledAnimations.end()) { sendAnimationRequest(ANIM_AGENT_AIM_RIFLE_R, ANIM_REQUEST_STOP); sendAnimationRequest(ANIM_AGENT_HOLD_RIFLE_R, ANIM_REQUEST_START); } - if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_AIM_HANDGUN_R) != mAvatarObject->mSignaledAnimations.end()) + if (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_AIM_HANDGUN_R) != gAgentAvatar->mSignaledAnimations.end()) { sendAnimationRequest(ANIM_AGENT_AIM_HANDGUN_R, ANIM_REQUEST_STOP); sendAnimationRequest(ANIM_AGENT_HOLD_HANDGUN_R, ANIM_REQUEST_START); } - if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_AIM_BAZOOKA_R) != mAvatarObject->mSignaledAnimations.end()) + if (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_AIM_BAZOOKA_R) != gAgentAvatar->mSignaledAnimations.end()) { sendAnimationRequest(ANIM_AGENT_AIM_BAZOOKA_R, ANIM_REQUEST_STOP); sendAnimationRequest(ANIM_AGENT_HOLD_BAZOOKA_R, ANIM_REQUEST_START); } - if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_AIM_BOW_L) != mAvatarObject->mSignaledAnimations.end()) + if (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_AIM_BOW_L) != gAgentAvatar->mSignaledAnimations.end()) { sendAnimationRequest(ANIM_AGENT_AIM_BOW_L, ANIM_REQUEST_STOP); sendAnimationRequest(ANIM_AGENT_HOLD_BOW_L, ANIM_REQUEST_START); @@ -1847,7 +1817,7 @@ void LLAgent::endAnimationUpdateUI() gMorphView->setVisible( FALSE ); } - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { if(mCustomAnim) { @@ -1907,43 +1877,43 @@ void LLAgent::endAnimationUpdateUI() gConsole->setVisible( TRUE ); - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { // Trigger mouselook-specific animations - if( mAvatarObject->isAnyAnimationSignaled(AGENT_GUN_HOLD_ANIMS, NUM_AGENT_GUN_HOLD_ANIMS) ) + if( gAgentAvatar->isAnyAnimationSignaled(AGENT_GUN_HOLD_ANIMS, NUM_AGENT_GUN_HOLD_ANIMS) ) { - if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_HOLD_RIFLE_R) != mAvatarObject->mSignaledAnimations.end()) + if (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_HOLD_RIFLE_R) != gAgentAvatar->mSignaledAnimations.end()) { sendAnimationRequest(ANIM_AGENT_HOLD_RIFLE_R, ANIM_REQUEST_STOP); sendAnimationRequest(ANIM_AGENT_AIM_RIFLE_R, ANIM_REQUEST_START); } - if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_HOLD_HANDGUN_R) != mAvatarObject->mSignaledAnimations.end()) + if (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_HOLD_HANDGUN_R) != gAgentAvatar->mSignaledAnimations.end()) { sendAnimationRequest(ANIM_AGENT_HOLD_HANDGUN_R, ANIM_REQUEST_STOP); sendAnimationRequest(ANIM_AGENT_AIM_HANDGUN_R, ANIM_REQUEST_START); } - if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_HOLD_BAZOOKA_R) != mAvatarObject->mSignaledAnimations.end()) + if (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_HOLD_BAZOOKA_R) != gAgentAvatar->mSignaledAnimations.end()) { sendAnimationRequest(ANIM_AGENT_HOLD_BAZOOKA_R, ANIM_REQUEST_STOP); sendAnimationRequest(ANIM_AGENT_AIM_BAZOOKA_R, ANIM_REQUEST_START); } - if (mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_HOLD_BOW_L) != mAvatarObject->mSignaledAnimations.end()) + if (gAgentAvatar->mSignaledAnimations.find(ANIM_AGENT_HOLD_BOW_L) != gAgentAvatar->mSignaledAnimations.end()) { sendAnimationRequest(ANIM_AGENT_HOLD_BOW_L, ANIM_REQUEST_STOP); sendAnimationRequest(ANIM_AGENT_AIM_BOW_L, ANIM_REQUEST_START); } } - if (mAvatarObject->getParent()) + if (gAgentAvatar->getParent()) { LLVector3 at_axis = LLViewerCamera::getInstance()->getAtAxis(); - LLViewerObject* root_object = (LLViewerObject*)mAvatarObject->getRoot(); + LLViewerObject* root_object = (LLViewerObject*)gAgentAvatar->getRoot(); if (root_object->flagCameraDecoupled()) { resetAxes(at_axis); } else { - resetAxes(at_axis * ~((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation()); + resetAxes(at_axis * ~((LLViewerObject*)gAgentAvatar->getParent())->getRenderRotation()); } } } @@ -1959,15 +1929,15 @@ void LLAgent::endAnimationUpdateUI() } // freeze avatar - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { - mPauseRequest = mAvatarObject->requestPause(); + mPauseRequest = gAgentAvatar->requestPause(); } } - if (getAvatarObject()) + if (isAgentAvatarValid()) { - getAvatarObject()->updateAttachmentVisibility(gAgentCamera.getCameraMode()); + gAgentAvatar->updateAttachmentVisibility(gAgentCamera.getCameraMode()); } gFloaterTools->dirty(); @@ -2043,10 +2013,10 @@ void LLAgent::setStartPosition( U32 location_id ) LLVector3 agent_pos = getPositionAgent(); - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { // the z height is at the agent's feet - agent_pos.mV[VZ] -= 0.5f * mAvatarObject->mBodySize.mV[VZ]; + agent_pos.mV[VZ] -= 0.5f * gAgentAvatar->mBodySize.mV[VZ]; } agent_pos.mV[VX] = llclamp( agent_pos.mV[VX], INSET, REGION_WIDTH - INSET ); @@ -2153,7 +2123,7 @@ void LLAgent::onAnimStop(const LLUUID& id) setControlFlags(AGENT_CONTROL_FINISH_ANIM); // now trigger dusting self off animation - if (mAvatarObject.notNull() && !mAvatarObject->mBelowWater && rand() % 3 == 0) + if (isAgentAvatarValid() && !gAgentAvatar->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) @@ -2352,9 +2322,9 @@ void LLAgent::buildFullnameAndTitle(std::string& name) const name.erase(0, name.length()); } - if (mAvatarObject.notNull()) + if (isAgentAvatarValid()) { - name += mAvatarObject->getFullname(); + name += gAgentAvatar->getFullname(); } } @@ -2500,14 +2470,14 @@ BOOL LLAgent::canJoinGroups() const LLQuaternion LLAgent::getHeadRotation() { - if (mAvatarObject.isNull() || !mAvatarObject->mPelvisp || !mAvatarObject->mHeadp) + if (!isAgentAvatarValid() || !gAgentAvatar->mPelvisp || !gAgentAvatar->mHeadp) { return LLQuaternion::DEFAULT; } if (!gAgentCamera.cameraMouselook()) { - return mAvatarObject->getRotation(); + return gAgentAvatar->getRotation(); } // We must be in mouselook @@ -2516,9 +2486,9 @@ LLQuaternion LLAgent::getHeadRotation() LLVector3 left = up % look_dir; LLQuaternion rot(look_dir, left, up); - if (mAvatarObject->getParent()) + if (gAgentAvatar->getParent()) { - rot = rot * ~mAvatarObject->getParent()->getRotation(); + rot = rot * ~gAgentAvatar->getParent()->getRotation(); } return rot; @@ -3141,8 +3111,7 @@ void LLAgent::processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void * { gAgentQueryManager.mNumPendingQueries--; - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp || avatarp->isDead()) + if (!isAgentAvatarValid() || gAgentAvatar->isDead()) { llwarns << "No avatar for user in cached texture update!" << llendl; return; @@ -3175,27 +3144,27 @@ void LLAgent::processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void * if (texture_id.notNull()) { //llinfos << "Received cached texture " << (U32)texture_index << ": " << texture_id << llendl; - avatarp->setCachedBakedTexture(LLVOAvatarDictionary::bakedToLocalTextureIndex((EBakedTextureIndex)texture_index), texture_id); - //avatarp->setTETexture( LLVOAvatar::sBakedTextureIndices[texture_index], texture_id ); + gAgentAvatar->setCachedBakedTexture(LLVOAvatarDictionary::bakedToLocalTextureIndex((EBakedTextureIndex)texture_index), texture_id); + //gAgentAvatar->setTETexture( LLVOAvatar::sBakedTextureIndices[texture_index], texture_id ); gAgentQueryManager.mActiveCacheQueries[texture_index] = 0; num_results++; } else { // no cache of this bake. request upload. - avatarp->requestLayerSetUpload((EBakedTextureIndex)texture_index); + gAgentAvatar->requestLayerSetUpload((EBakedTextureIndex)texture_index); } } } llinfos << "Received cached texture response for " << num_results << " textures." << llendl; - avatarp->updateMeshTextures(); + gAgentAvatar->updateMeshTextures(); if (gAgentQueryManager.mNumPendingQueries == 0) { // RN: not sure why composites are disabled at this point - avatarp->setCompositeUpdatesEnabled(TRUE); + gAgentAvatar->setCompositeUpdatesEnabled(TRUE); gAgent.sendAgentSetAppearance(); } } @@ -3248,11 +3217,10 @@ BOOL LLAgent::getHomePosGlobal( LLVector3d* pos_global ) void LLAgent::clearVisualParams(void *data) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { - avatarp->clearVisualParamWeights(); - avatarp->updateVisualParams(); + gAgentAvatar->clearVisualParamWeights(); + gAgentAvatar->updateVisualParams(); } } @@ -3276,16 +3244,15 @@ bool LLAgent::teleportCore(bool is_local) // sync with other viewers. Discuss in DEV-14145/VWR-6744 before reenabling. // Stop all animation before actual teleporting - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { - for ( LLVOAvatar::AnimIterator anim_it= avatarp->mPlayingAnimations.begin(); - anim_it != avatarp->mPlayingAnimations.end(); + for ( LLVOAvatar::AnimIterator anim_it= gAgentAvatar->mPlayingAnimations.begin(); + anim_it != gAgentAvatar->mPlayingAnimations.end(); ++anim_it) { - avatarp->stopMotion(anim_it->first); + gAgentAvatar->stopMotion(anim_it->first); } - avatarp->processAnimationStateChanges(); + gAgentAvatar->processAnimationStateChanges(); } #endif @@ -3478,13 +3445,11 @@ void LLAgent::stopCurrentAnimations() { // This function stops all current overriding animations on this // avatar, propagating this change back to the server. - - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { for ( LLVOAvatar::AnimIterator anim_it = - avatarp->mPlayingAnimations.begin(); - anim_it != avatarp->mPlayingAnimations.end(); + gAgentAvatar->mPlayingAnimations.begin(); + anim_it != gAgentAvatar->mPlayingAnimations.end(); anim_it++) { if (anim_it->first == @@ -3497,7 +3462,7 @@ void LLAgent::stopCurrentAnimations() else { // stop this animation locally - avatarp->stopMotion(anim_it->first, TRUE); + gAgentAvatar->stopMotion(anim_it->first, TRUE); // ...and tell the server to tell everyone. sendAnimationRequest(anim_it->first, ANIM_REQUEST_STOP); } @@ -3604,7 +3569,7 @@ void LLAgent::requestLeaveGodMode() //----------------------------------------------------------------------------- void LLAgent::sendAgentSetAppearance() { - if (mAvatarObject.isNull()) return; + if (!isAgentAvatarValid()) return; if (gAgentQueryManager.mNumPendingQueries > 0 && !gAgentCamera.cameraCustomizeAvatar()) { @@ -3612,7 +3577,7 @@ void LLAgent::sendAgentSetAppearance() } - llinfos << "TAT: Sent AgentSetAppearance: " << mAvatarObject->getBakedStatusForPrintout() << llendl; + llinfos << "TAT: Sent AgentSetAppearance: " << gAgentAvatar->getBakedStatusForPrintout() << llendl; //dumpAvatarTEs( "sendAgentSetAppearance()" ); LLMessageSystem* msg = gMessageSystem; @@ -3626,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 = mAvatarObject->mBodySize; + const LLVector3 body_size = gAgentAvatar->mBodySize; msg->addVector3Fast(_PREHASH_Size, body_size); // To guard against out of order packets @@ -3636,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 = mAvatarObject->areTexturesCurrent(); + BOOL textures_current = gAgentAvatar->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 && !mAvatarObject->isWearingWearableType(WT_SKIRT)) + if (texture_index == TEX_SKIRT_BAKED && !gAgentAvatar->isWearingWearableType(WT_SKIRT)) { continue; } // IMG_DEFAULT_AVATAR means not baked. 0 index should be ignored for baked textures - if (!mAvatarObject->isTextureDefined(texture_index, 0)) + if (!gAgentAvatar->isTextureDefined(texture_index, 0)) { textures_current = FALSE; break; @@ -3687,7 +3652,7 @@ void LLAgent::sendAgentSetAppearance() msg->addU8Fast(_PREHASH_TextureIndex, (U8)texture_index); } msg->nextBlockFast(_PREHASH_ObjectData); - mAvatarObject->sendAppearanceMessage( gMessageSystem ); + gAgentAvatar->sendAppearanceMessage( gMessageSystem ); } else { @@ -3700,9 +3665,9 @@ void LLAgent::sendAgentSetAppearance() S32 transmitted_params = 0; - for (LLViewerVisualParam* param = (LLViewerVisualParam*)mAvatarObject->getFirstVisualParam(); + for (LLViewerVisualParam* param = (LLViewerVisualParam*)gAgentAvatar->getFirstVisualParam(); param; - param = (LLViewerVisualParam*)mAvatarObject->getNextVisualParam()) + param = (LLViewerVisualParam*)gAgentAvatar->getNextVisualParam()) { if (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE) { diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 891ce799d2..53b4fea1dc 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -51,7 +51,6 @@ extern const U8 AGENT_STATE_TYPING; // Typing indication extern const U8 AGENT_STATE_EDITING; // Set when agent has objects selected class LLChat; -class LLVOAvatarSelf; class LLViewerRegion; class LLMotion; class LLToolset; @@ -109,7 +108,6 @@ public: virtual ~LLAgent(); void init(); void cleanup(); - void setAvatarObject(LLVOAvatarSelf *avatar); //-------------------------------------------------------------------- // Login @@ -171,20 +169,6 @@ private: ** ** *******************************************************************************/ -/******************************************************************************** - ** ** - ** GENERAL ACCESSORS - **/ - -public: - LLVOAvatarSelf* getAvatarObject() const { return mAvatarObject; } -private: - LLPointer mAvatarObject; // NULL until avatar object sent down from simulator - -/** General Accessors - ** ** - *******************************************************************************/ - /******************************************************************************** ** ** ** POSITION diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index b9555e1a37..62f1746f28 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -372,10 +372,9 @@ void LLAgentCamera::unlockView() { if (getFocusOnAvatar()) { - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { - setFocusGlobal(LLVector3d::zero, avatarp->mID); + setFocusGlobal(LLVector3d::zero, gAgentAvatar->mID); } setFocusOnAvatar(FALSE, FALSE); // no animation } @@ -1092,30 +1091,25 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y) { static LLVector3 last_at_axis; - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); + if (!isAgentAvatarValid()) return; - if (!avatarp) - { - return; - } - - LLQuaternion av_inv_rot = ~avatarp->mRoot.getWorldRotation(); - LLVector3 root_at = LLVector3::x_axis * avatarp->mRoot.getWorldRotation(); + LLQuaternion av_inv_rot = ~gAgentAvatar->mRoot.getWorldRotation(); + LLVector3 root_at = LLVector3::x_axis * gAgentAvatar->mRoot.getWorldRotation(); if ((gViewerWindow->getMouseVelocityStat()->getCurrent() < 0.01f) && (root_at * last_at_axis > 0.95f)) { - LLVector3 vel = avatarp->getVelocity(); + LLVector3 vel = gAgentAvatar->getVelocity(); if (vel.magVecSquared() > 4.f) { - setLookAt(LOOKAT_TARGET_IDLE, avatarp, vel * av_inv_rot); + setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatar, vel * av_inv_rot); } else { // *FIX: rotate mframeagent by sit object's rotation? - LLQuaternion look_rotation = avatarp->isSitting() ? avatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); // use camera's current rotation + LLQuaternion look_rotation = gAgentAvatar->isSitting() ? gAgentAvatar->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, avatarp, look_offset); + setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatar, look_offset); } last_at_axis = root_at; return; @@ -1125,7 +1119,7 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y) if (CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode()) { - setLookAt(LOOKAT_TARGET_NONE, avatarp, LLVector3(-2.f, 0.f, 0.f)); + setLookAt(LOOKAT_TARGET_NONE, gAgentAvatar, LLVector3(-2.f, 0.f, 0.f)); } else { @@ -1154,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, avatarp, headLookAxis); + setLookAt(lookAtType, gAgentAvatar, headLookAxis); } } @@ -1175,15 +1169,13 @@ void LLAgentCamera::updateCamera() validateFocusObject(); - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - - if (avatarp && - avatarp->isSitting() && + if (isAgentAvatarValid() && + gAgentAvatar->isSitting() && camera_mode == CAMERA_MODE_MOUSELOOK) { //Ventrella //changed camera_skyward to the new global "mCameraUpVector" - mCameraUpVector = mCameraUpVector * avatarp->getRenderRotation(); + mCameraUpVector = mCameraUpVector * gAgentAvatar->getRenderRotation(); //end Ventrella } @@ -1291,7 +1283,7 @@ void LLAgentCamera::updateCamera() //Ventrella if ( mCameraMode == CAMERA_MODE_FOLLOW ) { - if (avatarp) + if (isAgentAvatarValid()) { //-------------------------------------------------------------------------------- // this is where the avatar's position and rotation are given to followCam, and @@ -1299,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 = avatarp->isSitting() ? avatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); + LLQuaternion avatarRotationForFollowCam = gAgentAvatar->isSitting() ? gAgentAvatar->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); LLFollowCamParams* current_cam = LLFollowCamMgr::getActiveFollowCamParams(); if (current_cam) { mFollowCam.copyParams(*current_cam); - mFollowCam.setSubjectPositionAndRotation( avatarp->getRenderPosition(), avatarRotationForFollowCam ); + mFollowCam.setSubjectPositionAndRotation( gAgentAvatar->getRenderPosition(), avatarRotationForFollowCam ); mFollowCam.update(); LLViewerJoystick::getInstance()->setCameraNeedsUpdate(true); } @@ -1380,9 +1372,9 @@ void LLAgentCamera::updateCamera() gAgent.setShowAvatar(TRUE); } - if (avatarp && (mCameraMode != CAMERA_MODE_MOUSELOOK)) + if (isAgentAvatarValid() && (mCameraMode != CAMERA_MODE_MOUSELOOK)) { - avatarp->updateAttachmentVisibility(mCameraMode); + gAgentAvatar->updateAttachmentVisibility(mCameraMode); } } else @@ -1480,40 +1472,40 @@ void LLAgentCamera::updateCamera() } gAgent.setLastPositionGlobal(global_pos); - if (LLVOAvatar::sVisibleInFirstPerson && avatarp && !avatarp->isSitting() && cameraMouselook()) + if (LLVOAvatar::sVisibleInFirstPerson && isAgentAvatarValid() && !gAgentAvatar->isSitting() && cameraMouselook()) { - LLVector3 head_pos = avatarp->mHeadp->getWorldPosition() + - LLVector3(0.08f, 0.f, 0.05f) * avatarp->mHeadp->getWorldRotation() + - LLVector3(0.1f, 0.f, 0.f) * avatarp->mPelvisp->getWorldRotation(); + 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 diff = mCameraPositionAgent - head_pos; - diff = diff * ~avatarp->mRoot.getWorldRotation(); + diff = diff * ~gAgentAvatar->mRoot.getWorldRotation(); - LLJoint* torso_joint = avatarp->mTorsop; - LLJoint* chest_joint = avatarp->mChestp; + LLJoint* torso_joint = gAgentAvatar->mTorsop; + LLJoint* chest_joint = gAgentAvatar->mChestp; LLVector3 torso_scale = torso_joint->getScale(); LLVector3 chest_scale = chest_joint->getScale(); // shorten avatar skeleton to avoid foot interpenetration - if (!avatarp->mInAir) + if (!gAgentAvatar->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 = avatarp->mNeckp; + LLJoint* neck_joint = gAgentAvatar->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; } - avatarp->mPelvisp->setPosition(avatarp->mPelvisp->getPosition() + diff); + gAgentAvatar->mPelvisp->setPosition(gAgentAvatar->mPelvisp->getPosition() + diff); - avatarp->mRoot.updateWorldMatrixChildren(); + gAgentAvatar->mRoot.updateWorldMatrixChildren(); - for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); - iter != avatarp->mAttachmentPoints.end(); ) + for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); + iter != gAgentAvatar->mAttachmentPoints.end(); ) { LLVOAvatar::attachment_map_t::iterator curiter = iter++; LLViewerJointAttachment* attachment = curiter->second; @@ -1605,8 +1597,6 @@ LLVector3d LLAgentCamera::calcFocusPositionTargetGlobal() clearFocusObject(); } - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - // Ventrella if (mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar) { @@ -1617,12 +1607,12 @@ LLVector3d LLAgentCamera::calcFocusPositionTargetGlobal() { LLVector3d at_axis(1.0, 0.0, 0.0); LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion(); - if (avatarp && avatarp->getParent()) + if (isAgentAvatarValid() && gAgentAvatar->getParent()) { - LLViewerObject* root_object = (LLViewerObject*)avatarp->getRoot(); + LLViewerObject* root_object = (LLViewerObject*)gAgentAvatar->getRoot(); if (!root_object->flagCameraDecoupled()) { - agent_rot *= ((LLViewerObject*)(avatarp->getParent()))->getRenderRotation(); + agent_rot *= ((LLViewerObject*)(gAgentAvatar->getParent()))->getRenderRotation(); } } at_axis = at_axis * agent_rot; @@ -1672,7 +1662,7 @@ LLVector3d LLAgentCamera::calcFocusPositionTargetGlobal() } return mFocusTargetGlobal; } - else if (mSitCameraEnabled && avatarp && avatarp->isSitting() && mSitCameraReferenceObject.notNull()) + else if (mSitCameraEnabled && isAgentAvatarValid() && gAgentAvatar->isSitting() && mSitCameraReferenceObject.notNull()) { // sit camera LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition(); @@ -1691,12 +1681,10 @@ LLVector3d LLAgentCamera::calcThirdPersonFocusOffset() { // ...offset from avatar LLVector3d focus_offset; - - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion(); - if (avatarp && avatarp->getParent()) + if (isAgentAvatarValid() && gAgentAvatar->getParent()) { - agent_rot *= ((LLViewerObject*)(avatarp->getParent()))->getRenderRotation(); + agent_rot *= ((LLViewerObject*)(gAgentAvatar->getParent()))->getRenderRotation(); } focus_offset = mFocusOffsetInitial[mCameraPreset] * agent_rot; @@ -1705,12 +1693,10 @@ LLVector3d LLAgentCamera::calcThirdPersonFocusOffset() void LLAgentCamera::setupSitCamera() { - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - // agent frame entering this function is in world coordinates - if (avatarp && avatarp->getParent()) + if (isAgentAvatarValid() && gAgentAvatar->getParent()) { - LLQuaternion parent_rot = ((LLViewerObject*)avatarp->getParent())->getRenderRotation(); + LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatar->getParent())->getRenderRotation(); // slam agent coordinate frame to proper parent local version LLVector3 at_axis = gAgent.getFrameAgent().getAtAxis(); at_axis.mV[VZ] = 0.f; @@ -1773,13 +1759,11 @@ F32 LLAgentCamera::calcCameraFOVZoomFactor() //----------------------------------------------------------------------------- LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) { - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - // Compute base camera position and look-at points. F32 camera_land_height; - LLVector3d frame_center_global = !avatarp ? + LLVector3d frame_center_global = !isAgentAvatarValid() ? gAgent.getPositionGlobal() : - gAgent.getPosGlobalFromAgent(avatarp->mRoot.getWorldPosition()); + gAgent.getPosGlobalFromAgent(gAgentAvatar->mRoot.getWorldPosition()); BOOL isConstrained = FALSE; LLVector3d head_offset; @@ -1794,32 +1778,32 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) }// End Ventrella else if (mCameraMode == CAMERA_MODE_MOUSELOOK) { - if (!avatarp || avatarp->mDrawable.isNull()) + if (!isAgentAvatarValid() || gAgentAvatar->mDrawable.isNull()) { llwarns << "Null avatar drawable!" << llendl; return LLVector3d::zero; } head_offset.clearVec(); - if (avatarp->isSitting() && avatarp->getParent()) + if (gAgentAvatar->isSitting() && gAgentAvatar->getParent()) { - avatarp->updateHeadOffset(); - head_offset.mdV[VX] = avatarp->mHeadOffset.mV[VX]; - head_offset.mdV[VY] = avatarp->mHeadOffset.mV[VY]; - head_offset.mdV[VZ] = avatarp->mHeadOffset.mV[VZ] + 0.1f; - const LLMatrix4& mat = ((LLViewerObject*) avatarp->getParent())->getRenderMatrix(); + 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(); camera_position_global = gAgent.getPosGlobalFromAgent - ((avatarp->getPosition()+ - LLVector3(head_offset)*avatarp->getRotation()) * mat); + ((gAgentAvatar->getPosition()+ + LLVector3(head_offset)*gAgentAvatar->getRotation()) * mat); } else { - head_offset.mdV[VZ] = avatarp->mHeadOffset.mV[VZ]; - if (avatarp->isSitting()) + head_offset.mdV[VZ] = gAgentAvatar->mHeadOffset.mV[VZ]; + if (gAgentAvatar->isSitting()) { head_offset.mdV[VZ] += 0.1; } - camera_position_global = gAgent.getPosGlobalFromAgent(avatarp->getRenderPosition());//frame_center_global; - head_offset = head_offset * avatarp->getRenderRotation(); + camera_position_global = gAgent.getPosGlobalFromAgent(gAgentAvatar->getRenderPosition());//frame_center_global; + head_offset = head_offset * gAgentAvatar->getRenderRotation(); camera_position_global = camera_position_global + head_offset; } } @@ -1829,8 +1813,8 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) F32 camera_distance = 0.f; if (mSitCameraEnabled - && avatarp - && avatarp->isSitting() + && isAgentAvatarValid() + && gAgentAvatar->isSitting() && mSitCameraReferenceObject.notNull()) { // sit camera @@ -1846,9 +1830,9 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) local_camera_offset = mCameraZoomFraction * getCameraOffsetInitial() * gSavedSettings.getF32("CameraOffsetScale"); // are we sitting down? - if (avatarp && avatarp->getParent()) + if (isAgentAvatarValid() && gAgentAvatar->getParent()) { - LLQuaternion parent_rot = ((LLViewerObject*)avatarp->getParent())->getRenderRotation(); + LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatar->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; @@ -1862,7 +1846,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) local_camera_offset = gAgent.getFrameAgent().rotateToAbsolute( local_camera_offset ); } - if (!mCameraCollidePlane.isExactlyZero() && (!avatarp || !avatarp->isSitting())) + if (!mCameraCollidePlane.isExactlyZero() && (!isAgentAvatarValid() || !gAgentAvatar->isSitting())) { LLVector3 plane_normal; plane_normal.setVec(mCameraCollidePlane.mV); @@ -1915,11 +1899,11 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) // set the global camera position LLVector3d camera_offset; - LLVector3 av_pos = !avatarp ? LLVector3::zero : avatarp->getRenderPosition(); + LLVector3 av_pos = !isAgentAvatarValid() ? LLVector3::zero : gAgentAvatar->getRenderPosition(); camera_offset.setVec( local_camera_offset ); camera_position_global = frame_center_global + head_offset + camera_offset; - if (avatarp) + if (isAgentAvatarValid()) { LLVector3d camera_lag_d; F32 lag_interp = LLCriticalDamp::getInterpolant(CAMERA_LAG_HALF_LIFE); @@ -1927,8 +1911,8 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) LLVector3 vel = gAgent.getVelocity(); // lag by appropriate amount for flying - F32 time_in_air = avatarp->mTimeInAir.getElapsedTimeF32(); - if(!mCameraAnimating && avatarp->mInAir && time_in_air > GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME) + F32 time_in_air = gAgentAvatar->mTimeInAir.getElapsedTimeF32(); + if(!mCameraAnimating && gAgentAvatar->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()); @@ -1940,7 +1924,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) lag_interp *= u; - if (gViewerWindow->getLeftMouseDown() && gViewerWindow->getLastPick().mObjectID == avatarp->getID()) + if (gViewerWindow->getLeftMouseDown() && gViewerWindow->getLastPick().mObjectID == gAgentAvatar->getID()) { // disable camera lag when using mouse-directed steering target_lag.clearVec(); @@ -2141,8 +2125,6 @@ void LLAgentCamera::changeCameraToMouselook(BOOL animate) return; } - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - // visibility changes at end of animation gViewerWindow->getWindow()->resetBusyCount(); @@ -2151,10 +2133,10 @@ void LLAgentCamera::changeCameraToMouselook(BOOL animate) LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset); - if (avatarp) + if (isAgentAvatarValid()) { - avatarp->stopMotion(ANIM_AGENT_BODY_NOISE); - avatarp->stopMotion(ANIM_AGENT_BREATHE_ROT); + gAgentAvatar->stopMotion(ANIM_AGENT_BODY_NOISE); + gAgentAvatar->stopMotion(ANIM_AGENT_BREATHE_ROT); } //gViewerWindow->stopGrab(); @@ -2239,12 +2221,11 @@ void LLAgentCamera::changeCameraToFollow(BOOL animate) LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); } - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { - avatarp->mPelvisp->setPosition(LLVector3::zero); - avatarp->startMotion( ANIM_AGENT_BODY_NOISE ); - avatarp->startMotion( ANIM_AGENT_BREATHE_ROT ); + gAgentAvatar->mPelvisp->setPosition(LLVector3::zero); + gAgentAvatar->startMotion( ANIM_AGENT_BODY_NOISE ); + gAgentAvatar->startMotion( ANIM_AGENT_BREATHE_ROT ); } // unpause avatar animation @@ -2283,15 +2264,14 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate) mCameraZoomFraction = INITIAL_ZOOM_FRACTION; - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { - if (!avatarp->isSitting()) + if (!gAgentAvatar->isSitting()) { - avatarp->mPelvisp->setPosition(LLVector3::zero); + gAgentAvatar->mPelvisp->setPosition(LLVector3::zero); } - avatarp->startMotion(ANIM_AGENT_BODY_NOISE); - avatarp->startMotion(ANIM_AGENT_BREATHE_ROT); + gAgentAvatar->startMotion(ANIM_AGENT_BODY_NOISE); + gAgentAvatar->startMotion(ANIM_AGENT_BREATHE_ROT); } LLVector3 at_axis; @@ -2325,9 +2305,9 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate) } // Remove any pitch from the avatar - if (avatarp && avatarp->getParent()) + if (isAgentAvatarValid() && gAgentAvatar->getParent()) { - LLQuaternion obj_rot = ((LLViewerObject*)avatarp->getParent())->getRenderRotation(); + LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatar->getParent())->getRenderRotation(); at_axis = LLViewerCamera::getInstance()->getAtAxis(); at_axis.mV[VZ] = 0.f; at_axis.normalize(); @@ -2399,8 +2379,7 @@ void LLAgentCamera::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL came LLVOAvatarSelf::onCustomizeStart(); } - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { if(avatar_animate) { @@ -2412,8 +2391,8 @@ void LLAgentCamera::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL came gAgent.sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_START); gAgent.setCustomAnim(TRUE); - avatarp->startMotion(ANIM_AGENT_CUSTOMIZE); - LLMotion* turn_motion = avatarp->findMotion(ANIM_AGENT_CUSTOMIZE); + gAgentAvatar->startMotion(ANIM_AGENT_CUSTOMIZE); + LLMotion* turn_motion = gAgentAvatar->findMotion(ANIM_AGENT_CUSTOMIZE); if (turn_motion) { @@ -2516,16 +2495,15 @@ void LLAgentCamera::setFocusGlobal(const LLVector3d& focus, const LLUUID &object setFocusObject(gObjectList.findObject(object_id)); LLVector3d old_focus = mFocusTargetGlobal; LLViewerObject *focus_obj = mFocusObject; - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); // if focus has changed if (old_focus != focus) { if (focus.isExactlyZero()) { - if (avatarp) + if (isAgentAvatarValid()) { - mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(avatarp->mHeadp->getWorldPosition()); + mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatar->mHeadp->getWorldPosition()); } else { @@ -2568,9 +2546,9 @@ void LLAgentCamera::setFocusGlobal(const LLVector3d& focus, const LLUUID &object { if (focus.isExactlyZero()) { - if (avatarp) + if (isAgentAvatarValid()) { - mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(avatarp->mHeadp->getWorldPosition()); + mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatar->mHeadp->getWorldPosition()); } else { @@ -2707,10 +2685,9 @@ void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) if (mCameraMode == CAMERA_MODE_THIRD_PERSON) { LLVector3 at_axis; - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - if (avatarp && avatarp->getParent()) + if (isAgentAvatarValid() && gAgentAvatar->getParent()) { - LLQuaternion obj_rot = ((LLViewerObject*)avatarp->getParent())->getRenderRotation(); + LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatar->getParent())->getRenderRotation(); at_axis = LLViewerCamera::getInstance()->getAtAxis(); at_axis.mV[VZ] = 0.f; at_axis.normalize(); @@ -2738,16 +2715,15 @@ void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) BOOL LLAgentCamera::setLookAt(ELookAtType target_type, LLViewerObject *object, LLVector3 position) { - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); if(object && object->isAttachment()) { LLViewerObject* parent = object; while(parent) { - if (parent == avatarp) + if (parent == gAgentAvatar) { // looking at an attachment on ourselves, which we don't want to do - object = avatarp; + object = gAgentAvatar; position.clearVec(); } parent = (LLViewerObject*)parent->getParent(); @@ -2756,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(avatarp); + mLookAt->setSourceObject(gAgentAvatar); } return mLookAt->setLookAt(target_type, object, position); @@ -2779,14 +2755,13 @@ void LLAgentCamera::lookAtLastChat() return; } - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); LLVector3 delta_pos; if (chatter->isAvatar()) { LLVOAvatar *chatter_av = (LLVOAvatar*)chatter; - if (avatarp && chatter_av->mHeadp) + if (isAgentAvatarValid() && chatter_av->mHeadp) { - delta_pos = chatter_av->mHeadp->getWorldPosition() - avatarp->mHeadp->getWorldPosition(); + delta_pos = chatter_av->mHeadp->getWorldPosition() - gAgentAvatar->mHeadp->getWorldPosition(); } else { @@ -2798,7 +2773,7 @@ void LLAgentCamera::lookAtLastChat() changeCameraToThirdPerson(); - LLVector3 new_camera_pos = avatarp->mHeadp->getWorldPosition(); + LLVector3 new_camera_pos = gAgentAvatar->mHeadp->getWorldPosition(); LLVector3 left = delta_pos % LLVector3::z_axis; left.normalize(); LLVector3 up = left % delta_pos; @@ -2827,7 +2802,7 @@ void LLAgentCamera::lookAtLastChat() changeCameraToThirdPerson(); - LLVector3 new_camera_pos = avatarp->mHeadp->getWorldPosition(); + LLVector3 new_camera_pos = gAgentAvatar->mHeadp->getWorldPosition(); LLVector3 left = delta_pos % LLVector3::z_axis; left.normalize(); LLVector3 up = left % delta_pos; @@ -2852,8 +2827,7 @@ BOOL LLAgentCamera::setPointAt(EPointAtType target_type, LLViewerObject *object, if (!mPointAt || mPointAt->isDead()) { mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT); - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - mPointAt->setSourceObject(avatarp); + mPointAt->setSourceObject(gAgentAvatar); } return mPointAt->setPointAt(target_type, object, position); } diff --git a/indra/newview/llagentui.cpp b/indra/newview/llagentui.cpp index 97e956c082..452a11b01e 100644 --- a/indra/newview/llagentui.cpp +++ b/indra/newview/llagentui.cpp @@ -49,12 +49,10 @@ void LLAgentUI::buildName(std::string& name) { name.clear(); - - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { - LLNameValue *first_nv = avatarp->getNVPair("FirstName"); - LLNameValue *last_nv = avatarp->getNVPair("LastName"); + LLNameValue *first_nv = gAgentAvatar->getNVPair("FirstName"); + LLNameValue *last_nv = gAgentAvatar->getNVPair("LastName"); if (first_nv && last_nv) { name = first_nv->printData() + " " + last_nv->printData(); @@ -73,8 +71,8 @@ void LLAgentUI::buildName(std::string& name) //static void LLAgentUI::buildFullname(std::string& name) { - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - if (avatarp) name = avatarp->getFullname(); + if (isAgentAvatarValid()) + name = gAgentAvatar->getFullname(); } //static diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index aec8c6e403..91552a7f5b 100644 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -485,8 +485,7 @@ void LLAgentWearables::saveWearable(const EWearableType type, const U32 index, B return; } - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - avatarp->wearableUpdated( type, TRUE ); + gAgentAvatar->wearableUpdated( type, TRUE ); if (send_update) { @@ -784,8 +783,7 @@ U32 LLAgentWearables::pushWearable(const EWearableType type, LLWearable *wearabl void LLAgentWearables::wearableUpdated(LLWearable *wearable) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - avatarp->wearableUpdated(wearable->getType(), TRUE); + gAgentAvatar->wearableUpdated(wearable->getType(), TRUE); wearable->refreshName(); wearable->setLabelUpdated(); @@ -826,11 +824,10 @@ void LLAgentWearables::popWearable(LLWearable *wearable) void LLAgentWearables::popWearable(const EWearableType type, U32 index) { LLWearable *wearable = getWearable(type, index); - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); if (wearable) { mWearableDatas[type].erase(mWearableDatas[type].begin() + index); - avatarp->wearableUpdated(wearable->getType(), TRUE); + gAgentAvatar->wearableUpdated(wearable->getType(), TRUE); wearable->setLabelUpdated(); } } @@ -962,8 +959,7 @@ void LLAgentWearables::processAgentInitialWearablesUpdate(LLMessageSystem* mesgs LLUUID agent_id; gMessageSystem->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id); - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp && (agent_id == avatarp->getID())) + if (isAgentAvatarValid() && (agent_id == gAgentAvatar->getID())) { gMessageSystem->getU32Fast(_PREHASH_AgentData, _PREHASH_SerialNum, gAgentQueryManager.mUpdateSerialNum); @@ -1055,11 +1051,7 @@ void LLAgentWearables::onInitialWearableAssetArrived(LLWearable* wearable, void* const EWearableType type = wear_data->mType; U32 index = 0; - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) - { - return; - } + if (!isAgentAvatarValid()) return; if (wearable) { @@ -1069,9 +1061,9 @@ void LLAgentWearables::onInitialWearableAssetArrived(LLWearable* wearable, void* gAgentWearables.mItemsAwaitingWearableUpdate.erase(wear_data->mItemID); // disable composites if initial textures are baked - avatarp->setupComposites(); + gAgentAvatar->setupComposites(); - avatarp->setCompositeUpdatesEnabled(TRUE); + gAgentAvatar->setCompositeUpdatesEnabled(TRUE); gInventory.addChangedMask(LLInventoryObserver::LABEL, wearable->getItemID()); } else @@ -1100,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()) { - avatarp->requestLayerSetUploads(); + gAgentAvatar->requestLayerSetUploads(); } } } @@ -1240,13 +1232,9 @@ void LLAgentWearables::createStandardWearables(BOOL female) llwarns << "Creating Standard " << (female ? "female" : "male") << " Wearables" << llendl; - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) - { - return; - } + if (!isAgentAvatarValid()) return; - avatarp->setSex(female ? SEX_FEMALE : SEX_MALE); + gAgentAvatar->setSex(female ? SEX_FEMALE : SEX_MALE); const BOOL create[WT_COUNT] = { @@ -1294,11 +1282,8 @@ void LLAgentWearables::createStandardWearablesDone(S32 type, U32 index) { llinfos << "type " << type << " index " << index << llendl; - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp) - { - avatarp->updateVisualParams(); - } + if (!isAgentAvatarValid()) return; + gAgentAvatar->updateVisualParams(); } void LLAgentWearables::createStandardWearablesAllDone() @@ -1313,8 +1298,7 @@ void LLAgentWearables::createStandardWearablesAllDone() updateServer(); // Treat this as the first texture entry message, if none received yet - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - avatarp->onFirstTEMessageReceived(); + gAgentAvatar->onFirstTEMessageReceived(); } // MULTI-WEARABLE: Properly handle multiwearables later. @@ -1336,11 +1320,7 @@ void LLAgentWearables::makeNewOutfit(const std::string& new_folder_name, const LLDynamicArray& attachments_to_include, BOOL rename_clothing) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) - { - return; - } + if (!isAgentAvatarValid()) return; // First, make a folder in the Clothes directory. LLUUID folder_id = gInventory.createNewCategory( @@ -1438,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(avatarp->mAttachmentPoints, attachment_pt, (LLViewerJointAttachment*)NULL); + LLViewerJointAttachment* attachment = get_if_there(gAgentAvatar->mAttachmentPoints, attachment_pt, (LLViewerJointAttachment*)NULL); if (!attachment) continue; for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); attachment_iter != attachment->mAttachedObjects.end(); @@ -1513,11 +1493,7 @@ private: LLUUID LLAgentWearables::makeNewOutfitLinks(const std::string& new_folder_name) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) - { - return LLUUID::null; - } + if (!isAgentAvatarValid()) return LLUUID::null; // First, make a folder in the My Outfits directory. const LLUUID parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); @@ -1681,7 +1657,6 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it BOOL remove) { llinfos << "setWearableOutfit() start" << llendl; - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); BOOL wearables_to_remove[WT_COUNT]; wearables_to_remove[WT_SHAPE] = FALSE; @@ -1785,11 +1760,11 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it } } - if (avatarp) + if (isAgentAvatarValid()) { - avatarp->setCompositeUpdatesEnabled(TRUE); - avatarp->updateVisualParams(); - avatarp->invalidateAll(); + gAgentAvatar->setCompositeUpdatesEnabled(TRUE); + gAgentAvatar->updateVisualParams(); + gAgentAvatar->invalidateAll(); } // Start rendering & update the server @@ -2039,12 +2014,7 @@ void LLAgentWearables::userUpdateAttachments(LLInventoryModel::item_array_t& obj // already wearing and in request set -> leave alone. // not wearing and in request set -> put on. - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) - { - llwarns << "No avatar found." << llendl; - return; - } + if (!isAgentAvatarValid()) return; std::set requested_item_ids; std::set current_item_ids; @@ -2053,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 = avatarp->mAttachmentPoints.begin(); - iter != avatarp->mAttachmentPoints.end();) + for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); + iter != gAgentAvatar->mAttachmentPoints.end();) { LLVOAvatar::attachment_map_t::iterator curiter = iter++; LLViewerJointAttachment* attachment = curiter->second; @@ -2110,12 +2080,7 @@ void LLAgentWearables::userUpdateAttachments(LLInventoryModel::item_array_t& obj void LLAgentWearables::userRemoveMultipleAttachments(llvo_vec_t& objects_to_remove) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) - { - llwarns << "No avatar found." << llendl; - return; - } + if (!isAgentAvatarValid()) return; if (objects_to_remove.empty()) return; @@ -2138,17 +2103,12 @@ void LLAgentWearables::userRemoveMultipleAttachments(llvo_vec_t& objects_to_remo void LLAgentWearables::userRemoveAllAttachments() { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) - { - llwarns << "No avatar found." << llendl; - return; - } + if (!isAgentAvatarValid()) return; llvo_vec_t objects_to_remove; - for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); - iter != avatarp->mAttachmentPoints.end();) + for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); + iter != gAgentAvatar->mAttachmentPoints.end();) { LLVOAvatar::attachment_map_t::iterator curiter = iter++; LLViewerJointAttachment* attachment = curiter->second; @@ -2714,11 +2674,10 @@ void LLInitialWearablesFetch::processWearablesMessage() } // Add all current attachments to the requested items as well. - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { - for (LLVOAvatar::attachment_map_t::const_iterator iter = avatarp->mAttachmentPoints.begin(); - iter != avatarp->mAttachmentPoints.end(); ++iter) + for (LLVOAvatar::attachment_map_t::const_iterator iter = gAgentAvatar->mAttachmentPoints.begin(); + iter != gAgentAvatar->mAttachmentPoints.end(); ++iter) { LLViewerJointAttachment* attachment = iter->second; if (!attachment) continue; diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index b3dfb8f141..ef25faac26 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -469,8 +469,7 @@ void LLWearableHoldingPattern::onAllComplete() LLAppearanceManager::instance().updateAgentWearables(this, false); // Update attachments to match those requested. - LLVOAvatar* avatar = gAgent.getAvatarObject(); - if( avatar ) + if (isAgentAvatarValid()) { llinfos << "Updating " << mObjItems.count() << " attachments" << llendl; LLAgentWearables::userUpdateAttachments(mObjItems); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index d30d7fd26d..220b84500f 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -79,6 +79,7 @@ #include "lllocationhistory.h" #include "llfasttimerview.h" #include "llvoicechannel.h" +#include "llvoavatarself.h" #include "llsidetray.h" @@ -356,7 +357,7 @@ void request_initial_instant_messages() if (!requested && gMessageSystem && LLMuteList::getInstance()->isLoaded() - && gAgent.getAvatarObject()) + && isAgentAvatarValid()) { // Auto-accepted inventory items may require the avatar object // to build a correct name. Likewise, inventory offers from diff --git a/indra/newview/lldriverparam.cpp b/indra/newview/lldriverparam.cpp index c22c9d3048..75d1c437c3 100644 --- a/indra/newview/lldriverparam.cpp +++ b/indra/newview/lldriverparam.cpp @@ -118,13 +118,12 @@ void LLDriverParamInfo::toStream(std::ostream &out) out << std::endl; - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - if(avatarp) + if(isAgentAvatarValid()) { for (entry_info_list_t::iterator iter = mDrivenInfoList.begin(); iter != mDrivenInfoList.end(); iter++) { LLDrivenEntryInfo driven = *iter; - LLViewerVisualParam *param = (LLViewerVisualParam*)avatarp->getVisualParam(driven.mDrivenID); + LLViewerVisualParam *param = (LLViewerVisualParam*)gAgentAvatar->getVisualParam(driven.mDrivenID); if (param) { param->getInfo()->toStream(out); @@ -146,7 +145,7 @@ void LLDriverParamInfo::toStream(std::ostream &out) } else { - llwarns << "could not get parameter " << driven.mDrivenID << " from avatar " << avatarp << " for driver parameter " << getID() << llendl; + llwarns << "could not get parameter " << driven.mDrivenID << " from avatar " << gAgentAvatar << " for driver parameter " << getID() << llendl; } out << std::endl; } @@ -626,14 +625,13 @@ F32 LLDriverParam::getDrivenWeight(const LLDrivenEntry* driven, F32 input_weight void LLDriverParam::setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight, bool upload_bake) { - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - if(avatarp && + if(isAgentAvatarValid() && mWearablep && driven->mParam->getCrossWearable() && mWearablep->isOnTop()) { // call setWeight through LLVOAvatarSelf so other wearables can be updated with the correct values - avatarp->setVisualParamWeight( (LLVisualParam*)driven->mParam, driven_weight, upload_bake ); + gAgentAvatar->setVisualParamWeight( (LLVisualParam*)driven->mParam, driven_weight, upload_bake ); } else { diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp index 47a9961323..c9a950ed42 100644 --- a/indra/newview/llgesturemgr.cpp +++ b/indra/newview/llgesturemgr.cpp @@ -746,8 +746,7 @@ void LLGestureManager::stepGesture(LLMultiGesture* gesture) { return; } - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) return; + if (!isAgentAvatarValid()) return; // Of the ones that started playing, have any stopped? @@ -758,8 +757,8 @@ void LLGestureManager::stepGesture(LLMultiGesture* gesture) { // look in signaled animations (simulator's view of what is // currently playing. - LLVOAvatar::AnimIterator play_it = avatarp->mSignaledAnimations.find(*gest_it); - if (play_it != avatarp->mSignaledAnimations.end()) + LLVOAvatar::AnimIterator play_it = gAgentAvatar->mSignaledAnimations.find(*gest_it); + if (play_it != gAgentAvatar->mSignaledAnimations.end()) { ++gest_it; } @@ -777,8 +776,8 @@ void LLGestureManager::stepGesture(LLMultiGesture* gesture) gest_it != gesture->mRequestedAnimIDs.end(); ) { - LLVOAvatar::AnimIterator play_it = avatarp->mSignaledAnimations.find(*gest_it); - if (play_it != avatarp->mSignaledAnimations.end()) + LLVOAvatar::AnimIterator play_it = gAgentAvatar->mSignaledAnimations.find(*gest_it); + if (play_it != gAgentAvatar->mSignaledAnimations.end()) { // Hooray, this animation has started playing! // Copy into playing. diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 08734137b6..a62640c813 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -1506,11 +1506,7 @@ BOOL LLFolderBridge::isItemRemovable() const return FALSE; } - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) - { - return FALSE; - } + if (!isAgentAvatarValid()) return FALSE; LLInventoryCategory* category = model->getCategory(mUUID); if(!category) @@ -1661,8 +1657,7 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat, LLInventoryModel* model = getInventoryModel(); if(!model) return FALSE; - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) return FALSE; + if (!isAgentAvatarValid()) return FALSE; // cannot drag categories into library if(!isAgentInventory()) @@ -3026,8 +3021,7 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item, return FALSE; } - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) return FALSE; + if (!isAgentAvatarValid()) return FALSE; LLToolDragAndDrop::ESource source = LLToolDragAndDrop::getInstance()->getSource(); BOOL accept = FALSE; @@ -4155,8 +4149,7 @@ std::string LLObjectBridge::getLabelSuffix() const { if (get_is_item_worn(mUUID)) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - std::string attachment_point_name = avatarp->getAttachedPointName(mUUID); + std::string attachment_point_name = gAgentAvatar->getAttachedPointName(mUUID); // e.g. "(worn on ...)" / "(attached to ...)" LLStringUtil::format_map_t args; @@ -4175,11 +4168,10 @@ void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attach payload["item_id"] = item->getLinkedUUID(); // Wear the base object in case this is a link. S32 attach_pt = 0; - if (gAgent.getAvatarObject() && attachment) + if (isAgentAvatarValid() && attachment) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); - iter != avatarp->mAttachmentPoints.end(); ++iter) + for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); + iter != gAgentAvatar->mAttachmentPoints.end(); ++iter) { if (iter->second == attachment) { @@ -4205,9 +4197,7 @@ void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attach bool confirm_replace_attachment_rez(const LLSD& notification, const LLSD& response) { - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - - if (!avatarp->canAttachMoreObjects()) + if (!gAgentAvatar->canAttachMoreObjects()) { LLSD args; args["MAX_ATTACHMENTS"] = llformat("%d", MAX_AGENT_ATTACHMENTS); @@ -4269,11 +4259,7 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags) LLInventoryItem *item = getItem(); if(item) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) - { - return; - } + if (!isAgentAvatarValid()) return; if( get_is_item_worn( mUUID ) ) { @@ -4289,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 (!avatarp->canAttachMoreObjects()) + if (!gAgentAvatar->canAttachMoreObjects()) { disabled_items.push_back(std::string("Object Wear")); disabled_items.push_back(std::string("Attach To")); @@ -4297,15 +4283,14 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags) } LLMenuGL* attach_menu = menu.findChildMenuByName("Attach To", TRUE); LLMenuGL* attach_hud_menu = menu.findChildMenuByName("Attach To HUD", TRUE); - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); if (attach_menu && (attach_menu->getChildCount() == 0) && attach_hud_menu && (attach_hud_menu->getChildCount() == 0) - && avatarp) + && isAgentAvatarValid()) { - for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); - iter != avatarp->mAttachmentPoints.end(); ) + for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); + iter != gAgentAvatar->mAttachmentPoints.end(); ) { LLVOAvatar::attachment_map_t::iterator curiter = iter++; LLViewerJointAttachment* attachment = curiter->second; @@ -4355,10 +4340,9 @@ BOOL LLObjectBridge::renameItem(const std::string& new_name) model->notifyObservers(); - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { - LLViewerObject* obj = avatarp->getWornAttachment( item->getUUID() ); + LLViewerObject* obj = gAgentAvatar->getWornAttachment( item->getUUID() ); if(obj) { LLSelectMgr::getInstance()->deselectAll(); diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index d3e2a2f555..f1b7806635 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -352,8 +352,7 @@ BOOL get_is_item_worn(const LLUUID& id) { case LLAssetType::AT_OBJECT: { - const LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if(avatarp && avatarp->isWearingAttachment(item->getLinkedUUID())) + if (isAgentAvatarValid() && gAgentAvatar->isWearingAttachment(item->getLinkedUUID())) return TRUE; break; } diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 1f9840923c..7c8fb4f9b9 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -3774,7 +3774,6 @@ bool LLInventoryCollectFunctor::itemTransferCommonlyAllowed(LLInventoryItem* ite return false; bool allowed = false; - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); switch(item->getType()) { @@ -3783,7 +3782,7 @@ bool LLInventoryCollectFunctor::itemTransferCommonlyAllowed(LLInventoryItem* ite break; case LLAssetType::AT_OBJECT: - if(avatarp && !avatarp->isWearingAttachment(item->getUUID())) + if (isAgentAvatarValid() && !gAgentAvatar->isWearingAttachment(item->getUUID())) { allowed = true; } diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 2a8306f232..3520c7e0c0 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -871,10 +871,9 @@ bool LLInventoryPanel::attachObject(const LLSD& userdata) mFolders->getSelectionList(selected_items); std::string joint_name = userdata.asString(); - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); LLViewerJointAttachment* attachmentp = NULL; - for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); - iter != avatarp->mAttachmentPoints.end(); ) + for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); + iter != gAgentAvatar->mAttachmentPoints.end(); ) { LLVOAvatar::attachment_map_t::iterator curiter = iter++; LLViewerJointAttachment* attachment = curiter->second; diff --git a/indra/newview/llmaniprotate.cpp b/indra/newview/llmaniprotate.cpp index 6dc0a929c8..6747bcb9c9 100644 --- a/indra/newview/llmaniprotate.cpp +++ b/indra/newview/llmaniprotate.cpp @@ -65,6 +65,7 @@ #include "lldrawable.h" #include "llglheaders.h" #include "lltrans.h" +#include "llvoavatarself.h" const F32 RADIUS_PIXELS = 100.f; // size in screen space const F32 SQ_RADIUS = RADIUS_PIXELS * RADIUS_PIXELS; @@ -739,7 +740,7 @@ void LLManipRotate::renderSnapGuides() LLVector3 test_axis = constraint_axis; BOOL constrain_to_ref_object = FALSE; - if (mObjectSelection->getSelectType() == SELECT_TYPE_ATTACHMENT && gAgent.getAvatarObject()) + if (mObjectSelection->getSelectType() == SELECT_TYPE_ATTACHMENT && isAgentAvatarValid()) { test_axis = test_axis * ~grid_rotation; } @@ -766,7 +767,7 @@ void LLManipRotate::renderSnapGuides() } LLVector3 projected_snap_axis = world_snap_axis; - if (mObjectSelection->getSelectType() == SELECT_TYPE_ATTACHMENT && gAgent.getAvatarObject()) + if (mObjectSelection->getSelectType() == SELECT_TYPE_ATTACHMENT && isAgentAvatarValid()) { projected_snap_axis = projected_snap_axis * grid_rotation; } @@ -1282,7 +1283,7 @@ LLQuaternion LLManipRotate::dragConstrained( S32 x, S32 y ) LLVector3 axis2; LLVector3 test_axis = constraint_axis; - if (mObjectSelection->getSelectType() == SELECT_TYPE_ATTACHMENT && gAgent.getAvatarObject()) + if (mObjectSelection->getSelectType() == SELECT_TYPE_ATTACHMENT && isAgentAvatarValid()) { test_axis = test_axis * ~grid_rotation; } @@ -1306,7 +1307,7 @@ LLQuaternion LLManipRotate::dragConstrained( S32 x, S32 y ) axis1 = LLVector3::x_axis; } - if (mObjectSelection->getSelectType() == SELECT_TYPE_ATTACHMENT && gAgent.getAvatarObject()) + if (mObjectSelection->getSelectType() == SELECT_TYPE_ATTACHMENT && isAgentAvatarValid()) { axis1 = axis1 * grid_rotation; } diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp index 35c4f7f787..8d77ade253 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); - gAgent.getAvatarObject()->clampAttachmentPositions(); + gAgentAvatar->clampAttachmentPositions(); new_position_local = object->getPosition(); if (selectNode->mIndividualSelection) diff --git a/indra/newview/llmorphview.cpp b/indra/newview/llmorphview.cpp index cb48db15e4..6334d54e33 100644 --- a/indra/newview/llmorphview.cpp +++ b/indra/newview/llmorphview.cpp @@ -89,15 +89,14 @@ void LLMorphView::initialize() mCameraYaw = 0.f; mCameraDist = -1.f; - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - if (!avatarp || avatarp->isDead()) + if (!isAgentAvatarValid() || gAgentAvatar->isDead()) { gAgentCamera.changeCameraToDefault(); return; } - avatarp->stopMotion( ANIM_AGENT_BODY_NOISE ); - avatarp->mSpecialRenderMode = 3; + gAgentAvatar->stopMotion( ANIM_AGENT_BODY_NOISE ); + gAgentAvatar->mSpecialRenderMode = 3; // set up camera for close look at avatar mOldCameraNearClip = LLViewerCamera::getInstance()->getNear(); @@ -111,11 +110,10 @@ void LLMorphView::shutdown() { LLVOAvatarSelf::onCustomizeEnd(); - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - if (avatarp && !avatarp->isDead()) + if (isAgentAvatarValid()) { - avatarp->startMotion( ANIM_AGENT_BODY_NOISE ); - avatarp->mSpecialRenderMode = 0; + gAgentAvatar->startMotion( ANIM_AGENT_BODY_NOISE ); + gAgentAvatar->mSpecialRenderMode = 0; // reset camera LLViewerCamera::getInstance()->setNear(mOldCameraNearClip); } @@ -164,15 +162,11 @@ void LLMorphView::updateCamera() { if (!mCameraTargetJoint) { - setCameraTargetJoint(gAgent.getAvatarObject()->getJoint("mHead")); - } - - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) - { - return; - } - LLJoint* root_joint = avatarp->getRootJoint(); + setCameraTargetJoint(gAgentAvatar->getJoint("mHead")); + } + if (!isAgentAvatarValid()) return; + + LLJoint* root_joint = gAgentAvatar->getRootJoint(); if( !root_joint ) { return; diff --git a/indra/newview/llmoveview.cpp b/indra/newview/llmoveview.cpp index 58fac14349..b47acefc76 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 gAgent.getAvatarObject()->isSitting() +#include "llvoavatarself.h" // to check gAgentAvatar->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 - || (gAgent.getAvatarObject() && gAgent.getAvatarObject()->isSitting()); + || (isAgentAvatarValid() && gAgentAvatar->isSitting()); showModeButtons(!bHideModeButtons); @@ -388,9 +388,9 @@ void LLFloaterMove::initMovementMode() } setMovementMode(initMovementMode); - if (gAgent.getAvatarObject()) + if (isAgentAvatarValid()) { - setEnabled(!gAgent.getAvatarObject()->isSitting()); + setEnabled(!gAgentAvatar->isSitting()); } } @@ -491,7 +491,7 @@ void LLFloaterMove::onOpen(const LLSD& key) showModeButtons(FALSE); } - if (gAgent.getAvatarObject() && gAgent.getAvatarObject()->isSitting()) + if (isAgentAvatarValid() && gAgentAvatar->isSitting()) { setSittingMode(TRUE); showModeButtons(FALSE); diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp index e7acc68b93..89fd4715fc 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 = gAgent.getAvatarObject()->getSex(); + ESex avatar_sex = gAgentAvatar->getSex(); mWearablePtr->getVisualParams(param_list); diff --git a/indra/newview/llpreview.cpp b/indra/newview/llpreview.cpp index 312bbc0e11..87c7bdbfab 100644 --- a/indra/newview/llpreview.cpp +++ b/indra/newview/llpreview.cpp @@ -179,10 +179,9 @@ void LLPreview::onCommit() // update the object itself. if( item->getType() == LLAssetType::AT_OBJECT ) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { - LLViewerObject* obj = avatarp->getWornAttachment( item->getUUID() ); + LLViewerObject* obj = gAgentAvatar->getWornAttachment( item->getUUID() ); if( obj ) { LLSelectMgr::getInstance()->deselectAll(); diff --git a/indra/newview/llpreviewanim.cpp b/indra/newview/llpreviewanim.cpp index 49b297f702..9210f5b8b7 100644 --- a/indra/newview/llpreviewanim.cpp +++ b/indra/newview/llpreviewanim.cpp @@ -71,7 +71,7 @@ BOOL LLPreviewAnim::postBuild() const LLInventoryItem* item = getItem(); if(item) { - gAgent.getAvatarObject()->createMotion(item->getAssetUUID()); // preload the animation + gAgentAvatar->createMotion(item->getAssetUUID()); // preload the animation childSetText("desc", item->getDescription()); } @@ -110,7 +110,6 @@ void LLPreviewAnim::playAnim( void *userdata ) { LLPreviewAnim* self = (LLPreviewAnim*) userdata; const LLInventoryItem *item = self->getItem(); - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); if(item) { @@ -126,7 +125,7 @@ void LLPreviewAnim::playAnim( void *userdata ) { self->mPauseRequest = NULL; gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_START); - LLMotion* motion = avatarp->findMotion(itemID); + LLMotion* motion = gAgentAvatar->findMotion(itemID); if (motion) { motion->setDeactivateCallback(&endAnimCallback, (void *)(new LLHandle(self->getHandle()))); @@ -134,7 +133,7 @@ void LLPreviewAnim::playAnim( void *userdata ) } else { - avatarp->stopMotion(itemID); + gAgentAvatar->stopMotion(itemID); gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_STOP); } } @@ -159,9 +158,8 @@ void LLPreviewAnim::auditionAnim( void *userdata ) if (self->childGetValue("Anim audition btn").asBoolean() ) { self->mPauseRequest = NULL; - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - gAgent.getAvatarObject()->startMotion(item->getAssetUUID()); - LLMotion* motion = avatarp->findMotion(itemID); + gAgentAvatar->startMotion(item->getAssetUUID()); + LLMotion* motion = gAgentAvatar->findMotion(itemID); if (motion) { @@ -170,7 +168,7 @@ void LLPreviewAnim::auditionAnim( void *userdata ) } else { - gAgent.getAvatarObject()->stopMotion(itemID); + gAgentAvatar->stopMotion(itemID); gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_STOP); } } @@ -183,11 +181,9 @@ void LLPreviewAnim::onClose(bool app_quitting) if(item) { - gAgent.getAvatarObject()->stopMotion(item->getAssetUUID()); + gAgentAvatar->stopMotion(item->getAssetUUID()); gAgent.sendAnimationRequest(item->getAssetUUID(), ANIM_REQUEST_STOP); - - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - LLMotion* motion = avatarp->findMotion(item->getAssetUUID()); + LLMotion* motion = gAgentAvatar->findMotion(item->getAssetUUID()); if (motion) { diff --git a/indra/newview/llscrollingpanelparam.cpp b/indra/newview/llscrollingpanelparam.cpp index 95e12bf46f..b47b384308 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 ); - gAgent.getAvatarObject()->updateVisualParams(); + gAgentAvatar->updateVisualParams(); } } @@ -298,7 +298,7 @@ void LLScrollingPanelParam::onHintHeldDown( LLVisualParamHint* hint ) && new_percent < slider->getMaxValue()) { mWearable->setVisualParamWeight( hint->getVisualParam()->getID(), new_weight, FALSE); - gAgent.getAvatarObject()->updateVisualParams(); + gAgentAvatar->updateVisualParams(); slider->setValue( weightToPercent( new_weight ) ); } @@ -344,8 +344,7 @@ void LLScrollingPanelParam::onHintMaxMouseUp( void* userdata ) F32 elapsed_time = self->mMouseDownTimer.getElapsedTimeF32(); - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { LLVisualParamHint* hint = self->mHintMax; diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 69f9a7e6fa..26d1ec1d6c 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(gAgent.getAvatarObject()); + effectp->setSourceObject(gAgentAvatar); effectp->setTargetObject(object); effectp->setDuration(LL_HUD_DUR_SHORT); effectp->setColor(LLColor4U(gAgent.getEffectColor())); @@ -3619,7 +3619,7 @@ void LLSelectMgr::sendAttach(U8 attachment_point) { LLViewerObject* attach_object = mSelectedObjects->getFirstRootObject(); - if (!attach_object || !gAgent.getAvatarObject() || mSelectedObjects->mSelectType != SELECT_TYPE_WORLD) + if (!attach_object || !isAgentAvatarValid() || mSelectedObjects->mSelectType != SELECT_TYPE_WORLD) { return; } @@ -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(gAgent.getAvatarObject()->mAttachmentPoints, (S32)attachment_point, (LLViewerJointAttachment*)NULL)) + get_if_there(gAgentAvatar->mAttachmentPoints, (S32)attachment_point, (LLViewerJointAttachment*)NULL)) { sendListToRegions( "ObjectAttach", @@ -4911,10 +4911,9 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud) LLGLEnable blend(GL_BLEND); LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp && for_hud) + if (isAgentAvatarValid() && for_hud) { - LLBBox hud_bbox = avatarp->getHUDBBox(); + LLBBox hud_bbox = gAgentAvatar->getHUDBBox(); F32 cur_zoom = gAgentCamera.mHUDCurZoom; @@ -5023,7 +5022,7 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud) } } - if (avatarp && for_hud) + if (isAgentAvatarValid() && for_hud) { glMatrixMode(GL_PROJECTION); gGL.popMatrix(); @@ -5399,8 +5398,7 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color) if (volume) { F32 silhouette_thickness; - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp && is_hud_object) + if (isAgentAvatarValid() && is_hud_object) { silhouette_thickness = LLSelectMgr::sHighlightThickness / gAgentCamera.mHUDCurZoom; } @@ -5610,16 +5608,16 @@ void LLSelectMgr::updateSelectionCenter() { mSelectedObjects->mSelectType = getSelectTypeForObject(object); - if (mSelectedObjects->mSelectType == SELECT_TYPE_ATTACHMENT && gAgent.getAvatarObject()) + if (mSelectedObjects->mSelectType == SELECT_TYPE_ATTACHMENT && isAgentAvatarValid()) { - mPauseRequest = gAgent.getAvatarObject()->requestPause(); + mPauseRequest = gAgentAvatar->requestPause(); } else { mPauseRequest = NULL; } - if (mSelectedObjects->mSelectType != SELECT_TYPE_HUD && gAgent.getAvatarObject()) + if (mSelectedObjects->mSelectType != SELECT_TYPE_HUD && isAgentAvatarValid()) { // reset hud ZOOM gAgentCamera.mHUDTargetZoom = 1.f; @@ -5642,10 +5640,10 @@ void LLSelectMgr::updateSelectionCenter() LLViewerObject* object = node->getObject(); if (!object) continue; - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); + LLViewerObject *root = object->getRootEdit(); if (mSelectedObjects->mSelectType == SELECT_TYPE_WORLD && // not an attachment - !root->isChild(avatarp) && // not the object you're sitting on + !root->isChild(gAgentAvatar) && // 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 c6fba61886..e65da0022e 100644 --- a/indra/newview/llsidepanelappearance.cpp +++ b/indra/newview/llsidepanelappearance.cpp @@ -366,11 +366,10 @@ void LLSidepanelAppearance::fetchInventory() } } - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { - for (LLVOAvatar::attachment_map_t::const_iterator iter = avatarp->mAttachmentPoints.begin(); - iter != avatarp->mAttachmentPoints.end(); ++iter) + for (LLVOAvatar::attachment_map_t::const_iterator iter = gAgentAvatar->mAttachmentPoints.begin(); + iter != gAgentAvatar->mAttachmentPoints.end(); ++iter) { LLViewerJointAttachment* attachment = iter->second; if (!attachment) continue; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index edd03dc836..7ed095c68e 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1861,7 +1861,7 @@ bool idle_startup() if (gAgent.isFirstLogin() && !sInitialOutfit.empty() // registration set up an outfit && !sInitialOutfitGender.empty() // and a gender - && gAgent.getAvatarObject() // can't wear clothes without object + && isAgentAvatarValid() // can't wear clothes without object && !gAgent.isGenderChosen() ) // nothing already loading { // Start loading the wearables, textures, gestures @@ -1869,7 +1869,7 @@ bool idle_startup() } // wait precache-delay and for agent's avatar or a lot longer. - if(((timeout_frac > 1.f) && gAgent.getAvatarObject()) + if(((timeout_frac > 1.f) && isAgentAvatarValid()) || (timeout_frac > 3.f)) { LLStartUp::setStartupState( STATE_WEARABLES_WAIT ); @@ -1925,8 +1925,8 @@ bool idle_startup() if (gAgent.isFirstLogin()) { // wait for avatar to be completely loaded - if (gAgent.getAvatarObject() - && gAgent.getAvatarObject()->isFullyLoaded()) + if (isAgentAvatarValid() + && gAgentAvatar->isFullyLoaded()) { //llinfos << "avatar fully loaded" << llendl; LLStartUp::setStartupState( STATE_CLEANUP ); diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index 3052134d4f..add1cea8cc 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -445,11 +445,9 @@ void LLStatusBar::setHealth(S32 health) { if (mHealth > (health + gSavedSettings.getF32("UISndHealthReductionThreshold"))) { - LLVOAvatar *me; - - if ((me = gAgent.getAvatarObject())) + if (isAgentAvatarValid()) { - if (me->getSex() == SEX_FEMALE) + if (gAgentAvatar->getSex() == SEX_FEMALE) { make_ui_sound("UISndHealthReductionF"); } diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp index 21c928282a..6461ec8221 100644 --- a/indra/newview/lltexlayer.cpp +++ b/indra/newview/lltexlayer.cpp @@ -284,8 +284,6 @@ void LLTexLayerSetBuffer::readBackAndUpload() llinfos << "Baked " << mTexLayerSet->getBodyRegion() << llendl; LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_BAKES); - llassert( gAgent.getAvatarObject() == mTexLayerSet->getAvatar() ); - // We won't need our caches since we're baked now. (Techically, we won't // really be baked until this image is sent to the server and the Avatar // Appearance message is received.) @@ -352,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(gAgent.getAvatarObject(), this->mTexLayerSet, asset_id); + new LLBakedUploadData(gAgentAvatar, this->mTexLayerSet, asset_id); mUploadID = asset_id; // upload the image @@ -409,12 +407,10 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, { LLBakedUploadData* baked_upload_data = (LLBakedUploadData*)userdata; - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (0 == result && - avatarp && - !avatarp->isDead() && - baked_upload_data->mAvatar == avatarp && // Sanity check: only the user's avatar should be uploading textures. + isAgentAvatarValid() && + !gAgentAvatar->isDead() && + baked_upload_data->mAvatar == gAgentAvatar && // Sanity check: only the user's avatar should be uploading textures. baked_upload_data->mTexLayerSet->hasComposite() ) { @@ -439,11 +435,11 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, if (result >= 0) { - LLVOAvatarDefines::ETextureIndex baked_te = avatarp->getBakedTE(layerset_buffer->mTexLayerSet); + LLVOAvatarDefines::ETextureIndex baked_te = gAgentAvatar->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; - avatarp->setNewBakedTexture(baked_te, uuid); + gAgentAvatar->setNewBakedTexture(baked_te, uuid); } else { @@ -457,7 +453,7 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid, llinfos << "Received baked texture out of date, ignored." << llendl; } - avatarp->dirtyMesh(); + gAgentAvatar->dirtyMesh(); } else { diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 1f6f840c45..f9d0c7c307 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(gAgent.getAvatarObject()); + effectp->setSourceObject(gAgentAvatar); 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(gAgent.getAvatarObject()); + effectp->setSourceObject(gAgentAvatar); 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(gAgent.getAvatarObject()); + effectp->setSourceObject(gAgentAvatar); 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(gAgent.getAvatarObject()); + effectp->setSourceObject(gAgentAvatar); effectp->setTargetObject(gObjectList.findObject(to_agent)); effectp->setDuration(LL_HUD_DUR_SHORT); effectp->setColor(LLColor4U(gAgent.getEffectColor())); @@ -1547,11 +1547,7 @@ void LLToolDragAndDrop::giveInventoryCategory(const LLUUID& to_agent, llinfos << "LLToolDragAndDrop::giveInventoryCategory() - " << cat->getUUID() << llendl; - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) - { - return; - } + if (!isAgentAvatarValid()) return; // Test out how many items are being given. LLViewerInventoryCategory::cat_array_t cats; @@ -1739,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(gAgent.getAvatarObject()); + effectp->setSourceObject(gAgentAvatar); effectp->setTargetObject(gObjectList.findObject(to_agent)); effectp->setDuration(LL_HUD_DUR_SHORT); effectp->setColor(LLColor4U(gAgent.getEffectColor())); @@ -1765,17 +1761,13 @@ BOOL LLToolDragAndDrop::isInventoryGiveAcceptable(LLInventoryItem* item) BOOL copyable = FALSE; if (item->getPermissions().allowCopyBy(gAgent.getID())) copyable = TRUE; - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) - { - return FALSE; - } + if (!isAgentAvatarValid()) return FALSE; BOOL acceptable = TRUE; switch(item->getType()) { case LLAssetType::AT_OBJECT: - if (avatarp->isWearingAttachment(item->getUUID())) + if (gAgentAvatar->isWearingAttachment(item->getUUID())) { acceptable = FALSE; } @@ -1812,17 +1804,13 @@ BOOL LLToolDragAndDrop::isInventoryGroupGiveAcceptable(LLInventoryItem* item) return FALSE; } - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) - { - return FALSE; - } + if (!isAgentAvatarValid()) return FALSE; BOOL acceptable = TRUE; switch(item->getType()) { case LLAssetType::AT_OBJECT: - if (avatarp->isWearingAttachment(item->getUUID())) + if (gAgentAvatar->isWearingAttachment(item->getUUID())) { acceptable = FALSE; } @@ -1857,12 +1845,10 @@ EAcceptance LLToolDragAndDrop::willObjectAcceptInventory(LLViewerObject* obj, LL // gAgent.getGroupID()) // && (obj->mPermModify || obj->mFlagAllowInventoryAdd)); BOOL worn = FALSE; - LLVOAvatarSelf* avatarp = NULL; switch(item->getType()) { case LLAssetType::AT_OBJECT: - avatarp = gAgent.getAvatarObject(); - if (avatarp && avatarp->isWearingAttachment(item->getUUID())) + if (isAgentAvatarValid() && gAgentAvatar->isWearingAttachment(item->getUUID())) { worn = TRUE; } @@ -2013,8 +1999,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezAttachmentFromInv( } // must not be already wearing it - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp || avatarp->isWearingAttachment(item->getUUID())) + if (!isAgentAvatarValid() || gAgentAvatar->isWearingAttachment(item->getUUID())) { return ACCEPT_NO; } @@ -2055,8 +2040,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezObjectOnLand( locateInventory(item, cat); if (!item || !item->isComplete()) return ACCEPT_NO; - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp || avatarp->isWearingAttachment(item->getUUID())) + if (!isAgentAvatarValid() || gAgentAvatar->isWearingAttachment(item->getUUID())) { return ACCEPT_NO; } @@ -2117,8 +2101,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezObjectOnObject( LLViewerInventoryCategory* cat; locateInventory(item, cat); if (!item || !item->isComplete()) return ACCEPT_NO; - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp || avatarp->isWearingAttachment(item->getUUID())) + if (!isAgentAvatarValid() || gAgentAvatar->isWearingAttachment(item->getUUID())) { return ACCEPT_NO; } @@ -2267,7 +2250,7 @@ EAcceptance LLToolDragAndDrop::dad3dTextureObject( // VEFFECT: SetTexture LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE); - effectp->setSourceObject(gAgent.getAvatarObject()); + effectp->setSourceObject(gAgentAvatar); effectp->setTargetObject(obj); effectp->setDuration(LL_HUD_DUR_SHORT); effectp->setColor(LLColor4U(gAgent.getEffectColor())); @@ -2627,13 +2610,12 @@ EAcceptance LLToolDragAndDrop::dad3dGiveInventoryObject( // cannot give away no-transfer objects return ACCEPT_NO; } - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp && avatarp->isWearingAttachment(item->getUUID())) + if (isAgentAvatarValid() && gAgentAvatar->isWearingAttachment(item->getUUID())) { // You can't give objects that are attached to you return ACCEPT_NO; } - if (obj && avatarp) + if (obj && isAgentAvatarValid()) { if (drop) { diff --git a/indra/newview/lltoolfocus.cpp b/indra/newview/lltoolfocus.cpp index 363df74379..b362d564df 100644 --- a/indra/newview/lltoolfocus.cpp +++ b/indra/newview/lltoolfocus.cpp @@ -173,8 +173,7 @@ void LLToolCamera::pickCallback(const LLPickInfo& pick_info) BOOL good_customize_avatar_hit = FALSE; if( hit_obj ) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp &&(hit_obj == avatarp)) + if (isAgentAvatarValid() && (hit_obj == gAgentAvatar)) { // It's you good_customize_avatar_hit = TRUE; @@ -222,8 +221,8 @@ void LLToolCamera::pickCallback(const LLPickInfo& pick_info) gAgentCamera.cameraThirdPerson() && gViewerWindow->getLeftMouseDown() && !gSavedSettings.getBOOL("FreezeTime") && - (hit_obj == gAgent.getAvatarObject() || - (hit_obj && hit_obj->isAttachment() && LLVOAvatar::findAvatarFromAttachment(hit_obj)->isSelf()))) + (hit_obj == gAgentAvatar || + (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 008cf16f2e..982d55914d 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() == gAgent.getAvatarObject()->getRoot()) + objectp->getRoot() == gAgentAvatar->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 c42c47c486..67d696d7d7 100644 --- a/indra/newview/lltoolmorph.cpp +++ b/indra/newview/lltoolmorph.cpp @@ -139,22 +139,20 @@ void LLVisualParamHint::requestHintUpdates( LLVisualParamHint* exception1, LLVis BOOL LLVisualParamHint::needsRender() { - return mNeedsUpdate && mDelayFrames-- <= 0 && !gAgent.getAvatarObject()->mAppearanceAnimating && mAllowsUpdates; + return mNeedsUpdate && mDelayFrames-- <= 0 && !gAgentAvatar->mAppearanceAnimating && mAllowsUpdates; } void LLVisualParamHint::preRender(BOOL clear_depth) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - mLastParamWeight = mVisualParam->getWeight(); mVisualParam->setWeight(mVisualParamWeight, FALSE); - avatarp->setVisualParamWeight(mVisualParam->getID(), mVisualParamWeight, FALSE); - avatarp->setVisualParamWeight("Blink_Left", 0.f); - avatarp->setVisualParamWeight("Blink_Right", 0.f); - avatarp->updateComposites(); - avatarp->updateVisualParams(); - avatarp->updateGeometry(avatarp->mDrawable); - avatarp->updateLOD(); + 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(); LLViewerDynamicTexture::preRender(clear_depth); } @@ -165,7 +163,6 @@ void LLVisualParamHint::preRender(BOOL clear_depth) BOOL LLVisualParamHint::render() { LLVisualParamReset::sDirty = TRUE; - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); gGL.pushUIMatrix(); gGL.loadUIIdentity(); @@ -196,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*)avatarp->getJoint( cam_target_mesh_name ); + cam_target_joint = (LLViewerJointMesh*)gAgentAvatar->getJoint( cam_target_mesh_name ); } if( !cam_target_joint ) { @@ -204,11 +201,11 @@ BOOL LLVisualParamHint::render() } if( !cam_target_joint ) { - cam_target_joint = (LLViewerJointMesh*)avatarp->getJoint("mHead"); + cam_target_joint = (LLViewerJointMesh*)gAgentAvatar->getJoint("mHead"); } LLQuaternion avatar_rotation; - LLJoint* root_joint = avatarp->getRootJoint(); + LLJoint* root_joint = gAgentAvatar->getRootJoint(); if( root_joint ) { avatar_rotation = root_joint->getWorldRotation(); @@ -236,17 +233,17 @@ BOOL LLVisualParamHint::render() LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, FALSE); - if (avatarp->mDrawable.notNull()) + if (gAgentAvatar->mDrawable.notNull()) { - LLDrawPoolAvatar *avatarPoolp = (LLDrawPoolAvatar *)avatarp->mDrawable->getFace(0)->getPool(); + LLDrawPoolAvatar *avatarPoolp = (LLDrawPoolAvatar *)gAgentAvatar->mDrawable->getFace(0)->getPool(); LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE); gGL.setAlphaRejectSettings(LLRender::CF_ALWAYS); gGL.setSceneBlendType(LLRender::BT_REPLACE); - avatarPoolp->renderAvatars(avatarp); // renders only one avatar + avatarPoolp->renderAvatars(gAgentAvatar); // renders only one avatar gGL.setSceneBlendType(LLRender::BT_ALPHA); gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } - avatarp->setVisualParamWeight(mVisualParam->getID(), mLastParamWeight); + gAgentAvatar->setVisualParamWeight(mVisualParam->getID(), mLastParamWeight); mVisualParam->setWeight(mLastParamWeight, FALSE); gGL.color4f(1,1,1,1); mGLTexturep->setGLTextureCreated(true); @@ -297,10 +294,9 @@ BOOL LLVisualParamReset::render() { if (sDirty) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - avatarp->updateComposites(); - avatarp->updateVisualParams(); - avatarp->updateGeometry(avatarp->mDrawable); + gAgentAvatar->updateComposites(); + gAgentAvatar->updateVisualParams(); + gAgentAvatar->updateGeometry(gAgentAvatar->mDrawable); sDirty = FALSE; } diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index c80db89ef0..580b483b6b 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -206,8 +206,7 @@ BOOL LLToolPie::pickLeftMouseDownCallback() break; case CLICK_ACTION_SIT: { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp && !avatarp->isSitting()) // agent not already sitting + if (isAgentAvatarValid() && !gAgentAvatar->isSitting()) // agent not already sitting { handle_object_sit_or_stand(); // put focus in world when sitting on an object @@ -331,7 +330,7 @@ BOOL LLToolPie::pickLeftMouseDownCallback() } object = (LLViewerObject*)object->getParent(); } - if (object && object == gAgent.getAvatarObject()) + if (object && object == gAgentAvatar) { // we left clicked on avatar, switch to focus mode LLToolMgr::getInstance()->setTransientTool(LLToolCamera::getInstance()); @@ -413,8 +412,7 @@ ECursorType cursor_from_object(LLViewerObject* object) { case CLICK_ACTION_SIT: { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp && !avatarp->isSitting()) // not already sitting? + if (isAgentAvatarValid() && !gAgentAvatar->isSitting()) // not already sitting? { cursor = UI_CURSOR_TOOLSIT; } diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp index b10ee590e0..847852f8af 100644 --- a/indra/newview/lltoolplacer.cpp +++ b/indra/newview/lltoolplacer.cpp @@ -62,6 +62,7 @@ #include "llviewerobjectlist.h" #include "llviewercamera.h" #include "llviewerstats.h" +#include "llvoavatarself.h" // linden library headers #include "llprimitive.h" @@ -433,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*)gAgent.getAvatarObject()); + effectp->setSourceObject((LLViewerObject*)gAgentAvatar); 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 6e0c6663e9..a45bb2a4de 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) != gAgent.getAvatarObject() && // and it's not one of your attachments - object != gAgent.getAvatarObject()) // and it's not you + LLVOAvatar::findAvatarFromAttachment(object) != gAgentAvatar && // and it's not one of your attachments + object != gAgentAvatar) // 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 7bbe40a486..f0f911b996 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -345,9 +345,9 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) const F32 TELEPORT_ARRIVAL_DELAY = 2.f; // Time to preload the world before raising the curtain after we've actually already arrived. S32 attach_count = 0; - if (gAgent.getAvatarObject()) + if (isAgentAvatarValid()) { - attach_count = gAgent.getAvatarObject()->getAttachmentCount(); + attach_count = gAgentAvatar->getAttachmentCount(); } F32 teleport_save_time = TELEPORT_EXPIRY + TELEPORT_EXPIRY_PER_ATTACHMENT * attach_count; F32 teleport_elapsed = gTeleportDisplayTimer.getElapsedTimeF32(); @@ -1032,11 +1032,10 @@ LLRect get_whole_screen_region() bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::matrix4f &model) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp && avatarp->hasHUDAttachment()) + if (isAgentAvatarValid() && gAgentAvatar->hasHUDAttachment()) { F32 zoom_level = gAgentCamera.mHUDCurZoom; - LLBBox hud_bbox = avatarp->getHUDBBox(); + LLBBox hud_bbox = gAgentAvatar->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); @@ -1300,7 +1299,7 @@ void render_ui_2d() gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); // render outline for HUD - if (gAgent.getAvatarObject() && gAgentCamera.mHUDCurZoom < 0.98f) + if (isAgentAvatarValid() && gAgentCamera.mHUDCurZoom < 0.98f) { glPushMatrix(); S32 half_width = (gViewerWindow->getWorldViewWidthScaled() / 2); diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp index 00046ed3dd..d899c72e0e 100644 --- a/indra/newview/llviewerkeyboard.cpp +++ b/indra/newview/llviewerkeyboard.cpp @@ -869,7 +869,6 @@ S32 LLViewerKeyboard::loadBindings(const std::string& filename) EKeyboardMode LLViewerKeyboard::getMode() { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); if ( gAgentCamera.cameraMouselook() ) { return MODE_FIRST_PERSON; @@ -878,7 +877,7 @@ EKeyboardMode LLViewerKeyboard::getMode() { return MODE_EDIT_AVATAR; } - else if (avatarp && avatarp->isSitting()) + else if (isAgentAvatarValid() && gAgentAvatar->isSitting()) { return MODE_SITTING; } diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 2fcd3f1114..49a3ed14dc 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 != gAgent.getAvatarObject()) + if ((NULL != avatar) && (avatar != gAgentAvatar)) { result = true; break; diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index b8a3232c29..f838d1436d 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -2692,11 +2692,10 @@ class LLSelfEnableRemoveAllAttachments : public view_listener_t bool handleEvent(const LLSD& userdata) { bool new_value = false; - if (gAgent.getAvatarObject()) + if (isAgentAvatarValid()) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); - iter != avatarp->mAttachmentPoints.end(); ) + for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); + iter != gAgentAvatar->mAttachmentPoints.end(); ) { LLVOAvatar::attachment_map_t::iterator curiter = iter++; LLViewerJointAttachment* attachment = curiter->second; @@ -2824,9 +2823,9 @@ bool handle_go_to() LLViewerParcelMgr::getInstance()->deselectLand(); - if (gAgent.getAvatarObject() && !gSavedSettings.getBOOL("AutoPilotLocksCamera")) + if (isAgentAvatarValid() && !gSavedSettings.getBOOL("AutoPilotLocksCamera")) { - gAgentCamera.setFocusGlobal(gAgentCamera.getFocusTargetGlobal(), gAgent.getAvatarObject()->getID()); + gAgentCamera.setFocusGlobal(gAgentCamera.getFocusTargetGlobal(), gAgentAvatar->getID()); } else { @@ -3365,7 +3364,7 @@ class LLSelfStandUp : public view_listener_t bool enable_standup_self() { - bool new_value = gAgent.getAvatarObject() && gAgent.getAvatarObject()->isSitting(); + bool new_value = isAgentAvatarValid() && gAgentAvatar->isSitting(); return new_value; } @@ -3694,9 +3693,9 @@ class LLLandSit : public view_listener_t LLVector3d posGlobal = LLToolPie::getInstance()->getPick().mPosGlobal; LLQuaternion target_rot; - if (gAgent.getAvatarObject()) + if (isAgentAvatarValid()) { - target_rot = gAgent.getAvatarObject()->getRotation(); + target_rot = gAgentAvatar->getRotation(); } else { @@ -4587,13 +4586,9 @@ BOOL sitting_on_selection() } // Need to determine if avatar is sitting on this object - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) - { - return FALSE; - } + if (!isAgentAvatarValid()) return FALSE; - return (avatarp->isSitting() && avatarp->getRoot() == root_object); + return (gAgentAvatar->isSitting() && gAgentAvatar->getRoot() == root_object); } class LLToolsSaveToInventory : public view_listener_t @@ -5846,7 +5841,7 @@ private: S32 index = userdata.asInteger(); LLViewerJointAttachment* attachment_point = NULL; if (index > 0) - attachment_point = get_if_there(gAgent.getAvatarObject()->mAttachmentPoints, index, (LLViewerJointAttachment*)NULL); + attachment_point = get_if_there(gAgentAvatar->mAttachmentPoints, index, (LLViewerJointAttachment*)NULL); confirm_replace_attachment(0, attachment_point); } return true; @@ -5867,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 = gAgent.getAvatarObject()->mAttachmentPoints.begin(); - iter != gAgent.getAvatarObject()->mAttachmentPoints.end(); ++iter) + for (LLVOAvatar::attachment_map_t::const_iterator iter = gAgentAvatar->mAttachmentPoints.begin(); + iter != gAgentAvatar->mAttachmentPoints.end(); ++iter) { if (iter->second == attachment) { @@ -5993,7 +5988,7 @@ class LLAttachmentDetachFromPoint : public view_listener_t { bool handleEvent(const LLSD& user_data) { - const LLViewerJointAttachment *attachment = get_if_there(gAgent.getAvatarObject()->mAttachmentPoints, user_data.asInteger(), (LLViewerJointAttachment*)NULL); + const LLViewerJointAttachment *attachment = get_if_there(gAgentAvatar->mAttachmentPoints, user_data.asInteger(), (LLViewerJointAttachment*)NULL); if (attachment->getNumObjects() > 0) { gMessageSystem->newMessage("ObjectDetach"); @@ -6021,7 +6016,7 @@ static bool onEnableAttachmentLabel(LLUICtrl* ctrl, const LLSD& data) LLMenuItemGL* menu = dynamic_cast(ctrl); if (menu) { - const LLViewerJointAttachment *attachment = get_if_there(gAgent.getAvatarObject()->mAttachmentPoints, data["index"].asInteger(), (LLViewerJointAttachment*)NULL); + const LLViewerJointAttachment *attachment = get_if_there(gAgentAvatar->mAttachmentPoints, data["index"].asInteger(), (LLViewerJointAttachment*)NULL); if (attachment) { label = data["label"].asString(); @@ -6139,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(gAgent.getAvatarObject()->mAttachmentPoints, attachmentID, (LLViewerJointAttachment*)NULL); + attachment = get_if_there(gAgentAvatar->mAttachmentPoints, attachmentID, (LLViewerJointAttachment*)NULL); if (attachment) { @@ -6271,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 = gAgent.getAvatarObject()->mAttachmentPoints.find(user_data.asInteger()); - if (found_it != gAgent.getAvatarObject()->mAttachmentPoints.end()) + LLVOAvatar::attachment_map_t::iterator found_it = gAgentAvatar->mAttachmentPoints.find(user_data.asInteger()); + if (found_it != gAgentAvatar->mAttachmentPoints.end()) { enable = found_it->second->getNumObjects() > 0; } @@ -6489,15 +6484,10 @@ void handle_toggle_pg(void*) void handle_dump_attachments(void*) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if(!avatarp) - { - llinfos << "NO AVATAR" << llendl; - return; - } + if(!isAgentAvatarValid()) return; - for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); - iter != avatarp->mAttachmentPoints.end(); ) + for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); + iter != gAgentAvatar->mAttachmentPoints.end(); ) { LLVOAvatar::attachment_map_t::iterator curiter = iter++; LLViewerJointAttachment* attachment = curiter->second; @@ -6917,7 +6907,7 @@ void reload_vertex_shader(void *) void handle_dump_avatar_local_textures(void*) { - gAgent.getAvatarObject()->dumpLocalTextures(); + gAgentAvatar->dumpLocalTextures(); } void handle_dump_timers() @@ -6937,86 +6927,83 @@ void handle_debug_avatar_textures(void*) void handle_grab_texture(void* data) { ETextureIndex tex_index = (ETextureIndex)((intptr_t)data); - const LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp) - { - // MULTI-WEARABLE: change to support an index - const LLUUID& asset_id = avatarp->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; - const LLUUID folder_id = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(asset_type)); - if(folder_id.notNull()) - { - std::string name = "Unknown"; - const LLVOAvatarDictionary::TextureEntry *texture_dict = LLVOAvatarDictionary::getInstance()->getTexture(tex_index); - if (texture_dict->mIsBakedTexture) - { - EBakedTextureIndex baked_index = texture_dict->mBakedTextureIndex; - name = "Baked " + LLVOAvatarDictionary::getInstance()->getBakedTexture(baked_index)->mNameCapitalized; - } - name += " Texture"; - - LLUUID item_id; - item_id.generate(); - LLPermissions perm; - perm.init(gAgentID, - gAgentID, - LLUUID::null, - LLUUID::null); - U32 next_owner_perm = PERM_MOVE | PERM_TRANSFER; - perm.initMasks(PERM_ALL, - PERM_ALL, - PERM_NONE, - PERM_NONE, - next_owner_perm); - time_t creation_date_now = time_corrected(); - LLPointer item - = new LLViewerInventoryItem(item_id, - folder_id, - perm, - asset_id, - asset_type, - inv_type, - name, - LLStringUtil::null, - LLSaleInfo::DEFAULT, - LLInventoryItem::II_FLAGS_NONE, - creation_date_now); - - item->updateServer(TRUE); - gInventory.updateItem(item); - gInventory.notifyObservers(); - - // Show the preview panel for textures to let - // user know that the image is now in inventory. - LLInventoryPanel *active_panel = LLInventoryPanel::getActiveInventoryPanel(); - if(active_panel) - { - LLFocusableElement* focus_ctrl = gFocusMgr.getKeyboardFocus(); - - active_panel->setSelection(item_id, TAKE_FOCUS_NO); - active_panel->openSelected(); - //LLFloaterInventory::dumpSelectionInformation((void*)view); - // restore keyboard focus - gFocusMgr.setKeyboardFocus(focus_ctrl); - } - } - else - { - llwarns << "Can't find a folder to put it in" << llendl; + if (!isAgentAvatarValid()) return; + + // MULTI-WEARABLE: change to support an index + const LLUUID& asset_id = gAgentAvatar->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; + const LLUUID folder_id = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(asset_type)); + if(folder_id.notNull()) + { + std::string name = "Unknown"; + const LLVOAvatarDictionary::TextureEntry *texture_dict = LLVOAvatarDictionary::getInstance()->getTexture(tex_index); + if (texture_dict->mIsBakedTexture) + { + EBakedTextureIndex baked_index = texture_dict->mBakedTextureIndex; + name = "Baked " + LLVOAvatarDictionary::getInstance()->getBakedTexture(baked_index)->mNameCapitalized; + } + name += " Texture"; + + LLUUID item_id; + item_id.generate(); + LLPermissions perm; + perm.init(gAgentID, + gAgentID, + LLUUID::null, + LLUUID::null); + U32 next_owner_perm = PERM_MOVE | PERM_TRANSFER; + perm.initMasks(PERM_ALL, + PERM_ALL, + PERM_NONE, + PERM_NONE, + next_owner_perm); + time_t creation_date_now = time_corrected(); + LLPointer item + = new LLViewerInventoryItem(item_id, + folder_id, + perm, + asset_id, + asset_type, + inv_type, + name, + LLStringUtil::null, + LLSaleInfo::DEFAULT, + LLInventoryItem::II_FLAGS_NONE, + creation_date_now); + + item->updateServer(TRUE); + gInventory.updateItem(item); + gInventory.notifyObservers(); + + // Show the preview panel for textures to let + // user know that the image is now in inventory. + LLInventoryPanel *active_panel = LLInventoryPanel::getActiveInventoryPanel(); + if(active_panel) + { + LLFocusableElement* focus_ctrl = gFocusMgr.getKeyboardFocus(); + + active_panel->setSelection(item_id, TAKE_FOCUS_NO); + active_panel->openSelected(); + //LLFloaterInventory::dumpSelectionInformation((void*)view); + // restore keyboard focus + gFocusMgr.setKeyboardFocus(focus_ctrl); } } + else + { + llwarns << "Can't find a folder to put it in" << llendl; + } } BOOL enable_grab_texture(void* data) { ETextureIndex index = (ETextureIndex)((intptr_t)data); - const LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { // MULTI-WEARABLE: - return avatarp->canGrabLocalTexture(index,0); + return gAgentAvatar->canGrabLocalTexture(index,0); } return FALSE; } @@ -7227,12 +7214,11 @@ void handle_buy_currency_test(void*) void handle_rebake_textures(void*) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) return; + if (!isAgentAvatarValid()) return; // Slam pending upload count to "unstick" things bool slam_for_debug = true; - avatarp->forceBakeAllTextures(slam_for_debug); + gAgentAvatar->forceBakeAllTextures(slam_for_debug); } void toggle_visibility(void* user_data) diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 1ead7bac10..96bb687bbb 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -3002,9 +3002,9 @@ void process_teleport_finish(LLMessageSystem* msg, void**) gAgent.setRegion(regionp); gObjectList.shiftObjects(shift_vector); - if (gAgent.getAvatarObject()) + if (isAgentAvatarValid()) { - gAgent.getAvatarObject()->clearChatText(); + gAgentAvatar->clearChatText(); gAgentCamera.slamLookAt(look_at); } gAgent.setPositionAgent(pos); @@ -3084,8 +3084,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) std::string version_channel; msg->getString("SimData", "ChannelVersion", version_channel); - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) + if (!isAgentAvatarValid()) { // Could happen if you were immediately god-teleported away on login, // maybe other cases. Continue, but warn. @@ -3139,7 +3138,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) // know what you look like. gAgent.sendAgentSetAppearance(); - if (avatarp) + if (isAgentAvatarValid()) { // Chat the "back" SLURL. (DEV-4907) @@ -3152,9 +3151,9 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) LLNotificationsUtil::add("SystemMessageTip", args); // Set the new position - avatarp->setPositionAgent(agent_pos); - avatarp->clearChat(); - avatarp->slamPosition(); + gAgentAvatar->setPositionAgent(agent_pos); + gAgentAvatar->clearChat(); + gAgentAvatar->slamPosition(); } } else @@ -3214,9 +3213,9 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) gAgent.clearBusy(); } - if (avatarp) + if (isAgentAvatarValid()) { - avatarp->mFootPlane.clearVec(); + gAgentAvatar->mFootPlane.clearVec(); } // send walk-vs-run status @@ -4031,7 +4030,7 @@ void process_avatar_animation(LLMessageSystem *mesgsys, void **user_data) //clear animation flags avatarp = (LLVOAvatar *)gObjectList.findObject(uuid); - if (!avatarp) + if (!isAgentAvatarValid()) { // no agent by this ID...error? LL_WARNS("Messaging") << "Received animation state for unknown avatar" << uuid << LL_ENDL; @@ -4165,9 +4164,7 @@ void process_avatar_sit_response(LLMessageSystem *mesgsys, void **user_data) BOOL force_mouselook; mesgsys->getBOOLFast(_PREHASH_SitTransform, _PREHASH_ForceMouselook, force_mouselook); - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - - if (avatarp && dist_vec_squared(camera_eye, camera_at) > 0.0001f) + if (isAgentAvatarValid() && dist_vec_squared(camera_eye, camera_at) > 0.0001f) { gAgentCamera.setSitCamera(sitObjectID, camera_eye, camera_at); } @@ -4178,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 || (avatarp && avatarp->isSitting() && avatarp->getRoot() == object->getRoot())) + if (!use_autopilot || isAgentAvatarValid() && gAgentAvatar->isSitting() && gAgentAvatar->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 abcb7e5452..f3eb75bcd0 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -134,7 +134,15 @@ LLViewerObject *LLViewerObject::createObject(const LLUUID &id, const LLPCode pco { if (id == gAgentID) { - res = new LLVOAvatarSelf(id, pcode, regionp); + if (!gAgentAvatar) + { + gAgentAvatar = new LLVOAvatarSelf(id, pcode, regionp); + } + else + { + gAgentAvatar->updateRegion(regionp); + } + res = gAgentAvatar; } else { @@ -223,7 +231,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe mClickAction(0), mAttachmentItemID(LLUUID::null) { - if(!is_global) + if (!is_global) { llassert(mRegionp); } @@ -235,7 +243,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe mPositionRegion = LLVector3(0.f, 0.f, 0.f); - if(!is_global) + if (!is_global && mRegionp) { mPositionAgent = mRegionp->getOriginAgent(); } @@ -377,11 +385,10 @@ void LLViewerObject::markDead() if (flagAnimSource()) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp && !avatarp->isDead()) + if (isAgentAvatarValid()) { // stop motions associated with this object - avatarp->stopMotionFromSource(mID); + gAgentAvatar->stopMotionFromSource(mID); } } @@ -4920,7 +4927,6 @@ void LLViewerObject::setIncludeInSearch(bool include_in_search) void LLViewerObject::setRegion(LLViewerRegion *regionp) { - llassert(regionp); mLatestRecvPacketID = 0; mRegionp = regionp; diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 64a7b2166b..eb966a1535 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -474,7 +474,6 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, if (objectp->getRegion() != regionp) { // Object changed region, so update it - objectp->setRegion(regionp); objectp->updateRegion(regionp); // for LLVOAvatar } } @@ -895,6 +894,13 @@ 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) + { + objectp->setRegion(NULL); + return FALSE; + } + // When we're killing objects, all we do is mark them as dead. // We clean up the dead objects later. @@ -1210,11 +1216,10 @@ void LLViewerObjectList::generatePickList(LLCamera &camera) } // add all hud objects to pick list - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { - for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); - iter != avatarp->mAttachmentPoints.end(); ) + for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); + iter != gAgentAvatar->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 6d2bbb27ee..4b6ac07a94 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -365,9 +365,9 @@ public: agent_center_text = llformat("AgentCenter %f %f %f", (F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ])); - if (gAgent.getAvatarObject()) + if (isAgentAvatarValid()) { - tvector = gAgent.getPosGlobalFromAgent(gAgent.getAvatarObject()->mRoot.getWorldPosition()); + tvector = gAgent.getPosGlobalFromAgent(gAgentAvatar->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 = gAgent.getAvatarObject()->getHUDBBox(); + LLBBox hud_bbox = gAgentAvatar->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 bb69622135..8e9e15352a 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -755,11 +755,6 @@ LLVOAvatar::~LLVOAvatar() { lldebugs << "LLVOAvatar Destructor (0x" << this << ") id:" << mID << llendl; - if (isSelf()) - { - gAgent.setAvatarObject(NULL); - } - mRoot.removeAllChildren(); deleteAndClearArray(mSkeleton); @@ -965,15 +960,14 @@ void LLVOAvatar::dumpBakedStatus() //static void LLVOAvatar::restoreGL() { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) return; + if (!isAgentAvatarValid()) return; - avatarp->setCompositeUpdatesEnabled(TRUE); - for (U32 i = 0; i < avatarp->mBakedTextureDatas.size(); i++) + gAgentAvatar->setCompositeUpdatesEnabled(TRUE); + for (U32 i = 0; i < gAgentAvatar->mBakedTextureDatas.size(); i++) { - avatarp->invalidateComposite(avatarp->mBakedTextureDatas[i].mTexLayerSet, FALSE); + gAgentAvatar->invalidateComposite(gAgentAvatar->mBakedTextureDatas[i].mTexLayerSet, FALSE); } - avatarp->updateMeshTextures(); + gAgentAvatar->updateMeshTextures(); } //static @@ -2085,7 +2079,7 @@ U32 LLVOAvatar::processUpdateMessage(LLMessageSystem *mesgsys, if(retval & LLViewerObject::INVALID_UPDATE) { - if(this == gAgent.getAvatarObject()) + if (isSelf()) { //tell sim to cancel this update gAgent.teleportViaLocation(gAgent.getPositionGlobal()); @@ -6859,7 +6853,6 @@ void LLVOAvatar::useBakedTexture( const LLUUID& id ) // static void LLVOAvatar::dumpArchetypeXML( void* ) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); LLAPRFile outfile; outfile.open(gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,"new archetype.xml"), LL_APR_WB ); apr_file_t* file = outfile.getFileHandle() ; @@ -6878,7 +6871,7 @@ void LLVOAvatar::dumpArchetypeXML( void* ) const std::string& wearable_name = LLWearableDictionary::getTypeName((EWearableType)type); apr_file_printf( file, "\n\t\t\n", wearable_name.c_str() ); - for (LLVisualParam* param = avatarp->getFirstVisualParam(); param; param = avatarp->getNextVisualParam()) + for (LLVisualParam* param = gAgentAvatar->getFirstVisualParam(); param; param = gAgentAvatar->getNextVisualParam()) { LLViewerVisualParam* viewer_param = (LLViewerVisualParam*)param; if( (viewer_param->getWearableType() == type) && @@ -6894,7 +6887,7 @@ void LLVOAvatar::dumpArchetypeXML( void* ) if (LLVOAvatarDictionary::getTEWearableType((ETextureIndex)te) == type) { // MULTIPLE_WEARABLES: extend to multiple wearables? - LLViewerTexture* te_image = ((LLVOAvatar*)avatarp)->getImage((ETextureIndex)te, 0); + LLViewerTexture* te_image = ((LLVOAvatar *)(gAgentAvatar))->getImage((ETextureIndex)te, 0); if( te_image ) { std::string uuid_str; diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index e3583b4d6b..0183061c0e 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -67,6 +67,14 @@ #include +LLVOAvatarSelf *gAgentAvatar = NULL; +BOOL isAgentAvatarValid() +{ + return (gAgentAvatar && + (gAgentAvatar->getRegion() != NULL) && + (!gAgentAvatar->isDead())); +} + using namespace LLVOAvatarDefines; /********************************************************************************* @@ -133,7 +141,6 @@ LLVOAvatarSelf::LLVOAvatarSelf(const LLUUID& id, mLastRegionHandle(0), mRegionCrossingCount(0) { - gAgent.setAvatarObject(this); gAgentWearables.setAvatarObject(this); lldebugs << "Marking avatar as self " << id << llendl; @@ -513,12 +520,6 @@ BOOL LLVOAvatarSelf::buildMenus() LLVOAvatarSelf::~LLVOAvatarSelf() { - // gAgents pointer might have been set to a different Avatar Self, don't get rid of it if so. - if (gAgent.getAvatarObject() == this) - { - gAgent.setAvatarObject(NULL); - gAgentWearables.setAvatarObject(NULL); - } delete mScreenp; mScreenp = NULL; } @@ -610,6 +611,17 @@ BOOL LLVOAvatarSelf::updateCharacter(LLAgent &agent) return LLVOAvatar::updateCharacter(agent); } +// virtual +BOOL LLVOAvatarSelf::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) +{ + if (!isAgentAvatarValid()) + { + return TRUE; + } + LLVOAvatar::idleUpdate(agent, world, time); + return TRUE; +} + // virtual LLJoint *LLVOAvatarSelf::getJoint(const std::string &name) { @@ -621,7 +633,8 @@ LLJoint *LLVOAvatarSelf::getJoint(const std::string &name) return LLVOAvatar::getJoint(name); } -/*virtual*/ BOOL LLVOAvatarSelf::setVisualParamWeight(LLVisualParam *which_param, F32 weight, BOOL upload_bake ) +// virtual +BOOL LLVOAvatarSelf::setVisualParamWeight(LLVisualParam *which_param, F32 weight, BOOL upload_bake ) { if (!which_param) { @@ -631,7 +644,8 @@ LLJoint *LLVOAvatarSelf::getJoint(const std::string &name) return setParamWeight(param,weight,upload_bake); } -/*virtual*/ BOOL LLVOAvatarSelf::setVisualParamWeight(const char* param_name, F32 weight, BOOL upload_bake ) +// virtual +BOOL LLVOAvatarSelf::setVisualParamWeight(const char* param_name, F32 weight, BOOL upload_bake ) { if (!param_name) { @@ -641,7 +655,8 @@ LLJoint *LLVOAvatarSelf::getJoint(const std::string &name) return setParamWeight(param,weight,upload_bake); } -/*virtual*/ BOOL LLVOAvatarSelf::setVisualParamWeight(S32 index, F32 weight, BOOL upload_bake ) +// virtual +BOOL LLVOAvatarSelf::setVisualParamWeight(S32 index, F32 weight, BOOL upload_bake ) { LLViewerVisualParam *param = (LLViewerVisualParam*) LLCharacter::getVisualParam(index); return setParamWeight(param,weight,upload_bake); @@ -1073,7 +1088,7 @@ BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object) // Make sure the inventory is in sync with the avatar. // Update COF contents, don't trigger appearance update. - if (gAgent.getAvatarObject() == NULL) + if (!isAgentAvatarValid()) { llinfos << "removeItemLinks skipped, avatar is under destruction" << llendl; } @@ -1672,7 +1687,7 @@ void LLVOAvatarSelf::onLocalTextureLoaded(BOOL success, LLViewerFetchedTexture * void LLVOAvatarSelf::dumpTotalLocalTextureByteCount() { S32 gl_bytes = 0; - gAgent.getAvatarObject()->getLocalTextureByteCount(&gl_bytes); + gAgentAvatar->getLocalTextureByteCount(&gl_bytes); llinfos << "Total Avatar LocTex GL:" << (gl_bytes/1024) << "KB" << llendl; } @@ -1929,9 +1944,7 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**) { LLUUID texture_id; msg->getUUID("TextureData", "TextureID", texture_id); - - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (!avatarp) return; + if (!isAgentAvatarValid()) return; // If this is a texture corresponding to one of our baked entries, // just rebake that layer set. @@ -1948,13 +1961,13 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**) const LLVOAvatarDictionary::TextureEntry *texture_dict = iter->second; if (texture_dict->mIsBakedTexture) { - if (texture_id == avatarp->getTEImage(index)->getID()) + if (texture_id == gAgentAvatar->getTEImage(index)->getID()) { - LLTexLayerSet* layer_set = avatarp->getLayerSet(index); + LLTexLayerSet* layer_set = gAgentAvatar->getLayerSet(index); if (layer_set) { llinfos << "TAT: rebake - matched entry " << (S32)index << llendl; - avatarp->invalidateComposite(layer_set, TRUE); + gAgentAvatar->invalidateComposite(layer_set, TRUE); found = TRUE; LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES); } @@ -1965,12 +1978,12 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**) // If texture not found, rebake all entries. if (!found) { - avatarp->forceBakeAllTextures(); + gAgentAvatar->forceBakeAllTextures(); } else { // Not sure if this is necessary, but forceBakeAllTextures() does it. - avatarp->updateMeshTextures(); + gAgentAvatar->updateMeshTextures(); } } @@ -2050,10 +2063,9 @@ void LLVOAvatarSelf::onCustomizeStart() // static void LLVOAvatarSelf::onCustomizeEnd() { - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); - if (avatarp) + if (isAgentAvatarValid()) { - avatarp->invalidateAll(); + gAgentAvatar->invalidateAll(); } } diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h index 9514abc5bc..706a02c088 100644 --- a/indra/newview/llvoavatarself.h +++ b/indra/newview/llvoavatarself.h @@ -55,7 +55,7 @@ public: LLVOAvatarSelf(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp); virtual ~LLVOAvatarSelf(); virtual void markDead(); - virtual void initInstance(); // Called after construction to initialize the class. + virtual void initInstance(); // Called after construction to initialize the class. protected: /*virtual*/ BOOL loadAvatar(); BOOL loadAvatarSelf(); @@ -77,6 +77,7 @@ protected: //-------------------------------------------------------------------- public: /*virtual*/ void updateRegion(LLViewerRegion *regionp); + /*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time); //-------------------------------------------------------------------- // LLCharacter interface and related @@ -333,4 +334,8 @@ public: }; +extern LLVOAvatarSelf *gAgentAvatar; + +BOOL isAgentAvatarValid(); + #endif // LL_VO_AVATARSELF_H diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp index cc346c2345..710348ac4b 100644 --- a/indra/newview/llvoiceclient.cpp +++ b/indra/newview/llvoiceclient.cpp @@ -5872,12 +5872,10 @@ void LLVoiceClient::enforceTether(void) void LLVoiceClient::updatePosition(void) { - if(gVoiceClient) { - LLVOAvatarSelf *avatarp = gAgent.getAvatarObject(); LLViewerRegion *region = gAgent.getRegion(); - if(region && avatarp) + if(region && isAgentAvatarValid()) { LLMatrix3 rot; LLVector3d pos; @@ -5895,9 +5893,9 @@ void LLVoiceClient::updatePosition(void) rot); // rotation matrix // Send the current avatar position to the voice code - rot = avatarp->getRootJoint()->getWorldRotation().getMatrix3(); + rot = gAgentAvatar->getRootJoint()->getWorldRotation().getMatrix3(); - pos = avatarp->getPositionGlobal(); + pos = gAgentAvatar->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 c9fe032a24..23a14c07ab 100644 --- a/indra/newview/llwearable.cpp +++ b/indra/newview/llwearable.cpp @@ -62,22 +62,20 @@ class LLOverrideBakedTextureUpdate public: LLOverrideBakedTextureUpdate(bool temp_state) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); U32 num_bakes = (U32) LLVOAvatarDefines::BAKED_NUM_INDICES; for( U32 index = 0; index < num_bakes; ++index ) { - composite_enabled[index] = avatarp->isCompositeUpdateEnabled(index); + composite_enabled[index] = gAgentAvatar->isCompositeUpdateEnabled(index); } - avatarp->setCompositeUpdatesEnabled(temp_state); + gAgentAvatar->setCompositeUpdatesEnabled(temp_state); } ~LLOverrideBakedTextureUpdate() { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); U32 num_bakes = (U32)LLVOAvatarDefines::BAKED_NUM_INDICES; for( U32 index = 0; index < num_bakes; ++index ) { - avatarp->setCompositeUpdatesEnabled(index, composite_enabled[index]); + gAgentAvatar->setCompositeUpdatesEnabled(index, composite_enabled[index]); } } private: @@ -204,10 +202,9 @@ BOOL LLWearable::exportFile(LLFILE* file) const void LLWearable::createVisualParams() { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - for (LLViewerVisualParam* param = (LLViewerVisualParam*) avatarp->getFirstVisualParam(); + for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatar->getFirstVisualParam(); param; - param = (LLViewerVisualParam*) avatarp->getNextVisualParam()) + param = (LLViewerVisualParam*) gAgentAvatar->getNextVisualParam()) { if (param->getWearableType() == mType) { @@ -227,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,avatarp,_1 ), true)) + if( !param->linkDrivenParams(boost::bind(avatar_function,gAgentAvatar,_1 ), true)) { llwarns << "could not link driven params for wearable " << getName() << " id: " << param->getID() << llendl; continue; @@ -463,9 +460,7 @@ BOOL LLWearable::importFile( LLFILE* file ) // since this wearable was created. BOOL LLWearable::isOldVersion() const { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - llassert(avatarp); - if(!avatarp) return FALSE; + if (!isAgentAvatarValid()) return FALSE; if( LLWearable::sCurrentDefinitionVersion < mDefinitionVersion ) { @@ -479,9 +474,9 @@ BOOL LLWearable::isOldVersion() const } S32 param_count = 0; - for( LLViewerVisualParam* param = (LLViewerVisualParam*) avatarp->getFirstVisualParam(); + for( LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatar->getFirstVisualParam(); param; - param = (LLViewerVisualParam*) avatarp->getNextVisualParam() ) + param = (LLViewerVisualParam*) gAgentAvatar->getNextVisualParam() ) { if( (param->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) { @@ -527,13 +522,11 @@ BOOL LLWearable::isOldVersion() const // only if those values are the same as the defaults. BOOL LLWearable::isDirty() const { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - llassert(avatarp); - if(!avatarp) return FALSE; + if (!isAgentAvatarValid()) return FALSE; - for( LLViewerVisualParam* param = (LLViewerVisualParam*) avatarp->getFirstVisualParam(); + for( LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatar->getFirstVisualParam(); param; - param = (LLViewerVisualParam*) avatarp->getNextVisualParam() ) + param = (LLViewerVisualParam*) gAgentAvatar->getNextVisualParam() ) { if( (param->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) @@ -594,11 +587,9 @@ BOOL LLWearable::isDirty() const void LLWearable::setParamsToDefaults() { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - llassert(avatarp); - if (!avatarp) return; + if (!isAgentAvatarValid()) return; - for( LLVisualParam* param = avatarp->getFirstVisualParam(); param; param = avatarp->getNextVisualParam() ) + for( LLVisualParam* param = gAgentAvatar->getFirstVisualParam(); param; param = gAgentAvatar->getNextVisualParam() ) { if( (((LLViewerVisualParam*)param)->getWearableType() == mType ) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) { @@ -634,18 +625,12 @@ void LLWearable::setTexturesToDefaults() // Updates the user's avatar's appearance void LLWearable::writeToAvatar() { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - llassert(avatarp); - if (!avatarp) - { - llerrs << "could not get avatar object to write to for wearable " << this->getName() << llendl; - return; - } + if (!isAgentAvatarValid()) return; - ESex old_sex = avatarp->getSex(); + ESex old_sex = gAgentAvatar->getSex(); // Pull params - for( LLVisualParam* param = avatarp->getFirstVisualParam(); param; param = avatarp->getNextVisualParam() ) + for( LLVisualParam* param = gAgentAvatar->getFirstVisualParam(); param; param = gAgentAvatar->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. @@ -654,7 +639,7 @@ void LLWearable::writeToAvatar() S32 param_id = param->getID(); F32 weight = getVisualParamWeight(param_id); - avatarp->setVisualParamWeight( param_id, weight, FALSE ); + gAgentAvatar->setVisualParamWeight( param_id, weight, FALSE ); } } @@ -675,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 - avatarp->setLocalTextureTE(te, image, 0); + gAgentAvatar->setLocalTextureTE(te, image, 0); } } - ESex new_sex = avatarp->getSex(); + ESex new_sex = gAgentAvatar->getSex(); if( old_sex != new_sex ) { - avatarp->updateSexDependentLayerSets( FALSE ); + gAgentAvatar->updateSexDependentLayerSets( FALSE ); } // if( upload_bake ) @@ -696,12 +681,7 @@ void LLWearable::writeToAvatar() // static void LLWearable::removeFromAvatar( EWearableType type, BOOL upload_bake ) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - llassert(avatarp); - if (!avatarp) - { - return; - } + if (!isAgentAvatarValid()) return; // You can't just remove body parts. if( (type == WT_SHAPE) || @@ -713,12 +693,12 @@ void LLWearable::removeFromAvatar( EWearableType type, BOOL upload_bake ) } // Pull params - for( LLVisualParam* param = avatarp->getFirstVisualParam(); param; param = avatarp->getNextVisualParam() ) + for( LLVisualParam* param = gAgentAvatar->getFirstVisualParam(); param; param = gAgentAvatar->getNextVisualParam() ) { if( (((LLViewerVisualParam*)param)->getWearableType() == type) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) { S32 param_id = param->getID(); - avatarp->setVisualParamWeight( param_id, param->getDefaultWeight(), upload_bake ); + gAgentAvatar->setVisualParamWeight( param_id, param->getDefaultWeight(), upload_bake ); } } @@ -727,8 +707,8 @@ void LLWearable::removeFromAvatar( EWearableType type, BOOL upload_bake ) gFloaterCustomize->setWearable(type, NULL, PERM_ALL, TRUE); } - avatarp->updateVisualParams(); - avatarp->wearableUpdated(type, TRUE); + gAgentAvatar->updateVisualParams(); + gAgentAvatar->wearableUpdated(type, TRUE); // if( upload_bake ) // { @@ -740,12 +720,7 @@ void LLWearable::removeFromAvatar( EWearableType type, BOOL upload_bake ) // Definition version is current: removes obsolete enties and creates default values for new ones. void LLWearable::copyDataFrom(const LLWearable* src) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - llassert(avatarp); - if (!avatarp) - { - return; - } + if (!isAgentAvatarValid()) return; mDefinitionVersion = LLWearable::sCurrentDefinitionVersion; @@ -758,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*) avatarp->getFirstVisualParam(); + for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatar->getFirstVisualParam(); param; - param = (LLViewerVisualParam*) avatarp->getNextVisualParam() ) + param = (LLViewerVisualParam*) gAgentAvatar->getNextVisualParam() ) { if( (param->getWearableType() == mType) ) { @@ -865,14 +840,12 @@ void LLWearable::addVisualParam(LLVisualParam *param) void LLWearable::setVisualParams() { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - for (visual_param_index_map_t::const_iterator iter = mVisualParamIndexMap.begin(); iter != mVisualParamIndexMap.end(); iter++) { S32 id = iter->first; LLVisualParam *wearable_param = iter->second; F32 value = wearable_param->getWeight(); - avatarp->setVisualParamWeight(id, value, FALSE); + gAgentAvatar->setVisualParamWeight(id, value, FALSE); } } @@ -1013,8 +986,7 @@ BOOL LLWearable::isOnTop() const void LLWearable::createLayers(S32 te) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - LLTexLayerSet *layer_set = avatarp->getLayerSet((ETextureIndex)te); + LLTexLayerSet *layer_set = gAgentAvatar->getLayerSet((ETextureIndex)te); if (layer_set) { layer_set->cloneTemplates(mTEMap[te], (ETextureIndex)te, this); @@ -1112,10 +1084,9 @@ void LLWearable::destroyTextures() void LLWearable::pullCrossWearableValues() { // scan through all of the avatar's visual parameters - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - for (LLViewerVisualParam* param = (LLViewerVisualParam*) avatarp->getFirstVisualParam(); + for (LLViewerVisualParam* param = (LLViewerVisualParam*) gAgentAvatar->getFirstVisualParam(); param; - param = (LLViewerVisualParam*) avatarp->getNextVisualParam()) + param = (LLViewerVisualParam*) gAgentAvatar->getNextVisualParam()) { if( param ) { diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 685be043fc..fda89fae60 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3856,15 +3856,14 @@ void LLPipeline::renderForSelect(std::set& objects, BOOL render } // pick HUD objects - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - if (avatarp && sShowHUDAttachments) + if (isAgentAvatarValid() && sShowHUDAttachments) { glh::matrix4f save_proj(glh_get_current_projection()); glh::matrix4f save_model(glh_get_current_modelview()); setup_hud_matrices(screen_rect); - for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); - iter != avatarp->mAttachmentPoints.end(); ) + for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatar->mAttachmentPoints.begin(); + iter != gAgentAvatar->mAttachmentPoints.end(); ) { LLVOAvatar::attachment_map_t::iterator curiter = iter++; LLViewerJointAttachment* attachment = curiter->second; @@ -3964,9 +3963,9 @@ void LLPipeline::rebuildPools() max_count--; } - if (gAgent.getAvatarObject()) + if (isAgentAvatarValid()) { - gAgent.getAvatarObject()->rebuildHUD(); + gAgentAvatar->rebuildHUD(); } } @@ -4598,8 +4597,8 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV); } - if (gAgent.getAvatarObject() && - gAgent.getAvatarObject()->mSpecialRenderMode == 3) + if (isAgentAvatarValid() && + gAgentAvatar->mSpecialRenderMode == 3) { LLColor4 light_color = LLColor4::white; light_color.mV[3] = 0.0f; @@ -4708,15 +4707,13 @@ void LLPipeline::enableLightsDynamic() glColor4f(0.f, 0.f, 0.f, 1.f); // no local lighting by default } - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); - - if (avatarp && getLightingDetail() <= 0) + if (isAgentAvatarValid() && getLightingDetail() <= 0) { - if (avatarp->mSpecialRenderMode == 0) // normal + if (gAgentAvatar->mSpecialRenderMode == 0) // normal { gPipeline.enableLightsAvatar(); } - else if (avatarp->mSpecialRenderMode >= 1) // anim preview + else if (gAgentAvatar->mSpecialRenderMode >= 1) // anim preview { gPipeline.enableLightsAvatarEdit(LLColor4(0.7f, 0.6f, 0.3f, 1.f)); } @@ -7101,15 +7098,15 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) { if (LLPipeline::sWaterReflections && assertInitialized() && LLDrawPoolWater::sNeedsReflectionUpdate) { - LLVOAvatarSelf* avatarp = gAgent.getAvatarObject(); + BOOL skip_avatar_update = FALSE; if (gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK) { - avatarp = NULL; + skip_avatar_update = TRUE; } - if (avatarp) + if (!skip_avatar_update) { - avatarp->updateAttachmentVisibility(CAMERA_MODE_THIRD_PERSON); + gAgentAvatar->updateAttachmentVisibility(CAMERA_MODE_THIRD_PERSON); } LLVertexBuffer::unbind(); @@ -7333,9 +7330,9 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); - if (avatarp) + if (!skip_avatar_update) { - avatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode()); + gAgentAvatar->updateAttachmentVisibility(gAgentCamera.getCameraMode()); } } } -- cgit v1.3 From 58d76a9ecf83b49e42fabfada27ca20814f93cf3 Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Mon, 29 Mar 2010 12:11:51 -0400 Subject: 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(-) (limited to 'indra/newview/llviewerkeyboard.cpp') diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 645acca4ae..3eeaacf93b 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 62f1746f28..2dd523cb24 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 452a11b01e..c4597ad6f8 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 91552a7f5b..62fc5544ab 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 75d1c437c3..ebd767d654 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 c9a950ed42..1f8c42ad90 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 a62640c813..bcd53023ca 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 f1b7806635..1750dd79ac 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 7c8fb4f9b9..f88747c382 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 3520c7e0c0..e2ace7db01 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 8d77ade253..5f0c5e1795 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 6334d54e33..d670eb6ffd 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 b47acefc76..0f22a50093 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 89fd4715fc..805016f089 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 87c7bdbfab..d5ec3a36c3 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 9210f5b8b7..262961b73b 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(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 b47b384308..7980fe1945 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 26d1ec1d6c..6969ae5e1e 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 e65da0022e..587565bafd 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 7ed095c68e..87ced0352b 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 add1cea8cc..58f64ff1f3 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 6461ec8221..3f4dab4fea 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 f9d0c7c307..c3aba4e591 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 b362d564df..032714cabf 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 982d55914d..04d873f91b 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 67d696d7d7..969049ee65 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 580b483b6b..322da2e343 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 847852f8af..91f01f0b36 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 a45bb2a4de..2065ba1791 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 f0f911b996..823466e33e 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 d899c72e0e..dd7390a907 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 49a3ed14dc..9bf2a5fad2 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 f838d1436d..8d3bf4deab 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 @@ private: 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(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 96bb687bbb..85f501b2a1 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 f3eb75bcd0..8860b734bb 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 eb966a1535..5e0bd5b811 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 4b6ac07a94..f3ef4b38e9 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -367,7 +367,7 @@ public: 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 8e9e15352a..e82a988ed2 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\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 0183061c0e..74ee6a05d9 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -67,12 +67,12 @@ #include -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 706a02c088..3c7ec04fab 100644 --- a/indra/newview/llvoavatarself.h +++ b/indra/newview/llvoavatarself.h @@ -334,7 +334,7 @@ public: }; -extern LLVOAvatarSelf *gAgentAvatar; +extern LLVOAvatarSelf *gAgentAvatarp; BOOL isAgentAvatarValid(); diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp index 710348ac4b..e8fdccf30e 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 23a14c07ab..63f99273fe 100644 --- a/indra/newview/llwearable.cpp +++ b/indra/newview/llwearable.cpp @@ -65,9 +65,9 @@ public: 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 @@ public: 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 fda89fae60..4ca251af3e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3862,8 +3862,8 @@ void LLPipeline::renderForSelect(std::set& 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()); } } } -- cgit v1.3