aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llagent.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:42 -0500
committerJacek Antonelli2008-08-15 23:45:42 -0500
commitce28e056c20bf2723f565bbf464b87781ec248a2 (patch)
treeef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/newview/llagent.cpp
parentSecond Life viewer sources 1.19.1.4b (diff)
downloadmeta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz
Second Life viewer sources 1.20.2
Diffstat (limited to 'linden/indra/newview/llagent.cpp')
-rw-r--r--linden/indra/newview/llagent.cpp404
1 files changed, 220 insertions, 184 deletions
diff --git a/linden/indra/newview/llagent.cpp b/linden/indra/newview/llagent.cpp
index 2dab8ff..397a11e 100644
--- a/linden/indra/newview/llagent.cpp
+++ b/linden/indra/newview/llagent.cpp
@@ -51,13 +51,13 @@
51#include "llquaternion.h" 51#include "llquaternion.h"
52#include "v3math.h" 52#include "v3math.h"
53#include "v4math.h" 53#include "v4math.h"
54#include "llsmoothstep.h"
54#include "llsdutil.h" 55#include "llsdutil.h"
55//#include "vmath.h" 56//#include "vmath.h"
56 57
57#include "imageids.h" 58#include "imageids.h"
58#include "llbox.h" 59#include "llbox.h"
59#include "llbutton.h" 60#include "llbutton.h"
60#include "llcameraview.h"
61#include "llcallingcard.h" 61#include "llcallingcard.h"
62#include "llchatbar.h" 62#include "llchatbar.h"
63#include "llconsole.h" 63#include "llconsole.h"
@@ -68,6 +68,7 @@
68#include "llfloateractivespeakers.h" 68#include "llfloateractivespeakers.h"
69#include "llfloateravatarinfo.h" 69#include "llfloateravatarinfo.h"
70#include "llfloaterbuildoptions.h" 70#include "llfloaterbuildoptions.h"
71#include "llfloatercamera.h"
71#include "llfloaterchat.h" 72#include "llfloaterchat.h"
72#include "llfloatercustomize.h" 73#include "llfloatercustomize.h"
73#include "llfloaterdirectory.h" 74#include "llfloaterdirectory.h"
@@ -91,11 +92,10 @@
91#include "llquantize.h" 92#include "llquantize.h"
92#include "llselectmgr.h" 93#include "llselectmgr.h"
93#include "llsky.h" 94#include "llsky.h"
94#include "llsphere.h" 95#include "llrendersphere.h"
95#include "llstatusbar.h" 96#include "llstatusbar.h"
96#include "llimview.h" 97#include "llimview.h"
97#include "lltool.h" 98#include "lltool.h"
98#include "lltoolcomp.h" // for gToolGun
99#include "lltoolfocus.h" 99#include "lltoolfocus.h"
100#include "lltoolgrab.h" 100#include "lltoolgrab.h"
101#include "lltoolmgr.h" 101#include "lltoolmgr.h"
@@ -176,6 +176,8 @@ const F32 AVATAR_ZOOM_MIN_Z_FACTOR = 1.15f;
176 176
177const F32 MAX_CAMERA_DISTANCE_FROM_AGENT = 50.f; 177const F32 MAX_CAMERA_DISTANCE_FROM_AGENT = 50.f;
178 178
179const F32 MAX_CAMERA_SMOOTH_DISTANCE = 20.0f;
180
179const F32 HEAD_BUFFER_SIZE = 0.3f; 181const F32 HEAD_BUFFER_SIZE = 0.3f;
180const F32 CUSTOMIZE_AVATAR_CAMERA_ANIM_SLOP = 0.2f; 182const F32 CUSTOMIZE_AVATAR_CAMERA_ANIM_SLOP = 0.2f;
181 183
@@ -270,8 +272,14 @@ void LLAgentFriendObserver::changed(U32 mask)
270// LLAgent() 272// LLAgent()
271//----------------------------------------------------------------------------- 273//-----------------------------------------------------------------------------
272LLAgent::LLAgent() 274LLAgent::LLAgent()
273: mViewerPort(NET_USE_OS_ASSIGNED_PORT), 275: mDrawDistance( DEFAULT_FAR_PLANE ),
274 mDrawDistance( DEFAULT_FAR_PLANE ), 276
277 mDoubleTapRunTimer(),
278 mDoubleTapRunMode(DOUBLETAP_NONE),
279
280 mbAlwaysRun(false),
281 mbRunning(false),
282
275 mAccess(SIM_ACCESS_PG), 283 mAccess(SIM_ACCESS_PG),
276 mGroupPowers(0), 284 mGroupPowers(0),
277 mGroupID(), 285 mGroupID(),
@@ -303,7 +311,6 @@ LLAgent::LLAgent()
303 mLastCameraMode( CAMERA_MODE_THIRD_PERSON ), 311 mLastCameraMode( CAMERA_MODE_THIRD_PERSON ),
304 mViewsPushed(FALSE), 312 mViewsPushed(FALSE),
305 313
306 mbAlwaysRun(FALSE),
307 mShowAvatar(TRUE), 314 mShowAvatar(TRUE),
308 315
309 mCameraAnimating( FALSE ), 316 mCameraAnimating( FALSE ),
@@ -329,6 +336,8 @@ LLAgent::LLAgent()
329 mFocusObjectOffset(), 336 mFocusObjectOffset(),
330 mFocusDotRadius( 0.1f ), // meters 337 mFocusDotRadius( 0.1f ), // meters
331 mTrackFocusObject(TRUE), 338 mTrackFocusObject(TRUE),
339 mCameraSmoothingLastPositionGlobal(),
340 mCameraSmoothingLastPositionAgent(),
332 341
333 mFrameAgent(), 342 mFrameAgent(),
334 343
@@ -422,14 +431,14 @@ void LLAgent::init()
422{ 431{
423 mDrawDistance = gSavedSettings.getF32("RenderFarClip"); 432 mDrawDistance = gSavedSettings.getF32("RenderFarClip");
424 433
425 gCamera = new LLViewerCamera(); 434 // *Note: this is where LLViewerCamera::getInstance() used to be constructed.
426 435
427 gCamera->setView(DEFAULT_FIELD_OF_VIEW); 436 LLViewerCamera::getInstance()->setView(DEFAULT_FIELD_OF_VIEW);
428 // Leave at 0.1 meters until we have real near clip management 437 // Leave at 0.1 meters until we have real near clip management
429 gCamera->setNear(0.1f); 438 LLViewerCamera::getInstance()->setNear(0.1f);
430 gCamera->setFar(mDrawDistance); // if you want to change camera settings, do so in camera.h 439 LLViewerCamera::getInstance()->setFar(mDrawDistance); // if you want to change camera settings, do so in camera.h
431 gCamera->setAspect( gViewerWindow->getDisplayAspectRatio() ); // default, overridden in LLViewerWindow::reshape 440 LLViewerCamera::getInstance()->setAspect( gViewerWindow->getDisplayAspectRatio() ); // default, overridden in LLViewerWindow::reshape
432 gCamera->setViewHeightInPixels(768); // default, overridden in LLViewerWindow::reshape 441 LLViewerCamera::getInstance()->setViewHeightInPixels(768); // default, overridden in LLViewerWindow::reshape
433 442
434 setFlying( gSavedSettings.getBOOL("FlyingAtExit") ); 443 setFlying( gSavedSettings.getBOOL("FlyingAtExit") );
435 444
@@ -444,8 +453,6 @@ void LLAgent::init()
444 mTrackFocusObject = gSavedSettings.getBOOL("TrackFocusObject"); 453 mTrackFocusObject = gSavedSettings.getBOOL("TrackFocusObject");
445 454
446// LLDebugVarMessageBox::show("Camera Lag", &CAMERA_FOCUS_HALF_LIFE, 0.5f, 0.01f); 455// LLDebugVarMessageBox::show("Camera Lag", &CAMERA_FOCUS_HALF_LIFE, 0.5f, 0.01f);
447 gSavedSettings.getControl("RenderHideGroupTitle")->addListener(&mHideGroupTitleListener);
448 gSavedSettings.getControl("EffectColor")->addListener(&mEffectColorListener);
449 456
450 mEffectColor = gSavedSettings.getColor4("EffectColor"); 457 mEffectColor = gSavedSettings.getColor4("EffectColor");
451 458
@@ -475,8 +482,7 @@ LLAgent::~LLAgent()
475 delete [] mActiveCacheQueries; 482 delete [] mActiveCacheQueries;
476 mActiveCacheQueries = NULL; 483 mActiveCacheQueries = NULL;
477 484
478 delete gCamera; 485 // *Note: this is where LLViewerCamera::getInstance() used to be deleted.
479 gCamera = NULL;
480} 486}
481 487
482// Change camera back to third person, stop the autopilot, 488// Change camera back to third person, stop the autopilot,
@@ -493,16 +499,16 @@ void LLAgent::resetView(BOOL reset_camera)
493 499
494 if (!gNoRender) 500 if (!gNoRender)
495 { 501 {
496 gSelectMgr->unhighlightAll(); 502 LLSelectMgr::getInstance()->unhighlightAll();
497 503
498 // By popular request, keep land selection while walking around. JC 504 // By popular request, keep land selection while walking around. JC
499 // gParcelMgr->deselectLand(); 505 // LLViewerParcelMgr::getInstance()->deselectLand();
500 506
501 // force deselect when walking and attachment is selected 507 // force deselect when walking and attachment is selected
502 // this is so people don't wig out when their avatar moves without animating 508 // this is so people don't wig out when their avatar moves without animating
503 if (gSelectMgr->getSelection()->isAttachment()) 509 if (LLSelectMgr::getInstance()->getSelection()->isAttachment())
504 { 510 {
505 gSelectMgr->deselectAll(); 511 LLSelectMgr::getInstance()->deselectAll();
506 } 512 }
507 513
508 // Hide all popup menus 514 // Hide all popup menus
@@ -539,7 +545,7 @@ void LLAgent::onAppFocusGained()
539 if (CAMERA_MODE_MOUSELOOK == mCameraMode) 545 if (CAMERA_MODE_MOUSELOOK == mCameraMode)
540 { 546 {
541 changeCameraToDefault(); 547 changeCameraToDefault();
542 gToolMgr->clearSavedTool(); 548 LLToolMgr::getInstance()->clearSavedTool();
543 } 549 }
544} 550}
545 551
@@ -575,7 +581,7 @@ void LLAgent::unlockView()
575//----------------------------------------------------------------------------- 581//-----------------------------------------------------------------------------
576// moveAt() 582// moveAt()
577//----------------------------------------------------------------------------- 583//-----------------------------------------------------------------------------
578void LLAgent::moveAt(S32 direction) 584void LLAgent::moveAt(S32 direction, bool reset)
579{ 585{
580 // age chat timer so it fades more quickly when you are intentionally moving 586 // age chat timer so it fades more quickly when you are intentionally moving
581 ageChat(); 587 ageChat();
@@ -591,7 +597,10 @@ void LLAgent::moveAt(S32 direction)
591 setControlFlags(AGENT_CONTROL_AT_NEG | AGENT_CONTROL_FAST_AT); 597 setControlFlags(AGENT_CONTROL_AT_NEG | AGENT_CONTROL_FAST_AT);
592 } 598 }
593 599
594 resetView(); 600 if (reset)
601 {
602 resetView();
603 }
595} 604}
596 605
597//----------------------------------------------------------------------------- 606//-----------------------------------------------------------------------------
@@ -685,7 +694,7 @@ void LLAgent::moveUp(S32 direction)
685//----------------------------------------------------------------------------- 694//-----------------------------------------------------------------------------
686// moveYaw() 695// moveYaw()
687//----------------------------------------------------------------------------- 696//-----------------------------------------------------------------------------
688void LLAgent::moveYaw(F32 mag) 697void LLAgent::moveYaw(F32 mag, bool reset_view)
689{ 698{
690 mYawKey = mag; 699 mYawKey = mag;
691 700
@@ -698,7 +707,10 @@ void LLAgent::moveYaw(F32 mag)
698 setControlFlags(AGENT_CONTROL_YAW_NEG); 707 setControlFlags(AGENT_CONTROL_YAW_NEG);
699 } 708 }
700 709
701 resetView(); 710 if (reset_view)
711 {
712 resetView();
713 }
702} 714}
703 715
704//----------------------------------------------------------------------------- 716//-----------------------------------------------------------------------------
@@ -724,12 +736,10 @@ BOOL LLAgent::canFly()
724{ 736{
725 if (isGodlike()) return TRUE; 737 if (isGodlike()) return TRUE;
726 738
727 if (!gParcelMgr) return FALSE;
728
729 LLViewerRegion* regionp = getRegion(); 739 LLViewerRegion* regionp = getRegion();
730 if (regionp && regionp->getBlockFly()) return FALSE; 740 if (regionp && regionp->getBlockFly()) return FALSE;
731 741
732 LLParcel* parcel = gParcelMgr->getAgentParcel(); 742 LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
733 if (!parcel) return FALSE; 743 if (!parcel) return FALSE;
734 744
735 // Allow owners to fly on their own land. 745 // Allow owners to fly on their own land.
@@ -764,20 +774,17 @@ void LLAgent::setFlying(BOOL fly)
764 if (fly) 774 if (fly)
765 { 775 {
766 BOOL was_flying = getFlying(); 776 BOOL was_flying = getFlying();
767 if (gParcelMgr) 777 if (!canFly() && !was_flying)
768 { 778 {
769 if (!canFly() && !was_flying) 779 // parcel doesn't let you start fly
770 { 780 // gods can always fly
771 // parcel doesn't let you start fly 781 // and it's OK if you're already flying
772 // gods can always fly 782 make_ui_sound("UISndBadKeystroke");
773 // and it's OK if you're already flying 783 return;
774 make_ui_sound("UISndBadKeystroke");
775 return;
776 }
777 } 784 }
778 if( !was_flying ) 785 if( !was_flying )
779 { 786 {
780 gViewerStats->incStat(LLViewerStats::ST_FLY_COUNT); 787 LLViewerStats::getInstance()->incStat(LLViewerStats::ST_FLY_COUNT);
781 } 788 }
782 setControlFlags(AGENT_CONTROL_FLY); 789 setControlFlags(AGENT_CONTROL_FLY);
783 gSavedSettings.setBOOL("FlyBtnState", TRUE); 790 gSavedSettings.setBOOL("FlyBtnState", TRUE);
@@ -831,12 +838,12 @@ void LLAgent::setRegion(LLViewerRegion *regionp)
831 delta.setVec(regionp->getOriginGlobal() - mRegionp->getOriginGlobal()); 838 delta.setVec(regionp->getOriginGlobal() - mRegionp->getOriginGlobal());
832 839
833 setPositionAgent(getPositionAgent() - delta); 840 setPositionAgent(getPositionAgent() - delta);
834 LLVector3 camera_position_agent = gCamera->getOrigin(); 841
835 842 LLVector3 camera_position_agent = LLViewerCamera::getInstance()->getOrigin();
836 gCamera->setOrigin(camera_position_agent - delta); 843 LLViewerCamera::getInstance()->setOrigin(camera_position_agent - delta);
837 844
838 // Update all of the regions. 845 // Update all of the regions.
839 gWorldPointer->updateAgentOffset(agent_offset_global); 846 LLWorld::getInstance()->updateAgentOffset(agent_offset_global);
840 847
841 // Hack to keep sky in the agent's region, otherwise it may get deleted - DJS 08/02/02 848 // Hack to keep sky in the agent's region, otherwise it may get deleted - DJS 08/02/02
842 // *TODO: possibly refactor into gSky->setAgentRegion(regionp)? -Brad 849 // *TODO: possibly refactor into gSky->setAgentRegion(regionp)? -Brad
@@ -860,18 +867,18 @@ void LLAgent::setRegion(LLViewerRegion *regionp)
860 delta.setVec(regionp->getOriginGlobal()); 867 delta.setVec(regionp->getOriginGlobal());
861 868
862 setPositionAgent(getPositionAgent() - delta); 869 setPositionAgent(getPositionAgent() - delta);
863 LLVector3 camera_position_agent = gCamera->getOrigin(); 870 LLVector3 camera_position_agent = LLViewerCamera::getInstance()->getOrigin();
864 gCamera->setOrigin(camera_position_agent - delta); 871 LLViewerCamera::getInstance()->setOrigin(camera_position_agent - delta);
865 872
866 // Update all of the regions. 873 // Update all of the regions.
867 gWorldPointer->updateAgentOffset(mAgentOriginGlobal); 874 LLWorld::getInstance()->updateAgentOffset(mAgentOriginGlobal);
868 } 875 }
869 } 876 }
870 mRegionp = regionp; 877 mRegionp = regionp;
871 878
872 // Must shift hole-covering water object locations because local 879 // Must shift hole-covering water object locations because local
873 // coordinate frame changed. 880 // coordinate frame changed.
874 gWorldPointer->updateWaterObjects(); 881 LLWorld::getInstance()->updateWaterObjects();
875 882
876 // keep a list of regions we've been too 883 // keep a list of regions we've been too
877 // this is just an interesting stat, logged at the dataserver 884 // this is just an interesting stat, logged at the dataserver
@@ -879,7 +886,7 @@ void LLAgent::setRegion(LLViewerRegion *regionp)
879 U64 handle = regionp->getHandle(); 886 U64 handle = regionp->getHandle();
880 mRegionsVisited.insert(handle); 887 mRegionsVisited.insert(handle);
881 888
882 gSelectMgr->updateSelectionCenter(); 889 LLSelectMgr::getInstance()->updateSelectionCenter();
883} 890}
884 891
885 892
@@ -1215,7 +1222,16 @@ LLVector3 LLAgent::getReferenceUpVector()
1215void LLAgent::pitch(F32 angle) 1222void LLAgent::pitch(F32 angle)
1216{ 1223{
1217 // don't let user pitch if pointed almost all the way down or up 1224 // don't let user pitch if pointed almost all the way down or up
1218 1225 mFrameAgent.pitch(clampPitchToLimits(angle));
1226}
1227
1228
1229// Radians, positive is forward into ground
1230//-----------------------------------------------------------------------------
1231// clampPitchToLimits()
1232//-----------------------------------------------------------------------------
1233F32 LLAgent::clampPitchToLimits(F32 angle)
1234{
1219 // A dot B = mag(A) * mag(B) * cos(angle between A and B) 1235 // A dot B = mag(A) * mag(B) * cos(angle between A and B)
1220 // so... cos(angle between A and B) = A dot B / mag(A) / mag(B) 1236 // so... cos(angle between A and B) = A dot B / mag(A) / mag(B)
1221 // = A dot B for unit vectors 1237 // = A dot B for unit vectors
@@ -1245,8 +1261,8 @@ void LLAgent::pitch(F32 angle)
1245 { 1261 {
1246 angle = look_up_limit - angle_from_skyward; 1262 angle = look_up_limit - angle_from_skyward;
1247 } 1263 }
1248 1264
1249 mFrameAgent.pitch(angle); 1265 return angle;
1250} 1266}
1251 1267
1252 1268
@@ -1293,7 +1309,7 @@ LLVector3d LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y)
1293 LLVector3 obj_pos = is_avatar ? ((LLVOAvatar*)object)->mPelvisp->getWorldPosition() : object->getRenderPosition(); 1309 LLVector3 obj_pos = is_avatar ? ((LLVOAvatar*)object)->mPelvisp->getWorldPosition() : object->getRenderPosition();
1294 LLQuaternion inv_obj_rot = ~obj_rot; 1310 LLQuaternion inv_obj_rot = ~obj_rot;
1295 1311
1296 LLVector3 obj_dir_abs = obj_pos - gCamera->getOrigin(); 1312 LLVector3 obj_dir_abs = obj_pos - LLViewerCamera::getInstance()->getOrigin();
1297 obj_dir_abs.rotVec(inv_obj_rot); 1313 obj_dir_abs.rotVec(inv_obj_rot);
1298 obj_dir_abs.normVec(); 1314 obj_dir_abs.normVec();
1299 obj_dir_abs.abs(); 1315 obj_dir_abs.abs();
@@ -1327,7 +1343,7 @@ LLVector3d LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y)
1327 gViewerWindow->mousePointOnPlaneGlobal(focus_pt_global, x, y, gAgent.getPosGlobalFromAgent(obj_pos), normal); 1343 gViewerWindow->mousePointOnPlaneGlobal(focus_pt_global, x, y, gAgent.getPosGlobalFromAgent(obj_pos), normal);
1328 LLVector3 focus_pt = gAgent.getPosAgentFromGlobal(focus_pt_global); 1344 LLVector3 focus_pt = gAgent.getPosAgentFromGlobal(focus_pt_global);
1329 // find vector from camera to focus point in object coordinates 1345 // find vector from camera to focus point in object coordinates
1330 LLVector3 camera_focus_vec = focus_pt - gCamera->getOrigin(); 1346 LLVector3 camera_focus_vec = focus_pt - LLViewerCamera::getInstance()->getOrigin();
1331 // convert to object-local space 1347 // convert to object-local space
1332 camera_focus_vec.rotVec(inv_obj_rot); 1348 camera_focus_vec.rotVec(inv_obj_rot);
1333 1349
@@ -1387,7 +1403,6 @@ LLVector3d LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y)
1387 if (!is_avatar) 1403 if (!is_avatar)
1388 { 1404 {
1389 //unproject relative clicked coordinate from window coordinate using GL 1405 //unproject relative clicked coordinate from window coordinate using GL
1390
1391 GLint viewport[4]; 1406 GLint viewport[4];
1392 GLdouble modelview[16]; 1407 GLdouble modelview[16];
1393 GLdouble projection[16]; 1408 GLdouble projection[16];
@@ -1395,14 +1410,14 @@ LLVector3d LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y)
1395 GLdouble posX, posY, posZ; 1410 GLdouble posX, posY, posZ;
1396 1411
1397 // convert our matrices to something that has a multiply that works 1412 // convert our matrices to something that has a multiply that works
1398 glh::matrix4f newModel((F32*)gCamera->getModelview().mMatrix); 1413 glh::matrix4f newModel((F32*)LLViewerCamera::getInstance()->getModelview().mMatrix);
1399 glh::matrix4f tmpObjMat((F32*)obj_matrix.mMatrix); 1414 glh::matrix4f tmpObjMat((F32*)obj_matrix.mMatrix);
1400 newModel *= tmpObjMat; 1415 newModel *= tmpObjMat;
1401 1416
1402 for(U32 i = 0; i < 16; ++i) 1417 for(U32 i = 0; i < 16; ++i)
1403 { 1418 {
1404 modelview[i] = newModel.m[i]; 1419 modelview[i] = newModel.m[i];
1405 projection[i] = gCamera->getProjection().mMatrix[i/4][i%4]; 1420 projection[i] = LLViewerCamera::getInstance()->getProjection().mMatrix[i/4][i%4];
1406 } 1421 }
1407 glGetIntegerv( GL_VIEWPORT, viewport ); 1422 glGetIntegerv( GL_VIEWPORT, viewport );
1408 1423
@@ -1421,8 +1436,8 @@ LLVector3d LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y)
1421 //now that we have the object relative position, we should bias toward the center of the object 1436 //now that we have the object relative position, we should bias toward the center of the object
1422 //based on the distance of the camera to the focus point vs. the distance of the camera to the focus 1437 //based on the distance of the camera to the focus point vs. the distance of the camera to the focus
1423 1438
1424 F32 relDist = llabs(obj_rel * gCamera->getAtAxis()); 1439 F32 relDist = llabs(obj_rel * LLViewerCamera::getInstance()->getAtAxis());
1425 F32 viewDist = dist_vec(obj_center + obj_rel, gCamera->getOrigin()); 1440 F32 viewDist = dist_vec(obj_center + obj_rel, LLViewerCamera::getInstance()->getOrigin());
1426 1441
1427 1442
1428 LLBBox obj_bbox = object->getBoundingBoxAgent(); 1443 LLBBox obj_bbox = object->getBoundingBoxAgent();
@@ -1624,7 +1639,7 @@ BOOL LLAgent::calcCameraMinDistance(F32 &obj_min_distance)
1624 // clamp obj distance to diagonal of 10 by 10 cube 1639 // clamp obj distance to diagonal of 10 by 10 cube
1625 obj_min_distance = llmin(obj_min_distance, 10.f * F_SQRT3); 1640 obj_min_distance = llmin(obj_min_distance, 10.f * F_SQRT3);
1626 1641
1627 obj_min_distance += gCamera->getNear() + (soft_limit ? 0.1f : 0.2f); 1642 obj_min_distance += LLViewerCamera::getInstance()->getNear() + (soft_limit ? 0.1f : 0.2f);
1628 1643
1629 return TRUE; 1644 return TRUE;
1630} 1645}
@@ -1633,7 +1648,7 @@ F32 LLAgent::getCameraZoomFraction()
1633{ 1648{
1634 // 0.f -> camera zoomed all the way out 1649 // 0.f -> camera zoomed all the way out
1635 // 1.f -> camera zoomed all the way in 1650 // 1.f -> camera zoomed all the way in
1636 LLObjectSelectionHandle selection = gSelectMgr->getSelection(); 1651 LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
1637 if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) 1652 if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
1638 { 1653 {
1639 // already [0,1] 1654 // already [0,1]
@@ -1652,9 +1667,9 @@ F32 LLAgent::getCameraZoomFraction()
1652 { 1667 {
1653 F32 min_zoom; 1668 F32 min_zoom;
1654 const F32 DIST_FUDGE = 16.f; // meters 1669 const F32 DIST_FUDGE = 16.f; // meters
1655 F32 max_zoom = gWorldPointer ? llmin(mDrawDistance - DIST_FUDGE, 1670 F32 max_zoom = llmin(mDrawDistance - DIST_FUDGE,
1656 gWorldPointer->getRegionWidthInMeters() - DIST_FUDGE, 1671 LLWorld::getInstance()->getRegionWidthInMeters() - DIST_FUDGE,
1657 MAX_CAMERA_DISTANCE_FROM_AGENT) : MAX_CAMERA_DISTANCE_FROM_AGENT; 1672 MAX_CAMERA_DISTANCE_FROM_AGENT);
1658 1673
1659 F32 distance = (F32)mCameraFocusOffsetTarget.magVec(); 1674 F32 distance = (F32)mCameraFocusOffsetTarget.magVec();
1660 if (mFocusObject.notNull()) 1675 if (mFocusObject.notNull())
@@ -1681,7 +1696,7 @@ void LLAgent::setCameraZoomFraction(F32 fraction)
1681{ 1696{
1682 // 0.f -> camera zoomed all the way out 1697 // 0.f -> camera zoomed all the way out
1683 // 1.f -> camera zoomed all the way in 1698 // 1.f -> camera zoomed all the way in
1684 LLObjectSelectionHandle selection = gSelectMgr->getSelection(); 1699 LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
1685 1700
1686 if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) 1701 if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
1687 { 1702 {
@@ -1702,7 +1717,7 @@ void LLAgent::setCameraZoomFraction(F32 fraction)
1702 F32 min_zoom = LAND_MIN_ZOOM; 1717 F32 min_zoom = LAND_MIN_ZOOM;
1703 const F32 DIST_FUDGE = 16.f; // meters 1718 const F32 DIST_FUDGE = 16.f; // meters
1704 F32 max_zoom = llmin(mDrawDistance - DIST_FUDGE, 1719 F32 max_zoom = llmin(mDrawDistance - DIST_FUDGE,
1705 gWorldPointer->getRegionWidthInMeters() - DIST_FUDGE, 1720 LLWorld::getInstance()->getRegionWidthInMeters() - DIST_FUDGE,
1706 MAX_CAMERA_DISTANCE_FROM_AGENT); 1721 MAX_CAMERA_DISTANCE_FROM_AGENT);
1707 1722
1708 if (mFocusObject.notNull()) 1723 if (mFocusObject.notNull())
@@ -1733,7 +1748,7 @@ void LLAgent::setCameraZoomFraction(F32 fraction)
1733//----------------------------------------------------------------------------- 1748//-----------------------------------------------------------------------------
1734void LLAgent::cameraOrbitAround(const F32 radians) 1749void LLAgent::cameraOrbitAround(const F32 radians)
1735{ 1750{
1736 LLObjectSelectionHandle selection = gSelectMgr->getSelection(); 1751 LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
1737 if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) 1752 if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
1738 { 1753 {
1739 // do nothing for hud selection 1754 // do nothing for hud selection
@@ -1756,7 +1771,7 @@ void LLAgent::cameraOrbitAround(const F32 radians)
1756//----------------------------------------------------------------------------- 1771//-----------------------------------------------------------------------------
1757void LLAgent::cameraOrbitOver(const F32 angle) 1772void LLAgent::cameraOrbitOver(const F32 angle)
1758{ 1773{
1759 LLObjectSelectionHandle selection = gSelectMgr->getSelection(); 1774 LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
1760 if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) 1775 if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
1761 { 1776 {
1762 // do nothing for hud selection 1777 // do nothing for hud selection
@@ -1773,7 +1788,7 @@ void LLAgent::cameraOrbitOver(const F32 angle)
1773 F32 angle_from_up = acos( camera_offset_unit * getReferenceUpVector() ); 1788 F32 angle_from_up = acos( camera_offset_unit * getReferenceUpVector() );
1774 1789
1775 LLVector3d left_axis; 1790 LLVector3d left_axis;
1776 left_axis.setVec(gCamera->getLeftAxis()); 1791 left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis());
1777 F32 new_angle = llclamp(angle_from_up - angle, 1.f * DEG_TO_RAD, 179.f * DEG_TO_RAD); 1792 F32 new_angle = llclamp(angle_from_up - angle, 1.f * DEG_TO_RAD, 179.f * DEG_TO_RAD);
1778 mCameraFocusOffsetTarget.rotVec(angle_from_up - new_angle, left_axis); 1793 mCameraFocusOffsetTarget.rotVec(angle_from_up - new_angle, left_axis);
1779 1794
@@ -1791,7 +1806,7 @@ void LLAgent::cameraZoomIn(const F32 fraction)
1791 return; 1806 return;
1792 } 1807 }
1793 1808
1794 LLObjectSelectionHandle selection = gSelectMgr->getSelection(); 1809 LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
1795 if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) 1810 if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
1796 { 1811 {
1797 // just update hud zoom level 1812 // just update hud zoom level
@@ -1826,7 +1841,7 @@ void LLAgent::cameraZoomIn(const F32 fraction)
1826 // Don't zoom too far back 1841 // Don't zoom too far back
1827 const F32 DIST_FUDGE = 16.f; // meters 1842 const F32 DIST_FUDGE = 16.f; // meters
1828 F32 max_distance = llmin(mDrawDistance - DIST_FUDGE, 1843 F32 max_distance = llmin(mDrawDistance - DIST_FUDGE,
1829 gWorldPointer->getRegionWidthInMeters() - DIST_FUDGE ); 1844 LLWorld::getInstance()->getRegionWidthInMeters() - DIST_FUDGE );
1830 1845
1831 if (new_distance > max_distance) 1846 if (new_distance > max_distance)
1832 { 1847 {
@@ -1894,7 +1909,7 @@ void LLAgent::cameraOrbitIn(const F32 meters)
1894 // Don't zoom too far back 1909 // Don't zoom too far back
1895 const F32 DIST_FUDGE = 16.f; // meters 1910 const F32 DIST_FUDGE = 16.f; // meters
1896 F32 max_distance = llmin(mDrawDistance - DIST_FUDGE, 1911 F32 max_distance = llmin(mDrawDistance - DIST_FUDGE,
1897 gWorldPointer->getRegionWidthInMeters() - DIST_FUDGE ); 1912 LLWorld::getInstance()->getRegionWidthInMeters() - DIST_FUDGE );
1898 1913
1899 if (new_distance > max_distance) 1914 if (new_distance > max_distance)
1900 { 1915 {
@@ -1907,7 +1922,7 @@ void LLAgent::cameraOrbitIn(const F32 meters)
1907 1922
1908 if( CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode() ) 1923 if( CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode() )
1909 { 1924 {
1910 llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM ); 1925 new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM );
1911 } 1926 }
1912 1927
1913 // Compute new camera offset 1928 // Compute new camera offset
@@ -1923,7 +1938,7 @@ void LLAgent::cameraOrbitIn(const F32 meters)
1923void LLAgent::cameraPanIn(F32 meters) 1938void LLAgent::cameraPanIn(F32 meters)
1924{ 1939{
1925 LLVector3d at_axis; 1940 LLVector3d at_axis;
1926 at_axis.setVec(gCamera->getAtAxis()); 1941 at_axis.setVec(LLViewerCamera::getInstance()->getAtAxis());
1927 1942
1928 mFocusTargetGlobal += meters * at_axis; 1943 mFocusTargetGlobal += meters * at_axis;
1929 mFocusGlobal = mFocusTargetGlobal; 1944 mFocusGlobal = mFocusTargetGlobal;
@@ -1937,7 +1952,7 @@ void LLAgent::cameraPanIn(F32 meters)
1937void LLAgent::cameraPanLeft(F32 meters) 1952void LLAgent::cameraPanLeft(F32 meters)
1938{ 1953{
1939 LLVector3d left_axis; 1954 LLVector3d left_axis;
1940 left_axis.setVec(gCamera->getLeftAxis()); 1955 left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis());
1941 1956
1942 mFocusTargetGlobal += meters * left_axis; 1957 mFocusTargetGlobal += meters * left_axis;
1943 mFocusGlobal = mFocusTargetGlobal; 1958 mFocusGlobal = mFocusTargetGlobal;
@@ -1951,7 +1966,7 @@ void LLAgent::cameraPanLeft(F32 meters)
1951void LLAgent::cameraPanUp(F32 meters) 1966void LLAgent::cameraPanUp(F32 meters)
1952{ 1967{
1953 LLVector3d up_axis; 1968 LLVector3d up_axis;
1954 up_axis.setVec(gCamera->getUpAxis()); 1969 up_axis.setVec(LLViewerCamera::getInstance()->getUpAxis());
1955 1970
1956 mFocusTargetGlobal += meters * up_axis; 1971 mFocusTargetGlobal += meters * up_axis;
1957 mFocusGlobal = mFocusTargetGlobal; 1972 mFocusGlobal = mFocusTargetGlobal;
@@ -2126,10 +2141,7 @@ void LLAgent::setBusy()
2126 //*TODO:Translate 2141 //*TODO:Translate
2127 gBusyMenu->setLabel(LLString("Set Not Busy")); 2142 gBusyMenu->setLabel(LLString("Set Not Busy"));
2128 } 2143 }
2129 if (gFloaterMute) 2144 LLFloaterMute::getInstance()->updateButtons();
2130 {
2131 gFloaterMute->updateButtons();
2132 }
2133} 2145}
2134 2146
2135//----------------------------------------------------------------------------- 2147//-----------------------------------------------------------------------------
@@ -2144,10 +2156,7 @@ void LLAgent::clearBusy()
2144 //*TODO:Translate 2156 //*TODO:Translate
2145 gBusyMenu->setLabel(LLString("Set Busy")); 2157 gBusyMenu->setLabel(LLString("Set Busy"));
2146 } 2158 }
2147 if (gFloaterMute) 2159 LLFloaterMute::getInstance()->updateButtons();
2148 {
2149 gFloaterMute->updateButtons();
2150 }
2151} 2160}
2152 2161
2153//----------------------------------------------------------------------------- 2162//-----------------------------------------------------------------------------
@@ -2164,7 +2173,7 @@ BOOL LLAgent::getBusy() const
2164//----------------------------------------------------------------------------- 2173//-----------------------------------------------------------------------------
2165void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::string& behavior_name, const LLQuaternion *target_rotation, void (*finish_callback)(BOOL, void *), void *callback_data, F32 stop_distance, F32 rot_threshold) 2174void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::string& behavior_name, const LLQuaternion *target_rotation, void (*finish_callback)(BOOL, void *), void *callback_data, F32 stop_distance, F32 rot_threshold)
2166{ 2175{
2167 if (!gAgent.getAvatarObject() || !gWorldPointer) 2176 if (!gAgent.getAvatarObject())
2168 { 2177 {
2169 return; 2178 return;
2170 } 2179 }
@@ -2184,7 +2193,7 @@ void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::s
2184 LLVector3d intersection; 2193 LLVector3d intersection;
2185 LLVector3 normal; 2194 LLVector3 normal;
2186 LLViewerObject *hit_obj; 2195 LLViewerObject *hit_obj;
2187 F32 heightDelta = gWorldPointer->resolveStepHeightGlobal(NULL, target_global, trace_target, intersection, normal, &hit_obj); 2196 F32 heightDelta = LLWorld::getInstance()->resolveStepHeightGlobal(NULL, target_global, trace_target, intersection, normal, &hit_obj);
2188 2197
2189 if (stop_distance > 0.f) 2198 if (stop_distance > 0.f)
2190 { 2199 {
@@ -2224,7 +2233,7 @@ void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::s
2224 LLVector3 groundNorm; 2233 LLVector3 groundNorm;
2225 LLViewerObject *obj; 2234 LLViewerObject *obj;
2226 2235
2227 gWorldPointer->resolveStepHeightGlobal(NULL, target_global, traceEndPt, targetOnGround, groundNorm, &obj); 2236 LLWorld::getInstance()->resolveStepHeightGlobal(NULL, target_global, traceEndPt, targetOnGround, groundNorm, &obj);
2228 F64 target_height = llmax((F64)gAgent.getAvatarObject()->getPelvisToFoot(), target_global.mdV[VZ] - targetOnGround.mdV[VZ]); 2237 F64 target_height = llmax((F64)gAgent.getAvatarObject()->getPelvisToFoot(), target_global.mdV[VZ] - targetOnGround.mdV[VZ]);
2229 2238
2230 // clamp z value of target to minimum height above ground 2239 // clamp z value of target to minimum height above ground
@@ -2580,10 +2589,7 @@ void LLAgent::updateLookAt(const S32 mouse_x, const S32 mouse_y)
2580 // Move head based on cursor position 2589 // Move head based on cursor position
2581 ELookAtType lookAtType = LOOKAT_TARGET_NONE; 2590 ELookAtType lookAtType = LOOKAT_TARGET_NONE;
2582 LLVector3 headLookAxis; 2591 LLVector3 headLookAxis;
2583 LLCoordFrame frameCamera = *((LLCoordFrame*)gCamera); 2592 LLCoordFrame frameCamera = *((LLCoordFrame*)LLViewerCamera::getInstance());
2584
2585 F32 x_from_center = ((F32) mouse_x / (F32) gViewerWindow->getWindowWidth() ) - 0.5f;
2586 F32 y_from_center = ((F32) mouse_y / (F32) gViewerWindow->getWindowHeight() ) - 0.5f;
2587 2593
2588 if (cameraMouselook()) 2594 if (cameraMouselook())
2589 { 2595 {
@@ -2591,6 +2597,12 @@ void LLAgent::updateLookAt(const S32 mouse_x, const S32 mouse_y)
2591 } 2597 }
2592 else if (cameraThirdPerson()) 2598 else if (cameraThirdPerson())
2593 { 2599 {
2600 // range from -.5 to .5
2601 F32 x_from_center =
2602 ((F32) mouse_x / (F32) gViewerWindow->getWindowWidth() ) - 0.5f;
2603 F32 y_from_center =
2604 ((F32) mouse_y / (F32) gViewerWindow->getWindowHeight() ) - 0.5f;
2605
2594 frameCamera.yaw( - x_from_center * gSavedSettings.getF32("YawFromMousePosition") * DEG_TO_RAD); 2606 frameCamera.yaw( - x_from_center * gSavedSettings.getF32("YawFromMousePosition") * DEG_TO_RAD);
2595 frameCamera.pitch( - y_from_center * gSavedSettings.getF32("PitchFromMousePosition") * DEG_TO_RAD); 2607 frameCamera.pitch( - y_from_center * gSavedSettings.getF32("PitchFromMousePosition") * DEG_TO_RAD);
2596 lookAtType = LOOKAT_TARGET_FREELOOK; 2608 lookAtType = LOOKAT_TARGET_FREELOOK;
@@ -2636,11 +2648,11 @@ void LLAgent::setAvatarObject(LLVOAvatar *avatar)
2636 2648
2637 if (!mLookAt) 2649 if (!mLookAt)
2638 { 2650 {
2639 mLookAt = (LLHUDEffectLookAt *)gHUDManager->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT); 2651 mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT);
2640 } 2652 }
2641 if (!mPointAt) 2653 if (!mPointAt)
2642 { 2654 {
2643 mPointAt = (LLHUDEffectPointAt *)gHUDManager->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT); 2655 mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT);
2644 } 2656 }
2645 2657
2646 if (!mLookAt.isNull()) 2658 if (!mLookAt.isNull())
@@ -2741,7 +2753,7 @@ void LLAgent::clearRenderState(U8 clearstate)
2741//----------------------------------------------------------------------------- 2753//-----------------------------------------------------------------------------
2742U8 LLAgent::getRenderState() 2754U8 LLAgent::getRenderState()
2743{ 2755{
2744 if (gNoRender || gToolMgr == NULL || gSelectMgr == NULL || gKeyboard == NULL) 2756 if (gNoRender || gKeyboard == NULL)
2745 { 2757 {
2746 return 0; 2758 return 0;
2747 } 2759 }
@@ -2753,8 +2765,8 @@ U8 LLAgent::getRenderState()
2753 stopTyping(); 2765 stopTyping();
2754 } 2766 }
2755 2767
2756 if ((!gSelectMgr->getSelection()->isEmpty() && gSelectMgr->shouldShowSelection()) 2768 if ((!LLSelectMgr::getInstance()->getSelection()->isEmpty() && LLSelectMgr::getInstance()->shouldShowSelection())
2757 || gToolMgr->getCurrentTool()->isEditing() ) 2769 || LLToolMgr::getInstance()->getCurrentTool()->isEditing() )
2758 { 2770 {
2759 setRenderState(AGENT_STATE_EDITING); 2771 setRenderState(AGENT_STATE_EDITING);
2760 } 2772 }
@@ -2796,7 +2808,7 @@ void LLAgent::endAnimationUpdateUI()
2796 gMenuBarView->setVisible(TRUE); 2808 gMenuBarView->setVisible(TRUE);
2797 gStatusBar->setVisibleForMouselook(true); 2809 gStatusBar->setVisibleForMouselook(true);
2798 2810
2799 gToolMgr->setCurrentToolset(gBasicToolset); 2811 LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
2800 2812
2801 // Only pop if we have pushed... 2813 // Only pop if we have pushed...
2802 if (TRUE == mViewsPushed) 2814 if (TRUE == mViewsPushed)
@@ -2844,7 +2856,7 @@ void LLAgent::endAnimationUpdateUI()
2844 { 2856 {
2845 // make sure we ask to save changes 2857 // make sure we ask to save changes
2846 2858
2847 gToolMgr->setCurrentToolset(gBasicToolset); 2859 LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
2848 2860
2849 // HACK: If we're quitting, and we were in customize avatar, don't 2861 // HACK: If we're quitting, and we were in customize avatar, don't
2850 // let the mini-map go visible again. JC 2862 // let the mini-map go visible again. JC
@@ -2887,7 +2899,7 @@ void LLAgent::endAnimationUpdateUI()
2887 // JC - Added for always chat in third person option 2899 // JC - Added for always chat in third person option
2888 gFocusMgr.setKeyboardFocus(NULL); 2900 gFocusMgr.setKeyboardFocus(NULL);
2889 2901
2890 gToolMgr->setCurrentToolset(gMouselookToolset); 2902 LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset);
2891 2903
2892 mViewsPushed = TRUE; 2904 mViewsPushed = TRUE;
2893 2905
@@ -2929,7 +2941,7 @@ void LLAgent::endAnimationUpdateUI()
2929 } 2941 }
2930 if (mAvatarObject->getParent()) 2942 if (mAvatarObject->getParent())
2931 { 2943 {
2932 LLVector3 at_axis = gCamera->getAtAxis(); 2944 LLVector3 at_axis = LLViewerCamera::getInstance()->getAtAxis();
2933 LLViewerObject* root_object = (LLViewerObject*)mAvatarObject->getRoot(); 2945 LLViewerObject* root_object = (LLViewerObject*)mAvatarObject->getRoot();
2934 if (root_object->flagCameraDecoupled()) 2946 if (root_object->flagCameraDecoupled())
2935 { 2947 {
@@ -2945,7 +2957,7 @@ void LLAgent::endAnimationUpdateUI()
2945 } 2957 }
2946 else if (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR) 2958 else if (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR)
2947 { 2959 {
2948 gToolMgr->setCurrentToolset(gFaceEditToolset); 2960 LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset);
2949 2961
2950 gFloaterMap->pushVisible(FALSE); 2962 gFloaterMap->pushVisible(FALSE);
2951 /* 2963 /*
@@ -3028,24 +3040,21 @@ void LLAgent::updateCamera()
3028 } 3040 }
3029 3041
3030 // Update UI with our camera inputs 3042 // Update UI with our camera inputs
3031 if (gFloaterCamera) 3043 LLFloaterCamera::getInstance()->mRotate->setToggleState(
3032 { 3044 mOrbitRightKey > 0.f, // left
3033 gFloaterCamera->mRotate->setToggleState( 3045 mOrbitUpKey > 0.f, // top
3034 mOrbitRightKey > 0.f, // left 3046 mOrbitLeftKey > 0.f, // right
3035 mOrbitUpKey > 0.f, // top 3047 mOrbitDownKey > 0.f); // bottom
3036 mOrbitLeftKey > 0.f, // right 3048
3037 mOrbitDownKey > 0.f); // bottom 3049 LLFloaterCamera::getInstance()->mZoom->setToggleState(
3038 3050 mOrbitInKey > 0.f, // top
3039 gFloaterCamera->mZoom->setToggleState( 3051 mOrbitOutKey > 0.f); // bottom
3040 mOrbitInKey > 0.f, // top 3052
3041 mOrbitOutKey > 0.f); // bottom 3053 LLFloaterCamera::getInstance()->mTrack->setToggleState(
3042 3054 mPanLeftKey > 0.f, // left
3043 gFloaterCamera->mTrack->setToggleState( 3055 mPanUpKey > 0.f, // top
3044 mPanLeftKey > 0.f, // left 3056 mPanRightKey > 0.f, // right
3045 mPanUpKey > 0.f, // top 3057 mPanDownKey > 0.f); // bottom
3046 mPanRightKey > 0.f, // right
3047 mPanDownKey > 0.f); // bottom
3048 }
3049 3058
3050 // Handle camera movement based on keyboard. 3059 // Handle camera movement based on keyboard.
3051 const F32 ORBIT_OVER_RATE = 90.f * DEG_TO_RAD; // radians per second 3060 const F32 ORBIT_OVER_RATE = 90.f * DEG_TO_RAD; // radians per second
@@ -3068,7 +3077,7 @@ void LLAgent::updateCamera()
3068 { 3077 {
3069 F32 input_rate = mOrbitInKey - mOrbitOutKey; 3078 F32 input_rate = mOrbitInKey - mOrbitOutKey;
3070 3079
3071 LLVector3d to_focus = gAgent.getPosGlobalFromAgent(gCamera->getOrigin()) - calcFocusPositionTargetGlobal(); 3080 LLVector3d to_focus = gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()) - calcFocusPositionTargetGlobal();
3072 F32 distance_to_focus = (F32)to_focus.magVec(); 3081 F32 distance_to_focus = (F32)to_focus.magVec();
3073 // Move at distance (in meters) meters per second 3082 // Move at distance (in meters) meters per second
3074 cameraOrbitIn( input_rate * distance_to_focus / gFPSClamped ); 3083 cameraOrbitIn( input_rate * distance_to_focus / gFPSClamped );
@@ -3185,8 +3194,9 @@ void LLAgent::updateCamera()
3185 } 3194 }
3186 3195
3187 // ...adjust position for animation 3196 // ...adjust position for animation
3188 camera_pos_global = lerp(mAnimationCameraStartGlobal, camera_target_global, fraction_of_animation); 3197 F32 smooth_fraction_of_animation = llsmoothstep(0.0f, 1.0f, fraction_of_animation);
3189 mFocusGlobal = lerp(mAnimationFocusStartGlobal, focus_target_global, fraction_of_animation); 3198 camera_pos_global = lerp(mAnimationCameraStartGlobal, camera_target_global, smooth_fraction_of_animation);
3199 mFocusGlobal = lerp(mAnimationFocusStartGlobal, focus_target_global, smooth_fraction_of_animation);
3190 } 3200 }
3191 else 3201 else
3192 { 3202 {
@@ -3205,13 +3215,52 @@ void LLAgent::updateCamera()
3205 getAvatarObject()->updateAttachmentVisibility(mCameraMode); 3215 getAvatarObject()->updateAttachmentVisibility(mCameraMode);
3206 } 3216 }
3207 } 3217 }
3208 else 3218 else
3209 { 3219 {
3210 camera_pos_global = camera_target_global; 3220 camera_pos_global = camera_target_global;
3211 mFocusGlobal = focus_target_global; 3221 mFocusGlobal = focus_target_global;
3212 mShowAvatar = TRUE; 3222 mShowAvatar = TRUE;
3213 } 3223 }
3214 3224
3225 // smoothing
3226 if (TRUE)
3227 {
3228 LLVector3d agent_pos = getPositionGlobal();
3229 LLVector3d camera_pos_agent = camera_pos_global - agent_pos;
3230
3231 if (cameraThirdPerson()) // only smooth in third person mode
3232 {
3233 F32 smoothing = llclampf(1.f - pow(2.f, -4.f * gSavedSettings.getF32("CameraPositionSmoothing") / gFPSClamped));
3234 // we use average FPS instead of LLCriticalDamp b/c exact frame time is jittery
3235
3236
3237 if (!mFocusObject) // we differentiate on avatar mode
3238 {
3239 // for avatar-relative focus, we smooth in avatar space -
3240 // the avatar moves too jerkily w/r/t global space to smooth there.
3241
3242 LLVector3d delta = camera_pos_agent - mCameraSmoothingLastPositionAgent;
3243 if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE) // only smooth over short distances please
3244 {
3245 camera_pos_agent = lerp(camera_pos_agent, mCameraSmoothingLastPositionAgent, smoothing);
3246 camera_pos_global = camera_pos_agent + agent_pos;
3247 }
3248 }
3249 else
3250 {
3251 LLVector3d delta = camera_pos_global - mCameraSmoothingLastPositionGlobal;
3252 if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE) // only smooth over short distances please
3253 {
3254 camera_pos_global = lerp(camera_pos_global, mCameraSmoothingLastPositionGlobal, smoothing);
3255 }
3256 }
3257 }
3258
3259 mCameraSmoothingLastPositionGlobal = camera_pos_global;
3260 mCameraSmoothingLastPositionAgent = camera_pos_agent;
3261 }
3262
3263
3215 mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLCriticalDamp::getInterpolant(FOV_ZOOM_HALF_LIFE)); 3264 mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLCriticalDamp::getInterpolant(FOV_ZOOM_HALF_LIFE));
3216 3265
3217// llinfos << "Current FOV Zoom: " << mCameraCurrentFOVZoomFactor << " Target FOV Zoom: " << mCameraFOVZoomFactor << " Object penetration: " << mFocusObjectDist << llendl; 3266// llinfos << "Current FOV Zoom: " << mCameraCurrentFOVZoomFactor << " Target FOV Zoom: " << mCameraFOVZoomFactor << " Object penetration: " << mFocusObjectDist << llendl;
@@ -3230,15 +3279,15 @@ void LLAgent::updateCamera()
3230 // Move the camera 3279 // Move the camera
3231 3280
3232 //Ventrella 3281 //Ventrella
3233 gCamera->updateCameraLocation(mCameraPositionAgent, mCameraUpVector, focus_agent); 3282 LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, mCameraUpVector, focus_agent);
3234 //gCamera->updateCameraLocation(mCameraPositionAgent, camera_skyward, focus_agent); 3283 //LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, camera_skyward, focus_agent);
3235 //end Ventrella 3284 //end Ventrella
3236 3285
3237 //RN: translate UI offset after camera is oriented properly 3286 //RN: translate UI offset after camera is oriented properly
3238 gCamera->translate(gCamera->getLeftAxis() * ui_offset); 3287 LLViewerCamera::getInstance()->translate(LLViewerCamera::getInstance()->getLeftAxis() * ui_offset);
3239 3288
3240 // Change FOV 3289 // Change FOV
3241 gCamera->setView(gCamera->getDefaultFOV() / (1.f + mCameraCurrentFOVZoomFactor)); 3290 LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / (1.f + mCameraCurrentFOVZoomFactor));
3242 3291
3243 // follow camera when in customize mode 3292 // follow camera when in customize mode
3244 if (cameraCustomizeAvatar()) 3293 if (cameraCustomizeAvatar())
@@ -3250,11 +3299,11 @@ void LLAgent::updateCamera()
3250 if(gVoiceClient && getRegion()) 3299 if(gVoiceClient && getRegion())
3251 { 3300 {
3252 LLMatrix3 rot; 3301 LLMatrix3 rot;
3253 rot.setRows(gCamera->getAtAxis(), gCamera->getLeftAxis (), gCamera->getUpAxis()); 3302 rot.setRows(LLViewerCamera::getInstance()->getAtAxis(), LLViewerCamera::getInstance()->getLeftAxis (), LLViewerCamera::getInstance()->getUpAxis());
3254 3303
3255 // MBW -- XXX -- Setting velocity to 0 for now. May figure it out later... 3304 // MBW -- XXX -- Setting velocity to 0 for now. May figure it out later...
3256 gVoiceClient->setCameraPosition( 3305 gVoiceClient->setCameraPosition(
3257 getRegion()->getPosGlobalFromRegion(gCamera->getOrigin()),// position 3306 getRegion()->getPosGlobalFromRegion(LLViewerCamera::getInstance()->getOrigin()),// position
3258 LLVector3::zero, // velocity 3307 LLVector3::zero, // velocity
3259 rot); // rotation matrix 3308 rot); // rotation matrix
3260 } 3309 }
@@ -3356,7 +3405,7 @@ F32 LLAgent::calcCustomizeAvatarUIOffset( const LLVector3d& camera_pos_global )
3356 3405
3357 // Move the camera so that the avatar isn't covered up by this floater. 3406 // Move the camera so that the avatar isn't covered up by this floater.
3358 F32 fraction_of_fov = 0.5f - (0.5f * (1.f - llmin(1.f, ((F32)rect.getWidth() / (F32)gViewerWindow->getWindowWidth())))); 3407 F32 fraction_of_fov = 0.5f - (0.5f * (1.f - llmin(1.f, ((F32)rect.getWidth() / (F32)gViewerWindow->getWindowWidth()))));
3359 F32 apparent_angle = fraction_of_fov * gCamera->getView() * gCamera->getAspect(); // radians 3408 F32 apparent_angle = fraction_of_fov * LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect(); // radians
3360 F32 offset = tan(apparent_angle); 3409 F32 offset = tan(apparent_angle);
3361 3410
3362 if( rect.mLeft < (gViewerWindow->getWindowWidth() - rect.mRight) ) 3411 if( rect.mLeft < (gViewerWindow->getWindowWidth() - rect.mRight) )
@@ -3496,7 +3545,7 @@ void LLAgent::setupSitCamera()
3496//----------------------------------------------------------------------------- 3545//-----------------------------------------------------------------------------
3497const LLVector3 &LLAgent::getCameraPositionAgent() const 3546const LLVector3 &LLAgent::getCameraPositionAgent() const
3498{ 3547{
3499 return gCamera->getOrigin(); 3548 return LLViewerCamera::getInstance()->getOrigin();
3500} 3549}
3501 3550
3502//----------------------------------------------------------------------------- 3551//-----------------------------------------------------------------------------
@@ -3504,14 +3553,7 @@ const LLVector3 &LLAgent::getCameraPositionAgent() const
3504//----------------------------------------------------------------------------- 3553//-----------------------------------------------------------------------------
3505LLVector3d LLAgent::getCameraPositionGlobal() const 3554LLVector3d LLAgent::getCameraPositionGlobal() const
3506{ 3555{
3507 if (gCamera) 3556 return getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin());
3508 {
3509 return getPosGlobalFromAgent(gCamera->getOrigin());
3510 }
3511 else
3512 {
3513 return (LLVector3d::zero);
3514 }
3515} 3557}
3516 3558
3517//----------------------------------------------------------------------------- 3559//-----------------------------------------------------------------------------
@@ -3761,7 +3803,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit)
3761 3803
3762 if (!gSavedSettings.getBOOL("DisableCameraConstraints") && !gAgent.isGodlike()) 3804 if (!gSavedSettings.getBOOL("DisableCameraConstraints") && !gAgent.isGodlike())
3763 { 3805 {
3764 LLViewerRegion* regionp = gWorldPointer->getRegionFromPosGlobal( 3806 LLViewerRegion* regionp = LLWorld::getInstance()->getRegionFromPosGlobal(
3765 camera_position_global); 3807 camera_position_global);
3766 bool constrain = true; 3808 bool constrain = true;
3767 if(regionp && regionp->canManageEstate()) 3809 if(regionp && regionp->canManageEstate())
@@ -3786,7 +3828,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit)
3786 } 3828 }
3787 3829
3788// JC - Could constrain camera based on parcel stuff here. 3830// JC - Could constrain camera based on parcel stuff here.
3789// LLViewerRegion *regionp = gWorldPointer->getRegionFromPosGlobal(camera_position_global); 3831// LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global);
3790// 3832//
3791// if (regionp && !regionp->mParcelOverlay->isBuildCameraAllowed(regionp->getPosRegionFromGlobal(camera_position_global))) 3833// if (regionp && !regionp->mParcelOverlay->isBuildCameraAllowed(regionp->getPosRegionFromGlobal(camera_position_global)))
3792// { 3834// {
@@ -3799,14 +3841,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit)
3799 // Don't let camera go underground 3841 // Don't let camera go underground
3800 F32 camera_min_off_ground = getCameraMinOffGround(); 3842 F32 camera_min_off_ground = getCameraMinOffGround();
3801 3843
3802 if (gWorldPointer) 3844 camera_land_height = LLWorld::getInstance()->resolveLandHeightGlobal(camera_position_global);
3803 {
3804 camera_land_height = gWorldPointer->resolveLandHeightGlobal(camera_position_global);
3805 }
3806 else
3807 {
3808 camera_land_height = 0.f;
3809 }
3810 3845
3811 if (camera_position_global.mdV[VZ] < camera_land_height + camera_min_off_ground) 3846 if (camera_position_global.mdV[VZ] < camera_land_height + camera_min_off_ground)
3812 { 3847 {
@@ -3842,7 +3877,7 @@ void LLAgent::handleScrollWheel(S32 clicks)
3842 } 3877 }
3843 else 3878 else
3844 { 3879 {
3845 LLObjectSelectionHandle selection = gSelectMgr->getSelection(); 3880 LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
3846 const F32 ROOT_ROOT_TWO = sqrt(F_SQRT2); 3881 const F32 ROOT_ROOT_TWO = sqrt(F_SQRT2);
3847 3882
3848 // Block if camera is animating 3883 // Block if camera is animating
@@ -3922,7 +3957,7 @@ void LLAgent::changeCameraToMouselook(BOOL animate)
3922 // unpause avatar animation 3957 // unpause avatar animation
3923 mPauseRequest = NULL; 3958 mPauseRequest = NULL;
3924 3959
3925 gToolMgr->setCurrentToolset(gMouselookToolset); 3960 LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset);
3926 3961
3927 gSavedSettings.setBOOL("FirstPersonBtnState", FALSE); 3962 gSavedSettings.setBOOL("FirstPersonBtnState", FALSE);
3928 gSavedSettings.setBOOL("MouselookBtnState", TRUE); 3963 gSavedSettings.setBOOL("MouselookBtnState", TRUE);
@@ -3936,7 +3971,7 @@ void LLAgent::changeCameraToMouselook(BOOL animate)
3936 } 3971 }
3937 3972
3938 //gViewerWindow->stopGrab(); 3973 //gViewerWindow->stopGrab();
3939 gSelectMgr->deselectAll(); 3974 LLSelectMgr::getInstance()->deselectAll();
3940 gViewerWindow->hideCursor(); 3975 gViewerWindow->hideCursor();
3941 gViewerWindow->moveCursorToCenter(); 3976 gViewerWindow->moveCursorToCenter();
3942 3977
@@ -4000,11 +4035,11 @@ void LLAgent::changeCameraToFollow(BOOL animate)
4000 mCameraMode = CAMERA_MODE_FOLLOW; 4035 mCameraMode = CAMERA_MODE_FOLLOW;
4001 4036
4002 // bang-in the current focus, position, and up vector of the follow cam 4037 // bang-in the current focus, position, and up vector of the follow cam
4003 mFollowCam.reset( mCameraPositionAgent, gCamera->getPointOfInterest(), LLVector3::z_axis ); 4038 mFollowCam.reset( mCameraPositionAgent, LLViewerCamera::getInstance()->getPointOfInterest(), LLVector3::z_axis );
4004 4039
4005 if (gBasicToolset) 4040 if (gBasicToolset)
4006 { 4041 {
4007 gToolMgr->setCurrentToolset(gBasicToolset); 4042 LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
4008 } 4043 }
4009 4044
4010 if (mAvatarObject) 4045 if (mAvatarObject)
@@ -4073,7 +4108,7 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate)
4073 { 4108 {
4074 if (gBasicToolset) 4109 if (gBasicToolset)
4075 { 4110 {
4076 gToolMgr->setCurrentToolset(gBasicToolset); 4111 LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
4077 } 4112 }
4078 4113
4079 mCameraLag.clearVec(); 4114 mCameraLag.clearVec();
@@ -4098,7 +4133,7 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate)
4098 if (!mAvatarObject.isNull() && mAvatarObject->getParent()) 4133 if (!mAvatarObject.isNull() && mAvatarObject->getParent())
4099 { 4134 {
4100 LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); 4135 LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation();
4101 at_axis = gCamera->getAtAxis(); 4136 at_axis = LLViewerCamera::getInstance()->getAtAxis();
4102 at_axis.mV[VZ] = 0.f; 4137 at_axis.mV[VZ] = 0.f;
4103 at_axis.normVec(); 4138 at_axis.normVec();
4104 resetAxes(at_axis * ~obj_rot); 4139 resetAxes(at_axis * ~obj_rot);
@@ -4133,7 +4168,7 @@ void LLAgent::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL camera_ani
4133 4168
4134 if (gFaceEditToolset) 4169 if (gFaceEditToolset)
4135 { 4170 {
4136 gToolMgr->setCurrentToolset(gFaceEditToolset); 4171 LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset);
4137 } 4172 }
4138 4173
4139 gSavedSettings.setBOOL("FirstPersonBtnState", FALSE); 4174 gSavedSettings.setBOOL("FirstPersonBtnState", FALSE);
@@ -4353,11 +4388,11 @@ void LLAgent::setCameraPosAndFocusGlobal(const LLVector3d& camera_pos, const LLV
4353 if( CAMERA_MODE_CUSTOMIZE_AVATAR == mCameraMode ) 4388 if( CAMERA_MODE_CUSTOMIZE_AVATAR == mCameraMode )
4354 { 4389 {
4355 // Compensate for the fact that the camera has already been offset to make room for LLFloaterCustomize. 4390 // Compensate for the fact that the camera has already been offset to make room for LLFloaterCustomize.
4356 mAnimationCameraStartGlobal -= LLVector3d(gCamera->getLeftAxis() * calcCustomizeAvatarUIOffset( mAnimationCameraStartGlobal )); 4391 mAnimationCameraStartGlobal -= LLVector3d(LLViewerCamera::getInstance()->getLeftAxis() * calcCustomizeAvatarUIOffset( mAnimationCameraStartGlobal ));
4357 } 4392 }
4358 } 4393 }
4359 4394
4360 //gCamera->setOrigin( gAgent.getPosAgentFromGlobal( camera_pos ) ); 4395 //LLViewerCamera::getInstance()->setOrigin( gAgent.getPosAgentFromGlobal( camera_pos ) );
4361 setFocusObject(gObjectList.findObject(object_id)); 4396 setFocusObject(gObjectList.findObject(object_id));
4362 mFocusTargetGlobal = focus; 4397 mFocusTargetGlobal = focus;
4363 mCameraFocusOffsetTarget = camera_pos - focus; 4398 mCameraFocusOffsetTarget = camera_pos - focus;
@@ -4448,14 +4483,14 @@ void LLAgent::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate)
4448 if (!mAvatarObject.isNull() && mAvatarObject->getParent()) 4483 if (!mAvatarObject.isNull() && mAvatarObject->getParent())
4449 { 4484 {
4450 LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); 4485 LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation();
4451 at_axis = gCamera->getAtAxis(); 4486 at_axis = LLViewerCamera::getInstance()->getAtAxis();
4452 at_axis.mV[VZ] = 0.f; 4487 at_axis.mV[VZ] = 0.f;
4453 at_axis.normVec(); 4488 at_axis.normVec();
4454 resetAxes(at_axis * ~obj_rot); 4489 resetAxes(at_axis * ~obj_rot);
4455 } 4490 }
4456 else 4491 else
4457 { 4492 {
4458 at_axis = gCamera->getAtAxis(); 4493 at_axis = LLViewerCamera::getInstance()->getAtAxis();
4459 at_axis.mV[VZ] = 0.f; 4494 at_axis.mV[VZ] = 0.f;
4460 at_axis.normVec(); 4495 at_axis.normVec();
4461 resetAxes(at_axis); 4496 resetAxes(at_axis);
@@ -4473,7 +4508,7 @@ void LLAgent::heardChat(const LLUUID& id)
4473{ 4508{
4474 // log text and voice chat to speaker mgr 4509 // log text and voice chat to speaker mgr
4475 // for keeping track of active speakers, etc. 4510 // for keeping track of active speakers, etc.
4476 gLocalSpeakerMgr->speakerChatted(id); 4511 LLLocalSpeakerMgr::getInstance()->speakerChatted(id);
4477 4512
4478 // don't respond to your own voice 4513 // don't respond to your own voice
4479 if (id == getID()) return; 4514 if (id == getID()) return;
@@ -4583,7 +4618,7 @@ void LLAgent::setStartPosition(U32 location_id)
4583 // this simulator. Clamp it to the region the agent is 4618 // this simulator. Clamp it to the region the agent is
4584 // in, a little bit in on each side. 4619 // in, a little bit in on each side.
4585 const F32 INSET = 0.5f; //meters 4620 const F32 INSET = 0.5f; //meters
4586 const F32 REGION_WIDTH = gWorldPointer->getRegionWidthInMeters(); 4621 const F32 REGION_WIDTH = LLWorld::getInstance()->getRegionWidthInMeters();
4587 4622
4588 LLVector3 agent_pos = getPositionAgent(); 4623 LLVector3 agent_pos = getPositionAgent();
4589 4624
@@ -4599,7 +4634,7 @@ void LLAgent::setStartPosition(U32 location_id)
4599 // Don't let them go below ground, or too high. 4634 // Don't let them go below ground, or too high.
4600 agent_pos.mV[VZ] = llclamp( agent_pos.mV[VZ], 4635 agent_pos.mV[VZ] = llclamp( agent_pos.mV[VZ],
4601 mRegionp->getLandHeightRegion( agent_pos ), 4636 mRegionp->getLandHeightRegion( agent_pos ),
4602 gWorldPointer->getRegionMaxHeight() ); 4637 LLWorld::getInstance()->getRegionMaxHeight() );
4603 4638
4604 LLMessageSystem* msg = gMessageSystem; 4639 LLMessageSystem* msg = gMessageSystem;
4605 msg->newMessageFast(_PREHASH_SetStartLocationRequest); 4640 msg->newMessageFast(_PREHASH_SetStartLocationRequest);
@@ -4889,7 +4924,7 @@ void LLAgent::buildLocationString(std::string& str)
4889 4924
4890 // create a defult name and description for the landmark 4925 // create a defult name and description for the landmark
4891 std::string buffer; 4926 std::string buffer;
4892 if( gParcelMgr->getAgentParcelName().empty() ) 4927 if( LLViewerParcelMgr::getInstance()->getAgentParcelName().empty() )
4893 { 4928 {
4894 // the parcel doesn't have a name 4929 // the parcel doesn't have a name
4895 buffer = llformat("%.32s (%d, %d, %d)", 4930 buffer = llformat("%.32s (%d, %d, %d)",
@@ -4900,7 +4935,7 @@ void LLAgent::buildLocationString(std::string& str)
4900 { 4935 {
4901 // the parcel has a name, so include it in the landmark name 4936 // the parcel has a name, so include it in the landmark name
4902 buffer = llformat("%.32s, %.32s (%d, %d, %d)", 4937 buffer = llformat("%.32s, %.32s (%d, %d, %d)",
4903 gParcelMgr->getAgentParcelName().c_str(), 4938 LLViewerParcelMgr::getInstance()->getAgentParcelName().c_str(),
4904 getRegion()->getName().c_str(), 4939 getRegion()->getName().c_str(),
4905 pos_x, pos_y, pos_z); 4940 pos_x, pos_y, pos_z);
4906 } 4941 }
@@ -4920,7 +4955,7 @@ LLQuaternion LLAgent::getHeadRotation()
4920 } 4955 }
4921 4956
4922 // We must be in mouselook 4957 // We must be in mouselook
4923 LLVector3 look_dir( gCamera->getAtAxis() ); 4958 LLVector3 look_dir( LLViewerCamera::getInstance()->getAtAxis() );
4924 LLVector3 up = look_dir % mFrameAgent.getLeftAxis(); 4959 LLVector3 up = look_dir % mFrameAgent.getLeftAxis();
4925 LLVector3 left = up % look_dir; 4960 LLVector3 left = up % look_dir;
4926 4961
@@ -4990,6 +5025,20 @@ void LLAgent::sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request)
4990 sendReliableMessage(); 5025 sendReliableMessage();
4991} 5026}
4992 5027
5028void LLAgent::sendWalkRun(bool running)
5029{
5030 LLMessageSystem* msgsys = gMessageSystem;
5031 if (msgsys)
5032 {
5033 msgsys->newMessageFast(_PREHASH_SetAlwaysRun);
5034 msgsys->nextBlockFast(_PREHASH_AgentData);
5035 msgsys->addUUIDFast(_PREHASH_AgentID, getID());
5036 msgsys->addUUIDFast(_PREHASH_SessionID, getSessionID());
5037 msgsys->addBOOLFast(_PREHASH_AlwaysRun, BOOL(running) );
5038 sendReliableMessage();
5039 }
5040}
5041
4993void LLAgent::friendsChanged() 5042void LLAgent::friendsChanged()
4994{ 5043{
4995 LLCollectProxyBuddies collector; 5044 LLCollectProxyBuddies collector;
@@ -5147,7 +5196,7 @@ void LLAgent::processAgentDropGroup(LLMessageSystem *msg, void **)
5147 // refresh all group information 5196 // refresh all group information
5148 gAgent.sendAgentDataUpdateRequest(); 5197 gAgent.sendAgentDataUpdateRequest();
5149 5198
5150 gGroupMgr->clearGroupData(group_id); 5199 LLGroupMgr::getInstance()->clearGroupData(group_id);
5151 // close the floater for this group, if any. 5200 // close the floater for this group, if any.
5152 LLFloaterGroupInfo::closeGroup(group_id); 5201 LLFloaterGroupInfo::closeGroup(group_id);
5153 // refresh the group panel of the search window, if necessary. 5202 // refresh the group panel of the search window, if necessary.
@@ -5226,7 +5275,7 @@ class LLAgentDropGroupViewerNode : public LLHTTPNode
5226 // refresh all group information 5275 // refresh all group information
5227 gAgent.sendAgentDataUpdateRequest(); 5276 gAgent.sendAgentDataUpdateRequest();
5228 5277
5229 gGroupMgr->clearGroupData(group_id); 5278 LLGroupMgr::getInstance()->clearGroupData(group_id);
5230 // close the floater for this group, if any. 5279 // close the floater for this group, if any.
5231 LLFloaterGroupInfo::closeGroup(group_id); 5280 LLFloaterGroupInfo::closeGroup(group_id);
5232 // refresh the group panel of the search window, 5281 // refresh the group panel of the search window,
@@ -5687,14 +5736,14 @@ bool LLAgent::teleportCore(bool is_local)
5687 LLFloaterWorldMap::hide(NULL); 5736 LLFloaterWorldMap::hide(NULL);
5688 LLFloaterDirectory::hide(NULL); 5737 LLFloaterDirectory::hide(NULL);
5689 5738
5690 gParcelMgr->deselectLand(); 5739 LLViewerParcelMgr::getInstance()->deselectLand();
5691 5740
5692 // Close all pie menus, deselect land, etc. 5741 // Close all pie menus, deselect land, etc.
5693 // Don't change the camera until we know teleport succeeded. JC 5742 // Don't change the camera until we know teleport succeeded. JC
5694 resetView(FALSE); 5743 resetView(FALSE);
5695 5744
5696 // local logic 5745 // local logic
5697 gViewerStats->incStat(LLViewerStats::ST_TELEPORT_COUNT); 5746 LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TELEPORT_COUNT);
5698 if (!is_local) 5747 if (!is_local)
5699 { 5748 {
5700 gTeleportDisplay = TRUE; 5749 gTeleportDisplay = TRUE;
@@ -5802,7 +5851,7 @@ void LLAgent::teleportCancel()
5802void LLAgent::teleportViaLocation(const LLVector3d& pos_global) 5851void LLAgent::teleportViaLocation(const LLVector3d& pos_global)
5803{ 5852{
5804 LLViewerRegion* regionp = getRegion(); 5853 LLViewerRegion* regionp = getRegion();
5805 LLSimInfo* info = gWorldMap->simInfoFromPosGlobal(pos_global); 5854 LLSimInfo* info = LLWorldMap::getInstance()->simInfoFromPosGlobal(pos_global);
5806 if(regionp && info) 5855 if(regionp && info)
5807 { 5856 {
5808 U32 x_pos; 5857 U32 x_pos;
@@ -6857,7 +6906,7 @@ void LLAgent::sendAgentSetAppearance()
6857 msg->addUUIDFast(_PREHASH_AgentID, getID()); 6906 msg->addUUIDFast(_PREHASH_AgentID, getID());
6858 msg->addUUIDFast(_PREHASH_SessionID, getSessionID()); 6907 msg->addUUIDFast(_PREHASH_SessionID, getSessionID());
6859 6908
6860 // correct for the collisiton tolerance (to make it look like the 6909 // correct for the collision tolerance (to make it look like the
6861 // agent is actually walking on the ground/object) 6910 // agent is actually walking on the ground/object)
6862 // NOTE -- when we start correcting all of the other Havok geometry 6911 // NOTE -- when we start correcting all of the other Havok geometry
6863 // to compensate for the COLLISION_TOLERANCE ugliness we will have 6912 // to compensate for the COLLISION_TOLERANCE ugliness we will have
@@ -7401,19 +7450,6 @@ void LLAgent::userRemoveAllAttachments( void* userdata )
7401 gMessageSystem->sendReliable( gAgent.getRegionHost() ); 7450 gMessageSystem->sendReliable( gAgent.getRegionHost() );
7402} 7451}
7403 7452
7404bool LLAgent::LLHideGroupTitleListener::handleEvent(LLPointer<LLEvent> event, const LLSD &userdata)
7405{
7406 gAgent.setHideGroupTitle(event->getValue());
7407 return true;
7408
7409}
7410
7411bool LLAgent::LLEffectColorListener::handleEvent(LLPointer<LLEvent> event, const LLSD &userdata)
7412{
7413 gAgent.setEffectColor(LLColor4(event->getValue()));
7414 return true;
7415}
7416
7417void LLAgent::observeFriends() 7453void LLAgent::observeFriends()
7418{ 7454{
7419 if(!mFriendObserver) 7455 if(!mFriendObserver)