summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/CMakeLists.txt2
-rw-r--r--indra/newview/llagent.cpp2778
-rw-r--r--indra/newview/llagent.h316
-rw-r--r--indra/newview/llagentcamera.cpp2875
-rw-r--r--indra/newview/llagentcamera.h363
-rw-r--r--indra/newview/llagentui.cpp8
-rw-r--r--indra/newview/llagentwearables.cpp79
-rw-r--r--indra/newview/llagentwearables.h3
-rw-r--r--indra/newview/llappviewer.cpp59
-rw-r--r--indra/newview/llassetuploadresponders.cpp26
-rw-r--r--indra/newview/llassetuploadresponders.h12
-rw-r--r--indra/newview/llaudiosourcevo.cpp4
-rw-r--r--indra/newview/llbottomtray.cpp4
-rw-r--r--indra/newview/llfloateranimpreview.cpp9
-rw-r--r--indra/newview/llfloaterbeacons.cpp10
-rw-r--r--indra/newview/llfloatercamera.cpp20
-rw-r--r--indra/newview/llfloaterinventory.cpp4
-rw-r--r--indra/newview/llfloatermap.cpp4
-rw-r--r--indra/newview/llfloaternamedesc.cpp6
-rw-r--r--indra/newview/llfloatersnapshot.cpp634
-rw-r--r--indra/newview/llfloatersnapshot.h16
-rw-r--r--indra/newview/llfloatertools.cpp8
-rw-r--r--indra/newview/llfloaterworldmap.cpp5
-rw-r--r--indra/newview/llglsandbox.cpp93
-rw-r--r--indra/newview/llhudeffectlookat.cpp5
-rw-r--r--indra/newview/llhudeffectpointat.cpp3
-rw-r--r--indra/newview/llinventorybridge.cpp31
-rw-r--r--indra/newview/lljoystickbutton.cpp49
-rw-r--r--indra/newview/llmanip.cpp19
-rw-r--r--indra/newview/llmaniprotate.cpp31
-rw-r--r--indra/newview/llmanipscale.cpp17
-rw-r--r--indra/newview/llmaniptranslate.cpp21
-rw-r--r--indra/newview/llmenucommands.cpp4
-rw-r--r--indra/newview/llmorphview.cpp5
-rw-r--r--indra/newview/llmoveview.cpp3
-rw-r--r--indra/newview/llnetmap.cpp13
-rw-r--r--indra/newview/llpanelme.cpp3
-rw-r--r--indra/newview/llpanelprimmediacontrols.cpp6
-rw-r--r--indra/newview/llpreview.cpp6
-rw-r--r--indra/newview/llscrollingpanelparam.cpp4
-rw-r--r--indra/newview/llselectmgr.cpp47
-rw-r--r--indra/newview/llsidepanelappearance.cpp12
-rw-r--r--indra/newview/llsidetray.cpp4
-rw-r--r--indra/newview/llstartup.cpp23
-rw-r--r--indra/newview/llstatusbar.cpp3
-rw-r--r--indra/newview/llsurface.cpp3
-rw-r--r--indra/newview/lltexlayer.cpp14
-rw-r--r--indra/newview/lltexlayerparams.cpp4
-rw-r--r--indra/newview/lltexturefetch.cpp23
-rw-r--r--indra/newview/lltoolcomp.cpp3
-rw-r--r--indra/newview/lltooldraganddrop.cpp13
-rw-r--r--indra/newview/lltoolfocus.cpp45
-rw-r--r--indra/newview/lltoolgrab.cpp49
-rw-r--r--indra/newview/lltoolgun.cpp3
-rw-r--r--indra/newview/lltoolmgr.cpp19
-rw-r--r--indra/newview/lltoolmorph.cpp2
-rw-r--r--indra/newview/lltoolpie.cpp16
-rw-r--r--indra/newview/lltoolplacer.cpp3
-rw-r--r--indra/newview/lltoolselect.cpp3
-rw-r--r--indra/newview/lltracker.cpp5
-rw-r--r--indra/newview/llurldispatcher.cpp60
-rw-r--r--indra/newview/llvieweraudio.cpp7
-rw-r--r--indra/newview/llviewercamera.cpp3
-rw-r--r--indra/newview/llviewercontrol.cpp3
-rw-r--r--indra/newview/llviewerdisplay.cpp17
-rw-r--r--indra/newview/llviewerinventory.cpp3
-rw-r--r--indra/newview/llviewerjoystick.cpp7
-rw-r--r--indra/newview/llviewerkeyboard.cpp95
-rw-r--r--indra/newview/llviewermedia.cpp176
-rw-r--r--indra/newview/llviewermedia.h11
-rw-r--r--indra/newview/llviewermediafocus.cpp11
-rw-r--r--indra/newview/llviewermenu.cpp115
-rw-r--r--indra/newview/llviewermenufile.cpp132
-rw-r--r--indra/newview/llviewermenufile.h14
-rw-r--r--indra/newview/llviewermessage.cpp40
-rw-r--r--indra/newview/llviewerobject.cpp5
-rw-r--r--indra/newview/llviewerobjectlist.cpp9
-rw-r--r--indra/newview/llviewerparceloverlay.cpp6
-rw-r--r--indra/newview/llviewerregion.cpp3
-rw-r--r--indra/newview/llviewerstats.cpp5
-rw-r--r--indra/newview/llviewertexture.cpp14
-rw-r--r--indra/newview/llviewerwindow.cpp38
-rw-r--r--indra/newview/llvoavatar.cpp35
-rw-r--r--indra/newview/llvoavatarself.cpp19
-rw-r--r--indra/newview/llvograss.cpp4
-rw-r--r--indra/newview/llvoiceclient.cpp9
-rw-r--r--indra/newview/llvopartgroup.cpp4
-rw-r--r--indra/newview/llvosky.cpp5
-rw-r--r--indra/newview/llvotree.cpp4
-rw-r--r--indra/newview/llwaterparammanager.cpp3
-rw-r--r--indra/newview/llwearable.cpp54
-rw-r--r--indra/newview/llworldmapview.cpp9
-rw-r--r--indra/newview/pipeline.cpp21
-rw-r--r--indra/newview/skins/default/textures/arrow_down.tgabin1068 -> 0 bytes
-rw-r--r--indra/newview/skins/default/textures/locked_image.j2cbin6140 -> 0 bytes
-rw-r--r--indra/newview/skins/default/textures/map_infohub.tgabin1068 -> 0 bytes
-rw-r--r--indra/newview/skins/default/xui/en/floater_snapshot.xml484
-rw-r--r--indra/newview/skins/default/xui/en/notifications.xml7
-rw-r--r--indra/newview/skins/default/xui/en/panel_nearby_media.xml42
99 files changed, 4794 insertions, 4532 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 8ad3b2085d..f45237a73c 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -66,6 +66,7 @@ include_directories(
set(viewer_SOURCE_FILES
llagent.cpp
llagentaccess.cpp
+ llagentcamera.cpp
llagentdata.cpp
llagentlanguage.cpp
llagentlistener.cpp
@@ -564,6 +565,7 @@ set(viewer_HEADER_FILES
ViewerInstall.cmake
llagent.h
llagentaccess.h
+ llagentcamera.h
llagentdata.h
llagentlanguage.h
llagentlistener.h
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index c5d7f6f118..7a34112807 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -35,6 +35,7 @@
#include "pipeline.h"
+#include "llagentcamera.h"
#include "llagentlistener.h"
#include "llagentwearables.h"
#include "llagentui.h"
@@ -59,6 +60,7 @@
#include "llnearbychatbar.h"
#include "llnotificationsutil.h"
#include "llparcel.h"
+#include "llrendersphere.h"
#include "llsdutil.h"
#include "llsidetray.h"
#include "llsky.h"
@@ -106,56 +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;
@@ -218,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),
@@ -254,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),
@@ -307,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),
@@ -358,7 +264,6 @@ LLAgent::LLAgent() :
mControlsTakenPassedOnCount[i] = 0;
}
- mFollowCam.setMaxCameraDistantFromSubject( MAX_CAMERA_DISTANCE_FROM_AGENT );
mListener.reset(new LLAgentListener(*this));
}
@@ -372,37 +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.
- 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
-
setFlying( gSavedSettings.getBOOL("FlyingAtExit") );
- 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));
@@ -416,22 +294,8 @@ void LLAgent::init()
//-----------------------------------------------------------------------------
void LLAgent::cleanup()
{
- setSitCamera(LLUUID::null);
-
mAvatarObject = NULL;
-
- if(mLookAt)
- {
- mLookAt->markDead() ;
- mLookAt = NULL;
- }
- if(mPointAt)
- {
- mPointAt->markDead() ;
- mPointAt = NULL;
- }
mRegionp = NULL;
- setFocusObject(NULL);
}
//-----------------------------------------------------------------------------
@@ -444,83 +308,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).
//-----------------------------------------------------------------------------
@@ -528,9 +315,9 @@ void LLAgent::resetView(BOOL reset_camera, BOOL change_camera)
//-----------------------------------------------------------------------------
void LLAgent::onAppFocusGained()
{
- if (CAMERA_MODE_MOUSELOOK == mCameraMode)
+ if (CAMERA_MODE_MOUSELOOK == gAgentCamera.mCameraMode)
{
- changeCameraToDefault();
+ gAgentCamera.changeCameraToDefault();
LLToolMgr::getInstance()->clearSavedTool();
}
}
@@ -547,23 +334,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()
//-----------------------------------------------------------------------------
@@ -585,7 +355,7 @@ void LLAgent::moveAt(S32 direction, bool reset)
if (reset)
{
- resetView();
+ gAgentCamera.resetView();
}
}
@@ -608,7 +378,7 @@ void LLAgent::moveAtNudge(S32 direction)
setControlFlags(AGENT_CONTROL_NUDGE_AT_NEG);
}
- resetView();
+ gAgentCamera.resetView();
}
//-----------------------------------------------------------------------------
@@ -630,7 +400,7 @@ void LLAgent::moveLeft(S32 direction)
setControlFlags(AGENT_CONTROL_LEFT_NEG | AGENT_CONTROL_FAST_LEFT);
}
- resetView();
+ gAgentCamera.resetView();
}
//-----------------------------------------------------------------------------
@@ -652,7 +422,7 @@ void LLAgent::moveLeftNudge(S32 direction)
setControlFlags(AGENT_CONTROL_NUDGE_LEFT_NEG);
}
- resetView();
+ gAgentCamera.resetView();
}
//-----------------------------------------------------------------------------
@@ -674,7 +444,7 @@ void LLAgent::moveUp(S32 direction)
setControlFlags(AGENT_CONTROL_UP_NEG | AGENT_CONTROL_FAST_UP);
}
- resetView();
+ gAgentCamera.resetView();
}
//-----------------------------------------------------------------------------
@@ -695,7 +465,7 @@ void LLAgent::moveYaw(F32 mag, bool reset_view)
if (reset_view)
{
- resetView();
+ gAgentCamera.resetView();
}
}
@@ -806,7 +576,7 @@ void LLAgent::toggleFlying()
BOOL fly = !gAgent.getFlying();
gAgent.setFlying( fly );
- gAgent.resetView();
+ gAgentCamera.resetView();
}
// static
@@ -1029,17 +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()
//-----------------------------------------------------------------------------
const LLVector3d &LLAgent::getPositionGlobal() const
@@ -1193,7 +952,7 @@ LLVector3 LLAgent::getReferenceUpVector()
mAvatarObject->getParent() &&
mAvatarObject->mDrawable.notNull())
{
- U32 camera_mode = mCameraAnimating ? mLastCameraMode : mCameraMode;
+ U32 camera_mode = gAgentCamera.mCameraAnimating ? gAgentCamera.mLastCameraMode : gAgentCamera.mCameraMode;
// and in third person...
if (camera_mode == CAMERA_MODE_THIRD_PERSON)
{
@@ -1292,700 +1051,6 @@ LLQuaternion LLAgent::getQuat() const
return mFrameAgent.getQuaternion();
}
-
-//-----------------------------------------------------------------------------
-// calcFocusOffset()
-//-----------------------------------------------------------------------------
-LLVector3 LLAgent::calcFocusOffset(LLViewerObject *object, LLVector3 original_focus_point, S32 x, S32 y)
-{
- 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)
- {
- return original_focus_point - obj_pos;
- }
-
-
- 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());
- }
-
- // 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++)
- {
- //...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
- {
- clip_fraction.mV[axis] = dist_out_of_bounds / camera_to_focus_vec.mV[axis];
- }
- }
-
- 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;
-
- // 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;
- }
-
- return focus_offset_from_object_center;
-}
-
-//-----------------------------------------------------------------------------
-// calcCameraMinDistance()
-//-----------------------------------------------------------------------------
-BOOL LLAgent::calcCameraMinDistance(F32 &obj_min_distance)
-{
- BOOL soft_limit = FALSE; // is the bounding box to be treated literally (volumes) or as an approximation (avatars)
-
- if (!mFocusObject || mFocusObject->isDead())
- {
- obj_min_distance = 0.f;
- return TRUE;
- }
-
- if (mFocusObject->mDrawable.isNull())
- {
-#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;
- }
-
- 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())
- {
- // 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;
- }
- 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 (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
- {
- object_extents.mV[i] += target_offset_origin.mV[i] * 2.f;
- }
- }
-
- // 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];
-
- 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])
- {
- if (camera_offset_target_abs_norm.mV[VY] < 0.001f)
- {
- obj_min_distance = object_extents.mV[VY] * 0.5f;
- }
- else
- {
- 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];
- }
- }
-
- 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];
-
- 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])
- {
- object_split_axis = LLVector3::y_axis;
- }
- else
- {
- object_split_axis = LLVector3::z_axis;
- }
-
- LLVector3 camera_offset_object(getCameraPositionAgent() - mFocusObject->getPositionAgent());
-
- // 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)
- {
- // target is visible from camera, so turn off fov zoom
- exterior_target_visible = TRUE;
- }
-
- 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;
- }
- }
-
- // clamp obj distance to diagonal of 10 by 10 cube
- obj_min_distance = llmin(obj_min_distance, 10.f * F_SQRT3);
-
- obj_min_distance += LLViewerCamera::getInstance()->getNear() + (soft_limit ? 0.1f : 0.2f);
-
- return TRUE;
-}
-
-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())
- {
- F32 distance = (F32)mCameraFocusOffsetTarget.magVec();
- return clamp_rescale(distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM, 1.f, 0.f );
- }
- 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
- {
- min_zoom = LAND_MIN_ZOOM;
- }
-
- 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();
-
- if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
- {
- mHUDTargetZoom = fraction;
- }
- else if (mFocusOnAvatar && cameraThirdPerson())
- {
- mCameraZoomFraction = rescale(fraction, 0.f, 1.f, MAX_ZOOM_FRACTION, MIN_ZOOM_FRACTION);
- }
- else if (cameraCustomizeAvatar())
- {
- 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);
- }
- 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;
- }
- }
- }
-
- LLVector3d camera_offset_dir = mCameraFocusOffsetTarget;
- camera_offset_dir.normalize();
- mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, max_zoom, min_zoom);
- }
- startCameraAnimation();
-}
-
-
-//-----------------------------------------------------------------------------
-// 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))
- {
- mFrameAgent.rotate(radians, getReferenceUpVector());
- }
- else
- {
- mCameraFocusOffsetTarget.rotVec(radians, 0.f, 0.f, 1.f);
-
- cameraZoomIn(1.f);
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// cameraOrbitOver()
-//-----------------------------------------------------------------------------
-void LLAgent::cameraOrbitOver(const F32 angle)
-{
- 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);
- }
-}
-
-//-----------------------------------------------------------------------------
-// cameraZoomIn()
-//-----------------------------------------------------------------------------
-void LLAgent::cameraZoomIn(const F32 fraction)
-{
- if (gDisconnected)
- {
- return;
- }
-
- LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
- if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
- {
- // just update hud zoom level
- mHUDTargetZoom /= fraction;
- return;
- }
-
-
- 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)
- {
- 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())
- {
- calcCameraMinDistance(min_zoom);
- }
- else
- {
- min_zoom = OBJECT_MIN_ZOOM;
- }
- }
-
- 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;
-
- /*
- // Unless camera is unlocked
- if (!LLViewerCamera::sDisableCameraConstraints)
- {
- return;
- }
- */
- }
-
- if( cameraCustomizeAvatar() )
- {
- new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM );
- }
-
- mCameraFocusOffsetTarget = new_distance * camera_offset_unit;
-}
-
-//-----------------------------------------------------------------------------
-// cameraOrbitIn()
-//-----------------------------------------------------------------------------
-void LLAgent::cameraOrbitIn(const F32 meters)
-{
- if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON)
- {
- 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)
- {
- // No need to animate, camera is already there.
- changeCameraToMouselook(FALSE);
- }
-
- 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 (mFocusObject->isAvatar())
- {
- min_zoom = AVATAR_MIN_ZOOM;
- }
- else
- {
- min_zoom = OBJECT_MIN_ZOOM;
- }
- }
-
- 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)
- {
- // Unless camera is unlocked
- if (!gSavedSettings.getBOOL("DisableCameraConstraints"))
- {
- 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()
//-----------------------------------------------------------------------------
@@ -2546,79 +1611,7 @@ void LLAgent::updateAgentPosition(const F32 dt, const F32 yaw_radians, const S32
// Check for water and land collision, set underwater flag
//
- 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);
- }
+ gAgentCamera.updateLookAt(mouse_x, mouse_y);
}
// friends and operators
@@ -2651,24 +1644,9 @@ void LLAgent::setAvatarObject(LLVOAvatarSelf *avatar)
llinfos << "Setting LLAgent::mAvatarObject to NULL" << llendl;
return;
}
-
- if (!mLookAt)
- {
- mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT);
- }
- if (!mPointAt)
- {
- mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT);
- }
- if (!mLookAt.isNull())
- {
- mLookAt->setSourceObject(avatar);
- }
- if (!mPointAt.isNull())
- {
- mPointAt->setSourceObject(avatar);
- }
+ gAgentCamera.setAvatarObject(avatar);
+ gAgentWearables.setAvatarObject(avatar);
}
// TRUE if your own avatar needs to be rendered. Usually only
@@ -2678,7 +1656,7 @@ void LLAgent::setAvatarObject(LLVOAvatarSelf *avatar)
//-----------------------------------------------------------------------------
BOOL LLAgent::needsRenderAvatar()
{
- if (cameraMouselook() && !LLVOAvatar::sVisibleInFirstPerson)
+ if (gAgentCamera.cameraMouselook() && !LLVOAvatar::sVisibleInFirstPerson)
{
return FALSE;
}
@@ -2689,7 +1667,7 @@ BOOL LLAgent::needsRenderAvatar()
// TRUE if we need to render your own avatar's head.
BOOL LLAgent::needsRenderHead()
{
- return (LLVOAvatar::sVisibleInFirstPerson && LLPipeline::sReflectionRender) || (mShowAvatar && !cameraMouselook());
+ return (LLVOAvatar::sVisibleInFirstPerson && LLPipeline::sReflectionRender) || (mShowAvatar && !gAgentCamera.cameraMouselook());
}
//-----------------------------------------------------------------------------
@@ -2711,7 +1689,7 @@ void LLAgent::startTyping()
LLViewerObject* chatter = gObjectList.findObject(mLastChatterID);
if (chatter && chatter->isAvatar())
{
- gAgent.setLookAt(LOOKAT_TARGET_RESPOND, chatter, LLVector3::zero);
+ gAgentCamera.setLookAt(LOOKAT_TARGET_RESPOND, chatter, LLVector3::zero);
}
}
@@ -2790,14 +1768,14 @@ U8 LLAgent::getRenderState()
//-----------------------------------------------------------------------------
void LLAgent::endAnimationUpdateUI()
{
- if (mCameraMode == mLastCameraMode)
+ if (gAgentCamera.mCameraMode == gAgentCamera.mLastCameraMode)
{
// We're already done endAnimationUpdateUI for this transition.
return;
}
// clean up UI from mode we're leaving
- if ( mLastCameraMode == CAMERA_MODE_MOUSELOOK )
+ if (gAgentCamera.mLastCameraMode == CAMERA_MODE_MOUSELOOK )
{
// show mouse cursor
gViewerWindow->showCursor();
@@ -2835,7 +1813,7 @@ void LLAgent::endAnimationUpdateUI()
}
- gAgent.setLookAt(LOOKAT_TARGET_CLEAR);
+ gAgentCamera.setLookAt(LOOKAT_TARGET_CLEAR);
if( gMorphView )
{
gMorphView->setVisible( FALSE );
@@ -2869,8 +1847,7 @@ void LLAgent::endAnimationUpdateUI()
}
}
}
- else
- if( mLastCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR )
+ else if(gAgentCamera.mLastCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR)
{
// make sure we ask to save changes
@@ -2892,13 +1869,13 @@ void LLAgent::endAnimationUpdateUI()
}
}
- setLookAt(LOOKAT_TARGET_CLEAR);
+ gAgentCamera.setLookAt(LOOKAT_TARGET_CLEAR);
}
//---------------------------------------------------------------------
// Set up UI for mode we're entering
//---------------------------------------------------------------------
- if (mCameraMode == CAMERA_MODE_MOUSELOOK)
+ if (gAgentCamera.mCameraMode == CAMERA_MODE_MOUSELOOK)
{
// hide menus
gMenuBarView->setVisible(FALSE);
@@ -2913,7 +1890,7 @@ void LLAgent::endAnimationUpdateUI()
LLPanelStandStopFlying::getInstance()->setVisible(FALSE);
// clear out camera lag effect
- mCameraLag.clearVec();
+ gAgentCamera.mCameraLag.clearVec();
// JC - Added for always chat in third person option
gFocusMgr.setKeyboardFocus(NULL);
@@ -2983,7 +1960,7 @@ void LLAgent::endAnimationUpdateUI()
}
}
- else if (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR)
+ else if (gAgentCamera.mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR)
{
LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset);
@@ -3001,1580 +1978,15 @@ void LLAgent::endAnimationUpdateUI()
if (getAvatarObject())
{
- getAvatarObject()->updateAttachmentVisibility(mCameraMode);
+ getAvatarObject()->updateAttachmentVisibility(gAgentCamera.mCameraMode);
}
gFloaterTools->dirty();
// Don't let this be called more than once if the camera
// mode hasn't changed. --JC
- mLastCameraMode = 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<LLFloaterCamera>("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;
-
- if( gFloaterCustomize )
- {
- const LLRect& rect = gFloaterCustomize->getRect();
-
- // 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);
-
- if( rect.mLeft < (gViewerWindow->getWindowWidthScaled() - rect.mRight) )
- {
- // Move the avatar to the right (camera to the left)
- ui_offset = offset;
- }
- else
- {
- // Move the avatar to the left (camera to the right)
- ui_offset = -offset;
- }
- }
- F32 range = (F32)dist_vec(camera_pos_global, gAgent.getFocusGlobal());
- mUIOffset = lerp(mUIOffset, ui_offset, LLCriticalDamp::getInterpolant(0.05f));
- return mUIOffset * range;
-}
-
-//-----------------------------------------------------------------------------
-// calcFocusPositionTargetGlobal()
-//-----------------------------------------------------------------------------
-LLVector3d LLAgent::calcFocusPositionTargetGlobal()
-{
- if (mFocusObject.notNull() && mFocusObject->isDead())
- {
- clearFocusObject();
- }
-
- // 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())
- {
- LLViewerObject* root_object = (LLViewerObject*)mAvatarObject->getRoot();
- if (!root_object->flagCameraDecoupled())
- {
- agent_rot *= ((LLViewerObject*)(mAvatarObject->getParent()))->getRenderRotation();
- }
- }
- 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())
- {
- 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));
- }
- 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;
-
- // 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())
- {
- 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);
- }
- 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;
- }
- }
- 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
- {
- 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()))
- {
- 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])
- {
- // 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;
- }
- }
- else
- {
- if (offset_dot_norm + pos_dot_norm > mCameraCollidePlane.mV[VW])
- {
- camera_distance *= (mCameraCollidePlane.mV[VW] - pos_dot_norm - CAMERA_COLLIDE_EPSILON) / offset_dot_norm;
- }
- }
- }
- 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)
- {
- 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;
- }
- }
- else
- {
- mCameraLag = lerp(mCameraLag, LLVector3::zero, LLCriticalDamp::getInterpolant(0.15f));
- }
-
- 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();
-
- if(camera_distance > max_dist)
- {
- camera_position_global = gAgent.getPositionGlobal() +
- (max_dist / camera_distance) * camera_offset;
- isConstrained = TRUE;
- }
- }
-
-// 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 && gAgent.getFocusOnAvatar())
- {
- if ( ! mFollowCam.getPositionLocked() ) // not if the followCam position is locked in place
- {
- mFollowCam.zoom( clicks );
- if ( mFollowCam.isZoomedToMinimumDistance() )
- {
- changeCameraToMouselook(FALSE);
- }
- }
- }
- 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
- {
- F32 current_zoom_fraction = (F32)mCameraFocusOffsetTarget.magVec();
- cameraOrbitIn(current_zoom_fraction * (1.f - pow(ROOT_ROOT_TWO, clicks)));
- }
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// getCameraMinOffGround()
-//-----------------------------------------------------------------------------
-F32 LLAgent::getCameraMinOffGround()
-{
- if (mCameraMode == CAMERA_MODE_MOUSELOOK)
- {
- return 0.f;
- }
- else
- {
- if (gSavedSettings.getBOOL("DisableCameraConstraints"))
- {
- return -1000.f;
- }
- else
- {
- return 0.5f;
- }
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// 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();
-}
-
-//-----------------------------------------------------------------------------
-// changeCameraToMouselook()
-//-----------------------------------------------------------------------------
-void LLAgent::changeCameraToMouselook(BOOL animate)
-{
- if (LLViewerJoystick::getInstance()->getOverrideCamera())
- {
- return;
- }
-
- // visibility changes at end of animation
- gViewerWindow->getWindow()->resetBusyCount();
-
- // unpause avatar animation
- mPauseRequest = NULL;
-
- LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset);
-
- if (mAvatarObject.notNull())
- {
- mAvatarObject->stopMotion( ANIM_AGENT_BODY_NOISE );
- mAvatarObject->stopMotion( ANIM_AGENT_BREATHE_ROT );
- }
-
- //gViewerWindow->stopGrab();
- LLSelectMgr::getInstance()->deselectAll();
- gViewerWindow->hideCursor();
- gViewerWindow->moveCursorToCenter();
-
- 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;
- }
-
- if (animate)
- {
- startCameraAnimation();
- }
- else
- {
- mCameraAnimating = FALSE;
- endAnimationUpdateUI();
- }
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// changeCameraToDefault()
-//-----------------------------------------------------------------------------
-void LLAgent::changeCameraToDefault()
-{
- if (LLViewerJoystick::getInstance()->getOverrideCamera())
- {
- return;
- }
-
- if (LLFollowCamMgr::getActiveFollowCamParams())
- {
- changeCameraToFollow();
- }
- else
- {
- changeCameraToThirdPerson();
- }
-}
-
-
-// Ventrella
-//-----------------------------------------------------------------------------
-// changeCameraToFollow()
-//-----------------------------------------------------------------------------
-void LLAgent::changeCameraToFollow(BOOL animate)
-{
- if (LLViewerJoystick::getInstance()->getOverrideCamera())
- {
- return;
- }
-
- 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);
- }
+ gAgentCamera.mLastCameraMode = gAgentCamera.mCameraMode;
- 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;
- }
-
- if (animate)
- {
- startCameraAnimation();
- }
- else
- {
- mCameraAnimating = FALSE;
- endAnimationUpdateUI();
- }
- }
-}
-
-//-----------------------------------------------------------------------------
-// changeCameraToThirdPerson()
-//-----------------------------------------------------------------------------
-void LLAgent::changeCameraToThirdPerson(BOOL animate)
-{
- if (LLViewerJoystick::getInstance()->getOverrideCamera())
- {
- return;
- }
-
- gViewerWindow->getWindow()->resetBusyCount();
-
- mCameraZoomFraction = INITIAL_ZOOM_FRACTION;
-
- if (mAvatarObject.notNull())
- {
- if (!mAvatarObject->isSitting())
- {
- mAvatarObject->mPelvisp->setPosition(LLVector3::zero);
- }
- mAvatarObject->startMotion( ANIM_AGENT_BODY_NOISE );
- mAvatarObject->startMotion( ANIM_AGENT_BREATHE_ROT );
- }
-
- LLVector3 at_axis;
-
- // unpause avatar animation
- mPauseRequest = NULL;
-
- if( mCameraMode != CAMERA_MODE_THIRD_PERSON )
- {
- 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)
- {
- mbFlagsDirty = TRUE;
- }
-
- }
-
- // 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
- {
- at_axis = mFrameAgent.getAtAxis();
- at_axis.mV[VZ] = 0.f;
- at_axis.normalize();
- resetAxes(at_axis);
- }
-
-
- if (animate)
- {
- startCameraAnimation();
- }
- else
- {
- mCameraAnimating = FALSE;
- endAnimationUpdateUI();
- }
-}
-
-//-----------------------------------------------------------------------------
-// changeCameraToCustomizeAvatar()
-//-----------------------------------------------------------------------------
-void LLAgent::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL camera_animate)
-{
- if (LLViewerJoystick::getInstance()->getOverrideCamera())
- {
- return;
- }
-
- standUp(); // force stand up
- gViewerWindow->getWindow()->resetBusyCount();
-
- if (gFaceEditToolset)
- {
- LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset);
- }
-
- if (camera_animate)
- {
- startCameraAnimation();
- }
-
- // 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 )
- {
- 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();
- }
-
- if (mAvatarObject.notNull())
- {
- 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");
- }
- }
-
-
-
- gAgent.setFocusGlobal(LLVector3d::zero);
- }
- 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;
-
- gSavedSettings.setU32("CameraPreset", mCameraPreset);
-}
-
-
-//
-// Focus point management
-//
-
-//-----------------------------------------------------------------------------
-// startCameraAnimation()
-//-----------------------------------------------------------------------------
-void LLAgent::startCameraAnimation()
-{
- mAnimationCameraStartGlobal = getCameraPositionGlobal();
- mAnimationFocusStartGlobal = mFocusGlobal;
- mAnimationTimer.reset();
- mCameraAnimating = TRUE;
- mAnimationDuration = gSavedSettings.getF32("ZoomTime");
-}
-
-//-----------------------------------------------------------------------------
-// stopCameraAnimation()
-//-----------------------------------------------------------------------------
-void LLAgent::stopCameraAnimation()
-{
- mCameraAnimating = FALSE;
-}
-
-void LLAgent::clearFocusObject()
-{
- if (mFocusObject.notNull())
- {
- startCameraAnimation();
-
- setFocusObject(NULL);
- mFocusObjectOffset.clearVec();
- }
-}
-
-void LLAgent::setFocusObject(LLViewerObject* object)
-{
- mFocusObject = object;
-}
-
-// Focus on a point, but try to keep camera position stable.
-//-----------------------------------------------------------------------------
-// setFocusGlobal()
-//-----------------------------------------------------------------------------
-void LLAgent::setFocusGlobal(const LLPickInfo& pick)
-{
- LLViewerObject* objectp = gObjectList.findObject(pick.mObjectID);
-
- 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);
- }
-}
-
-
-void LLAgent::setFocusGlobal(const LLVector3d& focus, const LLUUID &object_id)
-{
- setFocusObject(gObjectList.findObject(object_id));
- LLVector3d old_focus = mFocusTargetGlobal;
- LLViewerObject *focus_obj = mFocusObject;
-
- // if focus has changed
- if (old_focus != focus)
- {
- if (focus.isExactlyZero())
- {
- if (mAvatarObject.notNull())
- {
- mFocusTargetGlobal = getPosGlobalFromAgent(mAvatarObject->mHeadp->getWorldPosition());
- }
- else
- {
- mFocusTargetGlobal = getPositionGlobal();
- }
- mCameraFocusOffsetTarget = getCameraPositionGlobal() - mFocusTargetGlobal;
- mCameraFocusOffset = mCameraFocusOffsetTarget;
- setLookAt(LOOKAT_TARGET_CLEAR);
- }
- else
- {
- mFocusTargetGlobal = focus;
- if (!focus_obj)
- {
- mCameraFOVZoomFactor = 0.f;
- }
-
- mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(mCameraVirtualPositionAgent) - mFocusTargetGlobal;
-
- startCameraAnimation();
-
- if (focus_obj)
- {
- if (focus_obj->isAvatar())
- {
- setLookAt(LOOKAT_TARGET_FOCUS, focus_obj);
- }
- else
- {
- setLookAt(LOOKAT_TARGET_FOCUS, focus_obj, (getPosAgentFromGlobal(focus) - focus_obj->getRenderPosition()) * ~focus_obj->getRenderRotation());
- }
- }
- else
- {
- setLookAt(LOOKAT_TARGET_FOCUS, NULL, getPosAgentFromGlobal(mFocusTargetGlobal));
- }
- }
- }
- else // focus == mFocusTargetGlobal
- {
- if (focus.isExactlyZero())
- {
- if (mAvatarObject.notNull())
- {
- mFocusTargetGlobal = getPosGlobalFromAgent(mAvatarObject->mHeadp->getWorldPosition());
- }
- else
- {
- mFocusTargetGlobal = getPositionGlobal();
- }
- }
- mCameraFocusOffsetTarget = (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor);;
- mCameraFocusOffset = mCameraFocusOffsetTarget;
- }
-
- if (mFocusObject.notNull())
- {
- // for attachments, make offset relative to avatar, not the attachment
- if (mFocusObject->isAttachment())
- {
- while (mFocusObject.notNull() // DEV-29123 - can crash with a messed-up attachment
- && !mFocusObject->isAvatar())
- {
- mFocusObject = (LLViewerObject*) mFocusObject->getParent();
- }
- setFocusObject((LLViewerObject*)mFocusObject);
- }
- updateFocusOffset();
- }
-}
-
-// 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 )
- {
- startCameraAnimation();
-
- 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;
-
- 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));
- }
-
- 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 );
- }
-
- updateFocusOffset();
-}
-
-//-----------------------------------------------------------------------------
-// setSitCamera()
-//-----------------------------------------------------------------------------
-void LLAgent::setSitCamera(const LLUUID &object_id, const LLVector3 &camera_pos, const LLVector3 &camera_focus)
-{
- BOOL camera_enabled = !object_id.isNull();
-
- 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;
- }
-}
-
-//-----------------------------------------------------------------------------
-// setFocusOnAvatar()
-//-----------------------------------------------------------------------------
-void LLAgent::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate)
-{
- if (focus_on_avatar != mFocusOnAvatar)
- {
- if (animate)
- {
- startCameraAnimation();
- }
- else
- {
- stopCameraAnimation();
- }
- }
-
- //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)
- {
- LLVector3 at_axis;
- 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
- {
- at_axis = LLViewerCamera::getInstance()->getAtAxis();
- at_axis.mV[VZ] = 0.f;
- at_axis.normalize();
- resetAxes(at_axis);
- }
- }
- }
- // unlocking camera from avatar
- else if (mFocusOnAvatar && !focus_on_avatar)
- {
- // keep camera focus point consistent, even though it is now unlocked
- setFocusGlobal(getPositionGlobal() + calcThirdPersonFocusOffset(), gAgent.getID());
- }
-
- mFocusOnAvatar = focus_on_avatar;
}
//-----------------------------------------------------------------------------
@@ -4592,90 +2004,13 @@ void LLAgent::heardChat(const LLUUID& id)
if (ll_rand(2) == 0)
{
LLViewerObject *chatter = gObjectList.findObject(mLastChatterID);
- setLookAt(LOOKAT_TARGET_AUTO_LISTEN, chatter, LLVector3::zero);
+ gAgentCamera.setLookAt(LOOKAT_TARGET_AUTO_LISTEN, chatter, LLVector3::zero);
}
mLastChatterID = id;
mChatTimer.reset();
}
-//-----------------------------------------------------------------------------
-// lookAtLastChat()
-//-----------------------------------------------------------------------------
-void LLAgent::lookAtLastChat()
-{
- // Block if camera is animating or not in normal third person camera mode
- if (mCameraAnimating || !cameraThirdPerson())
- {
- return;
- }
-
- LLViewerObject *chatter = gObjectList.findObject(mLastChatterID);
- if (chatter)
- {
- LLVector3 delta_pos;
- if (chatter->isAvatar())
- {
- LLVOAvatar *chatter_av = (LLVOAvatar*)chatter;
- if (mAvatarObject.notNull() && chatter_av->mHeadp)
- {
- delta_pos = chatter_av->mHeadp->getWorldPosition() - mAvatarObject->mHeadp->getWorldPosition();
- }
- else
- {
- delta_pos = chatter->getPositionAgent() - getPositionAgent();
- }
- delta_pos.normalize();
-
- setControlFlags(AGENT_CONTROL_STOP);
-
- changeCameraToThirdPerson();
-
- LLVector3 new_camera_pos = mAvatarObject->mHeadp->getWorldPosition();
- LLVector3 left = delta_pos % LLVector3::z_axis;
- left.normalize();
- LLVector3 up = left % delta_pos;
- up.normalize();
- new_camera_pos -= delta_pos * 0.4f;
- new_camera_pos += left * 0.3f;
- new_camera_pos += up * 0.2f;
- if (chatter_av->mHeadp)
- {
- setFocusGlobal(getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition()), mLastChatterID);
- mCameraFocusOffsetTarget = getPosGlobalFromAgent(new_camera_pos) - gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition());
- }
- else
- {
- setFocusGlobal(chatter->getPositionGlobal(), mLastChatterID);
- mCameraFocusOffsetTarget = getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal();
- }
- setFocusOnAvatar(FALSE, TRUE);
- }
- else
- {
- delta_pos = chatter->getRenderPosition() - getPositionAgent();
- delta_pos.normalize();
-
- setControlFlags(AGENT_CONTROL_STOP);
-
- changeCameraToThirdPerson();
-
- LLVector3 new_camera_pos = mAvatarObject->mHeadp->getWorldPosition();
- LLVector3 left = delta_pos % LLVector3::z_axis;
- left.normalize();
- LLVector3 up = left % delta_pos;
- up.normalize();
- new_camera_pos -= delta_pos * 0.4f;
- new_camera_pos += left * 0.3f;
- new_camera_pos += up * 0.2f;
-
- setFocusGlobal(chatter->getPositionGlobal(), mLastChatterID);
- mCameraFocusOffsetTarget = getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal();
- setFocusOnAvatar(FALSE, TRUE);
- }
- }
-}
-
const F32 SIT_POINT_EXTENTS = 0.2f;
LLSD ll_sdmap_from_vector3(const LLVector3& vec)
@@ -5182,7 +2517,7 @@ LLQuaternion LLAgent::getHeadRotation()
return LLQuaternion::DEFAULT;
}
- if (!gAgent.cameraMouselook())
+ if (!gAgentCamera.cameraMouselook())
{
return mAvatarObject->getRotation();
}
@@ -5353,10 +2688,11 @@ void LLAgent::initOriginGlobal(const LLVector3d &origin_global)
BOOL LLAgent::leftButtonGrabbed() const
{
- return (!cameraMouselook() && mControlsTakenCount[CONTROL_LBUTTON_DOWN_INDEX] > 0)
- || (cameraMouselook() && mControlsTakenCount[CONTROL_ML_LBUTTON_DOWN_INDEX] > 0)
- || (!cameraMouselook() && mControlsTakenPassedOnCount[CONTROL_LBUTTON_DOWN_INDEX] > 0)
- || (cameraMouselook() && mControlsTakenPassedOnCount[CONTROL_ML_LBUTTON_DOWN_INDEX] > 0);
+ 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)
+ || (camera_mouse_look && mControlsTakenPassedOnCount[CONTROL_ML_LBUTTON_DOWN_INDEX] > 0);
}
BOOL LLAgent::rotateGrabbed() const
@@ -5824,7 +3160,7 @@ void LLAgent::processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void *
return;
}
- if (gAgent.cameraCustomizeAvatar())
+ if (gAgentCamera.cameraCustomizeAvatar())
{
// ignore baked textures when in customize mode
return;
@@ -5924,7 +3260,7 @@ BOOL LLAgent::getHomePosGlobal( LLVector3d* pos_global )
void LLAgent::clearVisualParams(void *data)
{
- LLVOAvatar* avatarp = gAgent.getAvatarObject();
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
if (avatarp)
{
avatarp->clearVisualParamWeights();
@@ -5952,7 +3288,7 @@ bool LLAgent::teleportCore(bool is_local)
// sync with other viewers. Discuss in DEV-14145/VWR-6744 before reenabling.
// Stop all animation before actual teleporting
- LLVOAvatar* avatarp = gAgent.getAvatarObject();
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
if (avatarp)
{
for ( LLVOAvatar::AnimIterator anim_it= avatarp->mPlayingAnimations.begin();
@@ -5981,7 +3317,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
- resetView(FALSE);
+ gAgentCamera.resetView(FALSE);
// local logic
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TELEPORT_COUNT);
@@ -6155,7 +3491,7 @@ void LLAgent::stopCurrentAnimations()
// This function stops all current overriding animations on this
// avatar, propagating this change back to the server.
- LLVOAvatar* avatarp = gAgent.getAvatarObject();
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
if (avatarp)
{
for ( LLVOAvatar::AnimIterator anim_it =
@@ -6282,7 +3618,7 @@ void LLAgent::sendAgentSetAppearance()
{
if (mAvatarObject.isNull()) return;
- if (gAgentQueryManager.mNumPendingQueries > 0 && !gAgent.cameraCustomizeAvatar())
+ if (gAgentQueryManager.mNumPendingQueries > 0 && !gAgentCamera.cameraCustomizeAvatar())
{
return;
}
@@ -6500,7 +3836,39 @@ void LLAgent::dumpGroupInfo()
//llinfos << "insig " << gAgent.mGroupInsigniaID << llendl;
}
+// Draw a representation of current autopilot target
+void LLAgent::renderAutoPilotTarget()
+{
+ if (mAutoPilot)
+ {
+ F32 height_meters;
+ LLVector3d target_global;
+
+ glMatrixMode(GL_MODELVIEW);
+ gGL.pushMatrix();
+
+ // not textured
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+
+ // lovely green
+ glColor4f(0.f, 1.f, 1.f, 1.f);
+
+ target_global = mAutoPilotTargetGlobal;
+
+ gGL.translatef((F32)(target_global.mdV[VX]), (F32)(target_global.mdV[VY]), (F32)(target_global.mdV[VZ]));
+
+ height_meters = 1.f;
+
+ glScalef(height_meters, height_meters, height_meters);
+
+ gSphere.render(1500.f);
+
+ gGL.popMatrix();
+ }
+}
+
/********************************************************************************/
+
LLAgentQueryManager gAgentQueryManager;
LLAgentQueryManager::LLAgentQueryManager() :
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index f2df1992e7..b59a49be13 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -66,26 +66,6 @@ class LLAgentDropGroupViewerNode;
//--------------------------------------------------------------------
// 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
{
@@ -139,11 +119,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<LLAgentListener> mListener;
//--------------------------------------------------------------------
@@ -236,7 +217,7 @@ public:
// Coordinate System
//--------------------------------------------------------------------
public:
- LLCoordFrame getFrameAgent() const { return mFrameAgent; }
+ const LLCoordFrame& getFrameAgent() const { return mFrameAgent; }
void initOriginGlobal(const LLVector3d &origin_global); // Only to be used in ONE place
void resetAxes();
void resetAxes(const LLVector3 &look_at); // Makes reasonable left and up
@@ -279,6 +260,10 @@ private:
public:
S32 getRegionsVisited() const;
F64 getDistanceTraveled() const;
+ void setDistanceTraveled(F64 dist) { mDistanceTraveled = dist; }
+
+ const LLVector3d &getLastPositionGlobal() const { return mLastPositionGlobal; }
+ void setLastPositionGlobal(const LLVector3d &pos) { mLastPositionGlobal = pos; }
private:
std::set<U64> mRegionsVisited; // Stat - what distinct regions has the avatar been to?
F64 mDistanceTraveled; // Stat - how far has the avatar moved?
@@ -321,7 +306,6 @@ public:
//--------------------------------------------------------------------
public:
void heardChat(const LLUUID& id);
- void lookAtLastChat();
F32 getTypingTime() { return mTypingTimer.getElapsedTimeF32(); }
LLUUID getLastChatter() const { return mLastChatterID; }
F32 getNearChatRadius() { return mNearChatRadius; }
@@ -430,6 +414,8 @@ public:
// Send message to simulator to force grabbed controls to be
// released, in case of a poorly written script.
void forceReleaseControls();
+ void setFlagsDirty() { mbFlagsDirty = TRUE; }
+
private:
S32 mControlsTakenCount[TOTAL_CONTROLS];
S32 mControlsTakenPassedOnCount[TOTAL_CONTROLS];
@@ -447,9 +433,11 @@ public:
void sendAnimationRequests(LLDynamicArray<LLUUID> &anim_ids, EAnimRequest request);
void sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request);
void endAnimationUpdateUI();
+ void unpauseAnimation() { mPauseRequest = NULL; }
+ BOOL getCustomAnim() const { return mCustomAnim; }
+ void setCustomAnim(BOOL anim) { mCustomAnim = anim; }
+
private:
- LLFrameTimer mAnimationTimer; // Seconds that transition animation has been active
- F32 mAnimationDuration; // In seconds
BOOL mCustomAnim; // Current animation is ANIM_AGENT_CUSTOMIZE ?
LLAnimPauseRequest mPauseRequest;
BOOL mViewsPushed; // Keep track of whether or not we have pushed views
@@ -492,42 +480,6 @@ public:
void movePitch(F32 mag);
//--------------------------------------------------------------------
- // 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;
-
- //--------------------------------------------------------------------
- // 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
//--------------------------------------------------------------------
public:
@@ -640,232 +592,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 /*&& !mCameraAnimating*/); }
- 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<ECameraPreset, LLVector3> mCameraOffsetInitial;
-
- /** Initial focus offsets */
- std::map<ECameraPreset, LLVector3d> 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<LLViewerObject> 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
-
- //--------------------------------------------------------------------
- // 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<LLViewerObject>& 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<LLViewerObject> mFocusObject;
- F32 mFocusObjectDist;
- LLVector3 mFocusObjectOffset;
- F32 mFocusDotRadius; // Meters
- BOOL mTrackFocusObject;
- F32 mUIOffset;
-
- //--------------------------------------------------------------------
- // Lookat / Pointat
- //--------------------------------------------------------------------
-public:
- void updateLookAt(const S32 mouse_x, const S32 mouse_y);
- BOOL setLookAt(ELookAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
- ELookAtType getLookAtType();
- void slamLookAt(const LLVector3 &look_at); // Set the physics data
- BOOL setPointAt(EPointAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
- EPointAtType getPointAtType();
-public:
- LLPointer<LLHUDEffectLookAt> mLookAt;
- LLPointer<LLHUDEffectPointAt> mPointAt;
-
- //--------------------------------------------------------------------
- // 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);
-public:
- F32 mHUDTargetZoom; // Target zoom level for HUD objects (used when editing)
- F32 mHUDCurZoom; // Current animated zoom level for HUD objects
-private:
- LLUIColor mEffectColor;
-
-/** Camera
- ** **
- *******************************************************************************/
-
-/********************************************************************************
- ** **
** ACCESS
**/
@@ -938,8 +664,9 @@ public:
LLQuaternion getHeadRotation();
BOOL needsRenderAvatar(); // TRUE when camera mode is such that your own avatar should draw
BOOL needsRenderHead();
-public:
- F32 mDrawDistance;
+ void setShowAvatar(BOOL show) { mShowAvatar = show; }
+ BOOL getShowAvatar() const { return mShowAvatar; }
+
private:
BOOL mShowAvatar; // Should we render the avatar?
U32 mAppearanceSerialNum;
@@ -954,6 +681,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
new file mode 100644
index 0000000000..8eee53363e
--- /dev/null
+++ b/indra/newview/llagentcamera.cpp
@@ -0,0 +1,2875 @@
+/**
+ * @file llagentcamera.cpp
+ * @brief LLAgent class implementation
+ *
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ *
+ * Copyright (c) 2001-2009, Linden Research, Inc.
+ *
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab. Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ *
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ *
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ *
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+#include "llagentcamera.h"
+
+#include "pipeline.h"
+
+#include "llagentlistener.h"
+#include "llagentwearables.h"
+#include "llagentui.h"
+#include "llanimationstates.h"
+#include "llbottomtray.h"
+#include "llcallingcard.h"
+#include "llchannelmanager.h"
+#include "llconsole.h"
+//#include "llfirstuse.h"
+#include "llfloatercamera.h"
+#include "llfloatercustomize.h"
+#include "llfloaterreg.h"
+#include "llfloatertools.h"
+#include "llgroupactions.h"
+#include "llgroupmgr.h"
+#include "llhomelocationresponder.h"
+#include "llhudmanager.h"
+#include "lljoystickbutton.h"
+#include "llmorphview.h"
+#include "llmoveview.h"
+#include "llnavigationbar.h" // to show/hide navigation bar when changing mouse look state
+#include "llnearbychatbar.h"
+#include "llnotificationsutil.h"
+#include "llparcel.h"
+#include "llsdutil.h"
+#include "llsidetray.h"
+#include "llsky.h"
+#include "llsmoothstep.h"
+#include "llstatusbar.h"
+#include "llteleportflags.h"
+#include "lltool.h"
+#include "lltoolmgr.h"
+#include "lltrans.h"
+#include "llviewercontrol.h"
+#include "llviewerdisplay.h"
+#include "llviewerjoystick.h"
+#include "llviewermediafocus.h"
+#include "llviewerobjectlist.h"
+#include "llviewerparcelmgr.h"
+#include "llviewerstats.h"
+#include "llvoavatarself.h"
+#include "llwindow.h"
+#include "llworld.h"
+#include "llworldmap.h"
+
+using namespace LLVOAvatarDefines;
+
+extern LLMenuBarGL* gMenuBarView;
+
+// 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 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;
+
+const F32 GROUND_TO_AIR_CAMERA_TRANSITION_TIME = 0.5f;
+const F32 GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME = 0.5f;
+
+const F32 OBJECT_EXTENTS_PADDING = 0.5f;
+
+// The agent instance.
+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 ),
+
+ mCameraPreset(CAMERA_PRESET_REAR_VIEW),
+
+ 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),
+
+ 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)
+{
+ mFollowCam.setMaxCameraDistantFromSubject( MAX_CAMERA_DISTANCE_FROM_AGENT );
+}
+
+// Requires gSavedSettings to be initialized.
+//-----------------------------------------------------------------------------
+// init()
+//-----------------------------------------------------------------------------
+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);
+ 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");
+
+ mInitialized = TRUE;
+}
+
+//-----------------------------------------------------------------------------
+// cleanup()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::cleanup()
+{
+ setSitCamera(LLUUID::null);
+
+ if(mLookAt)
+ {
+ mLookAt->markDead() ;
+ mLookAt = NULL;
+ }
+ if(mPointAt)
+ {
+ mPointAt->markDead() ;
+ mPointAt = NULL;
+ }
+ setFocusObject(NULL);
+}
+
+void LLAgentCamera::setAvatarObject(LLVOAvatarSelf* avatar)
+{
+ if (!mLookAt)
+ {
+ mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT);
+ }
+ if (!mPointAt)
+ {
+ mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT);
+ }
+
+ if (!mLookAt.isNull())
+ {
+ mLookAt->setSourceObject(avatar);
+ }
+ if (!mPointAt.isNull())
+ {
+ mPointAt->setSourceObject(avatar);
+ }
+}
+
+//-----------------------------------------------------------------------------
+// LLAgent()
+//-----------------------------------------------------------------------------
+LLAgentCamera::~LLAgentCamera()
+{
+ cleanup();
+
+ // *Note: this is where LLViewerCamera::getInstance() used to be deleted.
+}
+
+// Change camera back to third person, stop the autopilot,
+// deselect stuff, etc.
+//-----------------------------------------------------------------------------
+// resetView()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera)
+{
+ if (gAgent.getAutoPilot())
+ {
+ gAgent.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 = gAgent.getAtAxis();
+ agent_at_axis -= projected_vec(agent_at_axis, gAgent.getReferenceUpVector());
+ agent_at_axis.normalize();
+ gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLCriticalDamp::getInterpolant(0.3f)));
+ }
+
+ setFocusOnAvatar(TRUE, ANIMATE);
+
+ mCameraFOVZoomFactor = 0.f;
+ }
+
+ mHUDTargetZoom = 1.f;
+}
+
+// Allow camera to be moved somewhere other than behind avatar.
+//-----------------------------------------------------------------------------
+// unlockView()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::unlockView()
+{
+ if (getFocusOnAvatar())
+ {
+ LLVOAvatarSelf *avatarp = gAgent.getAvatarObject();
+ if (avatarp)
+ {
+ setFocusGlobal(LLVector3d::zero, avatarp->mID);
+ }
+ setFocusOnAvatar(FALSE, FALSE); // no animation
+ }
+}
+
+//-----------------------------------------------------------------------------
+// slamLookAt()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::slamLookAt(const LLVector3 &look_at)
+{
+ LLVector3 look_at_norm = look_at;
+ look_at_norm.mV[VZ] = 0.f;
+ look_at_norm.normalize();
+ gAgent.resetAxes(look_at_norm);
+}
+
+//-----------------------------------------------------------------------------
+// calcFocusOffset()
+//-----------------------------------------------------------------------------
+LLVector3 LLAgentCamera::calcFocusOffset(LLViewerObject *object, LLVector3 original_focus_point, S32 x, S32 y)
+{
+ 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)
+ {
+ return original_focus_point - obj_pos;
+ }
+
+
+ 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());
+ }
+
+ // 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++)
+ {
+ //...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
+ {
+ clip_fraction.mV[axis] = dist_out_of_bounds / camera_to_focus_vec.mV[axis];
+ }
+ }
+
+ 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;
+
+ // 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;
+ }
+
+ return focus_offset_from_object_center;
+}
+
+//-----------------------------------------------------------------------------
+// calcCameraMinDistance()
+//-----------------------------------------------------------------------------
+BOOL LLAgentCamera::calcCameraMinDistance(F32 &obj_min_distance)
+{
+ BOOL soft_limit = FALSE; // is the bounding box to be treated literally (volumes) or as an approximation (avatars)
+
+ if (!mFocusObject || mFocusObject->isDead())
+ {
+ obj_min_distance = 0.f;
+ return TRUE;
+ }
+
+ if (mFocusObject->mDrawable.isNull())
+ {
+#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;
+ }
+
+ LLQuaternion inv_object_rot = ~mFocusObject->getRenderRotation();
+ LLVector3 target_offset_origin = mFocusObjectOffset;
+ LLVector3 camera_offset_target(getCameraPositionAgent() - gAgent.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())
+ {
+ // 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;
+ }
+ 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 (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
+ {
+ object_extents.mV[i] += target_offset_origin.mV[i] * 2.f;
+ }
+ }
+
+ // 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];
+
+ 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])
+ {
+ if (camera_offset_target_abs_norm.mV[VY] < 0.001f)
+ {
+ obj_min_distance = object_extents.mV[VY] * 0.5f;
+ }
+ else
+ {
+ 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];
+ }
+ }
+
+ 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];
+
+ 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])
+ {
+ object_split_axis = LLVector3::y_axis;
+ }
+ else
+ {
+ object_split_axis = LLVector3::z_axis;
+ }
+
+ LLVector3 camera_offset_object(getCameraPositionAgent() - mFocusObject->getPositionAgent());
+
+ // 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)
+ {
+ // target is visible from camera, so turn off fov zoom
+ exterior_target_visible = TRUE;
+ }
+
+ 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;
+ }
+ }
+
+ // clamp obj distance to diagonal of 10 by 10 cube
+ obj_min_distance = llmin(obj_min_distance, 10.f * F_SQRT3);
+
+ obj_min_distance += LLViewerCamera::getInstance()->getNear() + (soft_limit ? 0.1f : 0.2f);
+
+ return TRUE;
+}
+
+F32 LLAgentCamera::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())
+ {
+ F32 distance = (F32)mCameraFocusOffsetTarget.magVec();
+ return clamp_rescale(distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM, 1.f, 0.f );
+ }
+ 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
+ {
+ min_zoom = LAND_MIN_ZOOM;
+ }
+
+ return clamp_rescale(distance, min_zoom, max_zoom, 1.f, 0.f);
+ }
+}
+
+void LLAgentCamera::setCameraZoomFraction(F32 fraction)
+{
+ // 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)
+ {
+ mHUDTargetZoom = fraction;
+ }
+ else if (mFocusOnAvatar && cameraThirdPerson())
+ {
+ mCameraZoomFraction = rescale(fraction, 0.f, 1.f, MAX_ZOOM_FRACTION, MIN_ZOOM_FRACTION);
+ }
+ else if (cameraCustomizeAvatar())
+ {
+ 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);
+ }
+ 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;
+ }
+ }
+ }
+
+ LLVector3d camera_offset_dir = mCameraFocusOffsetTarget;
+ camera_offset_dir.normalize();
+ mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, max_zoom, min_zoom);
+ }
+ startCameraAnimation();
+}
+
+
+//-----------------------------------------------------------------------------
+// cameraOrbitAround()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::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))
+ {
+ gAgent.yaw(radians);
+ }
+ else
+ {
+ mCameraFocusOffsetTarget.rotVec(radians, 0.f, 0.f, 1.f);
+
+ cameraZoomIn(1.f);
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// cameraOrbitOver()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::cameraOrbitOver(const F32 angle)
+{
+ 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)
+ {
+ gAgent.pitch(angle);
+ }
+ else
+ {
+ LLVector3 camera_offset_unit(mCameraFocusOffsetTarget);
+ camera_offset_unit.normalize();
+
+ F32 angle_from_up = acos( camera_offset_unit * gAgent.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);
+ }
+}
+
+//-----------------------------------------------------------------------------
+// cameraZoomIn()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::cameraZoomIn(const F32 fraction)
+{
+ if (gDisconnected)
+ {
+ return;
+ }
+
+ LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
+ if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
+ {
+ // just update hud zoom level
+ mHUDTargetZoom /= fraction;
+ return;
+ }
+
+
+ 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)
+ {
+ 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())
+ {
+ calcCameraMinDistance(min_zoom);
+ }
+ else
+ {
+ min_zoom = OBJECT_MIN_ZOOM;
+ }
+ }
+
+ 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;
+
+ /*
+ // Unless camera is unlocked
+ if (!LLViewerCamera::sDisableCameraConstraints)
+ {
+ return;
+ }
+ */
+ }
+
+ if( cameraCustomizeAvatar() )
+ {
+ new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM );
+ }
+
+ mCameraFocusOffsetTarget = new_distance * camera_offset_unit;
+}
+
+//-----------------------------------------------------------------------------
+// cameraOrbitIn()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::cameraOrbitIn(const F32 meters)
+{
+ if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON)
+ {
+ 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)
+ {
+ // No need to animate, camera is already there.
+ changeCameraToMouselook(FALSE);
+ }
+
+ 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 (mFocusObject->isAvatar())
+ {
+ min_zoom = AVATAR_MIN_ZOOM;
+ }
+ else
+ {
+ min_zoom = OBJECT_MIN_ZOOM;
+ }
+ }
+
+ 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)
+ {
+ // Unless camera is unlocked
+ if (!gSavedSettings.getBOOL("DisableCameraConstraints"))
+ {
+ 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 LLAgentCamera::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 LLAgentCamera::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 LLAgentCamera::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();
+}
+
+//-----------------------------------------------------------------------------
+// updateLookAt()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y)
+{
+ static LLVector3 last_at_axis;
+
+ LLVOAvatarSelf *avatarp = gAgent.getAvatarObject();
+
+ if (!avatarp)
+ {
+ return;
+ }
+
+ LLQuaternion av_inv_rot = ~avatarp->mRoot.getWorldRotation();
+ LLVector3 root_at = LLVector3::x_axis * avatarp->mRoot.getWorldRotation();
+
+ if ((gViewerWindow->getMouseVelocityStat()->getCurrent() < 0.01f) &&
+ (root_at * last_at_axis > 0.95f))
+ {
+ LLVector3 vel = avatarp->getVelocity();
+ if (vel.magVecSquared() > 4.f)
+ {
+ setLookAt(LOOKAT_TARGET_IDLE, avatarp, 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
+ LLVector3 look_offset = LLVector3(2.f, 0.f, 0.f) * look_rotation * av_inv_rot;
+ setLookAt(LOOKAT_TARGET_IDLE, avatarp, look_offset);
+ }
+ last_at_axis = root_at;
+ return;
+ }
+
+ last_at_axis = root_at;
+
+ if (CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode())
+ {
+ setLookAt(LOOKAT_TARGET_NONE, avatarp, 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, avatarp, headLookAxis);
+ }
+}
+
+//-----------------------------------------------------------------------------
+// updateCamera()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::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();
+
+ LLVOAvatarSelf *avatarp = gAgent.getAvatarObject();
+
+ if (avatarp &&
+ avatarp->isSitting() &&
+ camera_mode == CAMERA_MODE_MOUSELOOK)
+ {
+ //Ventrella
+ //changed camera_skyward to the new global "mCameraUpVector"
+ mCameraUpVector = mCameraUpVector * avatarp->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<LLFloaterCamera>("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 (avatarp)
+ {
+ //--------------------------------------------------------------------------------
+ // 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 = avatarp->isSitting() ? avatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion();
+
+ LLFollowCamParams* current_cam = LLFollowCamMgr::getActiveFollowCamParams();
+ if (current_cam)
+ {
+ mFollowCam.copyParams(*current_cam);
+ mFollowCam.setSubjectPositionAndRotation( avatarp->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 = 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);
+
+ gAgent.setShowAvatar(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 )
+ {
+ gAgent.setShowAvatar(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;
+
+ gAgent.endAnimationUpdateUI();
+ gAgent.setShowAvatar(TRUE);
+ }
+
+ if (avatarp && (mCameraMode != CAMERA_MODE_MOUSELOOK))
+ {
+ avatarp->updateAttachmentVisibility(mCameraMode);
+ }
+ }
+ else
+ {
+ camera_pos_global = camera_target_global;
+ mFocusGlobal = focus_target_global;
+ gAgent.setShowAvatar(TRUE);
+ }
+
+ // smoothing
+ if (TRUE)
+ {
+ 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
+ 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 = gAgent.getPosAgentFromGlobal(mFocusGlobal);
+
+ mCameraPositionAgent = gAgent.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 = gAgent.getPositionGlobal();
+ if (!gAgent.getLastPositionGlobal().isExactlyZero())
+ {
+ LLVector3d delta = global_pos - gAgent.getLastPositionGlobal();
+ gAgent.setDistanceTraveled(gAgent.getDistanceTraveled() + delta.magVec());
+ }
+ gAgent.setLastPositionGlobal(global_pos);
+
+ if (LLVOAvatar::sVisibleInFirstPerson && avatarp && !avatarp->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 diff = mCameraPositionAgent - head_pos;
+ diff = diff * ~avatarp->mRoot.getWorldRotation();
+
+ LLJoint* torso_joint = avatarp->mTorsop;
+ LLJoint* chest_joint = avatarp->mChestp;
+ LLVector3 torso_scale = torso_joint->getScale();
+ LLVector3 chest_scale = chest_joint->getScale();
+
+ // shorten avatar skeleton to avoid foot interpenetration
+ if (!avatarp->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;
+ 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);
+
+ avatarp->mRoot.updateWorldMatrixChildren();
+
+ 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;
+ 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 LLAgentCamera::updateFocusOffset()
+{
+ validateFocusObject();
+ if (mFocusObject.notNull())
+ {
+ LLVector3d obj_pos = gAgent.getPosGlobalFromAgent(mFocusObject->getRenderPosition());
+ mFocusObjectOffset.setVec(mFocusTargetGlobal - obj_pos);
+ }
+}
+
+void LLAgentCamera::validateFocusObject()
+{
+ if (mFocusObject.notNull() &&
+ mFocusObject->isDead())
+ {
+ mFocusObjectOffset.clearVec();
+ clearFocusObject();
+ mCameraFOVZoomFactor = 0.f;
+ }
+}
+
+//-----------------------------------------------------------------------------
+// calcCustomizeAvatarUIOffset()
+//-----------------------------------------------------------------------------
+F32 LLAgentCamera::calcCustomizeAvatarUIOffset(const LLVector3d& camera_pos_global)
+{
+ F32 ui_offset = 0.f;
+
+ if (gFloaterCustomize)
+ {
+ const LLRect& rect = gFloaterCustomize->getRect();
+
+ // 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);
+
+ if( rect.mLeft < (gViewerWindow->getWindowWidthScaled() - rect.mRight) )
+ {
+ // Move the avatar to the right (camera to the left)
+ ui_offset = offset;
+ }
+ else
+ {
+ // Move the avatar to the left (camera to the right)
+ ui_offset = -offset;
+ }
+ }
+ F32 range = (F32)dist_vec(camera_pos_global, getFocusGlobal());
+ mUIOffset = lerp(mUIOffset, ui_offset, LLCriticalDamp::getInterpolant(0.05f));
+ return mUIOffset * range;
+}
+
+//-----------------------------------------------------------------------------
+// calcFocusPositionTargetGlobal()
+//-----------------------------------------------------------------------------
+LLVector3d LLAgentCamera::calcFocusPositionTargetGlobal()
+{
+ if (mFocusObject.notNull() && mFocusObject->isDead())
+ {
+ clearFocusObject();
+ }
+
+ LLVOAvatarSelf *avatarp = gAgent.getAvatarObject();
+
+ // 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 = gAgent.getFrameAgent().getQuaternion();
+ if (avatarp && avatarp->getParent())
+ {
+ LLViewerObject* root_object = (LLViewerObject*)avatarp->getRoot();
+ if (!root_object->flagCameraDecoupled())
+ {
+ agent_rot *= ((LLViewerObject*)(avatarp->getParent()))->getRenderRotation();
+ }
+ }
+ 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())
+ {
+ 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(gAgent.getPosGlobalFromAgent(focus_agent));
+ }
+ return mFocusTargetGlobal;
+ }
+ else if (mSitCameraEnabled && avatarp && avatarp->isSitting() && mSitCameraReferenceObject.notNull())
+ {
+ // sit camera
+ LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition();
+ LLQuaternion object_rot = mSitCameraReferenceObject->getRenderRotation();
+
+ LLVector3 target_pos = object_pos + (mSitCameraFocus * object_rot);
+ return gAgent.getPosGlobalFromAgent(target_pos);
+ }
+ else
+ {
+ return gAgent.getPositionGlobal() + calcThirdPersonFocusOffset();
+ }
+}
+
+LLVector3d LLAgentCamera::calcThirdPersonFocusOffset()
+{
+ // ...offset from avatar
+ LLVector3d focus_offset;
+
+ LLVOAvatarSelf *avatarp = gAgent.getAvatarObject();
+ LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion();
+ if (avatarp && avatarp->getParent())
+ {
+ agent_rot *= ((LLViewerObject*)(avatarp->getParent()))->getRenderRotation();
+ }
+
+ focus_offset = mFocusOffsetInitial[mCameraPreset] * agent_rot;
+ return focus_offset;
+}
+
+void LLAgentCamera::setupSitCamera()
+{
+ LLVOAvatarSelf *avatarp = gAgent.getAvatarObject();
+
+ // agent frame entering this function is in world coordinates
+ if (avatarp && avatarp->getParent())
+ {
+ LLQuaternion parent_rot = ((LLViewerObject*)avatarp->getParent())->getRenderRotation();
+ // slam agent coordinate frame to proper parent local version
+ LLVector3 at_axis = gAgent.getFrameAgent().getAtAxis();
+ at_axis.mV[VZ] = 0.f;
+ at_axis.normalize();
+ gAgent.resetAxes(at_axis * ~parent_rot);
+ }
+}
+
+//-----------------------------------------------------------------------------
+// getCameraPositionAgent()
+//-----------------------------------------------------------------------------
+const LLVector3 &LLAgentCamera::getCameraPositionAgent() const
+{
+ return LLViewerCamera::getInstance()->getOrigin();
+}
+
+//-----------------------------------------------------------------------------
+// getCameraPositionGlobal()
+//-----------------------------------------------------------------------------
+LLVector3d LLAgentCamera::getCameraPositionGlobal() const
+{
+ return gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin());
+}
+
+//-----------------------------------------------------------------------------
+// calcCameraFOVZoomFactor()
+//-----------------------------------------------------------------------------
+F32 LLAgentCamera::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 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 ?
+ gAgent.getPositionGlobal() :
+ gAgent.getPosGlobalFromAgent(avatarp->mRoot.getWorldPosition());
+
+ BOOL isConstrained = FALSE;
+ LLVector3d head_offset;
+ head_offset.setVec(mThirdPersonHeadOffset);
+
+ LLVector3d camera_position_global;
+
+ // Ventrella
+ if (mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar)
+ {
+ camera_position_global = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedPosition());
+ }// End Ventrella
+ else if (mCameraMode == CAMERA_MODE_MOUSELOOK)
+ {
+ if (!avatarp || avatarp->mDrawable.isNull())
+ {
+ llwarns << "Null avatar drawable!" << llendl;
+ return LLVector3d::zero;
+ }
+ head_offset.clearVec();
+ if (avatarp->isSitting() && avatarp->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();
+ camera_position_global = gAgent.getPosGlobalFromAgent
+ ((avatarp->getPosition()+
+ LLVector3(head_offset)*avatarp->getRotation()) * mat);
+ }
+ else
+ {
+ head_offset.mdV[VZ] = avatarp->mHeadOffset.mV[VZ];
+ if (avatarp->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 = camera_position_global + head_offset;
+ }
+ }
+ else if (mCameraMode == CAMERA_MODE_THIRD_PERSON && mFocusOnAvatar)
+ {
+ LLVector3 local_camera_offset;
+ F32 camera_distance = 0.f;
+
+ if (mSitCameraEnabled
+ && avatarp
+ && avatarp->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 = gAgent.getPosGlobalFromAgent(target_pos);
+ }
+ else
+ {
+ local_camera_offset = mCameraZoomFraction * getCameraOffsetInitial() * gSavedSettings.getF32("CameraOffsetScale");
+
+ // are we sitting down?
+ if (avatarp && avatarp->getParent())
+ {
+ LLQuaternion parent_rot = ((LLViewerObject*)avatarp->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;
+ at_axis.normalize();
+ gAgent.resetAxes(at_axis * ~parent_rot);
+
+ local_camera_offset = local_camera_offset * gAgent.getFrameAgent().getQuaternion() * parent_rot;
+ }
+ else
+ {
+ local_camera_offset = gAgent.getFrameAgent().rotateToAbsolute( local_camera_offset );
+ }
+
+ if (!mCameraCollidePlane.isExactlyZero() && (!avatarp || !avatarp->isSitting()))
+ {
+ 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 = gAgent.getPosAgentFromGlobal(frame_center_global + head_offset) * plane_normal;
+
+ // if agent is outside the colliding half-plane
+ if (pos_dot_norm > mCameraCollidePlane.mV[VW])
+ {
+ // 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;
+ }
+ }
+ else
+ {
+ if (offset_dot_norm + pos_dot_norm > mCameraCollidePlane.mV[VW])
+ {
+ camera_distance *= (mCameraCollidePlane.mV[VW] - pos_dot_norm - CAMERA_COLLIDE_EPSILON) / offset_dot_norm;
+ }
+ }
+ }
+ 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 = !avatarp ? LLVector3::zero : avatarp->getRenderPosition();
+ camera_offset.setVec( local_camera_offset );
+ camera_position_global = frame_center_global + head_offset + camera_offset;
+
+ if (avatarp)
+ {
+ LLVector3d camera_lag_d;
+ F32 lag_interp = LLCriticalDamp::getInterpolant(CAMERA_LAG_HALF_LIFE);
+ LLVector3 target_lag;
+ 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)
+ {
+ LLVector3 frame_at_axis = gAgent.getFrameAgent().getAtAxis();
+ frame_at_axis -= projected_vec(frame_at_axis, gAgent.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 == avatarp->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;
+ }
+ }
+ else
+ {
+ mCameraLag = lerp(mCameraLag, LLVector3::zero, LLCriticalDamp::getInterpolant(0.15f));
+ }
+
+ 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();
+
+ if(camera_distance > max_dist)
+ {
+ camera_position_global = gAgent.getPositionGlobal() + (max_dist/camera_distance)*camera_offset;
+ isConstrained = TRUE;
+ }
+ }
+
+// 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 LLAgentCamera::getCameraOffsetInitial()
+{
+ return mCameraOffsetInitial[mCameraPreset];
+}
+
+
+//-----------------------------------------------------------------------------
+// handleScrollWheel()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::handleScrollWheel(S32 clicks)
+{
+ if (mCameraMode == CAMERA_MODE_FOLLOW && getFocusOnAvatar())
+ {
+ if (!mFollowCam.getPositionLocked()) // not if the followCam position is locked in place
+ {
+ mFollowCam.zoom(clicks);
+ if (mFollowCam.isZoomedToMinimumDistance())
+ {
+ changeCameraToMouselook(FALSE);
+ }
+ }
+ }
+ 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
+ {
+ F32 current_zoom_fraction = (F32)mCameraFocusOffsetTarget.magVec();
+ cameraOrbitIn(current_zoom_fraction * (1.f - pow(ROOT_ROOT_TWO, clicks)));
+ }
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// getCameraMinOffGround()
+//-----------------------------------------------------------------------------
+F32 LLAgentCamera::getCameraMinOffGround()
+{
+ if (mCameraMode == CAMERA_MODE_MOUSELOOK)
+ {
+ return 0.f;
+ }
+ else
+ {
+ if (gSavedSettings.getBOOL("DisableCameraConstraints"))
+ {
+ return -1000.f;
+ }
+ else
+ {
+ return 0.5f;
+ }
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// resetCamera()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::resetCamera()
+{
+ // Remove any pitch from the avatar
+ LLVector3 at = gAgent.getFrameAgent().getAtAxis();
+ at.mV[VZ] = 0.f;
+ at.normalize();
+ gAgent.resetAxes(at);
+ // have to explicitly clear field of view zoom now
+ mCameraFOVZoomFactor = 0.f;
+
+ updateCamera();
+}
+
+//-----------------------------------------------------------------------------
+// changeCameraToMouselook()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::changeCameraToMouselook(BOOL animate)
+{
+ if (LLViewerJoystick::getInstance()->getOverrideCamera())
+ {
+ return;
+ }
+
+ LLVOAvatarSelf *avatarp = gAgent.getAvatarObject();
+
+ // visibility changes at end of animation
+ gViewerWindow->getWindow()->resetBusyCount();
+
+ // unpause avatar animation
+ gAgent.unpauseAnimation();
+
+ LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset);
+
+ if (avatarp)
+ {
+ avatarp->stopMotion(ANIM_AGENT_BODY_NOISE);
+ avatarp->stopMotion(ANIM_AGENT_BREATHE_ROT);
+ }
+
+ //gViewerWindow->stopGrab();
+ LLSelectMgr::getInstance()->deselectAll();
+ gViewerWindow->hideCursor();
+ gViewerWindow->moveCursorToCenter();
+
+ if (mCameraMode != CAMERA_MODE_MOUSELOOK)
+ {
+ gFocusMgr.setKeyboardFocus(NULL);
+
+ mLastCameraMode = mCameraMode;
+ mCameraMode = CAMERA_MODE_MOUSELOOK;
+ const U32 old_flags = gAgent.getControlFlags();
+ gAgent.setControlFlags(AGENT_CONTROL_MOUSELOOK);
+ if (old_flags != gAgent.getControlFlags())
+ {
+ gAgent.setFlagsDirty();
+ }
+
+ if (animate)
+ {
+ startCameraAnimation();
+ }
+ else
+ {
+ mCameraAnimating = FALSE;
+ gAgent.endAnimationUpdateUI();
+ }
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// changeCameraToDefault()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::changeCameraToDefault()
+{
+ if (LLViewerJoystick::getInstance()->getOverrideCamera())
+ {
+ return;
+ }
+
+ if (LLFollowCamMgr::getActiveFollowCamParams())
+ {
+ changeCameraToFollow();
+ }
+ else
+ {
+ changeCameraToThirdPerson();
+ }
+}
+
+
+// Ventrella
+//-----------------------------------------------------------------------------
+// changeCameraToFollow()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::changeCameraToFollow(BOOL animate)
+{
+ if (LLViewerJoystick::getInstance()->getOverrideCamera())
+ {
+ return;
+ }
+
+ 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);
+ }
+
+ LLVOAvatarSelf *avatarp = gAgent.getAvatarObject();
+ if (avatarp)
+ {
+ avatarp->mPelvisp->setPosition(LLVector3::zero);
+ avatarp->startMotion( ANIM_AGENT_BODY_NOISE );
+ avatarp->startMotion( ANIM_AGENT_BREATHE_ROT );
+ }
+
+ // unpause avatar animation
+ gAgent.unpauseAnimation();
+
+ const U32 old_flags = gAgent.getControlFlags();
+ gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK);
+ if (old_flags != gAgent.getControlFlags())
+ {
+ gAgent.setFlagsDirty();
+ }
+
+ if (animate)
+ {
+ startCameraAnimation();
+ }
+ else
+ {
+ mCameraAnimating = FALSE;
+ gAgent.endAnimationUpdateUI();
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------
+// changeCameraToThirdPerson()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::changeCameraToThirdPerson(BOOL animate)
+{
+ if (LLViewerJoystick::getInstance()->getOverrideCamera())
+ {
+ return;
+ }
+
+ gViewerWindow->getWindow()->resetBusyCount();
+
+ mCameraZoomFraction = INITIAL_ZOOM_FRACTION;
+
+ LLVOAvatarSelf *avatarp = gAgent.getAvatarObject();
+ if (avatarp)
+ {
+ if (!avatarp->isSitting())
+ {
+ avatarp->mPelvisp->setPosition(LLVector3::zero);
+ }
+ avatarp->startMotion(ANIM_AGENT_BODY_NOISE);
+ avatarp->startMotion(ANIM_AGENT_BREATHE_ROT);
+ }
+
+ LLVector3 at_axis;
+
+ // unpause avatar animation
+ gAgent.unpauseAnimation();
+
+ if (mCameraMode != CAMERA_MODE_THIRD_PERSON)
+ {
+ 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;
+ const U32 old_flags = gAgent.getControlFlags();
+ gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK);
+ if (old_flags != gAgent.getControlFlags())
+ {
+ gAgent.setFlagsDirty();
+ }
+
+ }
+
+ // Remove any pitch from the avatar
+ if (avatarp && avatarp->getParent())
+ {
+ LLQuaternion obj_rot = ((LLViewerObject*)avatarp->getParent())->getRenderRotation();
+ at_axis = LLViewerCamera::getInstance()->getAtAxis();
+ at_axis.mV[VZ] = 0.f;
+ at_axis.normalize();
+ gAgent.resetAxes(at_axis * ~obj_rot);
+ }
+ else
+ {
+ at_axis = gAgent.getFrameAgent().getAtAxis();
+ at_axis.mV[VZ] = 0.f;
+ at_axis.normalize();
+ gAgent.resetAxes(at_axis);
+ }
+
+
+ if (animate)
+ {
+ startCameraAnimation();
+ }
+ else
+ {
+ mCameraAnimating = FALSE;
+ gAgent.endAnimationUpdateUI();
+ }
+}
+
+//-----------------------------------------------------------------------------
+// changeCameraToCustomizeAvatar()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL camera_animate)
+{
+ if (LLViewerJoystick::getInstance()->getOverrideCamera())
+ {
+ return;
+ }
+
+ gAgent.standUp(); // force stand up
+ gViewerWindow->getWindow()->resetBusyCount();
+
+ if (gFaceEditToolset)
+ {
+ LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset);
+ }
+
+ if (camera_animate)
+ {
+ startCameraAnimation();
+ }
+
+ // Remove any pitch from the avatar
+ //LLVector3 at = gAgent.getFrameAgent().getAtAxis();
+ //at.mV[VZ] = 0.f;
+ //at.normalize();
+ //gAgent.resetAxes(at);
+
+ if (mCameraMode != CAMERA_MODE_CUSTOMIZE_AVATAR)
+ {
+ mLastCameraMode = mCameraMode;
+ mCameraMode = CAMERA_MODE_CUSTOMIZE_AVATAR;
+ const U32 old_flags = gAgent.getControlFlags();
+ gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK);
+ if (old_flags != gAgent.getControlFlags())
+ {
+ gAgent.setFlagsDirty();
+ }
+
+ gFocusMgr.setKeyboardFocus( NULL );
+ gFocusMgr.setMouseCapture( NULL );
+
+ LLVOAvatarSelf::onCustomizeStart();
+ }
+
+ LLVOAvatarSelf *avatarp = gAgent.getAvatarObject();
+ if (avatarp)
+ {
+ if(avatar_animate)
+ {
+ // Remove any pitch from the avatar
+ LLVector3 at = gAgent.getFrameAgent().getAtAxis();
+ at.mV[VZ] = 0.f;
+ at.normalize();
+ gAgent.resetAxes(at);
+
+ gAgent.sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_START);
+ gAgent.setCustomAnim(TRUE);
+ avatarp->startMotion(ANIM_AGENT_CUSTOMIZE);
+ LLMotion* turn_motion = avatarp->findMotion(ANIM_AGENT_CUSTOMIZE);
+
+ if (turn_motion)
+ {
+ mAnimationDuration = turn_motion->getDuration() + CUSTOMIZE_AVATAR_CAMERA_ANIM_SLOP;
+
+ }
+ else
+ {
+ mAnimationDuration = gSavedSettings.getF32("ZoomTime");
+ }
+ }
+ setFocusGlobal(LLVector3d::zero);
+ }
+ else
+ {
+ mCameraAnimating = FALSE;
+ gAgent.endAnimationUpdateUI();
+ }
+}
+
+
+void LLAgentCamera::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;
+
+ gSavedSettings.setU32("CameraPreset", mCameraPreset);
+}
+
+
+//
+// Focus point management
+//
+
+//-----------------------------------------------------------------------------
+// startCameraAnimation()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::startCameraAnimation()
+{
+ mAnimationCameraStartGlobal = getCameraPositionGlobal();
+ mAnimationFocusStartGlobal = mFocusGlobal;
+ mAnimationTimer.reset();
+ mCameraAnimating = TRUE;
+ mAnimationDuration = gSavedSettings.getF32("ZoomTime");
+}
+
+//-----------------------------------------------------------------------------
+// stopCameraAnimation()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::stopCameraAnimation()
+{
+ mCameraAnimating = FALSE;
+}
+
+void LLAgentCamera::clearFocusObject()
+{
+ if (mFocusObject.notNull())
+ {
+ startCameraAnimation();
+
+ setFocusObject(NULL);
+ mFocusObjectOffset.clearVec();
+ }
+}
+
+void LLAgentCamera::setFocusObject(LLViewerObject* object)
+{
+ mFocusObject = object;
+}
+
+// Focus on a point, but try to keep camera position stable.
+//-----------------------------------------------------------------------------
+// setFocusGlobal()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::setFocusGlobal(const LLPickInfo& pick)
+{
+ LLViewerObject* objectp = gObjectList.findObject(pick.mObjectID);
+
+ 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);
+ }
+}
+
+
+void LLAgentCamera::setFocusGlobal(const LLVector3d& focus, const LLUUID &object_id)
+{
+ 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)
+ {
+ mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(avatarp->mHeadp->getWorldPosition());
+ }
+ else
+ {
+ mFocusTargetGlobal = gAgent.getPositionGlobal();
+ }
+ mCameraFocusOffsetTarget = getCameraPositionGlobal() - mFocusTargetGlobal;
+ mCameraFocusOffset = mCameraFocusOffsetTarget;
+ setLookAt(LOOKAT_TARGET_CLEAR);
+ }
+ else
+ {
+ mFocusTargetGlobal = focus;
+ if (!focus_obj)
+ {
+ mCameraFOVZoomFactor = 0.f;
+ }
+
+ mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(mCameraVirtualPositionAgent) - mFocusTargetGlobal;
+
+ startCameraAnimation();
+
+ if (focus_obj)
+ {
+ if (focus_obj->isAvatar())
+ {
+ setLookAt(LOOKAT_TARGET_FOCUS, focus_obj);
+ }
+ else
+ {
+ setLookAt(LOOKAT_TARGET_FOCUS, focus_obj, (gAgent.getPosAgentFromGlobal(focus) - focus_obj->getRenderPosition()) * ~focus_obj->getRenderRotation());
+ }
+ }
+ else
+ {
+ setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgent.getPosAgentFromGlobal(mFocusTargetGlobal));
+ }
+ }
+ }
+ else // focus == mFocusTargetGlobal
+ {
+ if (focus.isExactlyZero())
+ {
+ if (avatarp)
+ {
+ mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(avatarp->mHeadp->getWorldPosition());
+ }
+ else
+ {
+ mFocusTargetGlobal = gAgent.getPositionGlobal();
+ }
+ }
+ mCameraFocusOffsetTarget = (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor);;
+ mCameraFocusOffset = mCameraFocusOffsetTarget;
+ }
+
+ if (mFocusObject.notNull())
+ {
+ // for attachments, make offset relative to avatar, not the attachment
+ if (mFocusObject->isAttachment())
+ {
+ while (mFocusObject.notNull() && !mFocusObject->isAvatar())
+ {
+ mFocusObject = (LLViewerObject*) mFocusObject->getParent();
+ }
+ setFocusObject((LLViewerObject*)mFocusObject);
+ }
+ updateFocusOffset();
+ }
+}
+
+// Used for avatar customization
+//-----------------------------------------------------------------------------
+// setCameraPosAndFocusGlobal()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::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)
+ {
+ startCameraAnimation();
+
+ 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;
+
+ if (mFocusObject)
+ {
+ if (mFocusObject->isAvatar())
+ {
+ setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject);
+ }
+ else
+ {
+ setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject, (gAgent.getPosAgentFromGlobal(focus) - mFocusObject->getRenderPosition()) * ~mFocusObject->getRenderRotation());
+ }
+ }
+ else
+ {
+ setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgent.getPosAgentFromGlobal(mFocusTargetGlobal));
+ }
+
+ 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 );
+ }
+
+ updateFocusOffset();
+}
+
+//-----------------------------------------------------------------------------
+// setSitCamera()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::setSitCamera(const LLUUID &object_id, const LLVector3 &camera_pos, const LLVector3 &camera_focus)
+{
+ BOOL camera_enabled = !object_id.isNull();
+
+ 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;
+ }
+}
+
+//-----------------------------------------------------------------------------
+// setFocusOnAvatar()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate)
+{
+ if (focus_on_avatar != mFocusOnAvatar)
+ {
+ if (animate)
+ {
+ startCameraAnimation();
+ }
+ else
+ {
+ stopCameraAnimation();
+ }
+ }
+
+ //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)
+ {
+ LLVector3 at_axis;
+ LLVOAvatarSelf *avatarp = gAgent.getAvatarObject();
+ if (avatarp && avatarp->getParent())
+ {
+ LLQuaternion obj_rot = ((LLViewerObject*)avatarp->getParent())->getRenderRotation();
+ at_axis = LLViewerCamera::getInstance()->getAtAxis();
+ at_axis.mV[VZ] = 0.f;
+ at_axis.normalize();
+ gAgent.resetAxes(at_axis * ~obj_rot);
+ }
+ else
+ {
+ at_axis = LLViewerCamera::getInstance()->getAtAxis();
+ at_axis.mV[VZ] = 0.f;
+ at_axis.normalize();
+ gAgent.resetAxes(at_axis);
+ }
+ }
+ }
+ // unlocking camera from avatar
+ else if (mFocusOnAvatar && !focus_on_avatar)
+ {
+ // keep camera focus point consistent, even though it is now unlocked
+ setFocusGlobal(gAgent.getPositionGlobal() + calcThirdPersonFocusOffset(), gAgent.getID());
+ }
+
+ mFocusOnAvatar = focus_on_avatar;
+}
+
+
+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)
+ {
+ // looking at an attachment on ourselves, which we don't want to do
+ object = avatarp;
+ position.clearVec();
+ }
+ parent = (LLViewerObject*)parent->getParent();
+ }
+ }
+ if(!mLookAt || mLookAt->isDead())
+ {
+ mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT);
+ mLookAt->setSourceObject(avatarp);
+ }
+
+ return mLookAt->setLookAt(target_type, object, position);
+}
+
+//-----------------------------------------------------------------------------
+// lookAtLastChat()
+//-----------------------------------------------------------------------------
+void LLAgentCamera::lookAtLastChat()
+{
+ // Block if camera is animating or not in normal third person camera mode
+ if (mCameraAnimating || !cameraThirdPerson())
+ {
+ return;
+ }
+
+ LLViewerObject *chatter = gObjectList.findObject(gAgent.getLastChatter());
+ if (!chatter)
+ {
+ return;
+ }
+
+ LLVOAvatarSelf *avatarp = gAgent.getAvatarObject();
+ LLVector3 delta_pos;
+ if (chatter->isAvatar())
+ {
+ LLVOAvatar *chatter_av = (LLVOAvatar*)chatter;
+ if (avatarp && chatter_av->mHeadp)
+ {
+ delta_pos = chatter_av->mHeadp->getWorldPosition() - avatarp->mHeadp->getWorldPosition();
+ }
+ else
+ {
+ delta_pos = chatter->getPositionAgent() - gAgent.getPositionAgent();
+ }
+ delta_pos.normalize();
+
+ gAgent.setControlFlags(AGENT_CONTROL_STOP);
+
+ changeCameraToThirdPerson();
+
+ LLVector3 new_camera_pos = avatarp->mHeadp->getWorldPosition();
+ LLVector3 left = delta_pos % LLVector3::z_axis;
+ left.normalize();
+ LLVector3 up = left % delta_pos;
+ up.normalize();
+ new_camera_pos -= delta_pos * 0.4f;
+ new_camera_pos += left * 0.3f;
+ new_camera_pos += up * 0.2f;
+ if (chatter_av->mHeadp)
+ {
+ setFocusGlobal(gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition()), gAgent.getLastChatter());
+ mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition());
+ }
+ else
+ {
+ setFocusGlobal(chatter->getPositionGlobal(), gAgent.getLastChatter());
+ mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal();
+ }
+ setFocusOnAvatar(FALSE, TRUE);
+ }
+ else
+ {
+ delta_pos = chatter->getRenderPosition() - gAgent.getPositionAgent();
+ delta_pos.normalize();
+
+ gAgent.setControlFlags(AGENT_CONTROL_STOP);
+
+ changeCameraToThirdPerson();
+
+ LLVector3 new_camera_pos = avatarp->mHeadp->getWorldPosition();
+ LLVector3 left = delta_pos % LLVector3::z_axis;
+ left.normalize();
+ LLVector3 up = left % delta_pos;
+ up.normalize();
+ new_camera_pos -= delta_pos * 0.4f;
+ new_camera_pos += left * 0.3f;
+ new_camera_pos += up * 0.2f;
+
+ setFocusGlobal(chatter->getPositionGlobal(), gAgent.getLastChatter());
+ mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal();
+ setFocusOnAvatar(FALSE, TRUE);
+ }
+}
+
+BOOL LLAgentCamera::setPointAt(EPointAtType target_type, LLViewerObject *object, LLVector3 position)
+{
+ // disallow pointing at attachments and avatars
+ if (object && (object->isAttachment() || object->isAvatar()))
+ {
+ return FALSE;
+ }
+ if (!mPointAt || mPointAt->isDead())
+ {
+ mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT);
+ LLVOAvatarSelf *avatarp = gAgent.getAvatarObject();
+ mPointAt->setSourceObject(avatarp);
+ }
+ return mPointAt->setPointAt(target_type, object, position);
+}
+
+ELookAtType LLAgentCamera::getLookAtType()
+{
+ if (mLookAt)
+ {
+ return mLookAt->getLookAtType();
+ }
+ return LOOKAT_TARGET_NONE;
+}
+
+EPointAtType LLAgentCamera::getPointAtType()
+{
+ if (mPointAt)
+ {
+ return mPointAt->getPointAtType();
+ }
+ return POINTAT_TARGET_NONE;
+}
+
+// EOF
+
diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h
new file mode 100644
index 0000000000..6fe645e7d1
--- /dev/null
+++ b/indra/newview/llagentcamera.h
@@ -0,0 +1,363 @@
+/**
+ * @file llagent.h
+ * @brief LLAgent class header file
+ *
+ * $LicenseInfo:firstyear=2000&license=viewergpl$
+ *
+ * Copyright (c) 2000-2009, Linden Research, Inc.
+ *
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab. Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ *
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ *
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ *
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLAGENTCAMERA_H
+#define LL_LLAGENTCAMERA_H
+
+#include "indra_constants.h"
+#include "llevent.h" // LLObservable base class
+#include "llagent.h"
+#include "llagentaccess.h"
+#include "llagentconstants.h"
+#include "llagentdata.h" // gAgentID, gAgentSessionID
+#include "llcharacter.h" // LLAnimPauseRequest
+#include "llfollowcam.h" // Ventrella
+#include "llhudeffectlookat.h" // EPointAtType
+#include "llhudeffectpointat.h" // ELookAtType
+#include "llpointer.h"
+#include "lluicolor.h"
+#include "llvoavatardefines.h"
+
+class LLChat;
+class LLVOAvatarSelf;
+class LLViewerRegion;
+class LLMotion;
+class LLToolset;
+class LLMessageSystem;
+class LLPermissions;
+class LLHost;
+class LLFriendObserver;
+class LLPickInfo;
+class LLViewerObject;
+class LLAgentDropGroupViewerNode;
+
+//--------------------------------------------------------------------
+// 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
+};
+
+//------------------------------------------------------------------------
+// LLAgentCamera
+//------------------------------------------------------------------------
+class LLAgentCamera
+{
+ LOG_CLASS(LLAgentCamera);
+
+public:
+ friend class LLAgent;
+
+ //--------------------------------------------------------------------
+ // Constructors / Destructors
+ //--------------------------------------------------------------------
+public:
+ LLAgentCamera();
+ virtual ~LLAgentCamera();
+ void init();
+ void cleanup();
+ void setAvatarObject(LLVOAvatarSelf* avatar);
+private:
+ BOOL mInitialized;
+
+
+ //--------------------------------------------------------------------
+ // 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 /*&& !mCameraAnimating*/); }
+ 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<ECameraPreset, LLVector3> mCameraOffsetInitial;
+
+ /** Initial focus offsets */
+ std::map<ECameraPreset, LLVector3d> 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)
+
+ //--------------------------------------------------------------------
+ // 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;
+
+ //--------------------------------------------------------------------
+ // 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;
+
+ //--------------------------------------------------------------------
+ // 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<LLViewerObject> 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
+
+ //--------------------------------------------------------------------
+ // Animation
+ //--------------------------------------------------------------------
+public:
+ void setCameraAnimating(BOOL b) { mCameraAnimating = b; }
+ BOOL getCameraAnimating() { return mCameraAnimating; }
+ void setAnimationDuration(F32 seconds) { mAnimationDuration = seconds; }
+ void startCameraAnimation();
+ void stopCameraAnimation();
+private:
+ 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
+ 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<LLViewerObject>& 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<LLViewerObject> mFocusObject;
+ F32 mFocusObjectDist;
+ LLVector3 mFocusObjectOffset;
+ F32 mFocusDotRadius; // Meters
+ BOOL mTrackFocusObject;
+ F32 mUIOffset;
+
+ //--------------------------------------------------------------------
+ // Lookat / Pointat
+ //--------------------------------------------------------------------
+public:
+ void updateLookAt(const S32 mouse_x, const S32 mouse_y);
+ BOOL setLookAt(ELookAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
+ ELookAtType getLookAtType();
+ void lookAtLastChat();
+ void slamLookAt(const LLVector3 &look_at); // Set the physics data
+ BOOL setPointAt(EPointAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
+ EPointAtType getPointAtType();
+public:
+ LLPointer<LLHUDEffectLookAt> mLookAt;
+ LLPointer<LLHUDEffectPointAt> mPointAt;
+
+ //--------------------------------------------------------------------
+ // 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();
+public:
+ F32 mDrawDistance;
+
+ //--------------------------------------------------------------------
+ // Mouselook
+ //--------------------------------------------------------------------
+public:
+ BOOL getForceMouselook() const { return mForceMouselook; }
+ void setForceMouselook(BOOL mouselook) { mForceMouselook = mouselook; }
+private:
+ BOOL mForceMouselook;
+
+ //--------------------------------------------------------------------
+ // HUD
+ //--------------------------------------------------------------------
+public:
+ F32 mHUDTargetZoom; // Target zoom level for HUD objects (used when editing)
+ F32 mHUDCurZoom; // Current animated zoom level for HUD objects
+};
+
+extern LLAgentCamera gAgentCamera;
+
+#endif
diff --git a/indra/newview/llagentui.cpp b/indra/newview/llagentui.cpp
index 72ab9235cf..4601e3241b 100644
--- a/indra/newview/llagentui.cpp
+++ b/indra/newview/llagentui.cpp
@@ -50,11 +50,11 @@ void LLAgentUI::buildName(std::string& name)
{
name.clear();
- LLVOAvatarSelf* avatar_object = gAgent.getAvatarObject();
- if (avatar_object)
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if (avatarp)
{
- LLNameValue *first_nv = avatar_object->getNVPair("FirstName");
- LLNameValue *last_nv = avatar_object->getNVPair("LastName");
+ LLNameValue *first_nv = avatarp->getNVPair("FirstName");
+ LLNameValue *last_nv = avatarp->getNVPair("LastName");
if (first_nv && last_nv)
{
name = first_nv->printData() + " " + last_nv->printData();
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index ebadd8a165..5eb943877a 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -32,7 +32,8 @@
#include "llviewerprecompiledheaders.h"
-#include "llagent.h"
+#include "llagent.h"
+#include "llagentcamera.h"
#include "llagentwearables.h"
#include "llcallbacklist.h"
@@ -218,8 +219,7 @@ struct LLAgentDumper
};
LLAgentWearables::LLAgentWearables() :
- mWearablesLoaded(FALSE),
- mAvatarObject(NULL)
+ mWearablesLoaded(FALSE)
{
}
@@ -230,12 +230,10 @@ LLAgentWearables::~LLAgentWearables()
void LLAgentWearables::cleanup()
{
- mAvatarObject = NULL;
}
void LLAgentWearables::setAvatarObject(LLVOAvatarSelf *avatar)
{
- mAvatarObject = avatar;
if (avatar)
{
sendAgentWearablesRequest();
@@ -686,13 +684,13 @@ const LLWearable* LLAgentWearables::getWearableFromItemID(const LLUUID& item_id)
return NULL;
}
-const LLWearable* LLAgentWearables::getWearableFromAssetID(const LLUUID& asset_id) const
+LLWearable* LLAgentWearables::getWearableFromAssetID(const LLUUID& asset_id)
{
for (S32 i=0; i < WT_COUNT; i++)
{
for (U32 j=0; j < getWearableCount((EWearableType)i); j++)
{
- const LLWearable * curr_wearable = getWearable((EWearableType)i, j);
+ LLWearable * curr_wearable = getWearable((EWearableType)i, j);
if (curr_wearable && (curr_wearable->getAssetID() == asset_id))
{
return curr_wearable;
@@ -785,7 +783,8 @@ U32 LLAgentWearables::pushWearable(const EWearableType type, LLWearable *wearabl
void LLAgentWearables::wearableUpdated(LLWearable *wearable)
{
- mAvatarObject->wearableUpdated(wearable->getType(), TRUE);
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ avatarp->wearableUpdated(wearable->getType(), TRUE);
wearable->refreshName();
wearable->setLabelUpdated();
@@ -826,10 +825,11 @@ 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);
- mAvatarObject->wearableUpdated(wearable->getType(), TRUE);
+ avatarp->wearableUpdated(wearable->getType(), TRUE);
wearable->setLabelUpdated();
}
}
@@ -961,8 +961,8 @@ void LLAgentWearables::processAgentInitialWearablesUpdate(LLMessageSystem* mesgs
LLUUID agent_id;
gMessageSystem->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
- LLVOAvatar* avatar = gAgent.getAvatarObject();
- if (avatar && (agent_id == avatar->getID()))
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if (avatarp && (agent_id == avatarp->getID()))
{
gMessageSystem->getU32Fast(_PREHASH_AgentData, _PREHASH_SerialNum, gAgentQueryManager.mUpdateSerialNum);
@@ -1054,8 +1054,8 @@ void LLAgentWearables::onInitialWearableAssetArrived(LLWearable* wearable, void*
const EWearableType type = wear_data->mType;
U32 index = 0;
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- if (!avatar)
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if (!avatarp)
{
return;
}
@@ -1068,9 +1068,9 @@ void LLAgentWearables::onInitialWearableAssetArrived(LLWearable* wearable, void*
gAgentWearables.mItemsAwaitingWearableUpdate.erase(wear_data->mItemID);
// disable composites if initial textures are baked
- avatar->setupComposites();
+ avatarp->setupComposites();
- avatar->setCompositeUpdatesEnabled(TRUE);
+ avatarp->setCompositeUpdatesEnabled(TRUE);
gInventory.addChangedMask(LLInventoryObserver::LABEL, wearable->getItemID());
}
else
@@ -1097,9 +1097,9 @@ void LLAgentWearables::onInitialWearableAssetArrived(LLWearable* wearable, void*
// Check to see if there are any baked textures that we hadn't uploaded before we logged off last time.
// If there are any, schedule them to be uploaded as soon as the layer textures they depend on arrive.
- if (gAgent.cameraCustomizeAvatar())
+ if (gAgentCamera.cameraCustomizeAvatar())
{
- avatar->requestLayerSetUploads();
+ avatarp->requestLayerSetUploads();
}
}
}
@@ -1239,12 +1239,13 @@ void LLAgentWearables::createStandardWearables(BOOL female)
llwarns << "Creating Standard " << (female ? "female" : "male")
<< " Wearables" << llendl;
- if (mAvatarObject.isNull())
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if (!avatarp)
{
return;
}
- mAvatarObject->setSex(female ? SEX_FEMALE : SEX_MALE);
+ avatarp->setSex(female ? SEX_FEMALE : SEX_MALE);
const BOOL create[WT_COUNT] =
{
@@ -1291,9 +1292,11 @@ void LLAgentWearables::createStandardWearables(BOOL female)
void LLAgentWearables::createStandardWearablesDone(S32 type, U32 index)
{
llinfos << "type " << type << " index " << index << llendl;
- if (mAvatarObject)
+
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if (avatarp)
{
- mAvatarObject->updateVisualParams();
+ avatarp->updateVisualParams();
}
}
@@ -1309,7 +1312,8 @@ void LLAgentWearables::createStandardWearablesAllDone()
updateServer();
// Treat this as the first texture entry message, if none received yet
- mAvatarObject->onFirstTEMessageReceived();
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ avatarp->onFirstTEMessageReceived();
}
// MULTI-WEARABLE: Properly handle multiwearables later.
@@ -1331,7 +1335,8 @@ void LLAgentWearables::makeNewOutfit(const std::string& new_folder_name,
const LLDynamicArray<S32>& attachments_to_include,
BOOL rename_clothing)
{
- if (mAvatarObject.isNull())
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if (!avatarp)
{
return;
}
@@ -1432,7 +1437,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(mAvatarObject->mAttachmentPoints, attachment_pt, (LLViewerJointAttachment*)NULL);
+ LLViewerJointAttachment* attachment = get_if_there(avatarp->mAttachmentPoints, attachment_pt, (LLViewerJointAttachment*)NULL);
if (!attachment) continue;
for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
attachment_iter != attachment->mAttachedObjects.end();
@@ -1507,7 +1512,8 @@ private:
LLUUID LLAgentWearables::makeNewOutfitLinks(const std::string& new_folder_name)
{
- if (mAvatarObject.isNull())
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if (!avatarp)
{
return LLUUID::null;
}
@@ -1674,6 +1680,7 @@ 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;
@@ -1777,11 +1784,11 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it
}
}
- if (mAvatarObject)
+ if (avatarp)
{
- mAvatarObject->setCompositeUpdatesEnabled(TRUE);
- mAvatarObject->updateVisualParams();
- mAvatarObject->invalidateAll();
+ avatarp->setCompositeUpdatesEnabled(TRUE);
+ avatarp->updateVisualParams();
+ avatarp->invalidateAll();
}
// Start rendering & update the server
@@ -2031,7 +2038,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.
- LLVOAvatar* avatarp = gAgent.getAvatarObject();
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
if (!avatarp)
{
llwarns << "No avatar found." << llendl;
@@ -2102,7 +2109,7 @@ void LLAgentWearables::userUpdateAttachments(LLInventoryModel::item_array_t& obj
void LLAgentWearables::userRemoveMultipleAttachments(llvo_vec_t& objects_to_remove)
{
- LLVOAvatar* avatarp = gAgent.getAvatarObject();
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
if (!avatarp)
{
llwarns << "No avatar found." << llendl;
@@ -2130,7 +2137,7 @@ void LLAgentWearables::userRemoveMultipleAttachments(llvo_vec_t& objects_to_remo
void LLAgentWearables::userRemoveAllAttachments()
{
- LLVOAvatar* avatarp = gAgent.getAvatarObject();
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
if (!avatarp)
{
llwarns << "No avatar found." << llendl;
@@ -2706,11 +2713,11 @@ void LLInitialWearablesFetch::processWearablesMessage()
}
// Add all current attachments to the requested items as well.
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- if( avatar )
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if(avatarp)
{
- for (LLVOAvatar::attachment_map_t::const_iterator iter = avatar->mAttachmentPoints.begin();
- iter != avatar->mAttachmentPoints.end(); ++iter)
+ for (LLVOAvatar::attachment_map_t::const_iterator iter = avatarp->mAttachmentPoints.begin();
+ iter != avatarp->mAttachmentPoints.end(); ++iter)
{
LLViewerJointAttachment* attachment = iter->second;
if (!attachment) continue;
diff --git a/indra/newview/llagentwearables.h b/indra/newview/llagentwearables.h
index 858540a5f5..652ffd4587 100644
--- a/indra/newview/llagentwearables.h
+++ b/indra/newview/llagentwearables.h
@@ -89,7 +89,7 @@ public:
const LLUUID getWearableItemID(EWearableType type, U32 index /*= 0*/) const;
const LLUUID getWearableAssetID(EWearableType type, U32 index /*= 0*/) const;
const LLWearable* getWearableFromItemID(const LLUUID& item_id) const;
- const LLWearable* getWearableFromAssetID(const LLUUID& asset_id) const;
+ LLWearable* getWearableFromAssetID(const LLUUID& asset_id);
LLInventoryItem* getWearableInventoryItem(EWearableType type, U32 index /*= 0*/);
// MULTI-WEARABLE: assuming one per type.
static BOOL selfHasWearable(EWearableType type);
@@ -218,7 +218,6 @@ private:
static BOOL mInitialWearablesUpdateReceived;
BOOL mWearablesLoaded;
std::set<LLUUID> mItemsAwaitingWearableUpdate;
- LLPointer<LLVOAvatarSelf> mAvatarObject; // NULL until avatar object sent down from simulator
//--------------------------------------------------------------------------------
// Support classes
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 11c252406a..a3d0b8d8d9 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -44,6 +44,7 @@
#include "llviewertexturelist.h"
#include "llgroupmgr.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llagentwearables.h"
#include "llwindow.h"
#include "llviewerstats.h"
@@ -1107,12 +1108,15 @@ bool LLAppViewer::mainLoop()
ms_sleep(500);
}
-
+ static const F64 FRAME_SLOW_THRESHOLD = 0.5; //2 frames per seconds
const F64 min_frame_time = 0.0; //(.0333 - .0010); // max video frame rate = 30 fps
const F64 min_idle_time = 0.0; //(.0010); // min idle time = 1 ms
const F64 max_idle_time = run_multiple_threads ? min_idle_time : llmin(.005*10.0*gFrameTimeSeconds, 0.005); // 5 ms a second
idleTimer.reset();
- while(1)
+ bool is_slow = (frameTimer.getElapsedTimeF64() > FRAME_SLOW_THRESHOLD) ;
+ S32 total_work_pending = 0;
+ S32 total_io_pending = 0;
+ while(!is_slow)//do not unpause threads if the frame rates are very low.
{
S32 work_pending = 0;
S32 io_pending = 0;
@@ -1143,6 +1147,8 @@ bool LLAppViewer::mainLoop()
ms_sleep(llmin(io_pending/100,100)); // give the vfs some time to catch up
}
+ total_work_pending += work_pending ;
+ total_io_pending += io_pending ;
F64 frame_time = frameTimer.getElapsedTimeF64();
F64 idle_time = idleTimer.getElapsedTimeF64();
if (frame_time >= min_frame_time &&
@@ -1152,25 +1158,32 @@ bool LLAppViewer::mainLoop()
break;
}
}
- if ((LLStartUp::getStartupState() >= STATE_CLEANUP) &&
- (frameTimer.getElapsedTimeF64() > FRAME_STALL_THRESHOLD))
- {
- gFrameStalls++;
- }
- frameTimer.reset();
// Prevent the worker threads from running while rendering.
// if (LLThread::processorCount()==1) //pause() should only be required when on a single processor client...
if (run_multiple_threads == FALSE)
{
- LLFastTimer ftm(FTM_PAUSE_THREADS);
-
- LLAppViewer::getTextureCache()->pause();
- LLAppViewer::getImageDecodeThread()->pause();
- // LLAppViewer::getTextureFetch()->pause(); // Don't pause the fetch (IO) thread
+ //LLFastTimer ftm(FTM_PAUSE_THREADS); //not necessary.
+
+ if(!total_work_pending) //pause texture fetching threads if nothing to process.
+ {
+ LLAppViewer::getTextureCache()->pause();
+ LLAppViewer::getImageDecodeThread()->pause();
+ LLAppViewer::getTextureFetch()->pause();
+ }
+ if(!total_io_pending) //pause file threads if nothing to process.
+ {
+ LLVFSThread::sLocal->pause();
+ LLLFSThread::sLocal->pause();
+ }
+ }
+
+ if ((LLStartUp::getStartupState() >= STATE_CLEANUP) &&
+ (frameTimer.getElapsedTimeF64() > FRAME_STALL_THRESHOLD))
+ {
+ gFrameStalls++;
}
- //LLVFSThread::sLocal->pause(); // Prevent the VFS thread from running while rendering.
- //LLLFSThread::sLocal->pause(); // Prevent the LFS thread from running while rendering.
+ frameTimer.reset();
resumeMainloopTimeout();
@@ -1513,6 +1526,8 @@ bool LLAppViewer::cleanup()
LLLocationHistory::getInstance()->save();
LLAvatarIconIDCache::getInstance()->save();
+
+ LLViewerMedia::saveCookieFile();
llinfos << "Shutting down Threads" << llendflush;
@@ -2482,9 +2497,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);
}
}
@@ -3319,10 +3334,10 @@ void LLAppViewer::saveFinalSnapshot()
{
if (!mSavedFinalSnapshot && !gNoRender)
{
- gSavedSettings.setVector3d("FocusPosOnLogout", gAgent.calcFocusPositionTargetGlobal());
- gSavedSettings.setVector3d("CameraPosOnLogout", gAgent.calcCameraPositionTargetGlobal());
+ gSavedSettings.setVector3d("FocusPosOnLogout", gAgentCamera.calcFocusPositionTargetGlobal());
+ gSavedSettings.setVector3d("CameraPosOnLogout", gAgentCamera.calcCameraPositionTargetGlobal());
gViewerWindow->setCursor(UI_CURSOR_WAIT);
- gAgent.changeCameraToThirdPerson( FALSE ); // don't animate, need immediate switch
+ gAgentCamera.changeCameraToThirdPerson( FALSE ); // don't animate, need immediate switch
gSavedSettings.setBOOL("ShowParcelOwners", FALSE);
idle();
@@ -3732,7 +3747,7 @@ void LLAppViewer::idle()
LLViewerJoystick::getInstance()->moveObjects();
}
- gAgent.updateCamera();
+ gAgentCamera.updateCamera();
}
// update media focus
@@ -4066,7 +4081,7 @@ void LLAppViewer::disconnectViewer()
LLFloaterInventory::cleanup();
gAgentWearables.cleanup();
-
+ gAgentCamera.cleanup();
// Also writes cached agent settings to gSavedSettings
gAgent.cleanup();
diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index 8441796219..2bd3728ab7 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -202,13 +202,19 @@ void LLAssetUploadResponder::uploadComplete(const LLSD& content)
LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data,
const LLUUID& vfile_id,
- LLAssetType::EType asset_type)
-: LLAssetUploadResponder(post_data, vfile_id, asset_type)
+ LLAssetType::EType asset_type,
+ boost::function<void(const LLUUID& uuid)> callback)
+: LLAssetUploadResponder(post_data, vfile_id, asset_type),
+ mCallback(callback)
{
}
-LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data, const std::string& file_name, LLAssetType::EType asset_type)
-: LLAssetUploadResponder(post_data, file_name, asset_type)
+LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data,
+ const std::string& file_name,
+ LLAssetType::EType asset_type,
+ boost::function<void(const LLUUID& uuid)> callback)
+: LLAssetUploadResponder(post_data, file_name, asset_type),
+ mCallback(callback)
{
}
@@ -286,6 +292,12 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
creation_date_now);
gInventory.updateItem(item);
gInventory.notifyObservers();
+
+ if (mCallback)
+ {
+ // call the callback with the new Asset UUID
+ mCallback(item->getAssetUUID());
+ }
// Show the preview panel for textures and sounds to let
// user know that the image (or snapshot) arrived intact.
@@ -333,13 +345,11 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
U32 group_perms = mPostData.has("group_mask") ? mPostData.get("group_mask" ).asInteger() : PERM_NONE;
U32 next_owner_perms = mPostData.has("next_owner_mask") ? mPostData.get("next_owner_mask").asInteger() : PERM_NONE;
std::string display_name = LLStringUtil::null;
- LLAssetStorage::LLStoreAssetCallback callback = NULL;
- void *userdata = NULL;
upload_new_resource(next_file, asset_name, asset_name,
- 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
+ LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
next_owner_perms, group_perms,
everyone_perms, display_name,
- callback, expected_upload_cost, userdata);
+ NULL, expected_upload_cost);
}
}
diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h
index e656351305..ade9c96758 100644
--- a/indra/newview/llassetuploadresponders.h
+++ b/indra/newview/llassetuploadresponders.h
@@ -33,6 +33,7 @@
#ifndef LL_LLASSETUPLOADRESPONDER_H
#define LL_LLASSETUPLOADRESPONDER_H
+#include "llassetstorage.h"
#include "llhttpclient.h"
// Abstract class for supporting asset upload
@@ -66,10 +67,15 @@ class LLNewAgentInventoryResponder : public LLAssetUploadResponder
public:
LLNewAgentInventoryResponder(const LLSD& post_data,
const LLUUID& vfile_id,
- LLAssetType::EType asset_type);
- LLNewAgentInventoryResponder(const LLSD& post_data, const std::string& file_name,
- LLAssetType::EType asset_type);
+ LLAssetType::EType asset_type,
+ boost::function<void(const LLUUID& uuid)> callback = NULL);
+ LLNewAgentInventoryResponder(const LLSD& post_data,
+ const std::string& file_name,
+ LLAssetType::EType asset_type,
+ boost::function<void(const LLUUID& uuid)> callback = NULL);
virtual void uploadComplete(const LLSD& content);
+
+ boost::function<void(const LLUUID& uuid)> mCallback;
};
class LLBakedUploadData;
diff --git a/indra/newview/llaudiosourcevo.cpp b/indra/newview/llaudiosourcevo.cpp
index 5e71e64b2f..50363ea2e7 100644
--- a/indra/newview/llaudiosourcevo.cpp
+++ b/indra/newview/llaudiosourcevo.cpp
@@ -35,7 +35,7 @@
#include "llaudiosourcevo.h"
-#include "llagent.h"
+#include "llagentcamera.h"
#include "llmutelist.h"
#include "llviewerparcelmgr.h"
@@ -148,7 +148,7 @@ void LLAudioSourceVO::update()
updateGain();
if (mObjectp->isHUDAttachment())
{
- mPositionGlobal = gAgent.getCameraPositionGlobal();
+ mPositionGlobal = gAgentCamera.getCameraPositionGlobal();
}
else
{
diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp
index b88be53d79..34cb6fd2eb 100644
--- a/indra/newview/llbottomtray.cpp
+++ b/indra/newview/llbottomtray.cpp
@@ -35,7 +35,7 @@
#define LLBOTTOMTRAY_CPP
#include "llbottomtray.h"
-#include "llagent.h"
+#include "llagentcamera.h"
#include "llchiclet.h"
#include "llfloaterreg.h"
#include "llflyoutbutton.h"
@@ -125,7 +125,7 @@ public:
void onFocusLost()
{
- if (gAgent.cameraMouselook())
+ if (gAgentCamera.cameraMouselook())
{
LLBottomTray::getInstance()->setVisible(FALSE);
}
diff --git a/indra/newview/llfloateranimpreview.cpp b/indra/newview/llfloateranimpreview.cpp
index 5ec58c8dd6..feb18fe393 100644
--- a/indra/newview/llfloateranimpreview.cpp
+++ b/indra/newview/llfloateranimpreview.cpp
@@ -1001,19 +1001,18 @@ void LLFloaterAnimPreview::onBtnOK(void* userdata)
{
std::string name = floaterp->childGetValue("name_form").asString();
std::string desc = floaterp->childGetValue("description_form").asString();
- LLAssetStorage::LLStoreAssetCallback callback = NULL;
S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
- void *userdata = NULL;
upload_new_resource(floaterp->mTransactionID, // tid
LLAssetType::AT_ANIMATION,
name,
desc,
- 0,
LLFolderType::FT_NONE,
LLInventoryType::IT_ANIMATION,
- LLFloaterPerms::getNextOwnerPerms(), LLFloaterPerms::getGroupPerms(), LLFloaterPerms::getEveryonePerms(),
+ LLFloaterPerms::getNextOwnerPerms(),
+ LLFloaterPerms::getGroupPerms(), LLFloaterPerms::getEveryonePerms(),
name,
- callback, expected_upload_cost, userdata);
+ NULL,
+ expected_upload_cost);
}
else
{
diff --git a/indra/newview/llfloaterbeacons.cpp b/indra/newview/llfloaterbeacons.cpp
index 13a7888f60..975c888a2b 100644
--- a/indra/newview/llfloaterbeacons.cpp
+++ b/indra/newview/llfloaterbeacons.cpp
@@ -71,7 +71,7 @@ void LLFloaterBeacons::onClickUICheck(LLUICtrl *ctrl)
{
LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl;
std::string name = check->getName();
- if( name == "touch_only")
+ if(name == "touch_only")
{
LLPipeline::toggleRenderScriptedTouchBeacons(NULL);
// Don't allow both to be ON at the same time. Toggle the other one off if both now on.
@@ -81,7 +81,9 @@ void LLFloaterBeacons::onClickUICheck(LLUICtrl *ctrl)
{
LLPipeline::setRenderScriptedBeacons(FALSE);
getChild<LLCheckBoxCtrl>("scripted")->setControlValue(LLSD(FALSE));
+ getChild<LLCheckBoxCtrl>("scripted")->setValue(FALSE);
getChild<LLCheckBoxCtrl>("touch_only")->setControlValue(LLSD(TRUE)); // just to be sure it's in sync with llpipeline
+ getChild<LLCheckBoxCtrl>("touch_only")->setValue(TRUE);
}
}
else if(name == "scripted")
@@ -94,7 +96,9 @@ void LLFloaterBeacons::onClickUICheck(LLUICtrl *ctrl)
{
LLPipeline::setRenderScriptedTouchBeacons(FALSE);
getChild<LLCheckBoxCtrl>("touch_only")->setControlValue(LLSD(FALSE));
+ getChild<LLCheckBoxCtrl>("touch_only")->setValue(FALSE);
getChild<LLCheckBoxCtrl>("scripted")->setControlValue(LLSD(TRUE)); // just to be sure it's in sync with llpipeline
+ getChild<LLCheckBoxCtrl>("scripted")->setValue(TRUE);
}
}
else if(name == "physical") LLPipeline::setRenderPhysicalBeacons(check->get());
@@ -110,7 +114,9 @@ void LLFloaterBeacons::onClickUICheck(LLUICtrl *ctrl)
{
LLPipeline::setRenderBeacons(TRUE);
getChild<LLCheckBoxCtrl>("beacons")->setControlValue(LLSD(TRUE));
+ getChild<LLCheckBoxCtrl>("beacons")->setValue(TRUE);
getChild<LLCheckBoxCtrl>("highlights")->setControlValue(LLSD(FALSE)); // just to be sure it's in sync with llpipeline
+ getChild<LLCheckBoxCtrl>("highlights")->setValue(FALSE);
}
}
else if(name == "beacons")
@@ -123,7 +129,9 @@ void LLFloaterBeacons::onClickUICheck(LLUICtrl *ctrl)
{
LLPipeline::setRenderHighlights(TRUE);
getChild<LLCheckBoxCtrl>("highlights")->setControlValue(LLSD(TRUE));
+ getChild<LLCheckBoxCtrl>("highlights")->setValue(TRUE);
getChild<LLCheckBoxCtrl>("beacons")->setControlValue(LLSD(FALSE)); // just to be sure it's in sync with llpipeline
+ getChild<LLCheckBoxCtrl>("beacons")->setValue(FALSE);
}
}
}
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index d0188352c7..d84ebef1dd 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -38,11 +38,11 @@
#include "llfloaterreg.h"
// Viewer includes
+#include "llagentcamera.h"
#include "lljoystickbutton.h"
#include "llviewercontrol.h"
#include "llviewercamera.h"
#include "llbottomtray.h"
-#include "llagent.h"
#include "lltoolmgr.h"
#include "lltoolfocus.h"
#include "llslider.h"
@@ -104,7 +104,7 @@ BOOL LLPanelCameraZoom::postBuild()
void LLPanelCameraZoom::draw()
{
- mSlider->setValue(gAgent.getCameraZoomFraction());
+ mSlider->setValue(gAgentCamera.getCameraZoomFraction());
LLPanel::draw();
}
@@ -131,7 +131,7 @@ void LLPanelCameraZoom::onZoomMinusHeldDown()
void LLPanelCameraZoom::onSliderValueChanged()
{
F32 zoom_level = mSlider->getValueF32();
- gAgent.setCameraZoomFraction(zoom_level);
+ gAgentCamera.setCameraZoomFraction(zoom_level);
}
void activate_camera_tool()
@@ -146,7 +146,7 @@ void activate_camera_tool()
/*static*/ bool LLFloaterCamera::inFreeCameraMode()
{
LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
- if (floater_camera && floater_camera->mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA && gAgent.getCameraMode() != CAMERA_MODE_MOUSELOOK)
+ if (floater_camera && floater_camera->mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA && gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK)
{
return true;
}
@@ -265,7 +265,7 @@ ECameraControlMode LLFloaterCamera::determineMode()
return CAMERA_CTRL_MODE_FREE_CAMERA;
}
- if (gAgent.getCameraMode() == CAMERA_MODE_MOUSELOOK)
+ if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
{
return CAMERA_CTRL_MODE_AVATAR_VIEW;
}
@@ -421,7 +421,7 @@ void LLFloaterCamera::updateCameraPresetButtons()
childSetValue("rear_view", preset == CAMERA_PRESET_REAR_VIEW);
childSetValue("group_view", preset == CAMERA_PRESET_GROUP_VIEW);
childSetValue("front_view", preset == CAMERA_PRESET_FRONT_VIEW);
- childSetValue("mouselook_view", gAgent.cameraMouselook());
+ childSetValue("mouselook_view", gAgentCamera.cameraMouselook());
}
void LLFloaterCamera::onClickCameraPresets(const LLSD& param)
@@ -430,19 +430,19 @@ void LLFloaterCamera::onClickCameraPresets(const LLSD& param)
if ("rear_view" == name)
{
- gAgent.switchCameraPreset(CAMERA_PRESET_REAR_VIEW);
+ gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW);
}
else if ("group_view" == name)
{
- gAgent.switchCameraPreset(CAMERA_PRESET_GROUP_VIEW);
+ gAgentCamera.switchCameraPreset(CAMERA_PRESET_GROUP_VIEW);
}
else if ("front_view" == name)
{
- gAgent.switchCameraPreset(CAMERA_PRESET_FRONT_VIEW);
+ gAgentCamera.switchCameraPreset(CAMERA_PRESET_FRONT_VIEW);
}
else if ("mouselook_view" == name)
{
- gAgent.changeCameraToMouselook();
+ gAgentCamera.changeCameraToMouselook();
}
LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance();
diff --git a/indra/newview/llfloaterinventory.cpp b/indra/newview/llfloaterinventory.cpp
index 6842d3dc74..4bffd41d29 100644
--- a/indra/newview/llfloaterinventory.cpp
+++ b/indra/newview/llfloaterinventory.cpp
@@ -34,7 +34,7 @@
#include "llfloaterinventory.h"
-#include "llagent.h"
+#include "llagentcamera.h"
//#include "llfirstuse.h"
#include "llfloaterreg.h"
#include "llinventorymodel.h"
@@ -79,7 +79,7 @@ LLFloaterInventory* LLFloaterInventory::showAgentInventory()
instance_num = (instance_num + 1) % S32_MAX;
LLFloaterInventory* iv = NULL;
- if (!gAgent.cameraMouselook())
+ if (!gAgentCamera.cameraMouselook())
{
iv = LLFloaterReg::showTypedInstance<LLFloaterInventory>("inventory", LLSD(instance_num));
}
diff --git a/indra/newview/llfloatermap.cpp b/indra/newview/llfloatermap.cpp
index 051ab585e2..8894628788 100644
--- a/indra/newview/llfloatermap.cpp
+++ b/indra/newview/llfloatermap.cpp
@@ -41,7 +41,7 @@
#include "llglheaders.h"
// Viewer includes
-#include "llagent.h"
+#include "llagentcamera.h"
#include "llviewercontrol.h"
#include "llnetmap.h"
#include "lltracker.h"
@@ -196,7 +196,7 @@ void LLFloaterMap::draw()
setDirectionPos( mTextBoxSouthEast, rotation + F_PI + F_PI_BY_TWO + F_PI_BY_TWO / 2);
// Note: we can't just gAgent.check cameraMouselook() because the transition states are wrong.
- if( gAgent.cameraMouselook())
+ if(gAgentCamera.cameraMouselook())
{
setMouseOpaque(FALSE);
getDragHandle()->setMouseOpaque(FALSE);
diff --git a/indra/newview/llfloaternamedesc.cpp b/indra/newview/llfloaternamedesc.cpp
index 159ce41b79..5c343ecb22 100644
--- a/indra/newview/llfloaternamedesc.cpp
+++ b/indra/newview/llfloaternamedesc.cpp
@@ -169,16 +169,14 @@ void LLFloaterNameDesc::onBtnOK( )
{
childDisable("ok_btn"); // don't allow inadvertent extra uploads
- LLAssetStorage::LLStoreAssetCallback callback = NULL;
S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(); // kinda hack - assumes that unsubclassed LLFloaterNameDesc is only used for uploading chargeable assets, which it is right now (it's only used unsubclassed for the sound upload dialog, and THAT should be a subclass).
- void *nruserdata = NULL;
std::string display_name = LLStringUtil::null;
upload_new_resource(mFilenameAndPath, // file
childGetValue("name_form").asString(),
childGetValue("description_form").asString(),
- 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
+ LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
LLFloaterPerms::getNextOwnerPerms(), LLFloaterPerms::getGroupPerms(), LLFloaterPerms::getEveryonePerms(),
- display_name, callback, expected_upload_cost, nruserdata);
+ display_name, NULL, expected_upload_cost);
closeFloater(false);
}
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index a0031f0193..adac9861d4 100644
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -38,28 +38,34 @@
// Viewer includes
#include "llagent.h"
-#include "llcallbacklist.h"
-#include "llcriticaldamp.h"
-#include "llui.h"
-#include "llfocusmgr.h"
+#include "llagentcamera.h"
+#include "llagentui.h"
+#include "llavatarpropertiesprocessor.h"
+#include "llbottomtray.h"
#include "llbutton.h"
+#include "llcallbacklist.h"
+#include "llcheckboxctrl.h"
#include "llcombobox.h"
+#include "llcriticaldamp.h"
#include "lleconomy.h"
+#include "llfloaterpostcard.h"
+#include "llfocusmgr.h"
+#include "lllandmarkactions.h"
+#include "llradiogroup.h"
#include "llsliderctrl.h"
+#include "llslurl.h"
#include "llspinctrl.h"
-#include "llviewercontrol.h"
+#include "lltoolfocus.h"
+#include "lltoolmgr.h"
+#include "llui.h"
#include "lluictrlfactory.h"
-#include "llviewerstats.h"
#include "llviewercamera.h"
-#include "llviewerwindow.h"
+#include "llviewercontrol.h"
#include "llviewermenufile.h" // upload_new_resource()
-#include "llfloaterpostcard.h"
-#include "llcheckboxctrl.h"
-#include "llradiogroup.h"
-#include "lltoolfocus.h"
-#include "lltoolmgr.h"
+#include "llviewerstats.h"
+#include "llviewerwindow.h"
+#include "llweb.h"
#include "llworld.h"
-#include "llagentui.h"
// Linden library includes
#include "llfontgl.h"
@@ -113,6 +119,7 @@ public:
enum ESnapshotType
{
SNAPSHOT_POSTCARD,
+ SNAPSHOT_WEB,
SNAPSHOT_TEXTURE,
SNAPSHOT_LOCAL
};
@@ -161,8 +168,9 @@ public:
void setSnapshotBufferType(LLViewerWindow::ESnapshotType type) { mSnapshotBufferType = type; }
void updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail = FALSE, F32 delay = 0.f);
LLFloaterPostcard* savePostcard();
- void saveTexture();
+ void saveTexture(bool set_as_profile_pic = false);
BOOL saveLocal();
+ void saveWeb(std::string url);
BOOL setThumbnailImageSize() ;
void generateThumbnailImage(BOOL force_update = FALSE) ;
@@ -171,6 +179,9 @@ public:
// Returns TRUE when snapshot generated, FALSE otherwise.
static BOOL onIdle( void* snapshot_preview );
+
+ // callback for region name resolve
+ void regionNameCallback(std::string url, LLSD body, const std::string& name, S32 x, S32 y, S32 z);
private:
LLColor4 mColor;
@@ -292,7 +303,7 @@ F32 LLSnapshotLivePreview::getAspect()
F32 image_aspect_ratio = ((F32)mWidth[mCurImageIndex]) / ((F32)mHeight[mCurImageIndex]);
F32 window_aspect_ratio = ((F32)getRect().getWidth()) / ((F32)getRect().getHeight());
- if (!mKeepAspectRatio)//gSavedSettings.getBOOL("KeepAspectForSnapshot"))
+ if (!mKeepAspectRatio)
{
return image_aspect_ratio;
}
@@ -625,20 +636,20 @@ BOOL LLSnapshotLivePreview::setThumbnailImageSize()
F32 window_aspect_ratio = ((F32)window_width) / ((F32)window_height);
// UI size for thumbnail
- S32 max_width = LLFloaterSnapshot::getUIWinWidth() - 20;
- S32 max_height = 90;
+ LLFloater* floater = LLFloaterReg::getInstance("snapshot");
+ mThumbnailWidth = floater->getChild<LLView>("thumbnail_placeholder")->getRect().getWidth();
+ mThumbnailHeight = floater->getChild<LLView>("thumbnail_placeholder")->getRect().getHeight();
- if (window_aspect_ratio > (F32)max_width / max_height)
+
+ if (window_aspect_ratio > (F32)mThumbnailWidth / mThumbnailHeight)
{
// image too wide, shrink to width
- mThumbnailWidth = max_width;
- mThumbnailHeight = llround((F32)max_width / window_aspect_ratio);
+ mThumbnailHeight = llround((F32)mThumbnailWidth / window_aspect_ratio);
}
else
{
// image too tall, shrink to height
- mThumbnailHeight = max_height;
- mThumbnailWidth = llround((F32)max_height * window_aspect_ratio);
+ mThumbnailWidth = llround((F32)mThumbnailHeight * window_aspect_ratio);
}
if(mThumbnailWidth > window_width || mThumbnailHeight > window_height)
@@ -824,10 +835,21 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
{
// delete any existing image
previewp->mFormattedImage = NULL;
+
// now create the new one of the appropriate format.
- // note: postcards hardcoded to use jpeg always.
- LLFloaterSnapshot::ESnapshotFormat format = previewp->getSnapshotType() == SNAPSHOT_POSTCARD
- ? LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG : previewp->getSnapshotFormat();
+ // note: postcards and web hardcoded to use jpeg always.
+ LLFloaterSnapshot::ESnapshotFormat format;
+
+ if (previewp->getSnapshotType() == SNAPSHOT_POSTCARD ||
+ previewp->getSnapshotType() == SNAPSHOT_WEB)
+ {
+ format = LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG;
+ }
+ else
+ {
+ format = previewp->getSnapshotFormat();
+ }
+
switch(format)
{
case LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG:
@@ -892,7 +914,7 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
previewp->mSnapshotUpToDate = TRUE;
previewp->generateThumbnailImage(TRUE) ;
- previewp->mPosTakenGlobal = gAgent.getCameraPositionGlobal();
+ previewp->mPosTakenGlobal = gAgentCamera.getCameraPositionGlobal();
previewp->mShineCountdown = 4; // wait a few frames to avoid animation glitch due to readback this frame
}
}
@@ -954,13 +976,21 @@ LLFloaterPostcard* LLSnapshotLivePreview::savePostcard()
return floater;
}
-void LLSnapshotLivePreview::saveTexture()
+// Callback for asset upload
+void profile_pic_upload_callback(const LLUUID& uuid)
+{
+ LLFloaterSnapshot* floater = LLFloaterReg::getTypedInstance<LLFloaterSnapshot>("snapshot");
+ floater->setAsProfilePic(uuid);
+}
+
+
+void LLSnapshotLivePreview::saveTexture(bool set_as_profile_pic)
{
// gen a new uuid for this asset
LLTransactionID tid;
tid.generate();
LLAssetID new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
-
+
LLPointer<LLImageJ2C> formatted = new LLImageJ2C;
LLPointer<LLImageRaw> scaled = new LLImageRaw(mPreviewImage->getData(),
mPreviewImage->getWidth(),
@@ -971,26 +1001,30 @@ void LLSnapshotLivePreview::saveTexture()
if (formatted->encode(scaled, 0.0f))
{
+ boost::function<void(const LLUUID& uuid)> callback = NULL;
+
+ if (set_as_profile_pic)
+ {
+ callback = profile_pic_upload_callback;
+ }
+
LLVFile::writeFile(formatted->getData(), formatted->getDataSize(), gVFS, new_asset_id, LLAssetType::AT_TEXTURE);
std::string pos_string;
LLAgentUI::buildLocationString(pos_string, LLAgentUI::LOCATION_FORMAT_FULL);
std::string who_took_it;
LLAgentUI::buildFullname(who_took_it);
- LLAssetStorage::LLStoreAssetCallback callback = NULL;
S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
- void *userdata = NULL;
upload_new_resource(tid, // tid
LLAssetType::AT_TEXTURE,
"Snapshot : " + pos_string,
"Taken by " + who_took_it + " at " + pos_string,
- 0,
LLFolderType::FT_SNAPSHOT_CATEGORY,
LLInventoryType::IT_SNAPSHOT,
PERM_ALL, // Note: Snapshots to inventory is a special case of content upload
PERM_NONE, // that ignores the user's premissions preferences and continues to
PERM_NONE, // always use these fairly permissive hard-coded initial perms. - MG
"Snapshot : " + pos_string,
- callback, expected_upload_cost, userdata);
+ callback, expected_upload_cost);
gViewerWindow->playSnapshotAnimAndSound();
}
else
@@ -1020,6 +1054,81 @@ BOOL LLSnapshotLivePreview::saveLocal()
return success;
}
+
+class LLSendWebResponder : public LLHTTPClient::Responder
+{
+public:
+
+ virtual void error(U32 status, const std::string& reason)
+ {
+ llwarns << status << ": " << reason << llendl;
+ LLNotificationsUtil::add("ShareToWebFailed");
+ }
+
+ virtual void result(const LLSD& content)
+ {
+ std::string response_url = content["response_url"].asString();
+
+ if (!response_url.empty())
+ {
+ LLWeb::loadURLExternal(response_url);
+ }
+ else
+ {
+ LLNotificationsUtil::add("ShareToWebFailed");
+ }
+ }
+
+};
+
+void LLSnapshotLivePreview::saveWeb(std::string url)
+{
+ if (url.empty())
+ {
+ llwarns << "No share to web url" << llendl;
+ return;
+ }
+
+ LLImageJPEG* jpg = dynamic_cast<LLImageJPEG*>(mFormattedImage.get());
+ if(!jpg)
+ {
+ llwarns << "Formatted image not a JPEG" << llendl;
+ return;
+ }
+
+/* figure out if there's a better way to serialize */
+ LLSD body;
+ std::vector<U8> binary_image;
+ U8* data = jpg->getData();
+ for (int i = 0; i < jpg->getDataSize(); i++)
+ {
+ binary_image.push_back(data[i]);
+ }
+
+ body["image"] = binary_image;
+
+ body["description"] = getChild<LLLineEditor>("description")->getText();
+
+ std::string name;
+ LLAgentUI::buildFullname(name);
+
+ body["avatar_name"] = name;
+
+ LLLandmarkActions::getRegionNameAndCoordsFromPosGlobal(gAgentCamera.getCameraPositionGlobal(),
+ boost::bind(&LLSnapshotLivePreview::regionNameCallback, this, url, body, _1, _2, _3, _4));
+
+ gViewerWindow->playSnapshotAnimAndSound();
+}
+
+
+void LLSnapshotLivePreview::regionNameCallback(std::string url, LLSD body, const std::string& name, S32 x, S32 y, S32 z)
+{
+ body["slurl"] = LLSLURL::buildSLURL(name, x, y, z);
+
+ LLHTTPClient::post(url, body,
+ new LLSendWebResponder());
+}
+
///----------------------------------------------------------------------------
/// Class LLFloaterSnapshot::Impl
///----------------------------------------------------------------------------
@@ -1039,9 +1148,6 @@ public:
mAvatarPauseHandles.clear();
}
- static void onClickDiscard(void* data);
- static void onClickKeep(void* data);
- static void onCommitSave(LLUICtrl* ctrl, void* data);
static void onClickNewSnapshot(void* data);
static void onClickAutoSnap(LLUICtrl *ctrl, void* data);
//static void onClickAdvanceSnap(LLUICtrl *ctrl, void* data);
@@ -1056,9 +1162,11 @@ public:
static void updateResolution(LLUICtrl* ctrl, void* data, BOOL do_update = TRUE);
static void onCommitFreezeFrame(LLUICtrl* ctrl, void* data);
static void onCommitLayerTypes(LLUICtrl* ctrl, void*data);
- static void onCommitSnapshotType(LLUICtrl* ctrl, void* data);
static void onCommitSnapshotFormat(LLUICtrl* ctrl, void* data);
static void onCommitCustomResolution(LLUICtrl *ctrl, void* data);
+ static void onCommitSnapshot(LLFloaterSnapshot* view, LLSnapshotLivePreview::ESnapshotType type);
+ static void onCommitProfilePic(LLFloaterSnapshot* view);
+ static void onToggleAdvanced(LLUICtrl *ctrl, void* data);
static void resetSnapshotSizeOnUI(LLFloaterSnapshot *view, S32 width, S32 height) ;
static BOOL checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value);
@@ -1066,10 +1174,8 @@ public:
static void setResolution(LLFloaterSnapshot* floater, const std::string& comboname);
static void updateControls(LLFloaterSnapshot* floater);
static void updateLayout(LLFloaterSnapshot* floater);
- static void updateResolutionTextEntry(LLFloaterSnapshot* floater);
private:
- static LLSnapshotLivePreview::ESnapshotType getTypeIndex(LLFloaterSnapshot* floater);
static ESnapshotFormat getFormatIndex(LLFloaterSnapshot* floater);
static LLViewerWindow::ESnapshotType getLayerType(LLFloaterSnapshot* floater);
static void comboSetCustom(LLFloaterSnapshot *floater, const std::string& comboname);
@@ -1092,22 +1198,6 @@ LLSnapshotLivePreview* LLFloaterSnapshot::Impl::getPreviewView(LLFloaterSnapshot
}
// static
-LLSnapshotLivePreview::ESnapshotType LLFloaterSnapshot::Impl::getTypeIndex(LLFloaterSnapshot* floater)
-{
- LLSnapshotLivePreview::ESnapshotType index = LLSnapshotLivePreview::SNAPSHOT_POSTCARD;
- LLSD value = floater->childGetValue("snapshot_type_radio");
- const std::string id = value.asString();
- if (id == "postcard")
- index = LLSnapshotLivePreview::SNAPSHOT_POSTCARD;
- else if (id == "texture")
- index = LLSnapshotLivePreview::SNAPSHOT_TEXTURE;
- else if (id == "local")
- index = LLSnapshotLivePreview::SNAPSHOT_LOCAL;
- return index;
-}
-
-
-// static
LLFloaterSnapshot::ESnapshotFormat LLFloaterSnapshot::Impl::getFormatIndex(LLFloaterSnapshot* floater)
{
ESnapshotFormat index = SNAPSHOT_FORMAT_PNG;
@@ -1155,20 +1245,12 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp)
{
LLSnapshotLivePreview* previewp = getPreviewView(floaterp);
- S32 delta_height = gSavedSettings.getBOOL("AdvanceSnapshot") ? 0 : floaterp->getUIWinHeightShort() - floaterp->getUIWinHeightLong() ;
-
if(!gSavedSettings.getBOOL("AdvanceSnapshot")) //set to original window resolution
{
previewp->mKeepAspectRatio = TRUE;
- floaterp->getChild<LLComboBox>("postcard_size_combo")->setCurrentByIndex(0);
- gSavedSettings.setS32("SnapshotPostcardLastResolution", 0);
-
- floaterp->getChild<LLComboBox>("texture_size_combo")->setCurrentByIndex(0);
- gSavedSettings.setS32("SnapshotTextureLastResolution", 0);
-
- floaterp->getChild<LLComboBox>("local_size_combo")->setCurrentByIndex(0);
- gSavedSettings.setS32("SnapshotLocalLastResolution", 0);
+ floaterp->getChild<LLComboBox>("snapshot_size_combo")->setCurrentByIndex(0);
+ gSavedSettings.setS32("SnapshotLastResolution", 0);
LLSnapshotLivePreview* previewp = getPreviewView(floaterp);
previewp->setSize(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw());
@@ -1181,9 +1263,6 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp)
// stop all mouse events at fullscreen preview layer
floaterp->getParent()->setMouseOpaque(TRUE);
- // shrink to smaller layout
- floaterp->reshape(floaterp->getRect().getWidth(), floaterp->getUIWinHeightLong() + delta_height);
-
// can see and interact with fullscreen preview now
if (previewp)
{
@@ -1212,7 +1291,6 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp)
else // turning off freeze frame mode
{
floaterp->getParent()->setMouseOpaque(FALSE);
- floaterp->reshape(floaterp->getRect().getWidth(), floaterp->getUIWinHeightLong() + delta_height);
if (previewp)
{
previewp->setVisible(FALSE);
@@ -1241,127 +1319,7 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp)
// static
void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
{
- LLRadioGroup* snapshot_type_radio = floater->getChild<LLRadioGroup>("snapshot_type_radio");
- snapshot_type_radio->setSelectedIndex(gSavedSettings.getS32("LastSnapshotType"));
- LLSnapshotLivePreview::ESnapshotType shot_type = getTypeIndex(floater);
- ESnapshotFormat shot_format = (ESnapshotFormat)gSavedSettings.getS32("SnapshotFormat"); //getFormatIndex(floater); LLViewerWindow::ESnapshotType layer_type = getLayerType(floater);
- LLViewerWindow::ESnapshotType layer_type = getLayerType(floater);
-
- floater->childSetVisible("postcard_size_combo", FALSE);
- floater->childSetVisible("texture_size_combo", FALSE);
- floater->childSetVisible("local_size_combo", FALSE);
-
- floater->getChild<LLComboBox>("postcard_size_combo")->selectNthItem(gSavedSettings.getS32("SnapshotPostcardLastResolution"));
- floater->getChild<LLComboBox>("texture_size_combo")->selectNthItem(gSavedSettings.getS32("SnapshotTextureLastResolution"));
- floater->getChild<LLComboBox>("local_size_combo")->selectNthItem(gSavedSettings.getS32("SnapshotLocalLastResolution"));
- floater->getChild<LLComboBox>("local_format_combo")->selectNthItem(gSavedSettings.getS32("SnapshotFormat"));
-
- floater->childSetVisible("upload_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_TEXTURE);
- floater->childSetVisible("send_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD);
- floater->childSetVisible("save_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL);
- floater->childSetEnabled("keep_aspect_check", shot_type != LLSnapshotLivePreview::SNAPSHOT_TEXTURE && !floater->impl.mAspectRatioCheckOff);
- floater->childSetEnabled("layer_types", shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL);
-
- BOOL is_advance = gSavedSettings.getBOOL("AdvanceSnapshot");
- BOOL is_local = shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL;
- BOOL show_slider =
- shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD
- || (is_local && shot_format == LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG);
-
- floater->childSetVisible("more_btn", !is_advance); // the only item hidden in advanced mode
- floater->childSetVisible("less_btn", is_advance);
- floater->childSetVisible("type_label2", is_advance);
- floater->childSetVisible("format_label", is_advance && is_local);
- floater->childSetVisible("local_format_combo", is_advance && is_local);
- floater->childSetVisible("layer_types", is_advance);
- floater->childSetVisible("layer_type_label", is_advance);
- floater->childSetVisible("snapshot_width", is_advance);
- floater->childSetVisible("snapshot_height", is_advance);
- floater->childSetVisible("keep_aspect_check", is_advance);
- floater->childSetVisible("ui_check", is_advance);
- floater->childSetVisible("hud_check", is_advance);
- floater->childSetVisible("keep_open_check", is_advance);
- floater->childSetVisible("freeze_frame_check", is_advance);
- floater->childSetVisible("auto_snapshot_check", is_advance);
- floater->childSetVisible("image_quality_slider", is_advance && show_slider);
-
- LLSnapshotLivePreview* previewp = getPreviewView(floater);
- BOOL got_bytes = previewp && previewp->getDataSize() > 0;
- BOOL got_snap = previewp && previewp->getSnapshotUpToDate();
-
- floater->childSetEnabled("send_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD && got_snap && previewp->getDataSize() <= MAX_POSTCARD_DATASIZE);
- floater->childSetEnabled("upload_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_TEXTURE && got_snap);
- floater->childSetEnabled("save_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL && got_snap);
-
- LLLocale locale(LLLocale::USER_LOCALE);
- std::string bytes_string;
- if (got_snap)
- {
- LLResMgr::getInstance()->getIntegerString(bytes_string, (previewp->getDataSize()) >> 10 );
- }
- S32 upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
- floater->childSetLabelArg("texture", "[AMOUNT]", llformat("%d",upload_cost));
- floater->childSetLabelArg("upload_btn", "[AMOUNT]", llformat("%d",upload_cost));
- floater->childSetTextArg("file_size_label", "[SIZE]", got_snap ? bytes_string : floater->getString("unknown"));
- floater->childSetColor("file_size_label",
- shot_type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD
- && got_bytes
- && previewp->getDataSize() > MAX_POSTCARD_DATASIZE ? LLUIColor(LLColor4::red) : LLUIColorTable::instance().getColor( "LabelTextColor" ));
-
- switch(shot_type)
- {
- case LLSnapshotLivePreview::SNAPSHOT_POSTCARD:
- layer_type = LLViewerWindow::SNAPSHOT_TYPE_COLOR;
- floater->childSetValue("layer_types", "colors");
- if(is_advance)
- {
- setResolution(floater, "postcard_size_combo");
- }
- break;
- case LLSnapshotLivePreview::SNAPSHOT_TEXTURE:
- layer_type = LLViewerWindow::SNAPSHOT_TYPE_COLOR;
- floater->childSetValue("layer_types", "colors");
- if(is_advance)
- {
- setResolution(floater, "texture_size_combo");
- }
- break;
- case LLSnapshotLivePreview::SNAPSHOT_LOCAL:
- if(is_advance)
- {
- setResolution(floater, "local_size_combo");
- }
- break;
- default:
- break;
- }
-
- updateResolutionTextEntry(floater);
-
- if (previewp)
- {
- previewp->setSnapshotType(shot_type);
- previewp->setSnapshotFormat(shot_format);
- previewp->setSnapshotBufferType(layer_type);
- }
-}
-
-// static
-void LLFloaterSnapshot::Impl::updateResolutionTextEntry(LLFloaterSnapshot* floater)
-{
- LLSpinCtrl* width_spinner = floater->getChild<LLSpinCtrl>("snapshot_width");
- LLSpinCtrl* height_spinner = floater->getChild<LLSpinCtrl>("snapshot_height");
- if(getTypeIndex(floater) == LLSnapshotLivePreview::SNAPSHOT_TEXTURE)
- {
- width_spinner->setAllowEdit(FALSE);
- height_spinner->setAllowEdit(FALSE);
- }
- else
- {
- width_spinner->setAllowEdit(TRUE);
- height_spinner->setAllowEdit(TRUE);
- }
}
// static
@@ -1375,70 +1333,6 @@ void LLFloaterSnapshot::Impl::checkAutoSnapshot(LLSnapshotLivePreview* previewp,
}
// static
-void LLFloaterSnapshot::Impl::onClickDiscard(void* data)
-{
- LLFloaterSnapshot *view = (LLFloaterSnapshot *)data;
-
- if (view)
- {
- view->closeFloater();
- }
-}
-
-
-// static
-void LLFloaterSnapshot::Impl::onCommitSave(LLUICtrl* ctrl, void* data)
-{
- if (ctrl->getValue().asString() == "save as")
- {
- gViewerWindow->resetSnapshotLoc();
- }
- onClickKeep(data);
-}
-
-// static
-void LLFloaterSnapshot::Impl::onClickKeep(void* data)
-{
- LLFloaterSnapshot *view = (LLFloaterSnapshot *)data;
- LLSnapshotLivePreview* previewp = getPreviewView(view);
-
- if (previewp)
- {
- if (previewp->getSnapshotType() == LLSnapshotLivePreview::SNAPSHOT_POSTCARD)
- {
- LLFloaterPostcard* floater = previewp->savePostcard();
- // if still in snapshot mode, put postcard floater in snapshot floaterview
- // and link it to snapshot floater
- if (floater && !gSavedSettings.getBOOL("CloseSnapshotOnKeep"))
- {
- gFloaterView->removeChild(floater);
- gSnapshotFloaterView->addChild(floater);
- view->addDependentFloater(floater, FALSE);
- }
- }
- else if (previewp->getSnapshotType() == LLSnapshotLivePreview::SNAPSHOT_TEXTURE)
- {
- previewp->saveTexture();
- }
- else
- {
- previewp->saveLocal();
- }
-
- if (gSavedSettings.getBOOL("CloseSnapshotOnKeep"))
- {
- view->closeFloater();
- }
- else
- {
- checkAutoSnapshot(previewp);
- }
-
- updateControls(view);
- }
-}
-
-// static
void LLFloaterSnapshot::Impl::onClickNewSnapshot(void* data)
{
LLSnapshotLivePreview* previewp = getPreviewView((LLFloaterSnapshot *)data);
@@ -1674,10 +1568,8 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL
}
// save off all selected resolution values
- gSavedSettings.setS32("SnapshotPostcardLastResolution", view->getChild<LLComboBox>("postcard_size_combo")->getCurrentIndex());
- gSavedSettings.setS32("SnapshotTextureLastResolution", view->getChild<LLComboBox>("texture_size_combo")->getCurrentIndex());
- gSavedSettings.setS32("SnapshotLocalLastResolution", view->getChild<LLComboBox>("local_size_combo")->getCurrentIndex());
-
+ gSavedSettings.setS32("SnapshotLastResolution", view->getChild<LLComboBox>("snapshot_size_combo")->getCurrentIndex());
+
std::string sdstring = combobox->getSelectedValue();
LLSD sdres;
std::stringstream sstream(sdstring);
@@ -1757,17 +1649,130 @@ void LLFloaterSnapshot::Impl::onCommitLayerTypes(LLUICtrl* ctrl, void*data)
}
//static
-void LLFloaterSnapshot::Impl::onCommitSnapshotType(LLUICtrl* ctrl, void* data)
+void LLFloaterSnapshot::Impl::onToggleAdvanced(LLUICtrl* ctrl, void* data)
{
- LLFloaterSnapshot *view = (LLFloaterSnapshot *)data;
- if (view)
+ LLFloaterSnapshot *view = (LLFloaterSnapshot *)data;
+
+ LLPanel* advanced_panel = view->getChild<LLPanel>("snapshot_advanced");
+
+ if (advanced_panel->getVisible())
{
- gSavedSettings.setS32("LastSnapshotType", getTypeIndex(view));
- getPreviewView(view)->updateSnapshot(TRUE);
- updateControls(view);
+ advanced_panel->setVisible(false);
+
+ // shrink floater back to original size
+ view->reshape(view->getRect().getWidth() - advanced_panel->getRect().getWidth(), view->getRect().getHeight());
+
+ view->getChild<LLButton>("hide_advanced")->setVisible(false);
+ view->getChild<LLButton>("show_advanced")->setVisible(true);
+ }
+ else
+ {
+ advanced_panel->setVisible(true);
+ // stretch the floater so it can accommodate the advanced panel
+ view->reshape(view->getRect().getWidth() + advanced_panel->getRect().getWidth(), view->getRect().getHeight());
+
+ view->getChild<LLButton>("hide_advanced")->setVisible(true);
+ view->getChild<LLButton>("show_advanced")->setVisible(false);
+ }
+}
+
+// This object represents a pending request for avatar properties information
+class LLAvatarDataRequest : public LLAvatarPropertiesObserver
+{
+public:
+ LLAvatarDataRequest(const LLUUID& avatar_id, const LLUUID& image_id, LLFloaterSnapshot* floater)
+ : mAvatarID(avatar_id),
+ mImageID(image_id),
+ mSnapshotFloater(floater)
+
+ {
+ }
+
+ ~LLAvatarDataRequest()
+ {
+ // remove ourselves as an observer
+ LLAvatarPropertiesProcessor::getInstance()->
+ removeObserver(mAvatarID, this);
+ }
+
+ void processProperties(void* data, EAvatarProcessorType type)
+ {
+ // route the data to the inspector
+ if (data
+ && type == APT_PROPERTIES)
+ {
+
+ LLAvatarData* avatar_data = static_cast<LLAvatarData*>(data);
+
+ LLAvatarData new_data(*avatar_data);
+ new_data.image_id = mImageID;
+
+ LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesUpdate(&new_data);
+
+ delete this;
+ }
+ }
+
+ // Store avatar ID so we can un-register the observer on destruction
+ LLUUID mAvatarID;
+ LLUUID mImageID;
+ LLFloaterSnapshot* mSnapshotFloater;
+};
+
+void LLFloaterSnapshot::Impl::onCommitProfilePic(LLFloaterSnapshot* view)
+{
+ //first save to harddrive
+ LLSnapshotLivePreview* previewp = getPreviewView(view);
+
+ if(previewp)
+ {
+ previewp->saveTexture(true);
}
}
+void LLFloaterSnapshot::Impl::onCommitSnapshot(LLFloaterSnapshot* view, LLSnapshotLivePreview::ESnapshotType type)
+{
+ LLSnapshotLivePreview* previewp = getPreviewView(view);
+
+ if (previewp)
+ {
+ previewp->setSnapshotType(type);
+
+ if (type == LLSnapshotLivePreview::SNAPSHOT_WEB)
+ {
+ previewp->saveWeb(view->getString("share_to_web_url"));
+ }
+ else if (type == LLSnapshotLivePreview::SNAPSHOT_LOCAL)
+ {
+ previewp->saveLocal();
+ }
+ else if (type == LLSnapshotLivePreview::SNAPSHOT_TEXTURE)
+ {
+ previewp->saveTexture();
+ }
+ else if (type == LLSnapshotLivePreview::SNAPSHOT_POSTCARD)
+ {
+ LLFloaterPostcard* floater = previewp->savePostcard();
+ // if still in snapshot mode, put postcard floater in snapshot floaterview
+ // and link it to snapshot floater
+ if (floater && !gSavedSettings.getBOOL("CloseSnapshotOnKeep"))
+ {
+ gFloaterView->removeChild(floater);
+ gSnapshotFloaterView->addChild(floater);
+ view->addDependentFloater(floater, FALSE);
+ }
+ }
+
+ if (gSavedSettings.getBOOL("CloseSnapshotOnKeep"))
+ {
+ view->closeFloater();
+ }
+ else
+ {
+ checkAutoSnapshot(previewp);
+ }
+ }
+}
//static
void LLFloaterSnapshot::Impl::onCommitSnapshotFormat(LLUICtrl* ctrl, void* data)
@@ -1781,8 +1786,6 @@ void LLFloaterSnapshot::Impl::onCommitSnapshotFormat(LLUICtrl* ctrl, void* data)
}
}
-
-
// Sets the named size combo to "custom" mode.
// static
void LLFloaterSnapshot::Impl::comboSetCustom(LLFloaterSnapshot* floater, const std::string& comboname)
@@ -1791,24 +1794,11 @@ void LLFloaterSnapshot::Impl::comboSetCustom(LLFloaterSnapshot* floater, const s
combo->setCurrentByIndex(combo->getItemCount() - 1); // "custom" is always the last index
- if(comboname == "postcard_size_combo")
- {
- gSavedSettings.setS32("SnapshotPostcardLastResolution", combo->getCurrentIndex());
- }
- else if(comboname == "texture_size_combo")
- {
- gSavedSettings.setS32("SnapshotTextureLastResolution", combo->getCurrentIndex());
- }
- else if(comboname == "local_size_combo")
- {
- gSavedSettings.setS32("SnapshotLocalLastResolution", combo->getCurrentIndex());
- }
+ gSavedSettings.setS32("SnapshotLastResolution", combo->getCurrentIndex());
checkAspectRatio(floater, -1); // -1 means custom
}
-
-
//static
BOOL LLFloaterSnapshot::Impl::checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value)
{
@@ -1949,9 +1939,7 @@ void LLFloaterSnapshot::Impl::onCommitCustomResolution(LLUICtrl *ctrl, void* dat
previewp->setSize(w,h);
checkAutoSnapshot(previewp, FALSE);
previewp->updateSnapshot(FALSE, TRUE);
- comboSetCustom(view, "postcard_size_combo");
- comboSetCustom(view, "texture_size_combo");
- comboSetCustom(view, "local_size_combo");
+ comboSetCustom(view, "snapshot_size_combo");
}
}
@@ -1968,7 +1956,7 @@ void LLFloaterSnapshot::Impl::onCommitCustomResolution(LLUICtrl *ctrl, void* dat
// Default constructor
LLFloaterSnapshot::LLFloaterSnapshot(const LLSD& key)
- : LLFloater(key),
+ : LLTransientDockableFloater(NULL, true, key),
impl (*(new Impl))
{
//Called from floater reg: LLUICtrlFactory::getInstance()->buildFloater(this, "floater_snapshot.xml", FALSE);
@@ -1993,7 +1981,20 @@ LLFloaterSnapshot::~LLFloaterSnapshot()
BOOL LLFloaterSnapshot::postBuild()
{
- childSetCommitCallback("snapshot_type_radio", Impl::onCommitSnapshotType, this);
+
+ getChild<LLButton>("share")->setCommitCallback(boost::bind(&LLFloaterSnapshot::updateButtons, this, SNAPSHOT_SHARE));
+ getChild<LLButton>("save")->setCommitCallback(boost::bind(&LLFloaterSnapshot::updateButtons, this, SNAPSHOT_SAVE));
+ getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterSnapshot::updateButtons, this, SNAPSHOT_MAIN));
+
+ getChild<LLButton>("share_to_web")->setCommitCallback(boost::bind(&Impl::onCommitSnapshot, this, LLSnapshotLivePreview::SNAPSHOT_WEB));
+ getChild<LLButton>("share_to_email")->setCommitCallback(boost::bind(&Impl::onCommitSnapshot, this, LLSnapshotLivePreview::SNAPSHOT_POSTCARD));
+ getChild<LLButton>("save_to_inventory")->setCommitCallback(boost::bind(&Impl::onCommitSnapshot, this, LLSnapshotLivePreview::SNAPSHOT_TEXTURE));
+ getChild<LLButton>("save_to_computer")->setCommitCallback(boost::bind(&Impl::onCommitSnapshot, this, LLSnapshotLivePreview::SNAPSHOT_LOCAL));
+ getChild<LLButton>("set_profile_pic")->setCommitCallback(boost::bind(&Impl::onCommitProfilePic, this));
+
+ childSetCommitCallback("show_advanced", Impl::onToggleAdvanced, this);
+ childSetCommitCallback("hide_advanced", Impl::onToggleAdvanced, this);
+
childSetCommitCallback("local_format_combo", Impl::onCommitSnapshotFormat, this);
childSetAction("new_snapshot_btn", Impl::onClickNewSnapshot, this);
@@ -2001,11 +2002,6 @@ BOOL LLFloaterSnapshot::postBuild()
childSetAction("more_btn", Impl::onClickMore, this);
childSetAction("less_btn", Impl::onClickLess, this);
- childSetAction("upload_btn", Impl::onClickKeep, this);
- childSetAction("send_btn", Impl::onClickKeep, this);
- childSetCommitCallback("save_btn", Impl::onCommitSave, this);
- childSetAction("discard_btn", Impl::onClickDiscard, this);
-
childSetCommitCallback("image_quality_slider", Impl::onCommitQuality, this);
childSetValue("image_quality_slider", gSavedSettings.getS32("SnapshotQuality"));
@@ -2026,7 +2022,6 @@ BOOL LLFloaterSnapshot::postBuild()
childSetCommitCallback("layer_types", Impl::onCommitLayerTypes, this);
childSetValue("layer_types", "colors");
- childSetEnabled("layer_types", FALSE);
childSetValue("snapshot_width", gSavedSettings.getS32(lastSnapshotWidthName()));
childSetValue("snapshot_height", gSavedSettings.getS32(lastSnapshotHeightName()));
@@ -2037,9 +2032,7 @@ BOOL LLFloaterSnapshot::postBuild()
childSetValue("auto_snapshot_check", gSavedSettings.getBOOL("AutoSnapshot"));
childSetCommitCallback("auto_snapshot_check", Impl::onClickAutoSnap, this);
- childSetCommitCallback("postcard_size_combo", Impl::onCommitResolution, this);
- childSetCommitCallback("texture_size_combo", Impl::onCommitResolution, this);
- childSetCommitCallback("local_size_combo", Impl::onCommitResolution, this);
+ childSetCommitCallback("snapshot_size_combo", Impl::onCommitResolution, this);
// create preview window
LLRect full_screen_rect = getRootView()->getRect();
@@ -2060,8 +2053,14 @@ BOOL LLFloaterSnapshot::postBuild()
impl.mPreviewHandle = previewp->getHandle();
impl.updateControls(this);
impl.updateLayout(this);
+
+ //save off the refresh button's rectangle so we can apply offsets with thumbnail resize
+ mRefreshBtnRect = getChild<LLButton>("new_snapshot_btn")->getRect();
+
+ // make sure we share/hide the general buttons
+ updateButtons(SNAPSHOT_MAIN);
- return TRUE;
+ return LLDockableFloater::postBuild();
}
void LLFloaterSnapshot::draw()
@@ -2074,15 +2073,19 @@ void LLFloaterSnapshot::draw()
return;
}
- LLFloater::draw();
+ LLDockableFloater::draw();
+
+ LLButton* refresh_btn = getChild<LLButton>("new_snapshot_btn");
+ // revert the refresh button to original intended position
+ LLRect refresh_rect = mRefreshBtnRect;
if (previewp)
{
if(previewp->getThumbnailImage())
{
- LLRect thumbnail_rect = getChild<LLUICtrl>("thumbnail_placeholder")->getRect();
+ LLRect thumbnail_rect = getChild<LLView>("thumbnail_placeholder")->getRect();
- S32 offset_x = (getRect().getWidth() - previewp->getThumbnailWidth()) / 2 ;
+ S32 offset_x = (thumbnail_rect.getWidth() - previewp->getThumbnailWidth()) / 2 + thumbnail_rect.mLeft;
S32 offset_y = thumbnail_rect.mBottom + (thumbnail_rect.getHeight() - previewp->getThumbnailHeight()) / 2 ;
glMatrixMode(GL_MODELVIEW);
@@ -2091,8 +2094,14 @@ void LLFloaterSnapshot::draw()
previewp->getThumbnailImage(), LLColor4::white);
previewp->drawPreviewRect(offset_x, offset_y) ;
+
+ refresh_rect.translate(offset_x - thumbnail_rect.mLeft, offset_y - thumbnail_rect.mBottom);
}
}
+
+ refresh_btn->setRect(refresh_rect);
+ drawChild(refresh_btn);
+
}
void LLFloaterSnapshot::onOpen(const LLSD& key)
@@ -2106,6 +2115,12 @@ void LLFloaterSnapshot::onOpen(const LLSD& key)
gSnapshotFloaterView->setEnabled(TRUE);
gSnapshotFloaterView->setVisible(TRUE);
gSnapshotFloaterView->adjustToFitScreen(this, FALSE);
+
+ LLButton *snapshots = LLBottomTray::getInstance()->getChild<LLButton>("snapshots");
+
+ setDockControl(new LLDockControl(
+ snapshots, this,
+ getDockTongue(), LLDockControl::TOP));
}
void LLFloaterSnapshot::onClose(bool app_quitting)
@@ -2133,6 +2148,33 @@ void LLFloaterSnapshot::update()
}
}
+bool LLFloaterSnapshot::updateButtons(ESnapshotMode mode)
+{
+ childSetVisible("share", mode == SNAPSHOT_MAIN);
+ childSetVisible("save", mode == SNAPSHOT_MAIN);
+ childSetVisible("set_profile_pic", mode == SNAPSHOT_MAIN);
+
+ childSetVisible("share_to_web", mode == SNAPSHOT_SHARE);
+ childSetVisible("share_to_email", mode == SNAPSHOT_SHARE);
+
+ childSetVisible("save_to_inventory", mode == SNAPSHOT_SAVE);
+ childSetVisible("save_to_computer", mode == SNAPSHOT_SAVE);
+
+ childSetVisible("cancel", mode != SNAPSHOT_MAIN);
+
+ return true;
+}
+
+void LLFloaterSnapshot::setAsProfilePic(const LLUUID& image_id)
+{
+ LLAvatarDataRequest* avatar_data_request = new LLAvatarDataRequest(gAgent.getID(), image_id, this);
+
+ LLAvatarPropertiesProcessor* processor =
+ LLAvatarPropertiesProcessor::getInstance();
+
+ processor->addObserver(gAgent.getID(), avatar_data_request);
+ processor->sendAvatarPropertiesRequest(gAgent.getID());
+}
///----------------------------------------------------------------------------
/// Class LLSnapshotFloaterView
diff --git a/indra/newview/llfloatersnapshot.h b/indra/newview/llfloatersnapshot.h
index 1333497bd2..931d355748 100644
--- a/indra/newview/llfloatersnapshot.h
+++ b/indra/newview/llfloatersnapshot.h
@@ -34,9 +34,10 @@
#define LL_LLFLOATERSNAPSHOT_H
#include "llfloater.h"
+#include "lltransientdockablefloater.h"
-class LLFloaterSnapshot : public LLFloater
+class LLFloaterSnapshot : public LLTransientDockableFloater
{
public:
typedef enum e_snapshot_format
@@ -46,6 +47,13 @@ public:
SNAPSHOT_FORMAT_BMP
} ESnapshotFormat;
+ enum ESnapshotMode
+ {
+ SNAPSHOT_SHARE,
+ SNAPSHOT_SAVE,
+ SNAPSHOT_MAIN
+ };
+
LLFloaterSnapshot(const LLSD& key);
virtual ~LLFloaterSnapshot();
@@ -56,6 +64,10 @@ public:
static void update();
+ void setAsProfilePic(const LLUUID& image_id);
+
+ bool updateButtons(ESnapshotMode mode);
+
static S32 getUIWinHeightLong() {return sUIWinHeightLong ;}
static S32 getUIWinHeightShort() {return sUIWinHeightShort ;}
static S32 getUIWinWidth() {return sUIWinWidth ;}
@@ -67,6 +79,8 @@ private:
static S32 sUIWinHeightLong ;
static S32 sUIWinHeightShort ;
static S32 sUIWinWidth ;
+
+ LLRect mRefreshBtnRect;
};
class LLSnapshotFloaterView : public LLFloaterView
diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp
index 7c42a581ff..d8d7057c4e 100644
--- a/indra/newview/llfloatertools.cpp
+++ b/indra/newview/llfloatertools.cpp
@@ -38,7 +38,7 @@
#include "llcoord.h"
//#include "llgl.h"
-#include "llagent.h"
+#include "llagentcamera.h"
#include "llbutton.h"
#include "llcheckboxctrl.h"
#include "llcombobox.h"
@@ -533,7 +533,7 @@ void LLFloaterTools::updatePopup(LLCoordGL center, MASK mask)
}
// multiply by correction factor because volume sliders go [0, 0.5]
- childSetValue( "slider zoom", gAgent.getCameraZoomFraction() * 0.5f);
+ childSetValue( "slider zoom", gAgentCamera.getCameraZoomFraction() * 0.5f);
// Move buttons
BOOL move_visible = (tool == LLToolGrab::getInstance());
@@ -766,7 +766,7 @@ void LLFloaterTools::onClose(bool app_quitting)
// Different from handle_reset_view in that it doesn't actually
// move the camera if EditCameraMovement is not set.
- gAgent.resetView(gSavedSettings.getBOOL("EditCameraMovement"));
+ gAgentCamera.resetView(gSavedSettings.getBOOL("EditCameraMovement"));
// exit component selection mode
LLSelectMgr::getInstance()->promoteSelectionToRoot();
@@ -847,7 +847,7 @@ void commit_slider_zoom(LLUICtrl *ctrl)
{
// renormalize value, since max "volume" level is 0.5 for some reason
F32 zoom_level = (F32)ctrl->getValue().asReal() * 2.f; // / 0.5f;
- gAgent.setCameraZoomFraction(zoom_level);
+ gAgentCamera.setCameraZoomFraction(zoom_level);
}
void click_popup_rotate_left(void*)
diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp
index 67c0b530eb..391e63f730 100644
--- a/indra/newview/llfloaterworldmap.cpp
+++ b/indra/newview/llfloaterworldmap.cpp
@@ -41,6 +41,7 @@
#include "llfloaterworldmap.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llbutton.h"
#include "llcallingcard.h"
#include "llcombobox.h"
@@ -1220,12 +1221,12 @@ void LLFloaterWorldMap::centerOnTarget(BOOL animate)
{
// We've got the position finally, so we're no longer busy. JC
// getWindow()->decBusyCount();
- pos_global = LLTracker::getTrackedPositionGlobal() - gAgent.getCameraPositionGlobal();
+ pos_global = LLTracker::getTrackedPositionGlobal() - gAgentCamera.getCameraPositionGlobal();
}
}
else if(LLWorldMap::getInstance()->isTracking())
{
- pos_global = LLWorldMap::getInstance()->getTrackedPositionGlobal() - gAgent.getCameraPositionGlobal();;
+ pos_global = LLWorldMap::getInstance()->getTrackedPositionGlobal() - gAgentCamera.getCameraPositionGlobal();;
}
else
{
diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp
index 8569e208eb..2aba0b5c09 100644
--- a/indra/newview/llglsandbox.cpp
+++ b/indra/newview/llglsandbox.cpp
@@ -71,99 +71,6 @@
// Height of the yellow selection highlight posts for land
const F32 PARCEL_POST_HEIGHT = 0.666f;
-BOOL LLAgent::setLookAt(ELookAtType target_type, LLViewerObject *object, LLVector3 position)
-{
- if(object && object->isAttachment())
- {
- LLViewerObject* parent = object;
- while(parent)
- {
- if (parent == mAvatarObject)
- {
- // looking at an attachment on ourselves, which we don't want to do
- object = mAvatarObject;
- position.clearVec();
- }
- parent = (LLViewerObject*)parent->getParent();
- }
- }
- if(!mLookAt || mLookAt->isDead())
- {
- mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT);
- mLookAt->setSourceObject(mAvatarObject);
- }
-
- return mLookAt->setLookAt(target_type, object, position);
-}
-
-BOOL LLAgent::setPointAt(EPointAtType target_type, LLViewerObject *object, LLVector3 position)
-{
- // disallow pointing at attachments and avatars
- if (object && (object->isAttachment() || object->isAvatar()))
- {
- return FALSE;
- }
-
- if(!mPointAt || mPointAt->isDead())
- {
- mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT);
- mPointAt->setSourceObject(mAvatarObject);
- }
-
- return mPointAt->setPointAt(target_type, object, position);
-}
-
-ELookAtType LLAgent::getLookAtType()
-{
- if (mLookAt)
- {
- return mLookAt->getLookAtType();
- }
-
- return LOOKAT_TARGET_NONE;
-}
-
-EPointAtType LLAgent::getPointAtType()
-{
- if (mPointAt)
- {
- return mPointAt->getPointAtType();
- }
-
- return POINTAT_TARGET_NONE;
-}
-
-// Draw a representation of current autopilot target
-void LLAgent::renderAutoPilotTarget()
-{
- if (mAutoPilot)
- {
- F32 height_meters;
- LLVector3d target_global;
-
- glMatrixMode(GL_MODELVIEW);
- gGL.pushMatrix();
-
- // not textured
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-
- // lovely green
- glColor4f(0.f, 1.f, 1.f, 1.f);
-
- target_global = mAutoPilotTargetGlobal;
-
- gGL.translatef((F32)(target_global.mdV[VX]), (F32)(target_global.mdV[VY]), (F32)(target_global.mdV[VZ]));
-
- height_meters = 1.f;
-
- glScalef(height_meters, height_meters, height_meters);
-
- gSphere.render(1500.f);
-
- gGL.popMatrix();
- }
-}
-
// Returns true if you got at least one object
void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask)
{
diff --git a/indra/newview/llhudeffectlookat.cpp b/indra/newview/llhudeffectlookat.cpp
index 07b81ef134..3be0fcbc5f 100644
--- a/indra/newview/llhudeffectlookat.cpp
+++ b/indra/newview/llhudeffectlookat.cpp
@@ -38,6 +38,7 @@
#include "message.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llvoavatar.h"
#include "lldrawable.h"
#include "llviewerobjectlist.h"
@@ -316,7 +317,7 @@ void LLHUDEffectLookAt::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
LLUUID dataId;
mesgsys->getUUIDFast(_PREHASH_Effect, _PREHASH_ID, dataId, blocknum);
- if (!gAgent.mLookAt.isNull() && dataId == gAgent.mLookAt->getID())
+ if (!gAgentCamera.mLookAt.isNull() && dataId == gAgentCamera.mLookAt->getID())
{
return;
}
@@ -637,7 +638,7 @@ bool LLHUDEffectLookAt::calcTargetPosition()
// mouselook and freelook target offsets are absolute
target_rot = LLQuaternion::DEFAULT;
}
- else if (looking_at_self && gAgent.cameraCustomizeAvatar())
+ else if (looking_at_self && gAgentCamera.cameraCustomizeAvatar())
{
// *NOTE: We have to do this because animation
// overrides do not set lookat behavior.
diff --git a/indra/newview/llhudeffectpointat.cpp b/indra/newview/llhudeffectpointat.cpp
index a13ee8572f..01dfb50b10 100644
--- a/indra/newview/llhudeffectpointat.cpp
+++ b/indra/newview/llhudeffectpointat.cpp
@@ -38,6 +38,7 @@
#include "llrender.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "lldrawable.h"
#include "llviewerobjectlist.h"
#include "llvoavatar.h"
@@ -152,7 +153,7 @@ void LLHUDEffectPointAt::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
mesgsys->getUUIDFast(_PREHASH_Effect, _PREHASH_ID, dataId, blocknum);
// ignore messages from ourselves
- if (!gAgent.mPointAt.isNull() && dataId == gAgent.mPointAt->getID())
+ if (!gAgentCamera.mPointAt.isNull() && dataId == gAgentCamera.mPointAt->getID())
{
return;
}
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 6fedd9ac4d..da21939a61 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -37,6 +37,7 @@
#include "llinventorybridge.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llagentwearables.h"
#include "llappearancemgr.h"
#include "llavataractions.h"
@@ -1505,14 +1506,14 @@ BOOL LLFolderBridge::isItemRemovable() const
return FALSE;
}
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- if( !avatar )
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if(!avatarp)
{
return FALSE;
}
LLInventoryCategory* category = model->getCategory(mUUID);
- if( !category )
+ if(!category)
{
return FALSE;
}
@@ -1660,8 +1661,8 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
LLInventoryModel* model = getInventoryModel();
if(!model) return FALSE;
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- if(!avatar) return FALSE;
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if(!avatarp) return FALSE;
// cannot drag categories into library
if(!isAgentInventory())
@@ -3025,8 +3026,8 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item,
return FALSE;
}
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- if(!avatar) return FALSE;
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if(!avatarp) return FALSE;
LLToolDragAndDrop::ESource source = LLToolDragAndDrop::getInstance()->getSource();
BOOL accept = FALSE;
@@ -4154,8 +4155,8 @@ std::string LLObjectBridge::getLabelSuffix() const
{
if (get_is_item_worn(mUUID))
{
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- std::string attachment_point_name = avatar->getAttachedPointName(mUUID);
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ std::string attachment_point_name = avatarp->getAttachedPointName(mUUID);
// e.g. "(worn on ...)" / "(attached to ...)"
LLStringUtil::format_map_t args;
@@ -4353,11 +4354,11 @@ BOOL LLObjectBridge::renameItem(const std::string& new_name)
model->notifyObservers();
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- if( avatar )
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if(avatarp)
{
- LLViewerObject* obj = avatar->getWornAttachment( item->getUUID() );
- if( obj )
+ LLViewerObject* obj = avatarp->getWornAttachment( item->getUUID() );
+ if(obj)
{
LLSelectMgr::getInstance()->deselectAll();
LLSelectMgr::getInstance()->addAsIndividual( obj, SELECT_ALL_TES, FALSE );
@@ -4906,10 +4907,10 @@ void LLWearableBridge::editOnAvatar()
if (gFloaterCustomize)
gFloaterCustomize->setCurrentWearableType( wearable->getType() );
- if( CAMERA_MODE_CUSTOMIZE_AVATAR != gAgent.getCameraMode() )
+ if( CAMERA_MODE_CUSTOMIZE_AVATAR != gAgentCamera.getCameraMode() )
{
// Start Avatar Customization
- gAgent.changeCameraToCustomizeAvatar();
+ gAgentCamera.changeCameraToCustomizeAvatar();
}
}
}
diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp
index 2cc5c8335d..9e1dc3a4b0 100644
--- a/indra/newview/lljoystickbutton.cpp
+++ b/indra/newview/lljoystickbutton.cpp
@@ -42,6 +42,7 @@
// Project includes
#include "llui.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llviewertexture.h"
#include "llviewertexturelist.h"
#include "llviewerwindow.h"
@@ -482,25 +483,25 @@ void LLJoystickCameraRotate::onHeldDown()
// left-right rotation
if (dx > mHorizSlopNear)
{
- gAgent.unlockView();
- gAgent.setOrbitLeftKey(getOrbitRate());
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitLeftKey(getOrbitRate());
}
else if (dx < -mHorizSlopNear)
{
- gAgent.unlockView();
- gAgent.setOrbitRightKey(getOrbitRate());
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitRightKey(getOrbitRate());
}
// over/under rotation
if (dy > mVertSlopNear)
{
- gAgent.unlockView();
- gAgent.setOrbitUpKey(getOrbitRate());
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitUpKey(getOrbitRate());
}
else if (dy < -mVertSlopNear)
{
- gAgent.unlockView();
- gAgent.setOrbitDownKey(getOrbitRate());
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitDownKey(getOrbitRate());
}
}
@@ -625,25 +626,25 @@ void LLJoystickCameraTrack::onHeldDown()
if (dx > mVertSlopNear)
{
- gAgent.unlockView();
- gAgent.setPanRightKey(getOrbitRate());
+ gAgentCamera.unlockView();
+ gAgentCamera.setPanRightKey(getOrbitRate());
}
else if (dx < -mVertSlopNear)
{
- gAgent.unlockView();
- gAgent.setPanLeftKey(getOrbitRate());
+ gAgentCamera.unlockView();
+ gAgentCamera.setPanLeftKey(getOrbitRate());
}
// over/under rotation
if (dy > mVertSlopNear)
{
- gAgent.unlockView();
- gAgent.setPanUpKey(getOrbitRate());
+ gAgentCamera.unlockView();
+ gAgentCamera.setPanUpKey(getOrbitRate());
}
else if (dy < -mVertSlopNear)
{
- gAgent.unlockView();
- gAgent.setPanDownKey(getOrbitRate());
+ gAgentCamera.unlockView();
+ gAgentCamera.setPanDownKey(getOrbitRate());
}
}
@@ -692,26 +693,26 @@ void LLJoystickCameraZoom::onHeldDown()
if (dy > mVertSlopFar)
{
// Zoom in fast
- gAgent.unlockView();
- gAgent.setOrbitInKey(FAST_RATE);
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitInKey(FAST_RATE);
}
else if (dy > mVertSlopNear)
{
// Zoom in slow
- gAgent.unlockView();
- gAgent.setOrbitInKey(getOrbitRate());
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitInKey(getOrbitRate());
}
else if (dy < -mVertSlopFar)
{
// Zoom out fast
- gAgent.unlockView();
- gAgent.setOrbitOutKey(FAST_RATE);
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitOutKey(FAST_RATE);
}
else if (dy < -mVertSlopNear)
{
// Zoom out slow
- gAgent.unlockView();
- gAgent.setOrbitOutKey(getOrbitRate());
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitOutKey(getOrbitRate());
}
}
diff --git a/indra/newview/llmanip.cpp b/indra/newview/llmanip.cpp
index a96240e31c..957e88960d 100644
--- a/indra/newview/llmanip.cpp
+++ b/indra/newview/llmanip.cpp
@@ -43,6 +43,7 @@
#include "llviewertexturelist.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llviewercontrol.h"
#include "lldrawable.h"
#include "llfontgl.h"
@@ -180,7 +181,7 @@ F32 LLManip::getSubdivisionLevel(const LLVector3 &reference_point, const LLVecto
LLVector3 cam_to_reference;
if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
- cam_to_reference = LLVector3(1.f / gAgent.mHUDCurZoom, 0.f, 0.f);
+ cam_to_reference = LLVector3(1.f / gAgentCamera.mHUDCurZoom, 0.f, 0.f);
}
else
{
@@ -265,8 +266,8 @@ BOOL LLManip::getMousePointOnPlaneGlobal(LLVector3d& point, S32 x, S32 y, LLVect
if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
BOOL result = FALSE;
- F32 mouse_x = ((F32)x / gViewerWindow->getWorldViewWidthScaled() - 0.5f) * LLViewerCamera::getInstance()->getAspect() / gAgent.mHUDCurZoom;
- F32 mouse_y = ((F32)y / gViewerWindow->getWorldViewHeightScaled() - 0.5f) / gAgent.mHUDCurZoom;
+ F32 mouse_x = ((F32)x / gViewerWindow->getWorldViewWidthScaled() - 0.5f) * LLViewerCamera::getInstance()->getAspect() / gAgentCamera.mHUDCurZoom;
+ F32 mouse_y = ((F32)y / gViewerWindow->getWorldViewHeightScaled() - 0.5f) / gAgentCamera.mHUDCurZoom;
LLVector3 origin_agent = gAgent.getPosAgentFromGlobal(origin);
LLVector3 mouse_pos = LLVector3(0.f, -mouse_x, mouse_y);
@@ -304,15 +305,15 @@ BOOL LLManip::nearestPointOnLineFromMouse( S32 x, S32 y, const LLVector3& b1, co
if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
- F32 mouse_x = (((F32)x / gViewerWindow->getWindowWidthScaled()) - 0.5f) * LLViewerCamera::getInstance()->getAspect() / gAgent.mHUDCurZoom;
- F32 mouse_y = (((F32)y / gViewerWindow->getWindowHeightScaled()) - 0.5f) / gAgent.mHUDCurZoom;
+ F32 mouse_x = (((F32)x / gViewerWindow->getWindowWidthScaled()) - 0.5f) * LLViewerCamera::getInstance()->getAspect() / gAgentCamera.mHUDCurZoom;
+ F32 mouse_y = (((F32)y / gViewerWindow->getWindowHeightScaled()) - 0.5f) / gAgentCamera.mHUDCurZoom;
a1 = LLVector3(llmin(b1.mV[VX] - 0.1f, b2.mV[VX] - 0.1f, 0.f), -mouse_x, mouse_y);
a2 = a1 + LLVector3(1.f, 0.f, 0.f);
}
else
{
- a1 = gAgent.getCameraPositionAgent();
- a2 = gAgent.getCameraPositionAgent() + LLVector3(gViewerWindow->mouseDirectionGlobal(x, y));
+ a1 = gAgentCamera.getCameraPositionAgent();
+ a2 = gAgentCamera.getCameraPositionAgent() + LLVector3(gViewerWindow->mouseDirectionGlobal(x, y));
}
BOOL parallel = TRUE;
@@ -491,7 +492,7 @@ void LLManip::renderTickText(const LLVector3& pos, const std::string& text, cons
LLVector3 render_pos = pos;
if (hud_selection)
{
- F32 zoom_amt = gAgent.mHUDCurZoom;
+ F32 zoom_amt = gAgentCamera.mHUDCurZoom;
F32 inv_zoom_amt = 1.f / zoom_amt;
// scale text back up to counter-act zoom level
render_pos = pos * zoom_amt;
@@ -549,7 +550,7 @@ void LLManip::renderTickValue(const LLVector3& pos, F32 value, const std::string
LLVector3 render_pos = pos;
if (hud_selection)
{
- F32 zoom_amt = gAgent.mHUDCurZoom;
+ F32 zoom_amt = gAgentCamera.mHUDCurZoom;
F32 inv_zoom_amt = 1.f / zoom_amt;
// scale text back up to counter-act zoom level
render_pos = pos * zoom_amt;
diff --git a/indra/newview/llmaniprotate.cpp b/indra/newview/llmaniprotate.cpp
index 8535d52015..6dc0a929c8 100644
--- a/indra/newview/llmaniprotate.cpp
+++ b/indra/newview/llmaniprotate.cpp
@@ -45,6 +45,7 @@
// viewer includes
#include "llagent.h"
+#include "llagentcamera.h"
#include "llbox.h"
#include "llbutton.h"
#include "llviewercontrol.h"
@@ -138,7 +139,7 @@ void LLManipRotate::render()
glPushMatrix();
if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
- F32 zoom = gAgent.mHUDCurZoom;
+ F32 zoom = gAgentCamera.mHUDCurZoom;
glScalef(zoom, zoom, zoom);
}
@@ -690,7 +691,7 @@ void LLManipRotate::drag( S32 x, S32 y )
LLSelectMgr::getInstance()->updateSelectionCenter();
// RN: just clear focus so camera doesn't follow spurious object updates
- gAgent.clearFocusObject();
+ gAgentCamera.clearFocusObject();
dialog_refresh_all();
}
@@ -730,7 +731,7 @@ void LLManipRotate::renderSnapGuides()
}
else
{
- cam_at_axis = center - gAgent.getCameraPositionAgent();
+ cam_at_axis = center - gAgentCamera.getCameraPositionAgent();
cam_at_axis.normVec();
}
@@ -1097,12 +1098,12 @@ BOOL LLManipRotate::updateVisiblity()
LLVector3 center = gAgent.getPosAgentFromGlobal( mRotationCenter );
if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
- mCenterToCam = LLVector3(-1.f / gAgent.mHUDCurZoom, 0.f, 0.f);
+ mCenterToCam = LLVector3(-1.f / gAgentCamera.mHUDCurZoom, 0.f, 0.f);
mCenterToCamNorm = mCenterToCam;
mCenterToCamMag = mCenterToCamNorm.normVec();
mRadiusMeters = RADIUS_PIXELS / (F32) LLViewerCamera::getInstance()->getViewHeightInPixels();
- mRadiusMeters /= gAgent.mHUDCurZoom;
+ mRadiusMeters /= gAgentCamera.mHUDCurZoom;
mCenterToProfilePlaneMag = mRadiusMeters * mRadiusMeters / mCenterToCamMag;
mCenterToProfilePlane = -mCenterToProfilePlaneMag * mCenterToCamNorm;
@@ -1110,8 +1111,8 @@ BOOL LLManipRotate::updateVisiblity()
// x axis range is (-aspect * 0.5f, +aspect * 0.5)
// y axis range is (-0.5, 0.5)
// so use getWorldViewHeightRaw as scale factor when converting to pixel coordinates
- mCenterScreen.set((S32)((0.5f - center.mV[VY]) / gAgent.mHUDCurZoom * gViewerWindow->getWorldViewHeightScaled()),
- (S32)((center.mV[VZ] + 0.5f) / gAgent.mHUDCurZoom * gViewerWindow->getWorldViewHeightScaled()));
+ mCenterScreen.set((S32)((0.5f - center.mV[VY]) / gAgentCamera.mHUDCurZoom * gViewerWindow->getWorldViewHeightScaled()),
+ (S32)((center.mV[VZ] + 0.5f) / gAgentCamera.mHUDCurZoom * gViewerWindow->getWorldViewHeightScaled()));
visible = TRUE;
}
else
@@ -1119,7 +1120,7 @@ BOOL LLManipRotate::updateVisiblity()
visible = LLViewerCamera::getInstance()->projectPosAgentToScreen(center, mCenterScreen );
if( visible )
{
- mCenterToCam = gAgent.getCameraPositionAgent() - center;
+ mCenterToCam = gAgentCamera.getCameraPositionAgent() - center;
mCenterToCamNorm = mCenterToCam;
mCenterToCamMag = mCenterToCamNorm.normVec();
LLVector3 cameraAtAxis = LLViewerCamera::getInstance()->getAtAxis();
@@ -1165,7 +1166,7 @@ BOOL LLManipRotate::updateVisiblity()
LLQuaternion LLManipRotate::dragUnconstrained( S32 x, S32 y )
{
- LLVector3 cam = gAgent.getCameraPositionAgent();
+ LLVector3 cam = gAgentCamera.getCameraPositionAgent();
LLVector3 center = gAgent.getPosAgentFromGlobal( mRotationCenter );
mMouseCur = intersectMouseWithSphere( x, y, center, mRadiusMeters);
@@ -1333,7 +1334,7 @@ LLQuaternion LLManipRotate::dragConstrained( S32 x, S32 y )
}
else
{
- cam_to_snap_plane = snap_plane_center - gAgent.getCameraPositionAgent();
+ cam_to_snap_plane = snap_plane_center - gAgentCamera.getCameraPositionAgent();
cam_to_snap_plane.normVec();
}
@@ -1383,7 +1384,7 @@ LLQuaternion LLManipRotate::dragConstrained( S32 x, S32 y )
}
else
{
- cam_to_snap_plane = snap_plane_center - gAgent.getCameraPositionAgent();
+ cam_to_snap_plane = snap_plane_center - gAgentCamera.getCameraPositionAgent();
cam_to_snap_plane.normVec();
}
@@ -1430,7 +1431,7 @@ LLQuaternion LLManipRotate::dragConstrained( S32 x, S32 y )
}
else
{
- cam_at_axis = snap_plane_center - gAgent.getCameraPositionAgent();
+ cam_at_axis = snap_plane_center - gAgentCamera.getCameraPositionAgent();
cam_at_axis.normVec();
}
@@ -1627,15 +1628,15 @@ void LLManipRotate::mouseToRay( S32 x, S32 y, LLVector3* ray_pt, LLVector3* ray_
{
if (LLSelectMgr::getInstance()->getSelection()->getSelectType() == SELECT_TYPE_HUD)
{
- F32 mouse_x = (((F32)x / gViewerWindow->getWorldViewRectScaled().getWidth()) - 0.5f) / gAgent.mHUDCurZoom;
- F32 mouse_y = ((((F32)y) / gViewerWindow->getWorldViewRectScaled().getHeight()) - 0.5f) / gAgent.mHUDCurZoom;
+ F32 mouse_x = (((F32)x / gViewerWindow->getWorldViewRectScaled().getWidth()) - 0.5f) / gAgentCamera.mHUDCurZoom;
+ F32 mouse_y = ((((F32)y) / gViewerWindow->getWorldViewRectScaled().getHeight()) - 0.5f) / gAgentCamera.mHUDCurZoom;
*ray_pt = LLVector3(-1.f, -mouse_x, mouse_y);
*ray_dir = LLVector3(1.f, 0.f, 0.f);
}
else
{
- *ray_pt = gAgent.getCameraPositionAgent();
+ *ray_pt = gAgentCamera.getCameraPositionAgent();
LLViewerCamera::getInstance()->projectScreenToPosAgent(x, y, ray_dir);
*ray_dir -= *ray_pt;
ray_dir->normVec();
diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp
index ee3ffa2450..63643a7fc6 100644
--- a/indra/newview/llmanipscale.cpp
+++ b/indra/newview/llmanipscale.cpp
@@ -45,6 +45,7 @@
// viewer includes
#include "llagent.h"
+#include "llagentcamera.h"
#include "llbbox.h"
#include "llbox.h"
#include "llviewercontrol.h"
@@ -210,7 +211,7 @@ void LLManipScale::render()
glPushMatrix();
if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
- F32 zoom = gAgent.mHUDCurZoom;
+ F32 zoom = gAgentCamera.mHUDCurZoom;
glScalef(zoom, zoom, zoom);
}
@@ -227,11 +228,11 @@ void LLManipScale::render()
if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
mBoxHandleSize = BOX_HANDLE_BASE_SIZE * BOX_HANDLE_BASE_FACTOR / (F32) LLViewerCamera::getInstance()->getViewHeightInPixels();
- mBoxHandleSize /= gAgent.mHUDCurZoom;
+ mBoxHandleSize /= gAgentCamera.mHUDCurZoom;
}
else
{
- range = dist_vec(gAgent.getCameraPositionAgent(), center_agent);
+ range = dist_vec(gAgentCamera.getCameraPositionAgent(), center_agent);
range_from_agent = dist_vec(gAgent.getPositionAgent(), center_agent);
// Don't draw manip if object too far away
@@ -438,7 +439,7 @@ void LLManipScale::highlightManipulators(S32 x, S32 y)
LLMatrix4 cfr(OGL_TO_CFR_ROTATION);
transform *= cfr;
LLMatrix4 window_scale;
- F32 zoom_level = 2.f * gAgent.mHUDCurZoom;
+ F32 zoom_level = 2.f * gAgentCamera.mHUDCurZoom;
window_scale.initAll(LLVector3(zoom_level / LLViewerCamera::getInstance()->getAspect(), zoom_level, 0.f),
LLQuaternion::DEFAULT,
LLVector3::zero);
@@ -635,7 +636,7 @@ void LLManipScale::renderFaces( const LLBBox& bbox )
}
// Find nearest vertex
- LLVector3 orientWRTHead = bbox.agentToLocalBasis( bbox.getCenterAgent() - gAgent.getCameraPositionAgent() );
+ LLVector3 orientWRTHead = bbox.agentToLocalBasis( bbox.getCenterAgent() - gAgentCamera.getCameraPositionAgent() );
U32 nearest =
(orientWRTHead.mV[0] < 0.0f ? 1 : 0) +
(orientWRTHead.mV[1] < 0.0f ? 2 : 0) +
@@ -825,7 +826,7 @@ void LLManipScale::drag( S32 x, S32 y )
}
LLSelectMgr::getInstance()->updateSelectionCenter();
- gAgent.clearFocusObject();
+ gAgentCamera.clearFocusObject();
}
// Scale around the
@@ -1364,7 +1365,7 @@ void LLManipScale::updateSnapGuides(const LLBBox& bbox)
if(mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
- mSnapRegimeOffset = SNAP_GUIDE_SCREEN_OFFSET / gAgent.mHUDCurZoom;
+ mSnapRegimeOffset = SNAP_GUIDE_SCREEN_OFFSET / gAgentCamera.mHUDCurZoom;
}
else
@@ -1377,7 +1378,7 @@ void LLManipScale::updateSnapGuides(const LLBBox& bbox)
if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
cam_at_axis.setVec(1.f, 0.f, 0.f);
- snap_guide_length = SNAP_GUIDE_SCREEN_LENGTH / gAgent.mHUDCurZoom;
+ snap_guide_length = SNAP_GUIDE_SCREEN_LENGTH / gAgentCamera.mHUDCurZoom;
}
else
{
diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp
index 52fe31fbba..35c4f7f787 100644
--- a/indra/newview/llmaniptranslate.cpp
+++ b/indra/newview/llmaniptranslate.cpp
@@ -42,6 +42,7 @@
#include "llrender.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llbbox.h"
#include "llbox.h"
#include "llviewercontrol.h"
@@ -437,12 +438,12 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
{
if (x < ROTATE_H_MARGIN)
{
- gAgent.cameraOrbitAround(rotate_angle);
+ gAgentCamera.cameraOrbitAround(rotate_angle);
rotated = TRUE;
}
else if (x > world_rect.getWidth() - ROTATE_H_MARGIN)
{
- gAgent.cameraOrbitAround(-rotate_angle);
+ gAgentCamera.cameraOrbitAround(-rotate_angle);
rotated = TRUE;
}
}
@@ -789,7 +790,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
}
LLSelectMgr::getInstance()->updateSelectionCenter();
- gAgent.clearFocusObject();
+ gAgentCamera.clearFocusObject();
dialog_refresh_all(); // ??? is this necessary?
lldebugst(LLERR_USER_INPUT) << "hover handled by LLManipTranslate (active)" << llendl;
@@ -830,7 +831,7 @@ void LLManipTranslate::highlightManipulators(S32 x, S32 y)
LLMatrix4 cfr(OGL_TO_CFR_ROTATION);
transform *= cfr;
LLMatrix4 window_scale;
- F32 zoom_level = 2.f * gAgent.mHUDCurZoom;
+ F32 zoom_level = 2.f * gAgentCamera.mHUDCurZoom;
window_scale.initAll(LLVector3(zoom_level / LLViewerCamera::getInstance()->getAspect(), zoom_level, 0.f),
LLQuaternion::DEFAULT,
LLVector3::zero);
@@ -1075,7 +1076,7 @@ void LLManipTranslate::render()
gGL.pushMatrix();
if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
- F32 zoom = gAgent.mHUDCurZoom;
+ F32 zoom = gAgentCamera.mHUDCurZoom;
glScalef(zoom, zoom, zoom);
}
{
@@ -1239,7 +1240,7 @@ void LLManipTranslate::renderSnapGuides()
if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
- guide_size_meters = 1.f / gAgent.mHUDCurZoom;
+ guide_size_meters = 1.f / gAgentCamera.mHUDCurZoom;
mSnapOffsetMeters = mArrowLengthMeters * 1.5f;
}
else
@@ -1822,11 +1823,11 @@ void LLManipTranslate::renderTranslationHandles()
if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
mArrowLengthMeters = mAxisArrowLength / gViewerWindow->getWorldViewHeightRaw();
- mArrowLengthMeters /= gAgent.mHUDCurZoom;
+ mArrowLengthMeters /= gAgentCamera.mHUDCurZoom;
}
else
{
- LLVector3 camera_pos_agent = gAgent.getCameraPositionAgent();
+ LLVector3 camera_pos_agent = gAgentCamera.getCameraPositionAgent();
F32 range = dist_vec(camera_pos_agent, selection_center);
F32 range_from_agent = dist_vec(gAgent.getPositionAgent(), selection_center);
@@ -2108,7 +2109,7 @@ void LLManipTranslate::renderTranslationHandles()
// Copied from LLDrawable::updateGeometry
LLVector3 pos_agent = first_object->getPositionAgent();
- LLVector3 camera_agent = gAgent.getCameraPositionAgent();
+ LLVector3 camera_agent = gAgentCamera.getCameraPositionAgent();
LLVector3 headPos = pos_agent - camera_agent;
LLVector3 orientWRTHead = headPos * invRotation;
@@ -2150,7 +2151,7 @@ void LLManipTranslate::renderTranslationHandles()
}
else
{
- camera_axis.setVec(gAgent.getCameraPositionAgent() - first_object->getPositionAgent());
+ camera_axis.setVec(gAgentCamera.getCameraPositionAgent() - first_object->getPositionAgent());
}
for (U32 i = 0; i < NUM_AXES*2; i++)
diff --git a/indra/newview/llmenucommands.cpp b/indra/newview/llmenucommands.cpp
index 8d950f072d..e6ca0dabda 100644
--- a/indra/newview/llmenucommands.cpp
+++ b/indra/newview/llmenucommands.cpp
@@ -42,7 +42,7 @@
#include "llstring.h"
#include "message.h"
-#include "llagent.h"
+#include "llagentcamera.h"
#include "llcallingcard.h"
#include "llviewercontrol.h"
//#include "llfirstuse.h"
@@ -66,7 +66,7 @@
void handle_mouselook(void*)
{
- gAgent.changeCameraToMouselook();
+ gAgentCamera.changeCameraToMouselook();
}
diff --git a/indra/newview/llmorphview.cpp b/indra/newview/llmorphview.cpp
index b95e8bd3a2..47234eb773 100644
--- a/indra/newview/llmorphview.cpp
+++ b/indra/newview/llmorphview.cpp
@@ -37,6 +37,7 @@
#include "lljoint.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "lldrawable.h"
#include "lldrawpoolavatar.h"
#include "llface.h"
@@ -91,7 +92,7 @@ void LLMorphView::initialize()
LLVOAvatar *avatarp = gAgent.getAvatarObject();
if (!avatarp || avatarp->isDead())
{
- gAgent.changeCameraToDefault();
+ gAgentCamera.changeCameraToDefault();
return;
}
@@ -187,7 +188,7 @@ void LLMorphView::updateCamera()
LLVector3d camera_pos = joint_pos + mCameraOffset * camera_rot_pitch * camera_rot_yaw * avatar_rot;
- gAgent.setCameraPosAndFocusGlobal( camera_pos, target_pos, gAgent.getID() );
+ gAgentCamera.setCameraPosAndFocusGlobal( camera_pos, target_pos, gAgent.getID() );
}
void LLMorphView::setCameraDrivenByKeys(BOOL b)
diff --git a/indra/newview/llmoveview.cpp b/indra/newview/llmoveview.cpp
index 1853b511be..58fac14349 100644
--- a/indra/newview/llmoveview.cpp
+++ b/indra/newview/llmoveview.cpp
@@ -41,6 +41,7 @@
// Viewer includes
#include "llagent.h"
+#include "llagentcamera.h"
#include "llvoavatarself.h" // to check gAgent.getAvatarObject()->isSitting()
#include "llbottomtray.h"
#include "llbutton.h"
@@ -593,7 +594,7 @@ BOOL LLPanelStandStopFlying::postBuild()
void LLPanelStandStopFlying::setVisible(BOOL visible)
{
//we dont need to show the panel if these buttons are not activated
- if (gAgent.getCameraMode() == CAMERA_MODE_MOUSELOOK) visible = false;
+ if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK) visible = false;
if (visible)
{
diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp
index 05623198ab..a8dee8a24a 100644
--- a/indra/newview/llnetmap.cpp
+++ b/indra/newview/llnetmap.cpp
@@ -49,6 +49,7 @@
// Viewer includes
#include "llagent.h"
+#include "llagentcamera.h"
#include "llappviewer.h" // for gDisconnected
#include "llcallingcard.h" // LLAvatarTracker
#include "lltracker.h"
@@ -87,7 +88,7 @@ LLNetMap::LLNetMap (const Params & p)
mCurPanX(0.f),
mCurPanY(0.f),
mUpdateNow(FALSE),
- mObjectImageCenterGlobal( gAgent.getCameraPositionGlobal() ),
+ mObjectImageCenterGlobal( gAgentCamera.getCameraPositionGlobal() ),
mObjectRawImagep(),
mObjectImagep(),
mClosestAgentToCursor(),
@@ -203,7 +204,7 @@ void LLNetMap::draw()
LLViewerRegion* regionp = *iter;
// Find x and y position relative to camera's center.
LLVector3 origin_agent = regionp->getOriginAgent();
- LLVector3 rel_region_pos = origin_agent - gAgent.getCameraPositionAgent();
+ LLVector3 rel_region_pos = origin_agent - gAgentCamera.getCameraPositionAgent();
F32 relative_x = (rel_region_pos.mV[0] / region_width) * mScale;
F32 relative_y = (rel_region_pos.mV[1] / region_width) * mScale;
@@ -264,7 +265,7 @@ void LLNetMap::draw()
LLVector3d old_center = mObjectImageCenterGlobal;
- LLVector3d new_center = gAgent.getCameraPositionGlobal();
+ LLVector3d new_center = gAgentCamera.getCameraPositionGlobal();
new_center.mdV[0] = (5.f/mObjectMapTPM)*floor(0.2f*mObjectMapTPM*new_center.mdV[0]);
new_center.mdV[1] = (5.f/mObjectMapTPM)*floor(0.2f*mObjectMapTPM*new_center.mdV[1]);
@@ -289,7 +290,7 @@ void LLNetMap::draw()
}
LLVector3 map_center_agent = gAgent.getPosAgentFromGlobal(mObjectImageCenterGlobal);
- map_center_agent -= gAgent.getCameraPositionAgent();
+ map_center_agent -= gAgentCamera.getCameraPositionAgent();
map_center_agent.mV[VX] *= mScale/region_width;
map_center_agent.mV[VY] *= mScale/region_width;
@@ -461,7 +462,7 @@ void LLNetMap::reshape(S32 width, S32 height, BOOL called_from_parent)
LLVector3 LLNetMap::globalPosToView( const LLVector3d& global_pos )
{
- LLVector3d relative_pos_global = global_pos - gAgent.getCameraPositionGlobal();
+ LLVector3d relative_pos_global = global_pos - gAgentCamera.getCameraPositionGlobal();
LLVector3 pos_local;
pos_local.setVec(relative_pos_global); // convert to floats from doubles
@@ -529,7 +530,7 @@ LLVector3d LLNetMap::viewPosToGlobal( S32 x, S32 y )
LLVector3d pos_global;
pos_global.setVec( pos_local );
- pos_global += gAgent.getCameraPositionGlobal();
+ pos_global += gAgentCamera.getCameraPositionGlobal();
return pos_global;
}
diff --git a/indra/newview/llpanelme.cpp b/indra/newview/llpanelme.cpp
index 3504cbd1ef..35acf8edcc 100644
--- a/indra/newview/llpanelme.cpp
+++ b/indra/newview/llpanelme.cpp
@@ -36,6 +36,7 @@
#include "llavatarconstants.h"
#include "llpanelme.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llagentwearables.h"
#include "lliconctrl.h"
#include "llsidetray.h"
@@ -144,7 +145,7 @@ void LLPanelMe::onEditAppearanceClicked()
{
if (gAgentWearables.areWearablesLoaded())
{
- gAgent.changeCameraToCustomizeAvatar();
+ gAgentCamera.changeCameraToCustomizeAvatar();
}
}
diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp
index a53a3ba1ad..a9ec01f33a 100644
--- a/indra/newview/llpanelprimmediacontrols.cpp
+++ b/indra/newview/llpanelprimmediacontrols.cpp
@@ -32,7 +32,7 @@
#include "llviewerprecompiledheaders.h"
//LLPanelPrimMediaControls
-#include "llagent.h"
+#include "llagentcamera.h"
#include "llparcel.h"
#include "llpanel.h"
#include "llselectmgr.h"
@@ -1010,7 +1010,7 @@ void LLPanelPrimMediaControls::updateZoom()
{
case ZOOM_NONE:
{
- gAgent.setFocusOnAvatar(TRUE, ANIMATE);
+ gAgentCamera.setFocusOnAvatar(TRUE, ANIMATE);
break;
}
case ZOOM_FAR:
@@ -1030,7 +1030,7 @@ void LLPanelPrimMediaControls::updateZoom()
}
default:
{
- gAgent.setFocusOnAvatar(TRUE, ANIMATE);
+ gAgentCamera.setFocusOnAvatar(TRUE, ANIMATE);
break;
}
}
diff --git a/indra/newview/llpreview.cpp b/indra/newview/llpreview.cpp
index 0b0c03e9e9..99e0b82b8f 100644
--- a/indra/newview/llpreview.cpp
+++ b/indra/newview/llpreview.cpp
@@ -179,10 +179,10 @@ void LLPreview::onCommit()
// update the object itself.
if( item->getType() == LLAssetType::AT_OBJECT )
{
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- if( avatar )
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if(avatarp)
{
- LLViewerObject* obj = avatar->getWornAttachment( item->getUUID() );
+ LLViewerObject* obj = avatarp->getWornAttachment( item->getUUID() );
if( obj )
{
LLSelectMgr::getInstance()->deselectAll();
diff --git a/indra/newview/llscrollingpanelparam.cpp b/indra/newview/llscrollingpanelparam.cpp
index dc64296521..95e12bf46f 100644
--- a/indra/newview/llscrollingpanelparam.cpp
+++ b/indra/newview/llscrollingpanelparam.cpp
@@ -344,8 +344,8 @@ void LLScrollingPanelParam::onHintMaxMouseUp( void* userdata )
F32 elapsed_time = self->mMouseDownTimer.getElapsedTimeF32();
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- if (avatar)
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if (avatarp)
{
LLVisualParamHint* hint = self->mHintMax;
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 9147bd1cba..d744f097d5 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -56,6 +56,7 @@
// viewer includes
#include "llagent.h"
+#include "llagentcamera.h"
#include "llviewerwindow.h"
#include "lldrawable.h"
#include "llfloaterinspect.h"
@@ -2872,7 +2873,7 @@ bool LLSelectMgr::confirmDelete(const LLSD& notification, const LLSD& response,
effectp->setDuration(duration);
}
- gAgent.setLookAt(LOOKAT_TARGET_CLEAR);
+ gAgentCamera.setLookAt(LOOKAT_TARGET_CLEAR);
// Keep track of how many objects have been deleted.
F64 obj_delete_count = LLViewerStats::getInstance()->getStat(LLViewerStats::ST_OBJECT_DELETE_COUNT);
@@ -4626,8 +4627,8 @@ void LLSelectMgr::updateSilhouettes()
{
S32 num_sils_genned = 0;
- LLVector3d cameraPos = gAgent.getCameraPositionGlobal();
- F32 currentCameraZoom = gAgent.getCurrentCameraBuildOffset();
+ LLVector3d cameraPos = gAgentCamera.getCameraPositionGlobal();
+ F32 currentCameraZoom = gAgentCamera.getCurrentCameraBuildOffset();
if (!mSilhouetteImagep)
{
@@ -4648,7 +4649,7 @@ void LLSelectMgr::updateSilhouettes()
} func;
getSelection()->applyToObjects(&func);
- mLastCameraPos = gAgent.getCameraPositionGlobal();
+ mLastCameraPos = gAgentCamera.getCameraPositionGlobal();
}
std::vector<LLViewerObject*> changed_objects;
@@ -4915,7 +4916,7 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud)
{
LLBBox hud_bbox = avatar->getHUDBBox();
- F32 cur_zoom = gAgent.mHUDCurZoom;
+ F32 cur_zoom = gAgentCamera.mHUDCurZoom;
// set up transform to encompass bounding box of HUD
glMatrixMode(GL_PROJECTION);
@@ -5400,7 +5401,7 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color)
F32 silhouette_thickness;
if (is_hud_object && gAgent.getAvatarObject())
{
- silhouette_thickness = LLSelectMgr::sHighlightThickness / gAgent.mHUDCurZoom;
+ silhouette_thickness = LLSelectMgr::sHighlightThickness / gAgentCamera.mHUDCurZoom;
}
else
{
@@ -5420,7 +5421,7 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color)
LLGLEnable fog(GL_FOG);
glFogi(GL_FOG_MODE, GL_LINEAR);
float d = (LLViewerCamera::getInstance()->getPointOfInterest()-LLViewerCamera::getInstance()->getOrigin()).magVec();
- LLColor4 fogCol = color * (F32)llclamp((LLSelectMgr::getInstance()->getSelectionCenterGlobal()-gAgent.getCameraPositionGlobal()).magVec()/(LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal().magVec()*4), 0.0, 1.0);
+ LLColor4 fogCol = color * (F32)llclamp((LLSelectMgr::getInstance()->getSelectionCenterGlobal()-gAgentCamera.getCameraPositionGlobal()).magVec()/(LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal().magVec()*4), 0.0, 1.0);
glFogf(GL_FOG_START, d);
glFogf(GL_FOG_END, d*(1 + (LLViewerCamera::getInstance()->getView() / LLViewerCamera::getInstance()->getDefaultFOV())));
glFogfv(GL_FOG_COLOR, fogCol.mV);
@@ -5620,8 +5621,8 @@ void LLSelectMgr::updateSelectionCenter()
if (mSelectedObjects->mSelectType != SELECT_TYPE_HUD && gAgent.getAvatarObject())
{
// reset hud ZOOM
- gAgent.mHUDTargetZoom = 1.f;
- gAgent.mHUDCurZoom = 1.f;
+ gAgentCamera.mHUDTargetZoom = 1.f;
+ gAgentCamera.mHUDCurZoom = 1.f;
}
mShowSelection = FALSE;
@@ -5713,26 +5714,26 @@ void LLSelectMgr::updatePointAt()
select_offset.setVec(pick.mObjectOffset);
select_offset.rotVec(~click_object->getRenderRotation());
- gAgent.setPointAt(POINTAT_TARGET_SELECT, click_object, select_offset);
- gAgent.setLookAt(LOOKAT_TARGET_SELECT, click_object, select_offset);
+ gAgentCamera.setPointAt(POINTAT_TARGET_SELECT, click_object, select_offset);
+ gAgentCamera.setLookAt(LOOKAT_TARGET_SELECT, click_object, select_offset);
}
else
{
// didn't click on an object this time, revert to pointing at center of first object
- gAgent.setPointAt(POINTAT_TARGET_SELECT, mSelectedObjects->getFirstObject());
- gAgent.setLookAt(LOOKAT_TARGET_SELECT, mSelectedObjects->getFirstObject());
+ gAgentCamera.setPointAt(POINTAT_TARGET_SELECT, mSelectedObjects->getFirstObject());
+ gAgentCamera.setLookAt(LOOKAT_TARGET_SELECT, mSelectedObjects->getFirstObject());
}
}
else
{
- gAgent.setPointAt(POINTAT_TARGET_CLEAR);
- gAgent.setLookAt(LOOKAT_TARGET_CLEAR);
+ gAgentCamera.setPointAt(POINTAT_TARGET_CLEAR);
+ gAgentCamera.setLookAt(LOOKAT_TARGET_CLEAR);
}
}
else
{
- gAgent.setPointAt(POINTAT_TARGET_CLEAR);
- gAgent.setLookAt(LOOKAT_TARGET_CLEAR);
+ gAgentCamera.setPointAt(POINTAT_TARGET_CLEAR);
+ gAgentCamera.setLookAt(LOOKAT_TARGET_CLEAR);
}
}
@@ -5922,20 +5923,20 @@ BOOL LLSelectMgr::setForceSelection(BOOL force)
void LLSelectMgr::resetAgentHUDZoom()
{
- gAgent.mHUDTargetZoom = 1.f;
- gAgent.mHUDCurZoom = 1.f;
+ gAgentCamera.mHUDTargetZoom = 1.f;
+ gAgentCamera.mHUDCurZoom = 1.f;
}
void LLSelectMgr::getAgentHUDZoom(F32 &target_zoom, F32 &current_zoom) const
{
- target_zoom = gAgent.mHUDTargetZoom;
- current_zoom = gAgent.mHUDCurZoom;
+ target_zoom = gAgentCamera.mHUDTargetZoom;
+ current_zoom = gAgentCamera.mHUDCurZoom;
}
void LLSelectMgr::setAgentHUDZoom(F32 target_zoom, F32 current_zoom)
{
- gAgent.mHUDTargetZoom = target_zoom;
- gAgent.mHUDCurZoom = current_zoom;
+ gAgentCamera.mHUDTargetZoom = target_zoom;
+ gAgentCamera.mHUDCurZoom = current_zoom;
}
/////////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp
index cd4a821774..9a37af4916 100644
--- a/indra/newview/llsidepanelappearance.cpp
+++ b/indra/newview/llsidepanelappearance.cpp
@@ -34,6 +34,7 @@
#include "llaccordionctrltab.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llagentwearables.h"
#include "llappearancemgr.h"
#include "llinventorypanel.h"
@@ -234,7 +235,7 @@ void LLSidepanelAppearance::onEditAppearanceButtonClicked()
{
if (gAgentWearables.areWearablesLoaded())
{
- gAgent.changeCameraToCustomizeAvatar();
+ gAgentCamera.changeCameraToCustomizeAvatar();
}
}
@@ -297,6 +298,7 @@ void LLSidepanelAppearance::toggleWearableEditPanel(BOOL visible, LLWearable *we
}
mEditWearable->setVisible(visible);
+ mEditWearable->setWearable(wearable);
mFilterEditor->setVisible(!visible);
mPanelOutfitsInventory->setVisible(!visible);
}
@@ -364,11 +366,11 @@ void LLSidepanelAppearance::fetchInventory()
}
}
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- if( avatar )
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if(avatarp)
{
- for (LLVOAvatar::attachment_map_t::const_iterator iter = avatar->mAttachmentPoints.begin();
- iter != avatar->mAttachmentPoints.end(); ++iter)
+ for (LLVOAvatar::attachment_map_t::const_iterator iter = avatarp->mAttachmentPoints.begin();
+ iter != avatarp->mAttachmentPoints.end(); ++iter)
{
LLViewerJointAttachment* attachment = iter->second;
if (!attachment) continue;
diff --git a/indra/newview/llsidetray.cpp b/indra/newview/llsidetray.cpp
index fba1503b4a..3ec1855484 100644
--- a/indra/newview/llsidetray.cpp
+++ b/indra/newview/llsidetray.cpp
@@ -34,7 +34,7 @@
#include "lltextbox.h"
-#include "llagent.h"
+#include "llagentcamera.h"
#include "llbottomtray.h"
#include "llsidetray.h"
#include "llviewerwindow.h"
@@ -730,7 +730,7 @@ void LLSideTray::updateSidetrayVisibility()
// set visibility of parent container based on collapsed state
if (getParent())
{
- getParent()->setVisible(!mCollapsed && !gAgent.cameraMouselook());
+ getParent()->setVisible(!mCollapsed && !gAgentCamera.cameraMouselook());
}
}
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index d4d6a74f0c..59d118abe2 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -88,6 +88,7 @@
#include "v3math.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llagentpicksinfo.h"
#include "llagentwearables.h"
#include "llagentpilot.h"
@@ -937,6 +938,9 @@ bool idle_startup()
// Load Avatars icons cache
LLAvatarIconIDCache::getInstance()->load();
+
+ // Load media plugin cookies
+ LLViewerMedia::loadCookieFile();
//-------------------------------------------------
// Handle startup progress screen
@@ -1134,6 +1138,7 @@ bool idle_startup()
// Finish agent initialization. (Requires gSavedSettings, builds camera)
gAgent.init();
+ gAgentCamera.init();
set_underclothes_menu_options();
// Since we connected, save off the settings so the user doesn't have to
@@ -1172,7 +1177,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
@@ -1336,8 +1341,8 @@ bool idle_startup()
gAgent.setPositionAgent(agent_start_position_region);
gAgent.resetAxes(gAgentStartLookAt);
- gAgent.stopCameraAnimation();
- gAgent.resetCamera();
+ gAgentCamera.stopCameraAnimation();
+ gAgentCamera.resetCamera();
// Initialize global class data needed for surfaces (i.e. textures)
if (!gNoRender)
@@ -1810,15 +1815,15 @@ bool idle_startup()
if (samename)
{
// restore old camera pos
- gAgent.setFocusOnAvatar(FALSE, FALSE);
- gAgent.setCameraPosAndFocusGlobal(gSavedSettings.getVector3d("CameraPosOnLogout"), gSavedSettings.getVector3d("FocusPosOnLogout"), LLUUID::null);
+ gAgentCamera.setFocusOnAvatar(FALSE, FALSE);
+ gAgentCamera.setCameraPosAndFocusGlobal(gSavedSettings.getVector3d("CameraPosOnLogout"), gSavedSettings.getVector3d("FocusPosOnLogout"), LLUUID::null);
BOOL limit_hit = FALSE;
- gAgent.calcCameraPositionTargetGlobal(&limit_hit);
+ gAgentCamera.calcCameraPositionTargetGlobal(&limit_hit);
if (limit_hit)
{
- gAgent.setFocusOnAvatar(TRUE, FALSE);
+ gAgentCamera.setFocusOnAvatar(TRUE, FALSE);
}
- gAgent.stopCameraAnimation();
+ gAgentCamera.stopCameraAnimation();
}
}
else
@@ -2719,6 +2724,8 @@ void LLStartUp::postStartupState()
void reset_login()
{
+ gAgentWearables.cleanup();
+ gAgentCamera.cleanup();
gAgent.cleanup();
LLWorld::getInstance()->destroyClass();
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index 9206b4a43a..3052134d4f 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -36,6 +36,7 @@
// viewer includes
#include "llagent.h"
+#include "llagentcamera.h"
#include "llbutton.h"
#include "llcommandhandler.h"
#include "llviewercontrol.h"
@@ -313,7 +314,7 @@ void LLStatusBar::refresh()
childSetVisible("scriptout", false);
}
- if (gAgent.getCameraMode() == CAMERA_MODE_MOUSELOOK &&
+ if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK &&
((region && region->getAllowDamage()) || (parcel && parcel->getAllowDamage())))
{
// set visibility based on flashing
diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp
index 1d479bac8c..ddb5d08e07 100644
--- a/indra/newview/llsurface.cpp
+++ b/indra/newview/llsurface.cpp
@@ -44,6 +44,7 @@
#include "llviewerobjectlist.h"
#include "llregionhandle.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llappviewer.h"
#include "llworld.h"
#include "llviewercontrol.h"
@@ -606,7 +607,7 @@ void LLSurface::moveZ(const S32 x, const S32 y, const F32 delta)
void LLSurface::updatePatchVisibilities(LLAgent &agent)
{
- LLVector3 pos_region = mRegionp->getPosRegionFromGlobal(gAgent.getCameraPositionGlobal());
+ LLVector3 pos_region = mRegionp->getPosRegionFromGlobal(gAgentCamera.getCameraPositionGlobal());
LLSurfacePatch *patchp;
diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp
index 386b636367..21c928282a 100644
--- a/indra/newview/lltexlayer.cpp
+++ b/indra/newview/lltexlayer.cpp
@@ -409,12 +409,12 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid,
{
LLBakedUploadData* baked_upload_data = (LLBakedUploadData*)userdata;
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
if (0 == result &&
- avatar &&
- !avatar->isDead() &&
- baked_upload_data->mAvatar == avatar && // Sanity check: only the user's avatar should be uploading textures.
+ avatarp &&
+ !avatarp->isDead() &&
+ baked_upload_data->mAvatar == avatarp && // Sanity check: only the user's avatar should be uploading textures.
baked_upload_data->mTexLayerSet->hasComposite()
)
{
@@ -439,11 +439,11 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid,
if (result >= 0)
{
- LLVOAvatarDefines::ETextureIndex baked_te = avatar->getBakedTE(layerset_buffer->mTexLayerSet);
+ LLVOAvatarDefines::ETextureIndex baked_te = avatarp->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;
- avatar->setNewBakedTexture(baked_te, uuid);
+ avatarp->setNewBakedTexture(baked_te, uuid);
}
else
{
@@ -457,7 +457,7 @@ void LLTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid,
llinfos << "Received baked texture out of date, ignored." << llendl;
}
- avatar->dirtyMesh();
+ avatarp->dirtyMesh();
}
else
{
diff --git a/indra/newview/lltexlayerparams.cpp b/indra/newview/lltexlayerparams.cpp
index d55468841d..5e5d344461 100644
--- a/indra/newview/lltexlayerparams.cpp
+++ b/indra/newview/lltexlayerparams.cpp
@@ -33,7 +33,7 @@
#include "lltexlayerparams.h"
-#include "llagent.h"
+#include "llagentcamera.h"
#include "llimagetga.h"
#include "lltexlayer.h"
#include "llvoavatarself.h"
@@ -180,7 +180,7 @@ void LLTexLayerParamAlpha::setWeight(F32 weight, BOOL upload_bake)
if ((mAvatar->getSex() & getSex()) && (mAvatar->isSelf() && !mIsDummy)) // only trigger a baked texture update if we're changing a wearable's visual param.
{
- if (gAgent.cameraCustomizeAvatar())
+ if (gAgentCamera.cameraCustomizeAvatar())
{
upload_bake = FALSE;
}
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 1c7b3a0fe0..2ea6e5936d 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -292,7 +292,10 @@ public:
const LLChannelDescriptors& channels,
const LLIOPipe::buffer_ptr_t& buffer)
{
- if ((gSavedSettings.getBOOL("LogTextureDownloadsToViewerLog")) || (gSavedSettings.getBOOL("LogTextureDownloadsToSimulator")))
+ static LLCachedControl<bool> log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog");
+ static LLCachedControl<bool> log_to_sim(gSavedSettings,"LogTextureDownloadsToSimulator");
+
+ if (log_to_viewer_log || log_to_sim)
{
mFetcher->mTextureInfo.setRequestStartTime(mID, mStartTime);
U64 timeNow = LLTimer::getTotalTime();
@@ -715,10 +718,10 @@ bool LLTextureFetchWorker::doWork(S32 param)
if (mState == LOAD_FROM_NETWORK)
{
- bool get_url = gSavedSettings.getBOOL("ImagePipelineUseHTTP");
- if (!mUrl.empty()) get_url = false;
+ static LLCachedControl<bool> use_http(gSavedSettings,"ImagePipelineUseHTTP");
+
// if (mHost != LLHost::invalid) get_url = false;
- if ( get_url )
+ if ( use_http && mUrl.empty())//get http url.
{
LLViewerRegion* region = NULL;
if (mHost == LLHost::invalid)
@@ -1717,7 +1720,8 @@ S32 LLTextureFetch::update(U32 max_time_ms)
{
S32 res;
- mMaxBandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS");
+ static LLCachedControl<F32> band_width(gSavedSettings,"ThrottleBandwidthKBPS");
+ mMaxBandwidth = band_width ;
res = LLWorkerThread::update(max_time_ms);
@@ -1923,7 +1927,9 @@ void LLTextureFetch::sendRequestListToSimulators()
// llinfos << "IMAGE REQUEST: " << req->mID << " Discard: " << req->mDesiredDiscard
// << " Packet: " << packet << " Priority: " << req->mImagePriority << llendl;
- if ((gSavedSettings.getBOOL("LogTextureDownloadsToViewerLog")) || (gSavedSettings.getBOOL("LogTextureDownloadsToSimulator")))
+ static LLCachedControl<bool> log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog");
+ static LLCachedControl<bool> log_to_sim(gSavedSettings,"LogTextureDownloadsToSimulator");
+ if (log_to_viewer_log || log_to_sim)
{
mTextureInfo.setRequestStartTime(req->mID, LLTimer::getTotalTime());
mTextureInfo.setRequestOffset(req->mID, 0);
@@ -2144,7 +2150,10 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U1
if(packet_num >= (worker->mTotalPackets - 1))
{
- if ((gSavedSettings.getBOOL("LogTextureDownloadsToViewerLog")) || (gSavedSettings.getBOOL("LogTextureDownloadsToSimulator")))
+ static LLCachedControl<bool> log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog");
+ static LLCachedControl<bool> log_to_sim(gSavedSettings,"LogTextureDownloadsToSimulator");
+
+ if (log_to_viewer_log || log_to_sim)
{
U64 timeNow = LLTimer::getTotalTime();
mTextureInfo.setRequestSize(id, worker->mFileSize);
diff --git a/indra/newview/lltoolcomp.cpp b/indra/newview/lltoolcomp.cpp
index fff18df442..d05bfc53e5 100644
--- a/indra/newview/lltoolcomp.cpp
+++ b/indra/newview/lltoolcomp.cpp
@@ -54,6 +54,7 @@
#include "llviewerobject.h"
#include "llviewerwindow.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llfloatertools.h"
#include "llviewercontrol.h"
@@ -784,7 +785,7 @@ BOOL LLToolCompGun::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
if (clicks > 0)
{
- gAgent.changeCameraToDefault();
+ gAgentCamera.changeCameraToDefault();
}
return TRUE;
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index 47e60a966e..813b3bd22f 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -37,6 +37,7 @@
#include "llnotificationsutil.h"
// project headers
#include "llagent.h"
+#include "llagentcamera.h"
#include "llagentui.h"
#include "llagentwearables.h"
#include "llappearancemgr.h"
@@ -959,7 +960,7 @@ void LLToolDragAndDrop::pick(const LLPickInfo& pick_info)
gViewerWindow->getWindow()->setCursor( cursor );
mLastHitPos = pick_info.mPosGlobal;
- mLastCameraPos = gAgent.getCameraPositionGlobal();
+ mLastCameraPos = gAgentCamera.getCameraPositionGlobal();
}
// static
@@ -2012,8 +2013,8 @@ EAcceptance LLToolDragAndDrop::dad3dRezAttachmentFromInv(
}
// must not be already wearing it
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- if( !avatar || avatar->isWearingAttachment(item->getUUID()) )
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if(!avatarp || avatarp->isWearingAttachment(item->getUUID()) )
{
return ACCEPT_NO;
}
@@ -2626,13 +2627,13 @@ EAcceptance LLToolDragAndDrop::dad3dGiveInventoryObject(
// cannot give away no-transfer objects
return ACCEPT_NO;
}
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- if(avatar && avatar->isWearingAttachment( item->getUUID() ) )
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if(avatarp && avatarp->isWearingAttachment( item->getUUID() ) )
{
// You can't give objects that are attached to you
return ACCEPT_NO;
}
- if( obj && avatar )
+ if(obj && avatarp)
{
if(drop)
{
diff --git a/indra/newview/lltoolfocus.cpp b/indra/newview/lltoolfocus.cpp
index 2320ae57df..1e2e7095d8 100644
--- a/indra/newview/lltoolfocus.cpp
+++ b/indra/newview/lltoolfocus.cpp
@@ -42,6 +42,7 @@
// Viewer includes
#include "llagent.h"
+#include "llagentcamera.h"
#include "llbutton.h"
#include "llviewercontrol.h"
#include "lldrawable.h"
@@ -167,7 +168,7 @@ void LLToolCamera::pickCallback(const LLPickInfo& pick_info)
}
}
- if( CAMERA_MODE_CUSTOMIZE_AVATAR == gAgent.getCameraMode() )
+ if( CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode() )
{
BOOL good_customize_avatar_hit = FALSE;
if( hit_obj )
@@ -207,19 +208,19 @@ void LLToolCamera::pickCallback(const LLPickInfo& pick_info)
// ...clicked on a world object, so focus at its position
if (!hit_obj->isHUDAttachment())
{
- gAgent.setFocusOnAvatar(FALSE, ANIMATE);
- gAgent.setFocusGlobal(pick_info);
+ gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE);
+ gAgentCamera.setFocusGlobal(pick_info);
}
}
else if (!pick_info.mPosGlobal.isExactlyZero())
{
// Hit the ground
- gAgent.setFocusOnAvatar(FALSE, ANIMATE);
- gAgent.setFocusGlobal(pick_info);
+ gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE);
+ gAgentCamera.setFocusGlobal(pick_info);
}
if (!(pick_info.mKeyMask & MASK_ALT) &&
- gAgent.cameraThirdPerson() &&
+ gAgentCamera.cameraThirdPerson() &&
gViewerWindow->getLeftMouseDown() &&
!gSavedSettings.getBOOL("FreezeTime") &&
(hit_obj == gAgent.getAvatarObject() ||
@@ -232,14 +233,14 @@ void LLToolCamera::pickCallback(const LLPickInfo& pick_info)
LLToolCamera::getInstance()->mValidClickPoint = TRUE;
- if( CAMERA_MODE_CUSTOMIZE_AVATAR == gAgent.getCameraMode() )
+ if( CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode() )
{
- gAgent.setFocusOnAvatar(FALSE, FALSE);
+ gAgentCamera.setFocusOnAvatar(FALSE, FALSE);
- LLVector3d cam_pos = gAgent.getCameraPositionGlobal();
- cam_pos -= LLVector3d(LLViewerCamera::getInstance()->getLeftAxis() * gAgent.calcCustomizeAvatarUIOffset( cam_pos ));
+ LLVector3d cam_pos = gAgentCamera.getCameraPositionGlobal();
+ cam_pos -= LLVector3d(LLViewerCamera::getInstance()->getLeftAxis() * gAgentCamera.calcCustomizeAvatarUIOffset( cam_pos ));
- gAgent.setCameraPosAndFocusGlobal( cam_pos, pick_info.mPosGlobal, pick_info.mObjectID);
+ gAgentCamera.setCameraPosAndFocusGlobal( cam_pos, pick_info.mPosGlobal, pick_info.mObjectID);
}
}
@@ -280,10 +281,10 @@ BOOL LLToolCamera::handleMouseUp(S32 x, S32 y, MASK mask)
{
if (mValidClickPoint)
{
- if( CAMERA_MODE_CUSTOMIZE_AVATAR == gAgent.getCameraMode() )
+ if( CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode() )
{
LLCoordGL mouse_pos;
- LLVector3 focus_pos = gAgent.getPosAgentFromGlobal(gAgent.getFocusGlobal());
+ LLVector3 focus_pos = gAgent.getPosAgentFromGlobal(gAgentCamera.getFocusGlobal());
BOOL success = LLViewerCamera::getInstance()->projectPosAgentToScreen(focus_pos, mouse_pos);
if (success)
{
@@ -369,12 +370,12 @@ BOOL LLToolCamera::handleHover(S32 x, S32 y, MASK mask)
if (dx != 0)
{
- gAgent.cameraOrbitAround( -dx * RADIANS_PER_PIXEL );
+ gAgentCamera.cameraOrbitAround( -dx * RADIANS_PER_PIXEL );
}
if (dy != 0)
{
- gAgent.cameraOrbitOver( -dy * RADIANS_PER_PIXEL );
+ gAgentCamera.cameraOrbitOver( -dy * RADIANS_PER_PIXEL );
}
gViewerWindow->moveCursorToCenter();
@@ -388,8 +389,8 @@ BOOL LLToolCamera::handleHover(S32 x, S32 y, MASK mask)
// Pan tool
if (hasMouseCapture())
{
- LLVector3d camera_to_focus = gAgent.getCameraPositionGlobal();
- camera_to_focus -= gAgent.getFocusGlobal();
+ LLVector3d camera_to_focus = gAgentCamera.getCameraPositionGlobal();
+ camera_to_focus -= gAgentCamera.getFocusGlobal();
F32 dist = (F32) camera_to_focus.normVec();
// Fudge factor for pan
@@ -397,12 +398,12 @@ BOOL LLToolCamera::handleHover(S32 x, S32 y, MASK mask)
if (dx != 0)
{
- gAgent.cameraPanLeft( dx * meters_per_pixel );
+ gAgentCamera.cameraPanLeft( dx * meters_per_pixel );
}
if (dy != 0)
{
- gAgent.cameraPanUp( -dy * meters_per_pixel );
+ gAgentCamera.cameraPanUp( -dy * meters_per_pixel );
}
gViewerWindow->moveCursorToCenter();
@@ -419,7 +420,7 @@ BOOL LLToolCamera::handleHover(S32 x, S32 y, MASK mask)
if (dx != 0)
{
- gAgent.cameraOrbitAround( -dx * RADIANS_PER_PIXEL );
+ gAgentCamera.cameraOrbitAround( -dx * RADIANS_PER_PIXEL );
}
const F32 IN_FACTOR = 0.99f;
@@ -428,11 +429,11 @@ BOOL LLToolCamera::handleHover(S32 x, S32 y, MASK mask)
{
if (mMouseSteering)
{
- gAgent.cameraOrbitOver( -dy * RADIANS_PER_PIXEL );
+ gAgentCamera.cameraOrbitOver( -dy * RADIANS_PER_PIXEL );
}
else
{
- gAgent.cameraZoomIn( pow( IN_FACTOR, dy ) );
+ gAgentCamera.cameraZoomIn( pow( IN_FACTOR, dy ) );
}
}
diff --git a/indra/newview/lltoolgrab.cpp b/indra/newview/lltoolgrab.cpp
index d837a334f1..008cf16f2e 100644
--- a/indra/newview/lltoolgrab.cpp
+++ b/indra/newview/lltoolgrab.cpp
@@ -46,6 +46,7 @@
// newview headers
#include "llagent.h"
+#include "llagentcamera.h"
#include "lldrawable.h"
#include "llfloatertools.h"
#include "llhudeffect.h"
@@ -225,7 +226,7 @@ BOOL LLToolGrab::handleObjectHit(const LLPickInfo& info)
// non-touchable objects. If it has a touch handler, we
// do grab it (so llDetectedGrab works), but movement is
// blocked on the server side. JC
- if (gAgent.cameraMouselook())
+ if (gAgentCamera.cameraMouselook())
{
mMode = GRAB_LOCKED;
}
@@ -285,8 +286,8 @@ BOOL LLToolGrab::handleObjectHit(const LLPickInfo& info)
LLVector3 local_edit_point = gAgent.getPosAgentFromGlobal(info.mPosGlobal);
local_edit_point -= edit_object->getPositionAgent();
local_edit_point = local_edit_point * ~edit_object->getRenderRotation();
- gAgent.setPointAt(POINTAT_TARGET_GRAB, edit_object, local_edit_point );
- gAgent.setLookAt(LOOKAT_TARGET_SELECT, edit_object, local_edit_point );
+ gAgentCamera.setPointAt(POINTAT_TARGET_GRAB, edit_object, local_edit_point );
+ gAgentCamera.setLookAt(LOOKAT_TARGET_SELECT, edit_object, local_edit_point );
}
// on transient grabs (clicks on world objects), kill the grab immediately
@@ -390,7 +391,7 @@ void LLToolGrab::startGrab()
// This planar drag starts at the grab point
mDragStartPointGlobal = grab_start_global;
- mDragStartFromCamera = grab_start_global - gAgent.getCameraPositionGlobal();
+ mDragStartFromCamera = grab_start_global - gAgentCamera.getCameraPositionGlobal();
LLMessageSystem *msg = gMessageSystem;
msg->newMessageFast(_PREHASH_ObjectGrab);
@@ -502,7 +503,7 @@ void LLToolGrab::handleHoverActive(S32 x, S32 y, MASK mask)
mVerticalDragging = FALSE;
mDragStartPointGlobal = gViewerWindow->clickPointInWorldGlobal(x, y, objectp);
- mDragStartFromCamera = mDragStartPointGlobal - gAgent.getCameraPositionGlobal();
+ mDragStartFromCamera = mDragStartPointGlobal - gAgentCamera.getCameraPositionGlobal();
}
else if (!mVerticalDragging && (mask == MASK_VERTICAL) )
{
@@ -510,7 +511,7 @@ void LLToolGrab::handleHoverActive(S32 x, S32 y, MASK mask)
mVerticalDragging = TRUE;
mDragStartPointGlobal = gViewerWindow->clickPointInWorldGlobal(x, y, objectp);
- mDragStartFromCamera = mDragStartPointGlobal - gAgent.getCameraPositionGlobal();
+ mDragStartFromCamera = mDragStartPointGlobal - gAgentCamera.getCameraPositionGlobal();
}
const F32 RADIANS_PER_PIXEL_X = 0.01f;
@@ -598,7 +599,7 @@ void LLToolGrab::handleHoverActive(S32 x, S32 y, MASK mask)
// need to return offset from mGrabStartPoint
LLVector3d grab_point_global;
- grab_point_global = gAgent.getCameraPositionGlobal() + mGrabHiddenOffsetFromCamera;
+ grab_point_global = gAgentCamera.getCameraPositionGlobal() + mGrabHiddenOffsetFromCamera;
/* Snap to grid disabled for grab tool - very confusing
// Handle snapping to grid, but only when the tool is formally selected.
@@ -632,7 +633,7 @@ void LLToolGrab::handleHoverActive(S32 x, S32 y, MASK mask)
grab_point_global = LLWorld::getInstance()->clipToVisibleRegions(mDragStartPointGlobal, grab_point_global);
// propagate constrained grab point back to grab offset
- mGrabHiddenOffsetFromCamera = grab_point_global - gAgent.getCameraPositionGlobal();
+ mGrabHiddenOffsetFromCamera = grab_point_global - gAgentCamera.getCameraPositionGlobal();
// Handle auto-rotation at screen edge.
LLVector3 grab_pos_agent = gAgent.getPosAgentFromGlobal( grab_point_global );
@@ -646,24 +647,24 @@ void LLToolGrab::handleHoverActive(S32 x, S32 y, MASK mask)
// ...build mode moves camera about focus point
if (grab_center_gl.mX < ROTATE_H_MARGIN)
{
- if (gAgent.getFocusOnAvatar())
+ if (gAgentCamera.getFocusOnAvatar())
{
gAgent.yaw(rotate_angle);
}
else
{
- gAgent.cameraOrbitAround(rotate_angle);
+ gAgentCamera.cameraOrbitAround(rotate_angle);
}
}
else if (grab_center_gl.mX > gViewerWindow->getWorldViewWidthScaled() - ROTATE_H_MARGIN)
{
- if (gAgent.getFocusOnAvatar())
+ if (gAgentCamera.getFocusOnAvatar())
{
gAgent.yaw(-rotate_angle);
}
else
{
- gAgent.cameraOrbitAround(-rotate_angle);
+ gAgentCamera.cameraOrbitAround(-rotate_angle);
}
}
@@ -705,17 +706,17 @@ void LLToolGrab::handleHoverActive(S32 x, S32 y, MASK mask)
// once we've initiated a drag, lock the camera down
if (mHasMoved)
{
- if (!gAgent.cameraMouselook() &&
+ if (!gAgentCamera.cameraMouselook() &&
!objectp->isHUDAttachment() &&
objectp->getRoot() == gAgent.getAvatarObject()->getRoot())
{
// force focus to point in space where we were looking previously
- gAgent.setFocusGlobal(gAgent.calcFocusPositionTargetGlobal(), LLUUID::null);
- gAgent.setFocusOnAvatar(FALSE, ANIMATE);
+ gAgentCamera.setFocusGlobal(gAgentCamera.calcFocusPositionTargetGlobal(), LLUUID::null);
+ gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE);
}
else
{
- gAgent.clearFocusObject();
+ gAgentCamera.clearFocusObject();
}
}
@@ -814,7 +815,7 @@ void LLToolGrab::handleHoverNonPhysical(S32 x, S32 y, MASK mask)
}
// need to return offset from mGrabStartPoint
- LLVector3d grab_point_global = gAgent.getCameraPositionGlobal() + mGrabHiddenOffsetFromCamera;
+ LLVector3d grab_point_global = gAgentCamera.getCameraPositionGlobal() + mGrabHiddenOffsetFromCamera;
grab_pos_region = objectp->getRegion()->getPosRegionFromGlobal( grab_point_global );
}
@@ -872,8 +873,8 @@ void LLToolGrab::handleHoverNonPhysical(S32 x, S32 y, MASK mask)
LLVector3 local_edit_point = pick.mIntersection;
local_edit_point -= objectp->getPositionAgent();
local_edit_point = local_edit_point * ~objectp->getRenderRotation();
- gAgent.setPointAt(POINTAT_TARGET_GRAB, objectp, local_edit_point );
- gAgent.setLookAt(LOOKAT_TARGET_SELECT, objectp, local_edit_point );
+ gAgentCamera.setPointAt(POINTAT_TARGET_GRAB, objectp, local_edit_point );
+ gAgentCamera.setLookAt(LOOKAT_TARGET_SELECT, objectp, local_edit_point );
}
@@ -892,7 +893,7 @@ void LLToolGrab::handleHoverInactive(S32 x, S32 y, MASK mask)
// Only works in fullscreen
if (gSavedSettings.getBOOL("WindowFullScreen"))
{
- if (gAgent.cameraThirdPerson() )
+ if (gAgentCamera.cameraThirdPerson() )
{
if (x == 0)
{
@@ -994,7 +995,7 @@ void LLToolGrab::onMouseCaptureLost()
return;
}
// First, fix cursor placement
- if( !gAgent.cameraMouselook()
+ if( !gAgentCamera.cameraMouselook()
&& (GRAB_ACTIVE_CENTER == mMode))
{
if (objectp->isHUDAttachment())
@@ -1035,8 +1036,8 @@ void LLToolGrab::onMouseCaptureLost()
mGrabPick.mObjectID.setNull();
LLSelectMgr::getInstance()->updateSelectionCenter();
- gAgent.setPointAt(POINTAT_TARGET_CLEAR);
- gAgent.setLookAt(LOOKAT_TARGET_CLEAR);
+ gAgentCamera.setPointAt(POINTAT_TARGET_CLEAR);
+ gAgentCamera.setLookAt(LOOKAT_TARGET_CLEAR);
dialog_refresh_all();
}
@@ -1128,7 +1129,7 @@ LLVector3d LLToolGrab::getGrabPointGlobal()
case GRAB_ACTIVE_CENTER:
case GRAB_NONPHYSICAL:
case GRAB_LOCKED:
- return gAgent.getCameraPositionGlobal() + mGrabHiddenOffsetFromCamera;
+ return gAgentCamera.getCameraPositionGlobal() + mGrabHiddenOffsetFromCamera;
case GRAB_NOOBJECT:
case GRAB_INACTIVE:
diff --git a/indra/newview/lltoolgun.cpp b/indra/newview/lltoolgun.cpp
index a441d653c7..c815f1e96a 100644
--- a/indra/newview/lltoolgun.cpp
+++ b/indra/newview/lltoolgun.cpp
@@ -36,6 +36,7 @@
#include "llviewerwindow.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llviewercontrol.h"
#include "llsky.h"
#include "llappviewer.h"
@@ -83,7 +84,7 @@ BOOL LLToolGun::handleMouseDown(S32 x, S32 y, MASK mask)
BOOL LLToolGun::handleHover(S32 x, S32 y, MASK mask)
{
- if( gAgent.cameraMouselook() && mIsSelected )
+ if( gAgentCamera.cameraMouselook() && mIsSelected )
{
const F32 NOMINAL_MOUSE_SENSITIVITY = 0.0025f;
diff --git a/indra/newview/lltoolmgr.cpp b/indra/newview/lltoolmgr.cpp
index fd12163fd3..a8696c22ef 100644
--- a/indra/newview/lltoolmgr.cpp
+++ b/indra/newview/lltoolmgr.cpp
@@ -56,6 +56,7 @@
#include "lltoolobjpicker.h"
#include "lltoolpipette.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llviewercontrol.h"
#include "llviewerjoystick.h"
#include "llviewermenu.h"
@@ -262,7 +263,7 @@ void LLToolMgr::toggleBuildMode()
else
{
// manually disable edit mode, but do not affect the camera
- gAgent.resetView(false);
+ gAgentCamera.resetView(false);
LLFloaterReg::hideInstance("build");
gViewerWindow->showCursor();
}
@@ -271,7 +272,7 @@ void LLToolMgr::toggleBuildMode()
}
else
{
- ECameraMode camMode = gAgent.getCameraMode();
+ ECameraMode camMode = gAgentCamera.getCameraMode();
if (CAMERA_MODE_MOUSELOOK == camMode || CAMERA_MODE_CUSTOMIZE_AVATAR == camMode)
{
// pull the user out of mouselook or appearance mode when entering build mode
@@ -286,13 +287,13 @@ void LLToolMgr::toggleBuildMode()
handle_toggle_flycam();
}
- if (gAgent.getFocusOnAvatar())
+ if (gAgentCamera.getFocusOnAvatar())
{
// zoom in if we're looking at the avatar
- gAgent.setFocusOnAvatar(FALSE, ANIMATE);
- gAgent.setFocusGlobal(gAgent.getPositionGlobal() + 2.0 * LLVector3d(gAgent.getAtAxis()));
- gAgent.cameraZoomIn(0.666f);
- gAgent.cameraOrbitOver( 30.f * DEG_TO_RAD );
+ gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE);
+ gAgentCamera.setFocusGlobal(gAgent.getPositionGlobal() + 2.0 * LLVector3d(gAgent.getAtAxis()));
+ gAgentCamera.cameraZoomIn(0.666f);
+ gAgentCamera.cameraOrbitOver( 30.f * DEG_TO_RAD );
}
}
@@ -303,7 +304,7 @@ void LLToolMgr::toggleBuildMode()
// Could be first use
//LLFirstUse::useBuild();
- gAgent.resetView(false);
+ gAgentCamera.resetView(false);
// avoid spurious avatar movements
LLViewerJoystick::getInstance()->setNeedsReset();
@@ -317,7 +318,7 @@ bool LLToolMgr::inBuildMode()
// cameraMouselook() actually starts returning true. Also, appearance edit
// sets build mode to true, so let's exclude that.
bool b=(inEdit()
- && !gAgent.cameraMouselook()
+ && !gAgentCamera.cameraMouselook()
&& mCurrentToolset != gFaceEditToolset);
return b;
diff --git a/indra/newview/lltoolmorph.cpp b/indra/newview/lltoolmorph.cpp
index 5f825b461e..c42c47c486 100644
--- a/indra/newview/lltoolmorph.cpp
+++ b/indra/newview/lltoolmorph.cpp
@@ -165,7 +165,7 @@ void LLVisualParamHint::preRender(BOOL clear_depth)
BOOL LLVisualParamHint::render()
{
LLVisualParamReset::sDirty = TRUE;
- LLVOAvatar* avatarp = gAgent.getAvatarObject();
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
gGL.pushUIMatrix();
gGL.loadUIIdentity();
diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp
index d15db536e6..b7947cf4ae 100644
--- a/indra/newview/lltoolpie.cpp
+++ b/indra/newview/lltoolpie.cpp
@@ -39,6 +39,7 @@
#include "llparcel.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llviewercontrol.h"
#include "llfocusmgr.h"
//#include "llfirstuse.h"
@@ -263,7 +264,7 @@ BOOL LLToolPie::pickLeftMouseDownCallback()
if (object)
{
- gAgent.setFocusOnAvatar(FALSE, ANIMATE);
+ gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE);
LLBBox bbox = object->getBoundingBoxAgent() ;
F32 angle_of_view = llmax(0.1f, LLViewerCamera::getInstance()->getAspect() > 1.f ? LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect() : LLViewerCamera::getInstance()->getView());
@@ -273,7 +274,7 @@ BOOL LLToolPie::pickLeftMouseDownCallback()
obj_to_cam.normVec();
LLVector3d object_center_global = gAgent.getPosGlobalFromAgent(bbox.getCenterAgent());
- gAgent.setCameraPosAndFocusGlobal(object_center_global + LLVector3d(obj_to_cam * distance),
+ gAgentCamera.setCameraPosAndFocusGlobal(object_center_global + LLVector3d(obj_to_cam * distance),
object_center_global,
mPick.mObjectID );
}
@@ -336,7 +337,7 @@ BOOL LLToolPie::pickLeftMouseDownCallback()
gViewerWindow->hideCursor();
LLToolCamera::getInstance()->setMouseCapture(TRUE);
LLToolCamera::getInstance()->pickCallback(mPick);
- gAgent.setFocusOnAvatar(TRUE, TRUE);
+ gAgentCamera.setFocusOnAvatar(TRUE, TRUE);
return TRUE;
}
@@ -496,6 +497,8 @@ void LLToolPie::selectionPropertiesReceived()
BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask)
{
mHoverPick = gViewerWindow->pickImmediate(x, y, FALSE);
+ // perform a separate pick that detects transparent objects since they respond to 1-click actions
+ LLPickInfo click_action_pick = gViewerWindow->pickImmediate(x, y, TRUE);
// Show screen-space highlight glow effect
bool show_highlight = false;
@@ -507,10 +510,11 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask)
parent = object->getRootEdit();
}
- if (object && useClickAction(mask, object, parent))
+ LLViewerObject* click_action_object = click_action_pick.getObject();
+ if (click_action_object && useClickAction(mask, click_action_object, click_action_object->getRootEdit()))
{
show_highlight = true;
- ECursorType cursor = cursor_from_object(object);
+ ECursorType cursor = cursor_from_object(click_action_object);
gViewerWindow->setCursor(cursor);
lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl;
}
@@ -592,7 +596,7 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask)
mGrabMouseButtonDown = FALSE;
LLToolMgr::getInstance()->clearTransientTool();
- gAgent.setLookAt(LOOKAT_TARGET_CONVERSATION, obj); // maybe look at object/person clicked on
+ gAgentCamera.setLookAt(LOOKAT_TARGET_CONVERSATION, obj); // maybe look at object/person clicked on
return LLTool::handleMouseUp(x, y, mask);
}
diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp
index 612bcc03bd..b10ee590e0 100644
--- a/indra/newview/lltoolplacer.cpp
+++ b/indra/newview/lltoolplacer.cpp
@@ -56,6 +56,7 @@
#include "llvolumemessage.h"
#include "llhudmanager.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llaudioengine.h"
#include "llhudeffecttrail.h"
#include "llviewerobjectlist.h"
@@ -120,7 +121,7 @@ BOOL LLToolPlacer::raycastForNewObjPos( S32 x, S32 y, LLViewerObject** hit_obj,
}
// Make sure the surface isn't too far away.
- LLVector3d ray_start_global = gAgent.getCameraPositionGlobal();
+ LLVector3d ray_start_global = gAgentCamera.getCameraPositionGlobal();
F32 dist_to_surface_sq = (F32)((surface_pos_global - ray_start_global).magVecSquared());
if( dist_to_surface_sq > (max_dist_from_camera * max_dist_from_camera) )
{
diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp
index 97e2865179..6e0c6663e9 100644
--- a/indra/newview/lltoolselect.cpp
+++ b/indra/newview/lltoolselect.cpp
@@ -35,6 +35,7 @@
#include "lltoolselect.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llviewercontrol.h"
#include "lldrawable.h"
#include "llmanip.h"
@@ -167,7 +168,7 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi
LLSelectMgr::getInstance()->setAgentHUDZoom(target_zoom, current_zoom);
}
- if (!gAgent.getFocusOnAvatar() && // if camera not glued to avatar
+ 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
{
diff --git a/indra/newview/lltracker.cpp b/indra/newview/lltracker.cpp
index 407cc23d0d..9a69adae31 100644
--- a/indra/newview/lltracker.cpp
+++ b/indra/newview/lltracker.cpp
@@ -50,6 +50,7 @@
#include "llappviewer.h"
#include "lltracker.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llcallingcard.h"
#include "llfloaterworldmap.h"
#include "llhudtext.h"
@@ -480,14 +481,14 @@ void LLTracker::renderBeacon(LLVector3d pos_global,
const std::string& label )
{
sCheesyBeacon = gSavedSettings.getBOOL("CheesyBeacon");
- LLVector3d to_vec = pos_global - gAgent.getCameraPositionGlobal();
+ LLVector3d to_vec = pos_global - gAgentCamera.getCameraPositionGlobal();
F32 dist = (F32)to_vec.magVec();
F32 color_frac = 1.f;
if (dist > 0.99f * LLViewerCamera::getInstance()->getFar())
{
color_frac = 0.4f;
- // pos_global = gAgent.getCameraPositionGlobal() + 0.99f*(LLViewerCamera::getInstance()->getFar()/dist)*to_vec;
+ // pos_global = gAgentCamera.getCameraPositionGlobal() + 0.99f*(LLViewerCamera::getInstance()->getFar()/dist)*to_vec;
}
else
{
diff --git a/indra/newview/llurldispatcher.cpp b/indra/newview/llurldispatcher.cpp
index 0b6bd4b401..b88069cd48 100644
--- a/indra/newview/llurldispatcher.cpp
+++ b/indra/newview/llurldispatcher.cpp
@@ -180,6 +180,16 @@ bool LLURLDispatcherImpl::dispatchRegion(const std::string& url, bool right_mous
return false;
}
+ std::string sim_string = LLSLURL::stripProtocol(url);
+ std::string region_name;
+ S32 x = 128;
+ S32 y = 128;
+ S32 z = 0;
+ if (! LLURLSimString::parse(sim_string, &region_name, &x, &y, &z))
+ {
+ return false;
+ }
+
// Before we're logged in, need to update the startup screen
// to tell the user where they are going.
if (LLStartUp::getStartupState() < STATE_LOGIN_CLEANUP)
@@ -194,22 +204,15 @@ bool LLURLDispatcherImpl::dispatchRegion(const std::string& url, bool right_mous
return true;
}
- std::string sim_string = LLSLURL::stripProtocol(url);
- std::string region_name;
- S32 x = 128;
- S32 y = 128;
- S32 z = 0;
- LLURLSimString::parse(sim_string, &region_name, &x, &y, &z);
-
// LLFloaterURLDisplay functionality moved to LLPanelPlaces in Side Tray.
//LLFloaterURLDisplay* url_displayp = LLFloaterReg::getTypedInstance<LLFloaterURLDisplay>("preview_url",LLSD());
//if(url_displayp) url_displayp->setName(region_name);
// Request a region handle by name
LLWorldMapMessage::getInstance()->sendNamedRegionRequest(region_name,
- LLURLDispatcherImpl::regionNameCallback,
- url,
- false); // don't teleport
+ LLURLDispatcherImpl::regionNameCallback,
+ url,
+ false); // don't teleport
return true;
}
@@ -221,34 +224,11 @@ void LLURLDispatcherImpl::regionNameCallback(U64 region_handle, const std::strin
S32 x = 128;
S32 y = 128;
S32 z = 0;
- LLURLSimString::parse(sim_string, &region_name, &x, &y, &z);
-
- LLVector3 local_pos;
- local_pos.mV[VX] = (F32)x;
- local_pos.mV[VY] = (F32)y;
- local_pos.mV[VZ] = (F32)z;
-
- // determine whether the point is in this region
- if ((x >= 0) && (x < REGION_WIDTH_UNITS) &&
- (y >= 0) && (y < REGION_WIDTH_UNITS))
+ if (LLURLSimString::parse(sim_string, &region_name, &x, &y, &z))
{
- // if so, we're done
regionHandleCallback(region_handle, url, snapshot_id, teleport);
}
-
- else
- {
- // otherwise find the new region from the location
-
- // add the position to get the new region
- LLVector3d global_pos = from_region_handle(region_handle) + LLVector3d(local_pos);
-
- U64 new_region_handle = to_region_handle(global_pos);
- LLWorldMapMessage::getInstance()->sendHandleRegionRequest(new_region_handle,
- LLURLDispatcherImpl::regionHandleCallback,
- url, teleport);
- }
}
/* static */
@@ -261,17 +241,9 @@ void LLURLDispatcherImpl::regionHandleCallback(U64 region_handle, const std::str
S32 z = 0;
LLURLSimString::parse(sim_string, &region_name, &x, &y, &z);
- // remap x and y to local coordinates
- S32 local_x = x % REGION_WIDTH_UNITS;
- S32 local_y = y % REGION_WIDTH_UNITS;
- if (local_x < 0)
- local_x += REGION_WIDTH_UNITS;
- if (local_y < 0)
- local_y += REGION_WIDTH_UNITS;
-
LLVector3 local_pos;
- local_pos.mV[VX] = (F32)local_x;
- local_pos.mV[VY] = (F32)local_y;
+ local_pos.mV[VX] = (F32)x;
+ local_pos.mV[VY] = (F32)y;
local_pos.mV[VZ] = (F32)z;
LLVector3d global_pos = from_region_handle(region_handle);
diff --git a/indra/newview/llvieweraudio.cpp b/indra/newview/llvieweraudio.cpp
index 1d935f5ab8..2661c9f32b 100644
--- a/indra/newview/llvieweraudio.cpp
+++ b/indra/newview/llvieweraudio.cpp
@@ -34,6 +34,7 @@
#include "llaudioengine.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llappviewer.h"
#include "llvieweraudio.h"
#include "llviewercamera.h"
@@ -51,7 +52,7 @@ void init_audio()
llwarns << "Failed to create an appropriate Audio Engine" << llendl;
return;
}
- LLVector3d lpos_global = gAgent.getCameraPositionGlobal();
+ LLVector3d lpos_global = gAgentCamera.getCameraPositionGlobal();
LLVector3 lpos_global_f;
lpos_global_f.setVec(lpos_global);
@@ -180,7 +181,7 @@ void audio_update_listener()
if (gAudiop)
{
// update listener position because agent has moved
- LLVector3d lpos_global = gAgent.getCameraPositionGlobal();
+ LLVector3d lpos_global = gAgentCamera.getCameraPositionGlobal();
LLVector3 lpos_global_f;
lpos_global_f.setVec(lpos_global);
@@ -203,7 +204,7 @@ void audio_update_wind(bool force_update)
if (region)
{
static F32 last_camera_water_height = -1000.f;
- LLVector3 camera_pos = gAgent.getCameraPositionAgent();
+ LLVector3 camera_pos = gAgentCamera.getCameraPositionAgent();
F32 camera_water_height = camera_pos.mV[VZ] - region->getWaterHeight();
//
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 6c1c1d1096..5a2b901bd7 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -38,6 +38,7 @@
#include "llrender.h"
#include "llglheaders.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llviewercontrol.h"
#include "llcoord.h"
#include "llcriticaldamp.h"
@@ -174,8 +175,8 @@ void display_update_camera()
// Cut draw distance in half when customizing avatar,
// but on the viewer only.
- F32 final_far = gAgent.mDrawDistance;
- if (CAMERA_MODE_CUSTOMIZE_AVATAR == gAgent.getCameraMode())
+ F32 final_far = gAgentCamera.mDrawDistance;
+ if (CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode())
{
final_far *= 0.5f;
}
@@ -393,7 +394,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
gAgent.setTeleportMessage(
LLAgent::sTeleportProgressMessages["arriving"]);
gTextureList.mForceResetTextureStats = TRUE;
- gAgent.resetView(TRUE, TRUE);
+ gAgentCamera.resetView(TRUE, TRUE);
break;
case LLAgent::TELEPORT_ARRIVING:
@@ -920,9 +921,9 @@ void render_hud_attachments()
glh::matrix4f current_mod = glh_get_current_modelview();
// clamp target zoom level to reasonable values
- gAgent.mHUDTargetZoom = llclamp(gAgent.mHUDTargetZoom, 0.1f, 1.f);
+ gAgentCamera.mHUDTargetZoom = llclamp(gAgentCamera.mHUDTargetZoom, 0.1f, 1.f);
// smoothly interpolate current zoom level
- gAgent.mHUDCurZoom = lerp(gAgent.mHUDCurZoom, gAgent.mHUDTargetZoom, LLCriticalDamp::getInterpolant(0.03f));
+ gAgentCamera.mHUDCurZoom = lerp(gAgentCamera.mHUDCurZoom, gAgentCamera.mHUDTargetZoom, LLCriticalDamp::getInterpolant(0.03f));
if (LLPipeline::sShowHUDAttachments && !gDisconnected && setup_hud_matrices())
{
@@ -1034,7 +1035,7 @@ bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::mat
LLVOAvatar* my_avatarp = gAgent.getAvatarObject();
if (my_avatarp && my_avatarp->hasHUDAttachment())
{
- F32 zoom_level = gAgent.mHUDCurZoom;
+ F32 zoom_level = gAgentCamera.mHUDCurZoom;
LLBBox hud_bbox = my_avatarp->getHUDBBox();
F32 hud_depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f);
@@ -1299,14 +1300,14 @@ void render_ui_2d()
gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
// render outline for HUD
- if (gAgent.getAvatarObject() && gAgent.mHUDCurZoom < 0.98f)
+ if (gAgent.getAvatarObject() && gAgentCamera.mHUDCurZoom < 0.98f)
{
glPushMatrix();
S32 half_width = (gViewerWindow->getWorldViewWidthScaled() / 2);
S32 half_height = (gViewerWindow->getWorldViewHeightScaled() / 2);
glScalef(LLUI::sGLScaleFactor.mV[0], LLUI::sGLScaleFactor.mV[1], 1.f);
glTranslatef((F32)half_width, (F32)half_height, 0.f);
- F32 zoom = gAgent.mHUDCurZoom;
+ F32 zoom = gAgentCamera.mHUDCurZoom;
glScalef(zoom,zoom,1.f);
gGL.color4fv(LLColor4::white.mV);
gl_rect_2d(-half_width, half_height, half_width, -half_height, FALSE);
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index 80336e5c5a..7bf7bf5e2f 100644
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -39,6 +39,7 @@
#include "indra_constants.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llviewerfoldertype.h"
#include "llfolderview.h"
#include "llviewercontrol.h"
@@ -791,7 +792,7 @@ void WearOnAvatarCallback::fire(const LLUUID& inv_item)
void ModifiedCOFCallback::fire(const LLUUID& inv_item)
{
LLAppearanceManager::instance().updateAppearanceFromCOF();
- if( CAMERA_MODE_CUSTOMIZE_AVATAR == gAgent.getCameraMode() )
+ if( CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode() )
{
// If we're in appearance editing mode, the current tab may need to be refreshed
if (gFloaterCustomize)
diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp
index b593fbfb00..b758f6c701 100644
--- a/indra/newview/llviewerjoystick.cpp
+++ b/indra/newview/llviewerjoystick.cpp
@@ -43,6 +43,7 @@
#include "llselectmgr.h"
#include "llviewermenu.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llfocusmgr.h"
@@ -106,7 +107,7 @@ void LLViewerJoystick::setOverrideCamera(bool val)
if (mOverrideCamera)
{
- gAgent.changeCameraToDefault();
+ gAgentCamera.changeCameraToDefault();
}
}
@@ -432,7 +433,7 @@ void LLViewerJoystick::agentPitch(F32 pitch_inc)
void LLViewerJoystick::agentYaw(F32 yaw_inc)
{
// Cannot steer some vehicles in mouselook if the script grabs the controls
- if (gAgent.cameraMouselook() && !gSavedSettings.getBOOL("JoystickMouselookYaw"))
+ if (gAgentCamera.cameraMouselook() && !gSavedSettings.getBOOL("JoystickMouselookYaw"))
{
gAgent.rotate(-yaw_inc, gAgent.getReferenceUpVector());
}
@@ -1005,7 +1006,7 @@ bool LLViewerJoystick::toggleFlycam()
if (!mOverrideCamera)
{
- gAgent.changeCameraToDefault();
+ gAgentCamera.changeCameraToDefault();
}
if (gAwayTimer.getElapsedTimeF32() > MIN_AFK_TIME)
diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp
index f757155b94..cbec2c890f 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,22 +280,22 @@ F32 get_orbit_rate()
void camera_spin_around_ccw( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setOrbitLeftKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitLeftKey( get_orbit_rate() );
}
void camera_spin_around_cw( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setOrbitRightKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.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);
@@ -302,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() );
}
}
@@ -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);
@@ -318,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() );
}
}
@@ -326,22 +327,22 @@ void camera_spin_around_cw_sitting( EKeystate s )
void camera_spin_over( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setOrbitUpKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitUpKey( get_orbit_rate() );
}
void camera_spin_under( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setOrbitDownKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.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);
@@ -349,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() );
}
}
@@ -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);
@@ -365,35 +366,35 @@ 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() );
}
}
void camera_move_forward( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setOrbitInKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitInKey( get_orbit_rate() );
}
void camera_move_backward( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setOrbitOutKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.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);
}
else
{
- gAgent.setOrbitInKey( get_orbit_rate() );
+ gAgentCamera.setOrbitInKey( get_orbit_rate() );
}
}
@@ -402,70 +403,70 @@ 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);
}
else
{
- gAgent.setOrbitOutKey( get_orbit_rate() );
+ gAgentCamera.setOrbitOutKey( get_orbit_rate() );
}
}
void camera_pan_up( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setPanUpKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setPanUpKey( get_orbit_rate() );
}
void camera_pan_down( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setPanDownKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setPanDownKey( get_orbit_rate() );
}
void camera_pan_left( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setPanLeftKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setPanLeftKey( get_orbit_rate() );
}
void camera_pan_right( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setPanRightKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setPanRightKey( get_orbit_rate() );
}
void camera_pan_in( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setPanInKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setPanInKey( get_orbit_rate() );
}
void camera_pan_out( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setPanOutKey( get_orbit_rate() );
+ gAgentCamera.unlockView();
+ gAgentCamera.setPanOutKey( get_orbit_rate() );
}
void camera_move_forward_fast( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setOrbitInKey(2.5f);
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitInKey(2.5f);
}
void camera_move_backward_fast( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
- gAgent.unlockView();
- gAgent.setOrbitOutKey(2.5f);
+ gAgentCamera.unlockView();
+ gAgentCamera.setOrbitOutKey(2.5f);
}
@@ -473,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() );
}
@@ -482,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() );
}
@@ -490,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() );
}
@@ -499,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() );
}
@@ -507,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();
}
@@ -516,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();
}
@@ -868,7 +869,7 @@ S32 LLViewerKeyboard::loadBindings(const std::string& filename)
EKeyboardMode LLViewerKeyboard::getMode()
{
- if ( gAgent.cameraMouselook() )
+ if ( gAgentCamera.cameraMouselook() )
{
return MODE_FIRST_PERSON;
}
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 2fcd3f1114..61a75f7227 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -45,6 +45,7 @@
#include "llviewertexturelist.h"
#include "llvovolume.h"
#include "llpluginclassmedia.h"
+#include "llplugincookiestore.h"
#include "llviewerwindow.h"
#include "llfocusmgr.h"
#include "llcallbacklist.h"
@@ -256,6 +257,7 @@ public:
LLViewerMediaImpl *mMediaImpl;
bool mInitialized;
};
+LLPluginCookieStore *LLViewerMedia::sCookieStore = NULL;
static LLViewerMedia::impl_list sViewerMediaImplList;
static LLViewerMedia::impl_id_map sViewerMediaTextureIDMap;
static LLTimer sMediaCreateTimer;
@@ -264,6 +266,8 @@ static F32 sGlobalVolume = 1.0f;
static F64 sLowestLoadableImplInterest = 0.0f;
static bool sAnyMediaShowing = false;
static boost::signals2::connection sTeleportFinishConnection;
+static std::string sUpdatedCookies;
+static const char *PLUGIN_COOKIE_FILE_NAME = "plugin_cookies.txt";
//////////////////////////////////////////////////////////////////////////////////////////
static void add_media_impl(LLViewerMediaImpl* media)
@@ -399,7 +403,6 @@ viewer_media_t LLViewerMedia::updateMediaImpl(LLMediaEntry* media_entry, const s
media_impl->setHomeURL(media_entry->getHomeURL());
media_impl->mMediaAutoPlay = media_entry->getAutoPlay();
media_impl->mMediaEntryURL = media_entry->getCurrentURL();
-
if(media_impl->isAutoPlayable())
{
needs_navigate = true;
@@ -698,6 +701,13 @@ static bool proximity_comparitor(const LLViewerMediaImpl* i1, const LLViewerMedi
void LLViewerMedia::updateMedia(void *dummy_arg)
{
sAnyMediaShowing = false;
+ sUpdatedCookies = getCookieStore()->getChangedCookies();
+ if(!sUpdatedCookies.empty())
+ {
+ lldebugs << "updated cookies will be sent to all loaded plugins: " << llendl;
+ lldebugs << sUpdatedCookies << llendl;
+ }
+
impl_list::iterator iter = sViewerMediaImplList.begin();
impl_list::iterator end = sViewerMediaImplList.end();
@@ -998,6 +1008,9 @@ void LLViewerMedia::clearAllCookies()
}
}
+ // Clear all cookies from the cookie store
+ getCookieStore()->setAllCookies("");
+
// FIXME: this may not be sufficient, since the on-disk cookie file won't get written until some browser instance exits cleanly.
// It also won't clear cookies for other accounts, or for any account if we're not logged in, and won't do anything at all if there are no webkit plugins loaded.
// Until such time as we can centralize cookie storage, the following hack should cover these cases:
@@ -1008,6 +1021,7 @@ void LLViewerMedia::clearAllCookies()
// Places that cookie files can be:
// <getOSUserAppDir>/browser_profile/cookies
// <getOSUserAppDir>/first_last/browser_profile/cookies (note that there may be any number of these!)
+ // <getOSUserAppDir>/first_last/plugin_cookies.txt (note that there may be any number of these!)
std::string base_dir = gDirUtilp->getOSUserAppDir() + gDirUtilp->getDirDelimiter();
std::string target;
@@ -1040,6 +1054,17 @@ void LLViewerMedia::clearAllCookies()
{
LLFile::remove(target);
}
+
+ // Other accounts may have new-style cookie files too -- delete them as well
+ target = base_dir;
+ target += filename;
+ target += gDirUtilp->getDirDelimiter();
+ target += PLUGIN_COOKIE_FILE_NAME;
+ lldebugs << "target = " << target << llendl;
+ if(LLFile::isfile(target))
+ {
+ LLFile::remove(target);
+ }
}
@@ -1095,6 +1120,127 @@ void LLViewerMedia::setProxyConfig(bool enable, const std::string &host, int por
/////////////////////////////////////////////////////////////////////////////////////////
// static
+/////////////////////////////////////////////////////////////////////////////////////////
+// static
+LLPluginCookieStore *LLViewerMedia::getCookieStore()
+{
+ if(sCookieStore == NULL)
+ {
+ sCookieStore = new LLPluginCookieStore;
+ }
+
+ return sCookieStore;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// static
+void LLViewerMedia::loadCookieFile()
+{
+ // build filename for each user
+ std::string resolved_filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PLUGIN_COOKIE_FILE_NAME);
+
+ if (resolved_filename.empty())
+ {
+ llinfos << "can't get path to plugin cookie file - probably not logged in yet." << llendl;
+ return;
+ }
+
+ // open the file for reading
+ llifstream file(resolved_filename);
+ if (!file.is_open())
+ {
+ llwarns << "can't load plugin cookies from file \"" << PLUGIN_COOKIE_FILE_NAME << "\"" << llendl;
+ return;
+ }
+
+ getCookieStore()->readAllCookies(file, true);
+
+ file.close();
+
+ // send the clear_cookies message to all loaded plugins
+ impl_list::iterator iter = sViewerMediaImplList.begin();
+ impl_list::iterator end = sViewerMediaImplList.end();
+ for (; iter != end; iter++)
+ {
+ LLViewerMediaImpl* pimpl = *iter;
+ if(pimpl->mMediaSource)
+ {
+ pimpl->mMediaSource->clear_cookies();
+ }
+ }
+
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// static
+void LLViewerMedia::saveCookieFile()
+{
+ // build filename for each user
+ std::string resolved_filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PLUGIN_COOKIE_FILE_NAME);
+
+ if (resolved_filename.empty())
+ {
+ llinfos << "can't get path to plugin cookie file - probably not logged in yet." << llendl;
+ return;
+ }
+
+ // open a file for writing
+ llofstream file (resolved_filename);
+ if (!file.is_open())
+ {
+ llwarns << "can't open plugin cookie file \"" << PLUGIN_COOKIE_FILE_NAME << "\" for writing" << llendl;
+ return;
+ }
+
+ getCookieStore()->writePersistentCookies(file);
+
+ file.close();
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// static
+void LLViewerMedia::addCookie(const std::string &name, const std::string &value, const std::string &domain, const LLDate &expires, const std::string &path, bool secure)
+{
+ std::stringstream cookie;
+
+ cookie << name << "=" << LLPluginCookieStore::quoteString(value);
+
+ if(expires.notNull())
+ {
+ cookie << "; expires=" << expires.asRFC1123();
+ }
+
+ cookie << "; domain=" << domain;
+
+ cookie << "; path=" << path;
+
+ if(secure)
+ {
+ cookie << "; secure";
+ }
+
+ getCookieStore()->setCookies(cookie.str());
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// static
+void LLViewerMedia::addSessionCookie(const std::string &name, const std::string &value, const std::string &domain, const std::string &path, bool secure)
+{
+ // A session cookie just has a NULL date.
+ addCookie(name, value, domain, LLDate(), path, secure);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// static
+void LLViewerMedia::removeCookie(const std::string &name, const std::string &domain, const std::string &path )
+{
+ // To remove a cookie, add one with the same name, domain, and path that expires in the past.
+
+ addCookie(name, "", domain, LLDate(LLDate::now().secondsSinceEpoch() - 1.0), path);
+}
+
+
bool LLViewerMedia::hasInWorldMedia()
{
if (sInWorldMediaDisabled) return false;
@@ -1455,6 +1601,17 @@ bool LLViewerMediaImpl::initializePlugin(const std::string& media_type)
media_source->clear_cache();
}
+ // TODO: Only send cookies to plugins that need them
+ // Ideally, the plugin should tell us whether it handles cookies or not -- either via the init response or through a separate message.
+ // Due to the ordering of messages, it's possible we wouldn't get that information back in time to send cookies before sending a navigate message,
+ // which could cause odd race conditions.
+ std::string all_cookies = LLViewerMedia::getCookieStore()->getAllCookies();
+ lldebugs << "setting cookies: " << all_cookies << llendl;
+ if(!all_cookies.empty())
+ {
+ media_source->set_cookies(all_cookies);
+ }
+
mMediaSource = media_source;
updateVolume();
@@ -2152,6 +2309,16 @@ void LLViewerMediaImpl::update()
}
}
}
+ else
+ {
+ // If we didn't just create the impl, it may need to get cookie updates.
+ if(!sUpdatedCookies.empty())
+ {
+ // TODO: Only send cookies to plugins that need them
+ mMediaSource->set_cookies(sUpdatedCookies);
+ }
+ }
+
if(mMediaSource == NULL)
{
@@ -2614,6 +2781,13 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla
////////////////////////////////////////////////////////////////////////////////
// virtual
+void LLViewerMediaImpl::handleCookieSet(LLPluginClassMedia* self, const std::string &cookie)
+{
+ LLViewerMedia::getCookieStore()->setCookies(cookie);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// virtual
void
LLViewerMediaImpl::cut()
{
diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h
index f9870fb3b9..10dacf9532 100644
--- a/indra/newview/llviewermedia.h
+++ b/indra/newview/llviewermedia.h
@@ -50,6 +50,7 @@ class LLViewerMediaTexture;
class LLMediaEntry;
class LLVOVolume;
class LLMimeDiscoveryResponder;
+class LLPluginCookieStore;
typedef LLPointer<LLViewerMediaImpl> viewer_media_t;
///////////////////////////////////////////////////////////////////////////////
@@ -145,8 +146,17 @@ public:
// Set the proxy config for all loaded plugins
static void setProxyConfig(bool enable, const std::string &host, int port);
+ static LLPluginCookieStore *getCookieStore();
+ static void loadCookieFile();
+ static void saveCookieFile();
+ static void addCookie(const std::string &name, const std::string &value, const std::string &domain, const LLDate &expires, const std::string &path = std::string("/"), bool secure = false );
+ static void addSessionCookie(const std::string &name, const std::string &value, const std::string &domain, const std::string &path = std::string("/"), bool secure = false );
+ static void removeCookie(const std::string &name, const std::string &domain, const std::string &path = std::string("/") );
+
private:
static void onTeleportFinished();
+
+ static LLPluginCookieStore *sCookieStore;
};
// Implementation functions not exported into header file
@@ -294,6 +304,7 @@ public:
// Inherited from LLPluginClassMediaOwner
/*virtual*/ void handleMediaEvent(LLPluginClassMedia* plugin, LLPluginClassMediaOwner::EMediaEvent);
+ /*virtual*/ void handleCookieSet(LLPluginClassMedia* self, const std::string &cookie);
// LLEditMenuHandler overrides
/*virtual*/ void cut();
diff --git a/indra/newview/llviewermediafocus.cpp b/indra/newview/llviewermediafocus.cpp
index b8179f7fc2..c1e851350b 100644
--- a/indra/newview/llviewermediafocus.cpp
+++ b/indra/newview/llviewermediafocus.cpp
@@ -38,6 +38,7 @@
#include "llpanelprimmediacontrols.h"
#include "llpluginclassmedia.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "lltoolpie.h"
#include "llviewercamera.h"
#include "llviewermedia.h"
@@ -201,7 +202,7 @@ void LLViewerMediaFocus::setCameraZoom(LLViewerObject* object, LLVector3 normal,
{
if (object)
{
- gAgent.setFocusOnAvatar(FALSE, ANIMATE);
+ gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE);
LLBBox bbox = object->getBoundingBoxAgent();
LLVector3d center = gAgent.getPosGlobalFromAgent(bbox.getCenterAgent());
@@ -260,7 +261,7 @@ void LLViewerMediaFocus::setCameraZoom(LLViewerObject* object, LLVector3 normal,
// orientation with respect to the face. In other words, if before zoom
// the media appears "upside down" from the camera, after zooming it will
// still be upside down, but at least it will not flip.
- LLVector3d cur_camera_pos = LLVector3d(gAgent.getCameraPositionGlobal());
+ LLVector3d cur_camera_pos = LLVector3d(gAgentCamera.getCameraPositionGlobal());
LLVector3d delta = (cur_camera_pos - camera_pos);
F64 len = delta.length();
delta.normalize();
@@ -271,18 +272,18 @@ void LLViewerMediaFocus::setCameraZoom(LLViewerObject* object, LLVector3 normal,
// If we are not allowing zooming out and the old camera position is closer to
// the center then the new intended camera position, don't move camera and return
if (zoom_in_only &&
- (dist_vec_squared(gAgent.getCameraPositionGlobal(), target_pos) < dist_vec_squared(camera_pos, target_pos)))
+ (dist_vec_squared(gAgentCamera.getCameraPositionGlobal(), target_pos) < dist_vec_squared(camera_pos, target_pos)))
{
return;
}
- gAgent.setCameraPosAndFocusGlobal(camera_pos, target_pos, object->getID() );
+ gAgentCamera.setCameraPosAndFocusGlobal(camera_pos, target_pos, object->getID() );
}
else
{
// If we have no object, focus back on the avatar.
- gAgent.setFocusOnAvatar(TRUE, ANIMATE);
+ gAgentCamera.setFocusOnAvatar(TRUE, ANIMATE);
}
}
void LLViewerMediaFocus::onFocusReceived()
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 5598a589cc..d79cb85730 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -42,6 +42,7 @@
// newview includes
#include "llagent.h"
+#include "llagentcamera.h"
#include "llagentwearables.h"
#include "llagentpilot.h"
#include "llbottomtray.h"
@@ -2482,18 +2483,18 @@ class LLObjectBuild : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
- if (gAgent.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit() && gSavedSettings.getBOOL("EditCameraMovement") )
+ if (gAgentCamera.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit() && gSavedSettings.getBOOL("EditCameraMovement") )
{
// zoom in if we're looking at the avatar
- gAgent.setFocusOnAvatar(FALSE, ANIMATE);
- gAgent.setFocusGlobal(LLToolPie::getInstance()->getPick());
- gAgent.cameraZoomIn(0.666f);
- gAgent.cameraOrbitOver( 30.f * DEG_TO_RAD );
+ gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE);
+ gAgentCamera.setFocusGlobal(LLToolPie::getInstance()->getPick());
+ gAgentCamera.cameraZoomIn(0.666f);
+ gAgentCamera.cameraOrbitOver( 30.f * DEG_TO_RAD );
gViewerWindow->moveCursorToCenter();
}
else if ( gSavedSettings.getBOOL("EditCameraMovement") )
{
- gAgent.setFocusGlobal(LLToolPie::getInstance()->getPick());
+ gAgentCamera.setFocusGlobal(LLToolPie::getInstance()->getPick());
gViewerWindow->moveCursorToCenter();
}
@@ -2511,7 +2512,7 @@ void handle_object_edit()
{
LLViewerParcelMgr::getInstance()->deselectLand();
- if (gAgent.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit())
+ if (gAgentCamera.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit())
{
LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
@@ -2519,19 +2520,19 @@ void handle_object_edit()
{
// always freeze camera in space, even if camera doesn't move
// so, for example, follow cam scripts can't affect you when in build mode
- gAgent.setFocusGlobal(gAgent.calcFocusPositionTargetGlobal(), LLUUID::null);
- gAgent.setFocusOnAvatar(FALSE, ANIMATE);
+ gAgentCamera.setFocusGlobal(gAgentCamera.calcFocusPositionTargetGlobal(), LLUUID::null);
+ gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE);
}
else
{
- gAgent.setFocusOnAvatar(FALSE, ANIMATE);
+ gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE);
LLViewerObject* selected_objectp = selection->getFirstRootObject();
if (selected_objectp)
{
// zoom in on object center instead of where we clicked, as we need to see the manipulator handles
- gAgent.setFocusGlobal(selected_objectp->getPositionGlobal(), selected_objectp->getID());
- gAgent.cameraZoomIn(0.666f);
- gAgent.cameraOrbitOver( 30.f * DEG_TO_RAD );
+ gAgentCamera.setFocusGlobal(selected_objectp->getPositionGlobal(), selected_objectp->getID());
+ gAgentCamera.cameraZoomIn(0.666f);
+ gAgentCamera.cameraOrbitOver( 30.f * DEG_TO_RAD );
gViewerWindow->moveCursorToCenter();
}
}
@@ -2576,19 +2577,19 @@ class LLLandBuild : public view_listener_t
{
LLViewerParcelMgr::getInstance()->deselectLand();
- if (gAgent.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit() && gSavedSettings.getBOOL("EditCameraMovement") )
+ if (gAgentCamera.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit() && gSavedSettings.getBOOL("EditCameraMovement") )
{
// zoom in if we're looking at the avatar
- gAgent.setFocusOnAvatar(FALSE, ANIMATE);
- gAgent.setFocusGlobal(LLToolPie::getInstance()->getPick());
- gAgent.cameraZoomIn(0.666f);
- gAgent.cameraOrbitOver( 30.f * DEG_TO_RAD );
+ gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE);
+ gAgentCamera.setFocusGlobal(LLToolPie::getInstance()->getPick());
+ gAgentCamera.cameraZoomIn(0.666f);
+ gAgentCamera.cameraOrbitOver( 30.f * DEG_TO_RAD );
gViewerWindow->moveCursorToCenter();
}
else if ( gSavedSettings.getBOOL("EditCameraMovement") )
{
// otherwise just move focus
- gAgent.setFocusGlobal(LLToolPie::getInstance()->getPick());
+ gAgentCamera.setFocusGlobal(LLToolPie::getInstance()->getPick());
gViewerWindow->moveCursorToCenter();
}
@@ -2693,7 +2694,7 @@ class LLSelfEnableRemoveAllAttachments : public view_listener_t
bool new_value = false;
if (gAgent.getAvatarObject())
{
- LLVOAvatar* avatarp = gAgent.getAvatarObject();
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin();
iter != avatarp->mAttachmentPoints.end(); )
{
@@ -2825,12 +2826,12 @@ bool handle_go_to()
if (gAgent.getAvatarObject() && !gSavedSettings.getBOOL("AutoPilotLocksCamera"))
{
- gAgent.setFocusGlobal(gAgent.getFocusTargetGlobal(), gAgent.getAvatarObject()->getID());
+ gAgentCamera.setFocusGlobal(gAgentCamera.getFocusTargetGlobal(), gAgent.getAvatarObject()->getID());
}
else
{
// Snap camera back to behind avatar
- gAgent.setFocusOnAvatar(TRUE, ANIMATE);
+ gAgentCamera.setFocusOnAvatar(TRUE, ANIMATE);
}
// Could be first use
@@ -3717,14 +3718,14 @@ void reset_view_final( BOOL proceed );
void handle_reset_view()
{
- if( (CAMERA_MODE_CUSTOMIZE_AVATAR == gAgent.getCameraMode()) && gFloaterCustomize )
+ if( (CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode()) && gFloaterCustomize )
{
// Show dialog box if needed.
gFloaterCustomize->askToSaveIfDirty( reset_view_final );
}
else
{
- gAgent.switchCameraPreset(CAMERA_PRESET_REAR_VIEW);
+ gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW);
reset_view_final( TRUE );
LLFloaterCamera::resetCameraMode();
}
@@ -3747,15 +3748,15 @@ void reset_view_final( BOOL proceed )
return;
}
- gAgent.resetView(TRUE, TRUE);
- gAgent.setLookAt(LOOKAT_TARGET_CLEAR);
+ gAgentCamera.resetView(TRUE, TRUE);
+ gAgentCamera.setLookAt(LOOKAT_TARGET_CLEAR);
}
class LLViewLookAtLastChatter : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
- gAgent.lookAtLastChat();
+ gAgentCamera.lookAtLastChat();
return true;
}
};
@@ -3764,13 +3765,13 @@ class LLViewMouselook : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
- if (!gAgent.cameraMouselook())
+ if (!gAgentCamera.cameraMouselook())
{
- gAgent.changeCameraToMouselook();
+ gAgentCamera.changeCameraToMouselook();
}
else
{
- gAgent.changeCameraToDefault();
+ gAgentCamera.changeCameraToDefault();
}
return true;
}
@@ -3989,9 +3990,9 @@ void handle_god_request_avatar_geometry(void *)
void derez_objects(EDeRezDestination dest, const LLUUID& dest_id)
{
- if(gAgent.cameraMouselook())
+ if(gAgentCamera.cameraMouselook())
{
- gAgent.changeCameraToDefault();
+ gAgentCamera.changeCameraToDefault();
}
//gInventoryView->setPanelOpen(TRUE);
@@ -5034,7 +5035,7 @@ class LLViewEnableLastChatter : public view_listener_t
bool handleEvent(const LLSD& userdata)
{
// *TODO: add check that last chatter is in range
- bool new_value = (gAgent.cameraThirdPerson() && gAgent.getLastChatter().notNull());
+ bool new_value = (gAgentCamera.cameraThirdPerson() && gAgent.getLastChatter().notNull());
return new_value;
}
};
@@ -5148,7 +5149,7 @@ void print_agent_nvpairs(void*)
llinfos << "Can't find agent object" << llendl;
}
- llinfos << "Camera at " << gAgent.getCameraPositionGlobal() << llendl;
+ llinfos << "Camera at " << gAgentCamera.getCameraPositionGlobal() << llendl;
}
void show_debug_menus()
@@ -5339,7 +5340,7 @@ void handle_look_at_selection(const LLSD& param)
BOOL zoom = (param.asString() == "zoom");
if (!LLSelectMgr::getInstance()->getSelection()->isEmpty())
{
- gAgent.setFocusOnAvatar(FALSE, ANIMATE);
+ gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE);
LLBBox selection_bbox = LLSelectMgr::getInstance()->getBBoxOfSelection();
F32 angle_of_view = llmax(0.1f, LLViewerCamera::getInstance()->getAspect() > 1.f ? LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect() : LLViewerCamera::getInstance()->getView());
@@ -5356,17 +5357,17 @@ void handle_look_at_selection(const LLSD& param)
if (zoom)
{
// Make sure we are not increasing the distance between the camera and object
- LLVector3d orig_distance = gAgent.getCameraPositionGlobal() - LLSelectMgr::getInstance()->getSelectionCenterGlobal();
+ LLVector3d orig_distance = gAgentCamera.getCameraPositionGlobal() - LLSelectMgr::getInstance()->getSelectionCenterGlobal();
distance = llmin(distance, (F32) orig_distance.length());
- gAgent.setCameraPosAndFocusGlobal(LLSelectMgr::getInstance()->getSelectionCenterGlobal() + LLVector3d(obj_to_cam * distance),
+ gAgentCamera.setCameraPosAndFocusGlobal(LLSelectMgr::getInstance()->getSelectionCenterGlobal() + LLVector3d(obj_to_cam * distance),
LLSelectMgr::getInstance()->getSelectionCenterGlobal(),
object_id );
}
else
{
- gAgent.setFocusGlobal( LLSelectMgr::getInstance()->getSelectionCenterGlobal(), object_id );
+ gAgentCamera.setFocusGlobal( LLSelectMgr::getInstance()->getSelectionCenterGlobal(), object_id );
}
}
}
@@ -5379,7 +5380,7 @@ void handle_zoom_to_object(LLUUID object_id)
if (object)
{
- gAgent.setFocusOnAvatar(FALSE, ANIMATE);
+ gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE);
LLBBox bbox = object->getBoundingBoxAgent() ;
F32 angle_of_view = llmax(0.1f, LLViewerCamera::getInstance()->getAspect() > 1.f ? LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect() : LLViewerCamera::getInstance()->getView());
@@ -5391,7 +5392,7 @@ void handle_zoom_to_object(LLUUID object_id)
LLVector3d object_center_global = gAgent.getPosGlobalFromAgent(bbox.getCenterAgent());
- gAgent.setCameraPosAndFocusGlobal(object_center_global + LLVector3d(obj_to_cam * distance),
+ gAgentCamera.setCameraPosAndFocusGlobal(object_center_global + LLVector3d(obj_to_cam * distance),
object_center_global,
object_id );
}
@@ -5589,7 +5590,7 @@ void handle_customize_avatar()
{
if (gAgentWearables.areWearablesLoaded())
{
- gAgent.changeCameraToCustomizeAvatar();
+ gAgentCamera.changeCameraToCustomizeAvatar();
}
}
@@ -5775,18 +5776,18 @@ class LLLandEdit : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
- if (gAgent.getFocusOnAvatar() && gSavedSettings.getBOOL("EditCameraMovement") )
+ if (gAgentCamera.getFocusOnAvatar() && gSavedSettings.getBOOL("EditCameraMovement") )
{
// zoom in if we're looking at the avatar
- gAgent.setFocusOnAvatar(FALSE, ANIMATE);
- gAgent.setFocusGlobal(LLToolPie::getInstance()->getPick());
+ gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE);
+ gAgentCamera.setFocusGlobal(LLToolPie::getInstance()->getPick());
- gAgent.cameraOrbitOver( F_PI * 0.25f );
+ gAgentCamera.cameraOrbitOver( F_PI * 0.25f );
gViewerWindow->moveCursorToCenter();
}
else if ( gSavedSettings.getBOOL("EditCameraMovement") )
{
- gAgent.setFocusGlobal(LLToolPie::getInstance()->getPick());
+ gAgentCamera.setFocusGlobal(LLToolPie::getInstance()->getPick());
gViewerWindow->moveCursorToCenter();
}
@@ -5912,7 +5913,7 @@ void confirm_replace_attachment(S32 option, void* user_data)
walkToSpot -= delta;
gAgent.startAutoPilotGlobal(gAgent.getPosGlobalFromAgent(walkToSpot), "Attach", NULL, near_attach_object, user_data, stop_distance);
- gAgent.clearFocusObject();
+ gAgentCamera.clearFocusObject();
}
}
}
@@ -6758,7 +6759,7 @@ class LLViewEnableMouselook : public view_listener_t
{
// You can't go directly from customize avatar to mouselook.
// TODO: write code with appropriate dialogs to handle this transition.
- bool new_value = (CAMERA_MODE_CUSTOMIZE_AVATAR != gAgent.getCameraMode() && !gSavedSettings.getBOOL("FreezeTime"));
+ bool new_value = (CAMERA_MODE_CUSTOMIZE_AVATAR != gAgentCamera.getCameraMode() && !gSavedSettings.getBOOL("FreezeTime"));
return new_value;
}
};
@@ -6936,11 +6937,11 @@ void handle_debug_avatar_textures(void*)
void handle_grab_texture(void* data)
{
ETextureIndex tex_index = (ETextureIndex)((intptr_t)data);
- const LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- if ( avatar )
+ const LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if (avatarp)
{
// MULTI-WEARABLE: change to support an index
- const LLUUID& asset_id = avatar->grabLocalTexture(tex_index, 0);
+ 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;
@@ -7011,11 +7012,11 @@ void handle_grab_texture(void* data)
BOOL enable_grab_texture(void* data)
{
ETextureIndex index = (ETextureIndex)((intptr_t)data);
- const LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- if ( avatar )
+ const LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if (avatarp)
{
// MULTI-WEARABLE:
- return avatar->canGrabLocalTexture(index,0);
+ return avatarp->canGrabLocalTexture(index,0);
}
return FALSE;
}
@@ -7226,12 +7227,12 @@ void handle_buy_currency_test(void*)
void handle_rebake_textures(void*)
{
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- if (!avatar) return;
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if (!avatarp) return;
// Slam pending upload count to "unstick" things
bool slam_for_debug = true;
- avatar->forceBakeAllTextures(slam_for_debug);
+ avatarp->forceBakeAllTextures(slam_for_debug);
}
void toggle_visibility(void* user_data)
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index dfde9a9d1d..c575656b24 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -36,6 +36,7 @@
// project includes
#include "llagent.h"
+#include "llagentcamera.h"
#include "llfilepicker.h"
#include "llfloaterreg.h"
#include "llfloaterbuycurrency.h"
@@ -140,9 +141,9 @@ std::string build_extensions_string(LLFilePicker::ELoadFilter filter)
**/
const std::string upload_pick(void* data)
{
- if( gAgent.cameraMouselook() )
+ if( gAgentCamera.cameraMouselook() )
{
- gAgent.changeCameraToDefault();
+ gAgentCamera.changeCameraToDefault();
// This doesn't seem necessary. JC
// display();
}
@@ -289,9 +290,9 @@ class LLFileUploadBulk : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
- if( gAgent.cameraMouselook() )
+ if( gAgentCamera.cameraMouselook() )
{
- gAgent.changeCameraToDefault();
+ gAgentCamera.changeCameraToDefault();
}
// TODO:
@@ -317,13 +318,11 @@ class LLFileUploadBulk : public view_listener_t
LLStringUtil::trim(asset_name);
std::string display_name = LLStringUtil::null;
- LLAssetStorage::LLStoreAssetCallback callback = NULL;
S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
- void *userdata = NULL;
- upload_new_resource(filename, asset_name, asset_name, 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
+ upload_new_resource(filename, asset_name, asset_name, LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
LLFloaterPerms::getNextOwnerPerms(), LLFloaterPerms::getGroupPerms(), LLFloaterPerms::getEveryonePerms(),
display_name,
- callback, expected_upload_cost, userdata);
+ NULL, expected_upload_cost);
// *NOTE: Ew, we don't iterate over the file list here,
// we handle the next files in upload_done_callback()
@@ -480,16 +479,15 @@ void handle_compress_image(void*)
}
void upload_new_resource(const std::string& src_filename, std::string name,
- std::string desc, S32 compression_info,
+ std::string desc,
LLFolderType::EType destination_folder_type,
LLInventoryType::EType inv_type,
U32 next_owner_perms,
U32 group_perms,
U32 everyone_perms,
const std::string& display_name,
- LLAssetStorage::LLStoreAssetCallback callback,
- S32 expected_upload_cost,
- void *userdata)
+ boost::function<void(const LLUUID& uuid)> callback,
+ S32 expected_upload_cost)
{
// Generate the temporary UUID.
std::string filename = gDirUtilp->getTempFilename();
@@ -771,9 +769,9 @@ void upload_new_resource(const std::string& src_filename, std::string name,
{
t_disp_name = src_filename;
}
- upload_new_resource(tid, asset_type, name, desc, compression_info, // tid
+ upload_new_resource(tid, asset_type, name, desc,
destination_folder_type, inv_type, next_owner_perms, group_perms, everyone_perms,
- display_name, callback, expected_upload_cost, userdata);
+ display_name, callback, expected_upload_cost);
}
else
{
@@ -892,30 +890,28 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt
LLStringUtil::trim(asset_name);
std::string display_name = LLStringUtil::null;
- LLAssetStorage::LLStoreAssetCallback callback = NULL;
- void *userdata = NULL;
upload_new_resource(next_file, asset_name, asset_name, // file
- 0, LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
+ LLFolderType::FT_NONE, LLInventoryType::IT_NONE,
PERM_NONE, PERM_NONE, PERM_NONE,
display_name,
- callback,
- expected_upload_cost, // assuming next in a group of uploads is of roughly the same type, i.e. same upload cost
- userdata);
+ NULL,
+ expected_upload_cost); // assuming next in a group of uploads is of roughly the same type, i.e. same upload cost
+
}
}
-void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_type,
+void upload_new_resource(const LLTransactionID &tid,
+ LLAssetType::EType asset_type,
std::string name,
- std::string desc, S32 compression_info,
+ std::string desc,
LLFolderType::EType destination_folder_type,
LLInventoryType::EType inv_type,
U32 next_owner_perms,
U32 group_perms,
U32 everyone_perms,
const std::string& display_name,
- LLAssetStorage::LLStoreAssetCallback callback,
- S32 expected_upload_cost,
- void *userdata)
+ boost::function<void(const LLUUID& uuid)> callback,
+ S32 expected_upload_cost)
{
if(gDisconnected)
{
@@ -959,78 +955,26 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty
upload_message.append(display_name);
LLUploadDialog::modalUploadDialog(upload_message);
- llinfos << "*** Uploading: " << llendl;
- llinfos << "Type: " << LLAssetType::lookup(asset_type) << llendl;
- llinfos << "UUID: " << uuid << llendl;
- llinfos << "Name: " << name << llendl;
- llinfos << "Desc: " << desc << llendl;
- llinfos << "Expected Upload Cost: " << expected_upload_cost << llendl;
- lldebugs << "Folder: " << gInventory.findCategoryUUIDForType((destination_folder_type == LLFolderType::FT_NONE) ? LLFolderType::assetTypeToFolderType(asset_type) : destination_folder_type) << llendl;
- lldebugs << "Asset Type: " << LLAssetType::lookup(asset_type) << llendl;
std::string url = gAgent.getRegion()->getCapability("NewFileAgentInventory");
- if (!url.empty())
- {
- llinfos << "New Agent Inventory via capability" << llendl;
- LLSD body;
- body["folder_id"] = gInventory.findCategoryUUIDForType((destination_folder_type == LLFolderType::FT_NONE) ? LLFolderType::assetTypeToFolderType(asset_type) : destination_folder_type);
- body["asset_type"] = LLAssetType::lookup(asset_type);
- body["inventory_type"] = LLInventoryType::lookup(inv_type);
- body["name"] = name;
- body["description"] = desc;
- body["next_owner_mask"] = LLSD::Integer(next_owner_perms);
- body["group_mask"] = LLSD::Integer(group_perms);
- body["everyone_mask"] = LLSD::Integer(everyone_perms);
- body["expected_upload_cost"] = LLSD::Integer(expected_upload_cost);
-
- //std::ostringstream llsdxml;
- //LLSDSerialize::toPrettyXML(body, llsdxml);
- //llinfos << "posting body to capability: " << llsdxml.str() << llendl;
-
- LLHTTPClient::post(url, body, new LLNewAgentInventoryResponder(body, uuid, asset_type));
+
+ if (url.empty()) {
+ llwarns << "Could not get NewFileAgentInventory capability" << llendl;
+ return;
}
- else
- {
- llinfos << "NewAgentInventory capability not found, new agent inventory via asset system." << llendl;
- // check for adequate funds
- // TODO: do this check on the sim
- if (LLAssetType::AT_SOUND == asset_type ||
- LLAssetType::AT_TEXTURE == asset_type ||
- LLAssetType::AT_ANIMATION == asset_type)
- {
- S32 balance = gStatusBar->getBalance();
- if (balance < expected_upload_cost)
- {
- // insufficient funds, bail on this upload
- LLStringUtil::format_map_t args;
- args["AMOUNT"] = llformat("%d", expected_upload_cost);
- LLFloaterBuyCurrency::buyCurrency(LLTrans::getString("uploading_costs", args), expected_upload_cost);
- return;
- }
- }
- LLResourceData* data = new LLResourceData;
- data->mAssetInfo.mTransactionID = tid;
- data->mAssetInfo.mUuid = uuid;
- data->mAssetInfo.mType = asset_type;
- data->mAssetInfo.mCreatorID = gAgentID;
- data->mInventoryType = inv_type;
- data->mNextOwnerPerm = next_owner_perms;
- data->mExpectedUploadCost = expected_upload_cost;
- data->mUserData = userdata;
- data->mAssetInfo.setName(name);
- data->mAssetInfo.setDescription(desc);
- data->mPreferredLocation = destination_folder_type;
-
- LLAssetStorage::LLStoreAssetCallback asset_callback = &upload_done_callback;
- if (callback)
- {
- asset_callback = callback;
- }
- gAssetStorage->storeAssetData(data->mAssetInfo.mTransactionID, data->mAssetInfo.mType,
- asset_callback,
- (void*)data,
- FALSE);
- }
+ llinfos << "New Agent Inventory via capability" << llendl;
+ LLSD body;
+ body["folder_id"] = gInventory.findCategoryUUIDForType((destination_folder_type == LLFolderType::FT_NONE) ? LLFolderType::assetTypeToFolderType(asset_type) : destination_folder_type);
+ body["asset_type"] = LLAssetType::lookup(asset_type);
+ body["inventory_type"] = LLInventoryType::lookup(inv_type);
+ body["name"] = name;
+ body["description"] = desc;
+ body["next_owner_mask"] = LLSD::Integer(next_owner_perms);
+ body["group_mask"] = LLSD::Integer(group_perms);
+ body["everyone_mask"] = LLSD::Integer(everyone_perms);
+ body["expected_upload_cost"] = LLSD::Integer(expected_upload_cost);
+
+ LLHTTPClient::post(url, body, new LLNewAgentInventoryResponder(body, uuid, asset_type, callback));
}
void init_menu_file()
diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h
index 1e6d13f1c6..33f8243ac0 100644
--- a/indra/newview/llviewermenufile.h
+++ b/indra/newview/llviewermenufile.h
@@ -34,41 +34,35 @@
#define LLVIEWERMENUFILE_H
#include "llfoldertype.h"
-#include "llassetstorage.h"
#include "llinventorytype.h"
class LLTransactionID;
-
void init_menu_file();
void upload_new_resource(const std::string& src_filename,
std::string name,
std::string desc,
- S32 compression_info,
LLFolderType::EType destination_folder_type,
LLInventoryType::EType inv_type,
U32 next_owner_perms,
U32 group_perms,
U32 everyone_perms,
const std::string& display_name,
- LLAssetStorage::LLStoreAssetCallback callback,
- S32 expected_upload_cost,
- void *userdata);
+ boost::function<void(const LLUUID& uuid)> callback,
+ S32 expected_upload_cost);
void upload_new_resource(const LLTransactionID &tid,
LLAssetType::EType type,
std::string name,
std::string desc,
- S32 compression_info,
LLFolderType::EType destination_folder_type,
LLInventoryType::EType inv_type,
U32 next_owner_perms,
U32 group_perms,
U32 everyone_perms,
const std::string& display_name,
- LLAssetStorage::LLStoreAssetCallback callback,
- S32 expected_upload_cost,
- void *userdata);
+ boost::function<void(const LLUUID& uuid)> callback,
+ S32 expected_upload_cost);
#endif
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 3d0dfbed40..c2a78f20e1 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -51,6 +51,7 @@
#include "mean_collision_data.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llcallingcard.h"
//#include "llfirstuse.h"
#include "llfloaterbuycurrency.h"
@@ -2945,6 +2946,9 @@ void process_teleport_finish(LLMessageSystem* msg, void**)
LL_WARNS("Messaging") << "Got teleport notification for wrong agent!" << LL_ENDL;
return;
}
+
+ // Teleport is finished; it can't be cancelled now.
+ gViewerWindow->setProgressCancelButtonVisible(FALSE);
// Do teleport effect for where you're leaving
// VEFFECT: TeleportStart
@@ -2990,10 +2994,10 @@ void process_teleport_finish(LLMessageSystem* msg, void**)
/*
// send camera update to new region
- gAgent.updateCamera();
+ gAgentCamera.updateCamera();
// likewise make sure the camera is behind the avatar
- gAgent.resetView(TRUE);
+ gAgentCamera.resetView(TRUE);
LLVector3 shift_vector = regionp->getPosRegionFromGlobal(gAgent.getRegion()->getOriginGlobal());
gAgent.setRegion(regionp);
gObjectList.shiftObjects(shift_vector);
@@ -3001,7 +3005,7 @@ void process_teleport_finish(LLMessageSystem* msg, void**)
if (gAgent.getAvatarObject())
{
gAgent.getAvatarObject()->clearChatText();
- gAgent.slamLookAt(look_at);
+ gAgentCamera.slamLookAt(look_at);
}
gAgent.setPositionAgent(pos);
gAssetStorage->setUpstream(sim);
@@ -3080,7 +3084,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**)
std::string version_channel;
msg->getString("SimData", "ChannelVersion", version_channel);
- LLVOAvatar* avatarp = gAgent.getAvatarObject();
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
if (!avatarp)
{
// Could happen if you were immediately god-teleported away on login,
@@ -3125,9 +3129,9 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**)
if( is_teleport )
{
// Force the camera back onto the agent, don't animate.
- gAgent.setFocusOnAvatar(TRUE, FALSE);
- gAgent.slamLookAt(look_at);
- gAgent.updateCamera();
+ gAgentCamera.setFocusOnAvatar(TRUE, FALSE);
+ gAgentCamera.slamLookAt(look_at);
+ gAgentCamera.updateCamera();
gAgent.setTeleportState( LLAgent::TELEPORT_START_ARRIVAL );
@@ -3176,7 +3180,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**)
global_agent_pos[1] += y;
look_at = (LLVector3)beacon_pos - global_agent_pos;
look_at.normVec();
- gAgent.slamLookAt(look_at);
+ gAgentCamera.slamLookAt(look_at);
}
}
@@ -3353,7 +3357,7 @@ void send_agent_update(BOOL force_send, BOOL send_reliable)
LLQuaternion body_rotation = gAgent.getFrameAgent().getQuaternion();
LLQuaternion head_rotation = gAgent.getHeadRotation();
- camera_pos_agent = gAgent.getCameraPositionAgent();
+ camera_pos_agent = gAgentCamera.getCameraPositionAgent();
render_state = gAgent.getRenderState();
@@ -3476,7 +3480,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);
@@ -4128,7 +4132,7 @@ void process_camera_constraint(LLMessageSystem *mesgsys, void **user_data)
LLVector4 cameraCollidePlane;
mesgsys->getVector4Fast(_PREHASH_CameraCollidePlane, _PREHASH_Plane, cameraCollidePlane);
- gAgent.setCameraCollidePlane(cameraCollidePlane);
+ gAgentCamera.setCameraCollidePlane(cameraCollidePlane);
}
void near_sit_object(BOOL success, void *data)
@@ -4165,10 +4169,10 @@ void process_avatar_sit_response(LLMessageSystem *mesgsys, void **user_data)
if (avatar && dist_vec_squared(camera_eye, camera_at) > 0.0001f)
{
- gAgent.setSitCamera(sitObjectID, camera_eye, camera_at);
+ gAgentCamera.setSitCamera(sitObjectID, camera_eye, camera_at);
}
- gAgent.setForceMouselook(force_mouselook);
+ gAgentCamera.setForceMouselook(force_mouselook);
LLViewerObject* object = gObjectList.findObject(sitObjectID);
if (object)
@@ -5219,9 +5223,9 @@ void container_inventory_arrived(LLViewerObject* object,
void* data)
{
LL_DEBUGS("Messaging") << "container_inventory_arrived()" << LL_ENDL;
- if( gAgent.cameraMouselook() )
+ if( gAgentCamera.cameraMouselook() )
{
- gAgent.changeCameraToDefault();
+ gAgentCamera.changeCameraToDefault();
}
LLInventoryPanel *active_panel = LLInventoryPanel::getActiveInventoryPanel();
@@ -5446,13 +5450,13 @@ void process_teleport_local(LLMessageSystem *msg,void**)
}
gAgent.setPositionAgent(pos);
- gAgent.slamLookAt(look_at);
+ gAgentCamera.slamLookAt(look_at);
// likewise make sure the camera is behind the avatar
- gAgent.resetView(TRUE, TRUE);
+ gAgentCamera.resetView(TRUE, TRUE);
// send camera update to new region
- gAgent.updateCamera();
+ gAgentCamera.updateCamera();
send_agent_update(TRUE, TRUE);
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 6c8346df86..abcb7e5452 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -60,6 +60,7 @@
#include "llaudiosourcevo.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llbbox.h"
#include "llbox.h"
#include "llcylinder.h"
@@ -376,7 +377,7 @@ void LLViewerObject::markDead()
if (flagAnimSource())
{
- LLVOAvatar* avatarp = gAgent.getAvatarObject();
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
if (avatarp && !avatarp->isDead())
{
// stop motions associated with this object
@@ -2757,7 +2758,7 @@ void LLViewerObject::setPixelAreaAndAngle(LLAgent &agent)
return;
}
- LLVector3 viewer_pos_agent = agent.getCameraPositionAgent();
+ LLVector3 viewer_pos_agent = gAgentCamera.getCameraPositionAgent();
LLVector3 pos_agent = getRenderPosition();
F32 dx = viewer_pos_agent.mV[VX] - pos_agent.mV[VX];
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 6347090f71..64a7b2166b 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -47,6 +47,7 @@
#include "llviewerwindow.h"
#include "llnetmap.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "pipeline.h"
#include "llspatialpartition.h"
#include "lltooltip.h"
@@ -288,7 +289,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
LLMemType mt(LLMemType::MTYPE_OBJECT_PROCESS_UPDATE);
LLFastTimer t(FTM_PROCESS_OBJECTS);
- LLVector3d camera_global = gAgent.getCameraPositionGlobal();
+ LLVector3d camera_global = gAgentCamera.getCameraPositionGlobal();
LLViewerObject *objectp;
S32 num_objects;
U32 local_id;
@@ -614,7 +615,7 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)
}
// Focused
- objectp = gAgent.getFocusObject();
+ objectp = gAgentCamera.getFocusObject();
if (objectp)
{
objectp->boostTexturePriority();
@@ -1209,7 +1210,7 @@ void LLViewerObjectList::generatePickList(LLCamera &camera)
}
// add all hud objects to pick list
- LLVOAvatar* avatarp = gAgent.getAvatarObject();
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
if (avatarp)
{
for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin();
@@ -1281,7 +1282,7 @@ void LLViewerObjectList::renderPickList(const LLRect& screen_rect, BOOL pick_par
gViewerWindow->renderSelections( TRUE, pick_parcel_wall, FALSE );
//fix for DEV-19335. Don't pick hud objects when customizing avatar (camera mode doesn't play nice with nametags).
- if (!gAgent.cameraCustomizeAvatar())
+ if (!gAgentCamera.cameraCustomizeAvatar())
{
// render pickable ui elements, like names, etc.
LLHUDObject::renderAllForSelect();
diff --git a/indra/newview/llviewerparceloverlay.cpp b/indra/newview/llviewerparceloverlay.cpp
index 9de1ef7190..2d17ea7bcd 100644
--- a/indra/newview/llviewerparceloverlay.cpp
+++ b/indra/newview/llviewerparceloverlay.cpp
@@ -43,11 +43,11 @@
#include "v2math.h"
// newview includes
+#include "llagentcamera.h"
#include "llviewertexture.h"
#include "llviewercontrol.h"
#include "llsurface.h"
#include "llviewerregion.h"
-#include "llagent.h"
#include "llviewercamera.h"
#include "llviewertexturelist.h"
#include "llselectmgr.h"
@@ -760,7 +760,7 @@ S32 LLViewerParcelOverlay::renderPropertyLines ()
LLGLDepthTest mDepthTest(GL_TRUE);
// Find camera height off the ground (not from zero)
- F32 ground_height_at_camera = land.resolveHeightGlobal( gAgent.getCameraPositionGlobal() );
+ F32 ground_height_at_camera = land.resolveHeightGlobal( gAgentCamera.getCameraPositionGlobal() );
F32 camera_z = LLViewerCamera::getInstance()->getOrigin().mV[VZ];
F32 camera_height = camera_z - ground_height_at_camera;
@@ -791,7 +791,7 @@ S32 LLViewerParcelOverlay::renderPropertyLines ()
const S32 vertex_per_edge = 3 + 2 * (GRID_STEP-1) + 3;
// Stomp the camera into two dimensions
- LLVector3 camera_region = mRegion->getPosRegionFromGlobal( gAgent.getCameraPositionGlobal() );
+ LLVector3 camera_region = mRegion->getPosRegionFromGlobal( gAgentCamera.getCameraPositionGlobal() );
// Set up a cull plane 2 * PARCEL_GRID_STEP_METERS behind
// the camera. The cull plane normal is the camera's at axis.
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index ce627494c8..07d4ac664f 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -47,6 +47,7 @@
#include "v4math.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llcallingcard.h"
#include "llcaphttpsender.h"
#include "llcommandhandler.h"
@@ -819,7 +820,7 @@ void LLViewerRegion::calculateCenterGlobal()
void LLViewerRegion::calculateCameraDistance()
{
- mCameraDistanceSquared = (F32)(gAgent.getCameraPositionGlobal() - getCenterGlobal()).magVecSquared();
+ mCameraDistanceSquared = (F32)(gAgentCamera.getCameraPositionGlobal() - getCenterGlobal()).magVecSquared();
}
std::ostream& operator<<(std::ostream &s, const LLViewerRegion &region)
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 41d9f6d067..b7c265be59 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -52,6 +52,7 @@
#include "llsurface.h"
#include "llvlmanager.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llviewercontrol.h"
#include "llfloatertools.h"
#include "lldebugview.h"
@@ -577,11 +578,11 @@ void update_statistics(U32 frame_count)
// make sure we have a valid time delta for this frame
if (gFrameIntervalSeconds > 0.f)
{
- if (gAgent.getCameraMode() == CAMERA_MODE_MOUSELOOK)
+ if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
{
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_MOUSELOOK_SECONDS, gFrameIntervalSeconds);
}
- else if (gAgent.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR)
+ else if (gAgentCamera.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR)
{
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_AVATAR_EDIT_SECONDS, gFrameIntervalSeconds);
}
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 9fbffdac35..af0dcd8e35 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -1578,12 +1578,12 @@ F32 LLViewerFetchedTexture::calcDecodePriority()
}
else if (!isJustBound() && mCachedRawImageReady)
{
- //if(mBoostLevel < BOOST_HIGH)
- //{
- // // We haven't rendered this in a while, de-prioritize it
- // desired_discard += 2;
- //}
- //else
+ if(mBoostLevel < BOOST_HIGH)
+ {
+ // We haven't rendered this in a while, de-prioritize it
+ desired_discard += 2;
+ }
+ else
{
// We haven't rendered this in the last half second, and we have a cached raw image, leave the desired discard as-is
desired_discard = cur_discard;
@@ -1591,7 +1591,7 @@ F32 LLViewerFetchedTexture::calcDecodePriority()
}
S32 ddiscard = cur_discard - desired_discard;
- ddiscard = llclamp(ddiscard, 0, MAX_DELTA_DISCARD_LEVEL_FOR_PRIORITY);
+ ddiscard = llclamp(ddiscard, -1, MAX_DELTA_DISCARD_LEVEL_FOR_PRIORITY);
priority = (ddiscard + 1) * PRIORITY_DELTA_DISCARD_LEVEL_FACTOR;
}
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index d91833fd22..6d2bbb27ee 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -44,6 +44,8 @@
#include <fstream>
#include <algorithm>
+#include "llagent.h"
+#include "llagentcamera.h"
#include "llfloaterreg.h"
#include "llpanellogin.h"
#include "llviewerkeyboard.h"
@@ -383,7 +385,7 @@ public:
agent_left_text = llformat("AgentLeftAxis %f %f %f",
(F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ]));
- tvector = gAgent.getCameraPositionGlobal();
+ tvector = gAgentCamera.getCameraPositionGlobal();
camera_center_text = llformat("CameraCenter %f %f %f",
(F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ]));
@@ -776,7 +778,7 @@ BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK
// *HACK: this should be rolled into the composite tool logic, not
// hardcoded at the top level.
- if (CAMERA_MODE_CUSTOMIZE_AVATAR != gAgent.getCameraMode() && LLToolMgr::getInstance()->getCurrentTool() != LLToolPie::getInstance())
+ if (CAMERA_MODE_CUSTOMIZE_AVATAR != gAgentCamera.getCameraMode() && LLToolMgr::getInstance()->getCurrentTool() != LLToolPie::getInstance())
{
// If the current tool didn't process the click, we should show
// the pie menu. This can be done by passing the event to the pie
@@ -1151,9 +1153,9 @@ BOOL LLViewerWindow::handleActivate(LLWindow *window, BOOL activated)
}
// SL-53351: Make sure we're not in mouselook when minimised, to prevent control issues
- if (gAgent.getCameraMode() == CAMERA_MODE_MOUSELOOK)
+ if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
{
- gAgent.changeCameraToDefault();
+ gAgentCamera.changeCameraToDefault();
}
send_agent_pause();
@@ -1171,7 +1173,7 @@ BOOL LLViewerWindow::handleActivate(LLWindow *window, BOOL activated)
BOOL LLViewerWindow::handleActivateApp(LLWindow *window, BOOL activating)
{
- //if (!activating) gAgent.changeCameraToDefault();
+ //if (!activating) gAgentCamera.changeCameraToDefault();
LLViewerJoystick::getInstance()->setNeedsReset(true);
return FALSE;
@@ -2088,7 +2090,7 @@ void LLViewerWindow::draw()
// Draw tool specific overlay on world
LLToolMgr::getInstance()->getCurrentTool()->draw();
- if( gAgent.cameraMouselook() )
+ if( gAgentCamera.cameraMouselook() )
{
drawMouselookInstructions();
stop_glerror();
@@ -2424,7 +2426,7 @@ void LLViewerWindow::handleScrollWheel(S32 clicks)
// Zoom the camera in and out behavior
if(top_ctrl == 0 && getWorldViewRectScaled().pointInRect(mCurrentMousePoint.mX, mCurrentMousePoint.mY) )
- gAgent.handleScrollWheel(clicks);
+ gAgentCamera.handleScrollWheel(clicks);
return;
}
@@ -3175,7 +3177,7 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls,
glPushMatrix();
if (selection->getSelectType() == SELECT_TYPE_HUD)
{
- F32 zoom = gAgent.mHUDCurZoom;
+ F32 zoom = gAgentCamera.mHUDCurZoom;
glScalef(zoom, zoom, zoom);
}
@@ -3294,7 +3296,7 @@ LLVector3d LLViewerWindow::clickPointInWorldGlobal(S32 x, S32 y_from_bot, LLView
// world at the location of the mouse click
LLVector3 mouse_direction_global = mouseDirectionGlobal( x, y_from_bot );
- LLVector3d relative_object = clicked_object->getPositionGlobal() - gAgent.getCameraPositionGlobal();
+ LLVector3d relative_object = clicked_object->getPositionGlobal() - gAgentCamera.getCameraPositionGlobal();
// make mouse vector as long as object vector, so it touchs a point near
// where the user clicked on the object
@@ -3303,7 +3305,7 @@ LLVector3d LLViewerWindow::clickPointInWorldGlobal(S32 x, S32 y_from_bot, LLView
LLVector3d new_pos;
new_pos.setVec(mouse_direction_global);
// transform mouse vector back to world coords
- new_pos += gAgent.getCameraPositionGlobal();
+ new_pos += gAgentCamera.getCameraPositionGlobal();
return new_pos;
}
@@ -3570,7 +3572,7 @@ LLVector3 LLViewerWindow::mousePointHUD(const S32 x, const S32 y) const
F32 hud_x = -((F32)x - center_x) / height;
F32 hud_y = ((F32)y - center_y) / height;
- return LLVector3(0.f, hud_x/gAgent.mHUDCurZoom, hud_y/gAgent.mHUDCurZoom);
+ return LLVector3(0.f, hud_x/gAgentCamera.mHUDCurZoom, hud_y/gAgentCamera.mHUDCurZoom);
}
// Returns unit vector relative to camera in camera space
@@ -3617,7 +3619,7 @@ BOOL LLViewerWindow::mousePointOnPlaneGlobal(LLVector3d& point, const S32 x, con
LLVector3d plane_normal_global_d;
plane_normal_global_d.setVec(plane_normal_global);
F64 plane_mouse_dot = (plane_normal_global_d * mouse_direction_global_d);
- LLVector3d plane_origin_camera_rel = plane_point_global - gAgent.getCameraPositionGlobal();
+ LLVector3d plane_origin_camera_rel = plane_point_global - gAgentCamera.getCameraPositionGlobal();
F64 mouse_look_at_scale = (plane_normal_global_d * plane_origin_camera_rel)
/ plane_mouse_dot;
if (llabs(plane_mouse_dot) < 0.00001)
@@ -3631,7 +3633,7 @@ BOOL LLViewerWindow::mousePointOnPlaneGlobal(LLVector3d& point, const S32 x, con
mouse_look_at_scale = plane_origin_camera_rel.magVec() / (plane_origin_dir * mouse_direction_global_d);
}
- point = gAgent.getCameraPositionGlobal() + mouse_look_at_scale * mouse_direction_global_d;
+ point = gAgentCamera.getCameraPositionGlobal() + mouse_look_at_scale * mouse_direction_global_d;
return mouse_look_at_scale > 0.0;
}
@@ -3649,12 +3651,12 @@ BOOL LLViewerWindow::mousePointOnLandGlobal(const S32 x, const S32 y, LLVector3d
const F32 SECOND_PASS_STEP = 0.1f; // meters
LLVector3d camera_pos_global;
- camera_pos_global = gAgent.getCameraPositionGlobal();
+ camera_pos_global = gAgentCamera.getCameraPositionGlobal();
LLVector3d probe_point_global;
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);
@@ -5039,9 +5041,9 @@ bool LLViewerWindow::onAlert(const LLSD& notify)
// If we're in mouselook, the mouse is hidden and so the user can't click
// the dialog buttons. In that case, change to First Person instead.
- if( gAgent.cameraMouselook() )
+ if( gAgentCamera.cameraMouselook() )
{
- gAgent.changeCameraToDefault();
+ gAgentCamera.changeCameraToDefault();
}
return false;
}
@@ -5153,7 +5155,7 @@ void LLPickInfo::fetchResults()
{
mPickType = PICK_OBJECT;
}
- mObjectOffset = gAgent.calcFocusOffset(objectp, intersection, mPickPt.mX, mPickPt.mY);
+ mObjectOffset = gAgentCamera.calcFocusOffset(objectp, intersection, mPickPt.mX, mPickPt.mY);
mObjectID = objectp->mID;
mObjectFace = (te_offset == NO_FACE) ? -1 : (S32)te_offset;
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index f5e83ed025..54379dece3 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -48,6 +48,7 @@
#include "sound_ids.h"
#include "llagent.h" // Get state values from here
+#include "llagentcamera.h"
#include "llagentwearables.h"
#include "llanimationstates.h"
#include "llavatarpropertiesprocessor.h"
@@ -885,7 +886,7 @@ BOOL LLVOAvatar::areAllNearbyInstancesBaked(S32& grey_avatars)
// static
void LLVOAvatar::dumpBakedStatus()
{
- LLVector3d camera_pos_global = gAgent.getCameraPositionGlobal();
+ LLVector3d camera_pos_global = gAgentCamera.getCameraPositionGlobal();
for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin();
iter != LLCharacter::sInstances.end(); ++iter)
@@ -2225,7 +2226,7 @@ BOOL LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
void LLVOAvatar::idleUpdateVoiceVisualizer(bool voice_enabled)
{
// disable voice visualizer when in mouselook
- mVoiceVisualizer->setVoiceEnabled( voice_enabled && !(isSelf() && gAgent.cameraMouselook()) );
+ mVoiceVisualizer->setVoiceEnabled( voice_enabled && !(isSelf() && gAgentCamera.cameraMouselook()) );
if ( voice_enabled )
{
//----------------------------------------------------------------
@@ -2671,7 +2672,7 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last)
if (isSelf())
{
render_name = render_name
- && !gAgent.cameraMouselook()
+ && !gAgentCamera.cameraMouselook()
&& (visible_chat || (gSavedSettings.getBOOL("RenderNameShowSelf")
&& gSavedSettings.getS32("AvatarNameTagMode") ));
}
@@ -3235,7 +3236,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
}
}
LLVector3 fwdDir = lerp(primDir, velDir, clamp_rescale(speed, 0.5f, 2.0f, 0.0f, 1.0f));
- if (isSelf() && gAgent.cameraMouselook())
+ if (isSelf() && gAgentCamera.cameraMouselook())
{
// make sure fwdDir stays in same general direction as primdir
if (gAgent.getFlying())
@@ -3266,7 +3267,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
// When moving very slow, the pelvis is allowed to deviate from the
// forward direction to allow it to hold it's position while the torso
// and head turn. Once in motion, it must conform however.
- BOOL self_in_mouselook = isSelf() && gAgent.cameraMouselook();
+ BOOL self_in_mouselook = isSelf() && gAgentCamera.cameraMouselook();
LLVector3 pelvisDir( mRoot.getWorldMatrix().getFwdRow4().mV );
F32 pelvis_rot_threshold = clamp_rescale(speed, 0.1f, 1.0f, PELVIS_ROT_THRESHOLD_SLOW, PELVIS_ROT_THRESHOLD_FAST);
@@ -5206,7 +5207,7 @@ BOOL LLVOAvatar::updateJointLODs()
{
if (isSelf())
{
- if(gAgent.cameraCustomizeAvatar() || gAgent.cameraMouselook())
+ if(gAgentCamera.cameraCustomizeAvatar() || gAgentCamera.cameraMouselook())
{
mAdjustedPixelArea = MAX_PIXEL_AREA;
}
@@ -5352,7 +5353,7 @@ void LLVOAvatar::updateShadowFaces()
// Render sprite
sprite.setNormal(normal);
- if (isSelf() && gAgent.getCameraMode() == CAMERA_MODE_MOUSELOOK)
+ if (isSelf() && gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
{
sprite.setColor(0.f, 0.f, 0.f, 0.f);
}
@@ -5385,7 +5386,7 @@ void LLVOAvatar::updateShadowFaces()
// Render sprite
sprite.setNormal(normal);
- if (isSelf() && gAgent.getCameraMode() == CAMERA_MODE_MOUSELOOK)
+ if (isSelf() && gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
{
sprite.setColor(0.f, 0.f, 0.f, 0.f);
}
@@ -5440,7 +5441,7 @@ BOOL LLVOAvatar::setParent(LLViewerObject* parent)
ret = LLViewerObject::setParent(parent);
if (isSelf())
{
- gAgent.resetCamera();
+ gAgentCamera.resetCamera();
}
}
else
@@ -5625,15 +5626,15 @@ void LLVOAvatar::sitOnObject(LLViewerObject *sit_object)
//LLFirstUse::useSit();
gAgent.setFlying(FALSE);
- gAgent.setThirdPersonHeadOffset(LLVector3::zero);
+ gAgentCamera.setThirdPersonHeadOffset(LLVector3::zero);
//interpolate to new camera position
- gAgent.startCameraAnimation();
+ gAgentCamera.startCameraAnimation();
// make sure we are not trying to autopilot
gAgent.stopAutoPilot();
- gAgent.setupSitCamera();
- if (gAgent.getForceMouselook())
+ gAgentCamera.setupSitCamera();
+ if (gAgentCamera.getForceMouselook())
{
- gAgent.changeCameraToMouselook();
+ gAgentCamera.changeCameraToMouselook();
}
}
@@ -5720,9 +5721,9 @@ void LLVOAvatar::getOffObject()
//reset orientation
// mRoot.setRotation(avWorldRot);
- gAgent.setThirdPersonHeadOffset(LLVector3(0.f, 0.f, 1.f));
+ gAgentCamera.setThirdPersonHeadOffset(LLVector3(0.f, 0.f, 1.f));
- gAgent.setSitCamera(LLUUID::null);
+ gAgentCamera.setSitCamera(LLUUID::null);
}
}
@@ -5937,7 +5938,7 @@ void LLVOAvatar::updateMeshTextures()
}
}
- const BOOL self_customizing = isSelf() && gAgent.cameraCustomizeAvatar(); // During face edit mode, we don't use baked textures
+ const BOOL self_customizing = isSelf() && gAgentCamera.cameraCustomizeAvatar(); // During face edit mode, we don't use baked textures
const BOOL other_culled = !isSelf() && mCulled;
std::vector<BOOL> is_layer_baked;
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 98ca76ed01..15be6b23b3 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -44,6 +44,7 @@
#include "pipeline.h"
#include "llagent.h" // Get state values from here
+#include "llagentcamera.h"
#include "llagentwearables.h"
#include "llhudeffecttrail.h"
#include "llhudmanager.h"
@@ -819,10 +820,10 @@ void LLVOAvatarSelf::idleUpdateTractorBeam()
{
LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
- if (gAgent.mPointAt.notNull())
+ if (gAgentCamera.mPointAt.notNull())
{
// get point from pointat effect
- mBeam->setPositionGlobal(gAgent.mPointAt->getPointAtPosGlobal());
+ mBeam->setPositionGlobal(gAgentCamera.mPointAt->getPointAtPosGlobal());
mBeam->triggerLocal();
}
else if (selection->getFirstRootObject() &&
@@ -873,7 +874,7 @@ void LLVOAvatarSelf::restoreMeshData()
//llinfos << "Restoring" << llendl;
mMeshValid = TRUE;
updateJointLODs();
- updateAttachmentVisibility(gAgent.getCameraMode());
+ updateAttachmentVisibility(gAgentCamera.getCameraMode());
// force mesh update as LOD might not have changed to trigger this
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_GEOMETRY, TRUE);
@@ -938,7 +939,7 @@ void LLVOAvatarSelf::wearableUpdated( EWearableType type, BOOL upload_result )
// if we're editing our appearance, ensure that we're not using baked textures
// The baked texture for alpha masks is set explicitly when you hit "save"
- if (gAgent.cameraCustomizeAvatar())
+ if (gAgentCamera.cameraCustomizeAvatar())
{
setNewBakedTexture(index,IMG_DEFAULT_AVATAR);
}
@@ -1027,7 +1028,7 @@ const LLViewerJointAttachment *LLVOAvatarSelf::attachObject(LLViewerObject *view
return 0;
}
- updateAttachmentVisibility(gAgent.getCameraMode());
+ updateAttachmentVisibility(gAgentCamera.getCameraMode());
// Then make sure the inventory is in sync with the avatar.
@@ -1115,11 +1116,11 @@ void LLVOAvatarSelf::localTextureLoaded(BOOL success, LLViewerFetchedTexture *sr
discard_level < local_tex_obj->getDiscard())
{
local_tex_obj->setDiscard(discard_level);
- if (!gAgent.cameraCustomizeAvatar())
+ if (!gAgentCamera.cameraCustomizeAvatar())
{
requestLayerSetUpdate(index);
}
- else if (gAgent.cameraCustomizeAvatar())
+ else if (gAgentCamera.cameraCustomizeAvatar())
{
LLVisualParamHint::requestHintUpdates();
}
@@ -1523,11 +1524,11 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te
if (tex_discard >= 0 && tex_discard <= desired_discard)
{
local_tex_obj->setDiscard(tex_discard);
- if (isSelf() && !gAgent.cameraCustomizeAvatar())
+ if (isSelf() && !gAgentCamera.cameraCustomizeAvatar())
{
requestLayerSetUpdate(type);
}
- else if (isSelf() && gAgent.cameraCustomizeAvatar())
+ else if (isSelf() && gAgentCamera.cameraCustomizeAvatar())
{
LLVisualParamHint::requestHintUpdates();
}
diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp
index e311f07912..a82afbeb76 100644
--- a/indra/newview/llvograss.cpp
+++ b/indra/newview/llvograss.cpp
@@ -37,7 +37,7 @@
#include "imageids.h"
#include "llviewercontrol.h"
-#include "llagent.h"
+#include "llagentcamera.h"
#include "llnotificationsutil.h"
#include "lldrawable.h"
#include "llface.h"
@@ -306,7 +306,7 @@ BOOL LLVOGrass::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
void LLVOGrass::setPixelAreaAndAngle(LLAgent &agent)
{
// This should be the camera's center, as soon as we move to all region-local.
- LLVector3 relative_position = getPositionAgent() - agent.getCameraPositionAgent();
+ LLVector3 relative_position = getPositionAgent() - gAgentCamera.getCameraPositionAgent();
F32 range = relative_position.length();
F32 max_scale = getMaxScale();
diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp
index 9bb85d2bd5..cc346c2345 100644
--- a/indra/newview/llvoiceclient.cpp
+++ b/indra/newview/llvoiceclient.cpp
@@ -60,6 +60,7 @@
#include "llappviewer.h" // for gDisconnected, gDisableVoice
#include "llmutelist.h" // to check for muted avatars
#include "llagent.h"
+#include "llvoavatarself.h"
#include "llcachename.h"
#include "llimview.h" // for LLIMMgr
#include "llparcel.h"
@@ -5874,9 +5875,9 @@ void LLVoiceClient::updatePosition(void)
if(gVoiceClient)
{
- LLVOAvatar *agent = gAgent.getAvatarObject();
+ LLVOAvatarSelf *avatarp = gAgent.getAvatarObject();
LLViewerRegion *region = gAgent.getRegion();
- if(region && agent)
+ if(region && avatarp)
{
LLMatrix3 rot;
LLVector3d pos;
@@ -5894,9 +5895,9 @@ void LLVoiceClient::updatePosition(void)
rot); // rotation matrix
// Send the current avatar position to the voice code
- rot = agent->getRootJoint()->getWorldRotation().getMatrix3();
+ rot = avatarp->getRootJoint()->getWorldRotation().getMatrix3();
- pos = agent->getPositionGlobal();
+ pos = avatarp->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/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp
index 139d2fbd88..3ba4ecad0c 100644
--- a/indra/newview/llvopartgroup.cpp
+++ b/indra/newview/llvopartgroup.cpp
@@ -40,7 +40,7 @@
#include "message.h"
#include "v2math.h"
-#include "llagent.h"
+#include "llagentcamera.h"
#include "lldrawable.h"
#include "llface.h"
#include "llsky.h"
@@ -136,7 +136,7 @@ F32 LLVOPartGroup::getPartSize(S32 idx)
LLVector3 LLVOPartGroup::getCameraPosition() const
{
- return gAgent.getCameraPositionAgent();
+ return gAgentCamera.getCameraPositionAgent();
}
static LLFastTimer::DeclareTimer FTM_UPDATE_PARTICLES("Update Particles");
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index 0550ed770b..d73850cb49 100644
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -41,6 +41,7 @@
#include "timing.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "lldrawable.h"
#include "llface.h"
#include "llcubemap.h"
@@ -357,7 +358,7 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
mFace[i] = NULL;
}
- mCameraPosAgent = gAgent.getCameraPositionAgent();
+ mCameraPosAgent = gAgentCamera.getCameraPositionAgent();
mAtmHeight = ATM_HEIGHT;
mEarthCenter = LLVector3(mCameraPosAgent.mV[0], mCameraPosAgent.mV[1], -EARTH_RADIUS);
@@ -2034,7 +2035,7 @@ void LLVOSky::updateFog(const F32 distance)
const F32 water_height = gAgent.getRegion() ? gAgent.getRegion()->getWaterHeight() : 0.f;
// LLWorld::getInstance()->getWaterHeight();
- F32 camera_height = gAgent.getCameraPositionAgent().mV[2];
+ F32 camera_height = gAgentCamera.getCameraPositionAgent().mV[2];
F32 near_clip_height = LLViewerCamera::getInstance()->getAtAxis().mV[VZ] * LLViewerCamera::getInstance()->getNear();
camera_height += near_clip_height;
diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp
index 55e2c58a52..b89c0cd638 100644
--- a/indra/newview/llvotree.cpp
+++ b/indra/newview/llvotree.cpp
@@ -44,7 +44,7 @@
#include "material_codes.h"
#include "object_flags.h"
-#include "llagent.h"
+#include "llagentcamera.h"
#include "lldrawable.h"
#include "llface.h"
#include "llviewercamera.h"
@@ -444,7 +444,7 @@ void LLVOTree::setPixelAreaAndAngle(LLAgent &agent)
// Re-calculate mPixelArea accurately
// This should be the camera's center, as soon as we move to all region-local.
- LLVector3 relative_position = getPositionAgent() - agent.getCameraPositionAgent();
+ LLVector3 relative_position = getPositionAgent() - gAgentCamera.getCameraPositionAgent();
F32 range = relative_position.length(); // ugh, square root
F32 max_scale = mBillboardScale * getMaxScale();
diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp
index 8be8f494da..436cd478b4 100644
--- a/indra/newview/llwaterparammanager.cpp
+++ b/indra/newview/llwaterparammanager.cpp
@@ -54,6 +54,7 @@
#include "llviewercontrol.h"
#include "lldrawpoolwater.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llviewerregion.h"
#include "llwlparammanager.h"
@@ -434,7 +435,7 @@ F32 LLWaterParamManager::getFogDensity(void)
// modify if we're underwater
const F32 water_height = gAgent.getRegion() ? gAgent.getRegion()->getWaterHeight() : 0.f;
- F32 camera_height = gAgent.getCameraPositionAgent().mV[2];
+ F32 camera_height = gAgentCamera.getCameraPositionAgent().mV[2];
if(camera_height <= water_height)
{
// raise it to the underwater fog density modifier
diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp
index 3334c17a8f..589099673d 100644
--- a/indra/newview/llwearable.cpp
+++ b/indra/newview/llwearable.cpp
@@ -645,18 +645,18 @@ void LLWearable::setTexturesToDefaults()
// Updates the user's avatar's appearance
void LLWearable::writeToAvatar()
{
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- llassert( avatar );
- if( !avatar )
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ llassert(avatarp);
+ if(!avatarp)
{
llerrs << "could not get avatar object to write to for wearable " << this->getName() << llendl;
return;
}
- ESex old_sex = avatar->getSex();
+ ESex old_sex = avatarp->getSex();
// Pull params
- for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() )
+ for( LLVisualParam* param = avatarp->getFirstVisualParam(); param; param = avatarp->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.
@@ -665,7 +665,7 @@ void LLWearable::writeToAvatar()
S32 param_id = param->getID();
F32 weight = getVisualParamWeight(param_id);
- avatar->setVisualParamWeight( param_id, weight, FALSE );
+ avatarp->setVisualParamWeight( param_id, weight, FALSE );
}
}
@@ -686,14 +686,14 @@ void LLWearable::writeToAvatar()
}
LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture( image_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE );
// MULTI-WEARABLE: replace hard-coded 0
- avatar->setLocalTextureTE(te, image, 0);
+ avatarp->setLocalTextureTE(te, image, 0);
}
}
- ESex new_sex = avatar->getSex();
+ ESex new_sex = avatarp->getSex();
if( old_sex != new_sex )
{
- avatar->updateSexDependentLayerSets( FALSE );
+ avatarp->updateSexDependentLayerSets( FALSE );
}
// if( upload_bake )
@@ -707,9 +707,9 @@ void LLWearable::writeToAvatar()
// static
void LLWearable::removeFromAvatar( EWearableType type, BOOL upload_bake )
{
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- llassert( avatar );
- if( !avatar )
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ llassert(avatarp);
+ if(!avatarp)
{
return;
}
@@ -724,12 +724,12 @@ void LLWearable::removeFromAvatar( EWearableType type, BOOL upload_bake )
}
// Pull params
- for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() )
+ for( LLVisualParam* param = avatarp->getFirstVisualParam(); param; param = avatarp->getNextVisualParam() )
{
if( (((LLViewerVisualParam*)param)->getWearableType() == type) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) )
{
S32 param_id = param->getID();
- avatar->setVisualParamWeight( param_id, param->getDefaultWeight(), upload_bake );
+ avatarp->setVisualParamWeight( param_id, param->getDefaultWeight(), upload_bake );
}
}
@@ -738,8 +738,8 @@ void LLWearable::removeFromAvatar( EWearableType type, BOOL upload_bake )
gFloaterCustomize->setWearable(type, NULL, PERM_ALL, TRUE);
}
- avatar->updateVisualParams();
- avatar->wearableUpdated(type, TRUE);
+ avatarp->updateVisualParams();
+ avatarp->wearableUpdated(type, TRUE);
// if( upload_bake )
// {
@@ -751,9 +751,9 @@ 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* avatar = gAgent.getAvatarObject();
- llassert( avatar );
- if( !avatar )
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ llassert(avatarp);
+ if(!avatarp)
{
return;
}
@@ -769,9 +769,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*) avatar->getFirstVisualParam();
+ for (LLViewerVisualParam* param = (LLViewerVisualParam*) avatarp->getFirstVisualParam();
param;
- param = (LLViewerVisualParam*) avatar->getNextVisualParam() )
+ param = (LLViewerVisualParam*) avatarp->getNextVisualParam() )
{
if( (param->getWearableType() == mType) )
{
@@ -783,7 +783,7 @@ void LLWearable::copyDataFrom(const LLWearable* src)
destroyTextures();
// Deep copy of mTEMap (copies only those tes that are current, filling in defaults where needed)
- for( S32 te = 0; te < TEX_NUM_INDICES; te++ )
+ for (S32 te = 0; te < TEX_NUM_INDICES; te++)
{
if (LLVOAvatarDictionary::getTEWearableType((ETextureIndex) te) == mType)
{
@@ -876,14 +876,14 @@ void LLWearable::addVisualParam(LLVisualParam *param)
void LLWearable::setVisualParams()
{
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
+ 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();
- avatar->setVisualParamWeight(id, value, FALSE);
+ avatarp->setVisualParamWeight(id, value, FALSE);
}
}
@@ -1024,9 +1024,9 @@ BOOL LLWearable::isOnTop() const
void LLWearable::createLayers(S32 te)
{
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- LLTexLayerSet *layer_set = avatar->getLayerSet((ETextureIndex)te);
- if( layer_set )
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ LLTexLayerSet *layer_set = avatarp->getLayerSet((ETextureIndex)te);
+ if (layer_set)
{
layer_set->cloneTemplates(mTEMap[te], (ETextureIndex)te, this);
}
diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp
index 27757d19e5..7afe81b436 100644
--- a/indra/newview/llworldmapview.cpp
+++ b/indra/newview/llworldmapview.cpp
@@ -44,6 +44,7 @@
#include "lltooltip.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llcallingcard.h"
#include "llcommandhandler.h"
#include "llviewercontrol.h"
@@ -311,7 +312,7 @@ void LLWorldMapView::draw()
const S32 height = getRect().getHeight();
const F32 half_width = F32(width) / 2.0f;
const F32 half_height = F32(height) / 2.0f;
- LLVector3d camera_global = gAgent.getCameraPositionGlobal();
+ LLVector3d camera_global = gAgentCamera.getCameraPositionGlobal();
S32 level = LLWorldMipmap::scaleToLevel(sMapScale);
@@ -913,7 +914,7 @@ void LLWorldMapView::drawFrustum()
LLVector3 LLWorldMapView::globalPosToView( const LLVector3d& global_pos )
{
- LLVector3d relative_pos_global = global_pos - gAgent.getCameraPositionGlobal();
+ LLVector3d relative_pos_global = global_pos - gAgentCamera.getCameraPositionGlobal();
LLVector3 pos_local;
pos_local.setVec(relative_pos_global); // convert to floats from doubles
@@ -1006,7 +1007,7 @@ LLVector3d LLWorldMapView::viewPosToGlobal( S32 x, S32 y )
LLVector3d pos_global;
pos_global.setVec( pos_local );
- pos_global += gAgent.getCameraPositionGlobal();
+ pos_global += gAgentCamera.getCameraPositionGlobal();
if(gAgent.isGodlike())
{
pos_global.mdV[VZ] = GODLY_TELEPORT_HEIGHT; // Godly height should always be 200.
@@ -1638,7 +1639,7 @@ void LLWorldMapView::updateVisibleBlocks()
// Load the blocks visible in the current World Map view
// Get the World Map view coordinates and boundaries
- LLVector3d camera_global = gAgent.getCameraPositionGlobal();
+ LLVector3d camera_global = gAgentCamera.getCameraPositionGlobal();
const S32 width = getRect().getWidth();
const S32 height = getRect().getHeight();
const F32 half_width = F32(width) / 2.0f;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 259ca21e93..685be043fc 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -56,6 +56,7 @@
// newview includes
#include "llagent.h"
+#include "llagentcamera.h"
#include "lldrawable.h"
#include "lldrawpoolalpha.h"
#include "lldrawpoolavatar.h"
@@ -3855,7 +3856,7 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects, BOOL render
}
// pick HUD objects
- LLVOAvatar* avatarp = gAgent.getAvatarObject();
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
if (avatarp && sShowHUDAttachments)
{
glh::matrix4f save_proj(glh_get_current_projection());
@@ -4361,7 +4362,7 @@ void LLPipeline::calcNearbyLights(LLCamera& camera)
// mNearbyLight (and all light_set_t's) are sorted such that
// begin() == the closest light and rbegin() == the farthest light
const S32 MAX_LOCAL_LIGHTS = 6;
-// LLVector3 cam_pos = gAgent.getCameraPositionAgent();
+// LLVector3 cam_pos = gAgentCamera.getCameraPositionAgent();
LLVector3 cam_pos = LLViewerJoystick::getInstance()->getOverrideCamera() ?
camera.getOrigin() :
gAgent.getPositionAgent();
@@ -4707,7 +4708,7 @@ void LLPipeline::enableLightsDynamic()
glColor4f(0.f, 0.f, 0.f, 1.f); // no local lighting by default
}
- LLVOAvatar* avatarp = gAgent.getAvatarObject();
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
if (avatarp && getLightingDetail() <= 0)
{
@@ -7100,15 +7101,15 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
{
if (LLPipeline::sWaterReflections && assertInitialized() && LLDrawPoolWater::sNeedsReflectionUpdate)
{
- LLVOAvatarSelf* avatar = gAgent.getAvatarObject();
- if (gAgent.getCameraAnimating() || gAgent.getCameraMode() != CAMERA_MODE_MOUSELOOK)
+ LLVOAvatarSelf* avatarp = gAgent.getAvatarObject();
+ if (gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK)
{
- avatar = NULL;
+ avatarp = NULL;
}
- if (avatar)
+ if (avatarp)
{
- avatar->updateAttachmentVisibility(CAMERA_MODE_THIRD_PERSON);
+ avatarp->updateAttachmentVisibility(CAMERA_MODE_THIRD_PERSON);
}
LLVertexBuffer::unbind();
@@ -7332,9 +7333,9 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
LLGLState::checkTextureChannels();
LLGLState::checkClientArrays();
- if (avatar)
+ if (avatarp)
{
- avatar->updateAttachmentVisibility(gAgent.getCameraMode());
+ avatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode());
}
}
}
diff --git a/indra/newview/skins/default/textures/arrow_down.tga b/indra/newview/skins/default/textures/arrow_down.tga
deleted file mode 100644
index 81dc9d3b6c..0000000000
--- a/indra/newview/skins/default/textures/arrow_down.tga
+++ /dev/null
Binary files differ
diff --git a/indra/newview/skins/default/textures/locked_image.j2c b/indra/newview/skins/default/textures/locked_image.j2c
deleted file mode 100644
index 9e8998d675..0000000000
--- a/indra/newview/skins/default/textures/locked_image.j2c
+++ /dev/null
Binary files differ
diff --git a/indra/newview/skins/default/textures/map_infohub.tga b/indra/newview/skins/default/textures/map_infohub.tga
deleted file mode 100644
index 545b8e532c..0000000000
--- a/indra/newview/skins/default/textures/map_infohub.tga
+++ /dev/null
Binary files differ
diff --git a/indra/newview/skins/default/xui/en/floater_snapshot.xml b/indra/newview/skins/default/xui/en/floater_snapshot.xml
index dda14f02ff..7dcf2aab99 100644
--- a/indra/newview/skins/default/xui/en/floater_snapshot.xml
+++ b/indra/newview/skins/default/xui/en/floater_snapshot.xml
@@ -1,395 +1,127 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<floater
legacy_header_height="18"
- can_minimize="false"
- can_close="true"
+ can_minimize="true"
+ can_close="false"
follows="left|top"
- height="516"
+ height="340"
layout="topleft"
name="Snapshot"
help_topic="snapshot"
save_rect="true"
save_visibility="true"
- title="SNAPSHOT PREVIEW"
- width="215">
- <floater.string
- name="unknown">
- unknown
- </floater.string>
- <radio_group
- height="58"
- label="Snapshot type"
- layout="topleft"
- left="10"
- name="snapshot_type_radio"
- top="25"
- width="205">
- <radio_item
- bottom="19"
- height="16"
- label="Email"
- layout="topleft"
- name="postcard" />
- <radio_item
- bottom="38"
- height="16"
- label="My inventory (L$[AMOUNT])"
- layout="topleft"
- name="texture" />
- <radio_item
- bottom="57"
- height="16"
- label="Save to my computer"
- layout="topleft"
- name="local" />
- </radio_group>
- <ui_ctrl
- height="90"
- width="125"
+ can_dock="true"
+ title="Snapshot"
+ width="250">
+ <floater.string
+ name="unknown">
+ unknown
+ </floater.string>
+ <floater.string
+ name="share_to_web_url" translate="false">
+ http://pdp36.lindenlab.com:12777/
+ </floater.string>
+ <view
+ height="160"
+ width="230"
layout="topleft"
name="thumbnail_placeholder"
- top_pad="6"
+ top_pad="30"
follows="left|top"
left="10"
/>
- <text
- type="string"
- font="SansSerifSmall"
- length="1"
- follows="left|top"
- height="14"
- layout="topleft"
- right="-5"
- left_delta="0"
- halign="right"
- name="file_size_label"
- top_pad="10"
- width="195">
- [SIZE] KB
- </text>
- <button
- follows="left|top"
+ <button
+ follows="left|top"
+ height="22"
+ image_overlay="Refresh_Off"
+ layout="topleft"
+ left="20"
+ top_pad="-30"
+ name="new_snapshot_btn"
+ width="23" />
+ <line_editor
+ border_style="line"
+ border_thickness="1"
+ follows="left|top"
+ height="20"
+ layout="topleft"
+ left="10"
+ max_length="500"
+ name="description"
+ top_pad="15"
+ width="230"
+ label="Description"/>
+ <button
+ label="Share Snapshot"
+ name="share"
+ top_pad="20"
+ left="10"
+ width="130"/>
+ <button
+ label="Share to Web"
+ name="share_to_web"
+ top_delta="0"
+ left="10"
+ width="130"/>
+ <button
+ label="Save to My Inventory"
+ name="save_to_inventory"
+ top_delta="0"
+ left="10"
+ width="130"/>
+ <button
+ label="Save Snapshot"
+ name="save"
+ top_pad="7"
+ left="10"
+ width="130"/>
+ <button
+ label="Email Snapshot"
+ name="share_to_email"
+ top_delta="0"
+ left="10"
+ width="130"/>
+ <button
+ label="Save to My Computer"
+ name="save_to_computer"
+ top_delta="0"
+ left="10"
+ width="130"/>
+ <button
+ label="Set As Profile Pic"
+ name="set_profile_pic"
+ top_pad="7"
+ left="10"
+ width="130"/>
+ <button
+ label="Back"
+ name="cancel"
+ top_delta="0"
+ left="10"
+ width="130"/>
+ <button
+ follows="left"
height="22"
- image_overlay="Refresh_Off"
- layout="topleft"
- left="10"
- name="new_snapshot_btn"
- width="23" />
- <button
- follows="left|top"
- height="23"
- label="Send"
- layout="topleft"
- left_pad="5"
- right="-5"
- name="send_btn"
- width="100" />
- <button
- follows="left|top"
- height="23"
- label="Save (L$[AMOUNT])"
- layout="topleft"
- right="-5"
- name="upload_btn"
- top_delta="0"
- width="100" />
- <flyout_button
- follows="left|top"
- height="23"
- label="Save"
- layout="topleft"
- right="-5"
- name="save_btn"
- tool_tip="Save image to a file"
- top_delta="0"
- width="100">
- <flyout_button.item
- label="Save"
- name="save_item"
- value="save" />
- <flyout_button.item
- label="Save As..."
- name="saveas_item"
- value="save as" />
- </flyout_button>
- <button
- follows="left|top"
- height="23"
- label="More"
- layout="topleft"
- left="10"
- name="more_btn"
- tool_tip="Advanced options"
- width="80" />
- <button
- follows="left|top"
- height="23"
- label="Less"
- layout="topleft"
- left_delta="0"
- name="less_btn"
- tool_tip="Advanced options"
- top_delta="0"
- width="80" />
- <button
- follows="left|top"
- height="23"
- label="Cancel"
- layout="topleft"
- right="-5"
- left_pad="5"
- name="discard_btn"
- width="100" />
- <text
- type="string"
- length="1"
- follows="top|left"
- height="12"
- layout="topleft"
- left="10"
- name="type_label2"
- top_pad="5"
- width="127">
- Size
- </text>
- <text
- type="string"
- length="1"
- follows="top|left"
- height="12"
- layout="topleft"
- left_pad="5"
- name="format_label"
- top_delta="0"
- width="70">
- Format
- </text>
- <combo_box
- height="23"
- label="Resolution"
- layout="topleft"
- left="10"
- name="postcard_size_combo"
- width="120">
- <combo_box.item
- label="Current Window"
- name="CurrentWindow"
- value="[i0,i0]" />
- <combo_box.item
- label="640x480"
- name="640x480"
- value="[i640,i480]" />
- <combo_box.item
- label="800x600"
- name="800x600"
- value="[i800,i600]" />
- <combo_box.item
- label="1024x768"
- name="1024x768"
- value="[i1024,i768]" />
- <combo_box.item
- label="Custom"
- name="Custom"
- value="[i-1,i-1]" />
- </combo_box>
- <combo_box
- height="23"
- label="Resolution"
layout="topleft"
- left_delta="0"
- name="texture_size_combo"
- top_delta="0"
- width="127">
- <combo_box.item
- label="Current Window"
- name="CurrentWindow"
- value="[i0,i0]" />
- <combo_box.item
- label="Small (128x128)"
- name="Small(128x128)"
- value="[i128,i128]" />
- <combo_box.item
- label="Medium (256x256)"
- name="Medium(256x256)"
- value="[i256,i256]" />
- <combo_box.item
- label="Large (512x512)"
- name="Large(512x512)"
- value="[i512,i512]" />
- <combo_box.item
- label="Custom"
- name="Custom"
- value="[i-1,i-1]" />
- </combo_box>
- <combo_box
- height="23"
- label="Resolution"
- layout="topleft"
- left_delta="0"
- name="local_size_combo"
- top_delta="0"
- width="127">
- <combo_box.item
- label="Current Window"
- name="CurrentWindow"
- value="[i0,i0]" />
- <combo_box.item
- label="320x240"
- name="320x240"
- value="[i320,i240]" />
- <combo_box.item
- label="640x480"
- name="640x480"
- value="[i640,i480]" />
- <combo_box.item
- label="800x600"
- name="800x600"
- value="[i800,i600]" />
- <combo_box.item
- label="1024x768"
- name="1024x768"
- value="[i1024,i768]" />
- <combo_box.item
- label="1280x1024"
- name="1280x1024"
- value="[i1280,i1024]" />
- <combo_box.item
- label="1600x1200"
- name="1600x1200"
- value="[i1600,i1200]" />
- <combo_box.item
- label="Custom"
- name="Custom"
- value="[i-1,i-1]" />
- </combo_box>
- <combo_box
- height="23"
- label="Format"
- layout="topleft"
- left_pad="5"
- name="local_format_combo"
- width="70">
- <combo_box.item
- label="PNG"
- name="PNG" />
- <combo_box.item
- label="JPEG"
- name="JPEG" />
- <combo_box.item
- label="BMP"
- name="BMP" />
- </combo_box>
- <spinner
- allow_text_entry="false"
- decimal_digits="0"
- follows="left|top"
- height="20"
- increment="32"
- label="Width"
- label_width="40"
- layout="topleft"
- left="10"
- max_val="6016"
- min_val="32"
- name="snapshot_width"
- top_pad="10"
- width="95" />
- <spinner
- allow_text_entry="false"
- decimal_digits="0"
- follows="left|top"
- height="20"
- increment="32"
- label="Height"
- label_width="40"
+ left="210"
+ name="show_advanced"
+ image_overlay="TabIcon_Close_Off"
+ top_delta="1"
+ width="30"/>
+ <button
+ follows="left"
+ height="22"
layout="topleft"
- left_pad="5"
- max_val="6016"
- min_val="32"
- name="snapshot_height"
+ left="210"
+ visible="false"
+ name="hide_advanced"
+ image_overlay="TabIcon_Open_Off"
top_delta="0"
- width="95" />
- <check_box
- bottom_delta="20"
- label="Constrain proportions"
- layout="topleft"
- left="10"
- name="keep_aspect_check" />
- <slider
- decimal_digits="0"
- follows="left|top"
- height="15"
- increment="1"
- initial_value="75"
- label="Image quality"
- label_width="100"
- layout="topleft"
- left_delta="0"
- max_val="100"
- name="image_quality_slider"
- top_pad="5"
- width="205" />
- <text
- type="string"
- length="1"
- follows="left|top"
- height="13"
- layout="topleft"
- left="10"
- name="layer_type_label"
- top_pad="5"
- width="50">
- Capture:
- </text>
- <combo_box
- height="23"
- label="Image Layers"
- layout="topleft"
- left="30"
- name="layer_types"
- width="145">
- <combo_box.item
- label="Colors"
- name="Colors"
- value="colors" />
- <combo_box.item
- label="Depth"
- name="Depth"
- value="depth" />
- </combo_box>
- <check_box
- label="Interface"
- layout="topleft"
- left="30"
- top_pad="10"
- width="180"
- name="ui_check" />
- <check_box
- label="HUDs"
- layout="topleft"
- left="30"
- top_pad="10"
- width="180"
- name="hud_check" />
- <check_box
- label="Keep open after saving"
- layout="topleft"
- left="10"
- top_pad="8"
- width="180"
- name="keep_open_check" />
- <check_box
- label="Freeze frame (fullscreen)"
- layout="topleft"
- left="10"
- top_pad="8"
- width="180"
- name="freeze_frame_check" />
- <check_box
- label="Auto-refresh"
- layout="topleft"
- left="10"
- top_pad="8"
- width="180"
- name="auto_snapshot_check" />
+ width="30"/>
+ <panel
+ visible="false"
+ left="250"
+ top="17"
+ name="snapshot_advanced"
+ filename="panel_snapshot_advanced.xml"/>
</floater>
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index 5680b91c05..c39a91281e 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -5294,6 +5294,13 @@ Failed to find [TYPE] named [DESC] in database.
<notification
icon="notify.tga"
+ name="ShareToWebFailed"
+ type="notify">
+ Failed to upload image to web.
+ </notification>
+
+ <notification
+ icon="notify.tga"
name="InvalidWearable"
type="notify">
The item you are trying to wear uses a feature that your Viewer can&apos;t read. Please upgrade your version of [APP_NAME] to wear this item.
diff --git a/indra/newview/skins/default/xui/en/panel_nearby_media.xml b/indra/newview/skins/default/xui/en/panel_nearby_media.xml
index d14712a7fa..53dda1927a 100644
--- a/indra/newview/skins/default/xui/en/panel_nearby_media.xml
+++ b/indra/newview/skins/default/xui/en/panel_nearby_media.xml
@@ -2,34 +2,34 @@
<panel
can_resize="true"
can_close="false"
- mouse_opaque="true"
- bg_opaque_image="Volume_Background"
- bg_alpha_image="Volume_Background"
- background_opaque="true"
+ bg_opaque_image="Volume_Background"
+ bg_alpha_image="Volume_Background"
+ background_opaque="true"
background_visible="true"
layout="topleft"
width="270"
- height="235"
+ height="230"
name="nearby_media"
help_topic="nearby_media">
+ <string name="media_item_count_format">(%ld media items)</string>
<string name="empty_item_text">&lt;empty&gt;</string>
<string name="parcel_media_name">Parcel Streaming Media</string>
<string name="parcel_audio_name">Parcel Streaming Audio</string>
<string name="playing_suffix">(playing)</string>
<panel
bevel_style="in"
- background_visible="false"
+ background_visible="false"
follows="left|right|top"
top="0"
- height="30"
+ height="35"
name="minimized_controls"
left="0">
<button
name="all_nearby_media_disable_btn"
follows="left"
tool_tip="Turn all nearby media off"
- left="15"
- width="60"
+ left="8"
+ width="66"
height="22"
label="Stop All">
<button.commit_callback
@@ -40,7 +40,7 @@
follows="left"
tool_tip="Turn all nearby media on"
left_pad="4"
- width="60"
+ width="66"
height="22"
label="Start All">
<button.commit_callback
@@ -68,8 +68,8 @@
follows="right"
tool_tip="Advanced Controls"
top_delta="0"
- right="-10"
- width="60"
+ right="-8"
+ width="66"
height="22"
toggle="true"
label="More &gt;&gt;"
@@ -95,7 +95,6 @@
follows="top|left"
font="SansSerif"
left="10"
- name="nearby_media"
width="100">
Nearby Media
</text>
@@ -106,7 +105,6 @@
font="SansSerif"
top_pad="15"
left="10"
- name="show"
width="40">
Show:
</text>
@@ -135,7 +133,6 @@
name="OnOthers" />
</combo_box>
<scroll_list
- name="media_list"
follows="left|top|bottom|right"
column_padding="0"
height="105"
@@ -144,7 +141,8 @@
bg_stripe_color="0.25 0.25 0.25 0.25"
top_pad="8"
left="10"
- right="-10">
+ right="-10"
+ name="media_list">
<scroll_list.columns
type="checkbox"
width="-1"
@@ -181,7 +179,6 @@
top_pad="5"
height="30"
left="10"
- name="media_controls_panel"
right="-10">
<layout_stack
name="media_controls"
@@ -190,12 +187,14 @@
height="26"
layout="topleft"
top="4"
- left="10"
+ left="8"
right="-10"
border_size="0"
+ mouse_opaque="false"
orientation="horizontal">
<layout_panel
name="stop"
+ mouse_opaque="false"
auto_resize="false"
user_resize="false"
layout="topleft"
@@ -223,6 +222,7 @@
</layout_panel>
<layout_panel
name="play"
+ mouse_opaque="false"
auto_resize="false"
user_resize="false"
layout="topleft"
@@ -250,6 +250,7 @@
</layout_panel>
<layout_panel
name="pause"
+ mouse_opaque="false"
auto_resize="false"
user_resize="false"
layout="topleft"
@@ -276,6 +277,7 @@
</layout_panel>
<layout_panel
name="volume_slider_ctrl"
+ mouse_opaque="false"
auto_resize="true"
user_resize="false"
follows="left|right"
@@ -300,6 +302,7 @@
</layout_panel>
<layout_panel
name="mute"
+ mouse_opaque="false"
auto_resize="false"
user_resize="false"
layout="topleft"
@@ -328,6 +331,7 @@
</layout_panel>
<layout_panel
name="zoom"
+ mouse_opaque="false"
auto_resize="false"
user_resize="false"
layout="topleft"
@@ -355,6 +359,7 @@
</layout_panel>
<layout_panel
name="unzoom"
+ mouse_opaque="false"
auto_resize="false"
user_resize="false"
layout="topleft"
@@ -383,6 +388,7 @@
<layout_panel
name="right_bookend"
width="0"
+ mouse_opaque="false"
user_resize="false" />
</layout_stack>
</panel>