diff options
Diffstat (limited to 'linden/indra/newview/llagent.cpp')
-rw-r--r-- | linden/indra/newview/llagent.cpp | 278 |
1 files changed, 175 insertions, 103 deletions
diff --git a/linden/indra/newview/llagent.cpp b/linden/indra/newview/llagent.cpp index d268397..2237d67 100644 --- a/linden/indra/newview/llagent.cpp +++ b/linden/indra/newview/llagent.cpp | |||
@@ -80,6 +80,7 @@ | |||
80 | #include "llfloatertools.h" | 80 | #include "llfloatertools.h" |
81 | #include "llfloaterworldmap.h" | 81 | #include "llfloaterworldmap.h" |
82 | #include "llgroupmgr.h" | 82 | #include "llgroupmgr.h" |
83 | #include "llhomelocationresponder.h" | ||
83 | #include "llhudeffectlookat.h" | 84 | #include "llhudeffectlookat.h" |
84 | #include "llhudmanager.h" | 85 | #include "llhudmanager.h" |
85 | #include "llinventorymodel.h" | 86 | #include "llinventorymodel.h" |
@@ -90,6 +91,7 @@ | |||
90 | #include "llmoveview.h" | 91 | #include "llmoveview.h" |
91 | #include "llnotify.h" | 92 | #include "llnotify.h" |
92 | #include "llquantize.h" | 93 | #include "llquantize.h" |
94 | #include "llsdutil.h" | ||
93 | #include "llselectmgr.h" | 95 | #include "llselectmgr.h" |
94 | #include "llsky.h" | 96 | #include "llsky.h" |
95 | #include "llrendersphere.h" | 97 | #include "llrendersphere.h" |
@@ -445,7 +447,7 @@ void LLAgent::init() | |||
445 | mCameraFocusOffsetTarget = LLVector4(gSavedSettings.getVector3("CameraOffsetBuild")); | 447 | mCameraFocusOffsetTarget = LLVector4(gSavedSettings.getVector3("CameraOffsetBuild")); |
446 | mCameraOffsetDefault = gSavedSettings.getVector3("CameraOffsetDefault"); | 448 | mCameraOffsetDefault = gSavedSettings.getVector3("CameraOffsetDefault"); |
447 | // mCameraOffsetNorm = mCameraOffsetDefault; | 449 | // mCameraOffsetNorm = mCameraOffsetDefault; |
448 | // mCameraOffsetNorm.normVec(); | 450 | // mCameraOffsetNorm.normalize(); |
449 | mCameraCollidePlane.clearVec(); | 451 | mCameraCollidePlane.clearVec(); |
450 | mCurrentCameraDistance = mCameraOffsetDefault.magVec(); | 452 | mCurrentCameraDistance = mCameraOffsetDefault.magVec(); |
451 | mTargetCameraDistance = mCurrentCameraDistance; | 453 | mTargetCameraDistance = mCurrentCameraDistance; |
@@ -490,7 +492,7 @@ LLAgent::~LLAgent() | |||
490 | //----------------------------------------------------------------------------- | 492 | //----------------------------------------------------------------------------- |
491 | // resetView() | 493 | // resetView() |
492 | //----------------------------------------------------------------------------- | 494 | //----------------------------------------------------------------------------- |
493 | void LLAgent::resetView(BOOL reset_camera) | 495 | void LLAgent::resetView(BOOL reset_camera, BOOL change_camera) |
494 | { | 496 | { |
495 | if (mAutoPilot) | 497 | if (mAutoPilot) |
496 | { | 498 | { |
@@ -515,6 +517,30 @@ void LLAgent::resetView(BOOL reset_camera) | |||
515 | gMenuHolder->hideMenus(); | 517 | gMenuHolder->hideMenus(); |
516 | } | 518 | } |
517 | 519 | ||
520 | if (change_camera && !gSavedSettings.getBOOL("FreezeTime")) | ||
521 | { | ||
522 | changeCameraToDefault(); | ||
523 | |||
524 | if (LLViewerJoystick::getInstance()->getOverrideCamera()) | ||
525 | { | ||
526 | handle_toggle_flycam(); | ||
527 | } | ||
528 | |||
529 | // reset avatar mode from eventual residual motion | ||
530 | if (LLToolMgr::getInstance()->inBuildMode()) | ||
531 | { | ||
532 | LLViewerJoystick::getInstance()->moveAvatar(true); | ||
533 | } | ||
534 | |||
535 | gFloaterTools->close(); | ||
536 | |||
537 | gViewerWindow->showCursor(); | ||
538 | |||
539 | // Switch back to basic toolset | ||
540 | LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); | ||
541 | } | ||
542 | |||
543 | |||
518 | if (reset_camera && !gSavedSettings.getBOOL("FreezeTime")) | 544 | if (reset_camera && !gSavedSettings.getBOOL("FreezeTime")) |
519 | { | 545 | { |
520 | if (!gViewerWindow->getLeftMouseDown() && cameraThirdPerson()) | 546 | if (!gViewerWindow->getLeftMouseDown() && cameraThirdPerson()) |
@@ -522,7 +548,7 @@ void LLAgent::resetView(BOOL reset_camera) | |||
522 | // leaving mouse-steer mode | 548 | // leaving mouse-steer mode |
523 | LLVector3 agent_at_axis = getAtAxis(); | 549 | LLVector3 agent_at_axis = getAtAxis(); |
524 | agent_at_axis -= projected_vec(agent_at_axis, getReferenceUpVector()); | 550 | agent_at_axis -= projected_vec(agent_at_axis, getReferenceUpVector()); |
525 | agent_at_axis.normVec(); | 551 | agent_at_axis.normalize(); |
526 | gAgent.resetAxes(lerp(getAtAxis(), agent_at_axis, LLCriticalDamp::getInterpolant(0.3f))); | 552 | gAgent.resetAxes(lerp(getAtAxis(), agent_at_axis, LLCriticalDamp::getInterpolant(0.3f))); |
527 | } | 553 | } |
528 | 554 | ||
@@ -1033,7 +1059,7 @@ void LLAgent::slamLookAt(const LLVector3 &look_at) | |||
1033 | { | 1059 | { |
1034 | LLVector3 look_at_norm = look_at; | 1060 | LLVector3 look_at_norm = look_at; |
1035 | look_at_norm.mV[VZ] = 0.f; | 1061 | look_at_norm.mV[VZ] = 0.f; |
1036 | look_at_norm.normVec(); | 1062 | look_at_norm.normalize(); |
1037 | resetAxes(look_at_norm); | 1063 | resetAxes(look_at_norm); |
1038 | } | 1064 | } |
1039 | 1065 | ||
@@ -1294,7 +1320,7 @@ LLQuaternion LLAgent::getQuat() const | |||
1294 | //----------------------------------------------------------------------------- | 1320 | //----------------------------------------------------------------------------- |
1295 | // calcFocusOffset() | 1321 | // calcFocusOffset() |
1296 | //----------------------------------------------------------------------------- | 1322 | //----------------------------------------------------------------------------- |
1297 | LLVector3 LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) | 1323 | LLVector3 LLAgent::calcFocusOffset(LLViewerObject *object, LLVector3 pos_agent, S32 x, S32 y) |
1298 | { | 1324 | { |
1299 | // calculate offset based on view direction | 1325 | // calculate offset based on view direction |
1300 | BOOL is_avatar = object->isAvatar(); | 1326 | BOOL is_avatar = object->isAvatar(); |
@@ -1305,7 +1331,7 @@ LLVector3 LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) | |||
1305 | 1331 | ||
1306 | LLVector3 obj_dir_abs = obj_pos - LLViewerCamera::getInstance()->getOrigin(); | 1332 | LLVector3 obj_dir_abs = obj_pos - LLViewerCamera::getInstance()->getOrigin(); |
1307 | obj_dir_abs.rotVec(inv_obj_rot); | 1333 | obj_dir_abs.rotVec(inv_obj_rot); |
1308 | obj_dir_abs.normVec(); | 1334 | obj_dir_abs.normalize(); |
1309 | obj_dir_abs.abs(); | 1335 | obj_dir_abs.abs(); |
1310 | 1336 | ||
1311 | LLVector3 object_extents = object->getScale(); | 1337 | LLVector3 object_extents = object->getScale(); |
@@ -1330,7 +1356,7 @@ LLVector3 LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) | |||
1330 | { | 1356 | { |
1331 | normal.setVec(obj_matrix.getUpRow4()); | 1357 | normal.setVec(obj_matrix.getUpRow4()); |
1332 | } | 1358 | } |
1333 | normal.normVec(); | 1359 | normal.normalize(); |
1334 | 1360 | ||
1335 | LLVector3d focus_pt_global; | 1361 | LLVector3d focus_pt_global; |
1336 | // RN: should we check return value for valid pick? | 1362 | // RN: should we check return value for valid pick? |
@@ -1397,7 +1423,7 @@ LLVector3 LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) | |||
1397 | if (!is_avatar) | 1423 | if (!is_avatar) |
1398 | { | 1424 | { |
1399 | //unproject relative clicked coordinate from window coordinate using GL | 1425 | //unproject relative clicked coordinate from window coordinate using GL |
1400 | GLint viewport[4]; | 1426 | /*GLint viewport[4]; |
1401 | GLdouble modelview[16]; | 1427 | GLdouble modelview[16]; |
1402 | GLdouble projection[16]; | 1428 | GLdouble projection[16]; |
1403 | GLfloat winX, winY, winZ; | 1429 | GLfloat winX, winY, winZ; |
@@ -1419,11 +1445,9 @@ LLVector3 LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) | |||
1419 | winY = ((F32)y) * gViewerWindow->getDisplayScale().mV[VY]; | 1445 | winY = ((F32)y) * gViewerWindow->getDisplayScale().mV[VY]; |
1420 | glReadPixels( llfloor(winX), llfloor(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ ); | 1446 | glReadPixels( llfloor(winX), llfloor(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ ); |
1421 | 1447 | ||
1422 | gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ); | 1448 | gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);*/ |
1423 | 1449 | ||
1424 | LLVector3 obj_rel((F32)posX, (F32)posY, (F32)posZ); | 1450 | LLVector3 obj_rel = pos_agent - object->getRenderPosition(); |
1425 | obj_rel = obj_rel * object->getRenderMatrix(); | ||
1426 | obj_rel -= object->getRenderPosition(); | ||
1427 | 1451 | ||
1428 | LLVector3 obj_center = LLVector3(0, 0, 0) * object->getRenderMatrix(); | 1452 | LLVector3 obj_center = LLVector3(0, 0, 0) * object->getRenderMatrix(); |
1429 | 1453 | ||
@@ -1534,7 +1558,7 @@ BOOL LLAgent::calcCameraMinDistance(F32 &obj_min_distance) | |||
1534 | camera_offset_target_abs_norm.abs(); | 1558 | camera_offset_target_abs_norm.abs(); |
1535 | // make sure offset is non-zero | 1559 | // make sure offset is non-zero |
1536 | camera_offset_target_abs_norm.clamp(0.001f, F32_MAX); | 1560 | camera_offset_target_abs_norm.clamp(0.001f, F32_MAX); |
1537 | camera_offset_target_abs_norm.normVec(); | 1561 | camera_offset_target_abs_norm.normalize(); |
1538 | 1562 | ||
1539 | // find camera position relative to normalized object extents | 1563 | // find camera position relative to normalized object extents |
1540 | LLVector3 camera_offset_target_scaled = camera_offset_target_abs_norm; | 1564 | LLVector3 camera_offset_target_scaled = camera_offset_target_abs_norm; |
@@ -1580,7 +1604,7 @@ BOOL LLAgent::calcCameraMinDistance(F32 &obj_min_distance) | |||
1580 | LLVector3 object_split_axis; | 1604 | LLVector3 object_split_axis; |
1581 | LLVector3 target_offset_scaled = target_offset_origin; | 1605 | LLVector3 target_offset_scaled = target_offset_origin; |
1582 | target_offset_scaled.abs(); | 1606 | target_offset_scaled.abs(); |
1583 | target_offset_scaled.normVec(); | 1607 | target_offset_scaled.normalize(); |
1584 | target_offset_scaled.mV[VX] /= object_extents.mV[VX]; | 1608 | target_offset_scaled.mV[VX] /= object_extents.mV[VX]; |
1585 | target_offset_scaled.mV[VY] /= object_extents.mV[VY]; | 1609 | target_offset_scaled.mV[VY] /= object_extents.mV[VY]; |
1586 | target_offset_scaled.mV[VZ] /= object_extents.mV[VZ]; | 1610 | target_offset_scaled.mV[VZ] /= object_extents.mV[VZ]; |
@@ -1703,7 +1727,7 @@ void LLAgent::setCameraZoomFraction(F32 fraction) | |||
1703 | else if (cameraCustomizeAvatar()) | 1727 | else if (cameraCustomizeAvatar()) |
1704 | { | 1728 | { |
1705 | LLVector3d camera_offset_dir = mCameraFocusOffsetTarget; | 1729 | LLVector3d camera_offset_dir = mCameraFocusOffsetTarget; |
1706 | camera_offset_dir.normVec(); | 1730 | camera_offset_dir.normalize(); |
1707 | mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, APPEARANCE_MAX_ZOOM, APPEARANCE_MIN_ZOOM); | 1731 | mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, APPEARANCE_MAX_ZOOM, APPEARANCE_MIN_ZOOM); |
1708 | } | 1732 | } |
1709 | else | 1733 | else |
@@ -1730,7 +1754,7 @@ void LLAgent::setCameraZoomFraction(F32 fraction) | |||
1730 | } | 1754 | } |
1731 | 1755 | ||
1732 | LLVector3d camera_offset_dir = mCameraFocusOffsetTarget; | 1756 | LLVector3d camera_offset_dir = mCameraFocusOffsetTarget; |
1733 | camera_offset_dir.normVec(); | 1757 | camera_offset_dir.normalize(); |
1734 | mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, max_zoom, min_zoom); | 1758 | mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, max_zoom, min_zoom); |
1735 | } | 1759 | } |
1736 | startCameraAnimation(); | 1760 | startCameraAnimation(); |
@@ -1777,7 +1801,7 @@ void LLAgent::cameraOrbitOver(const F32 angle) | |||
1777 | else | 1801 | else |
1778 | { | 1802 | { |
1779 | LLVector3 camera_offset_unit(mCameraFocusOffsetTarget); | 1803 | LLVector3 camera_offset_unit(mCameraFocusOffsetTarget); |
1780 | camera_offset_unit.normVec(); | 1804 | camera_offset_unit.normalize(); |
1781 | 1805 | ||
1782 | F32 angle_from_up = acos( camera_offset_unit * getReferenceUpVector() ); | 1806 | F32 angle_from_up = acos( camera_offset_unit * getReferenceUpVector() ); |
1783 | 1807 | ||
@@ -1812,7 +1836,7 @@ void LLAgent::cameraZoomIn(const F32 fraction) | |||
1812 | LLVector3d camera_offset(mCameraFocusOffsetTarget); | 1836 | LLVector3d camera_offset(mCameraFocusOffsetTarget); |
1813 | LLVector3d camera_offset_unit(mCameraFocusOffsetTarget); | 1837 | LLVector3d camera_offset_unit(mCameraFocusOffsetTarget); |
1814 | F32 min_zoom = LAND_MIN_ZOOM; | 1838 | F32 min_zoom = LAND_MIN_ZOOM; |
1815 | F32 current_distance = (F32)camera_offset_unit.normVec(); | 1839 | F32 current_distance = (F32)camera_offset_unit.normalize(); |
1816 | F32 new_distance = current_distance * fraction; | 1840 | F32 new_distance = current_distance * fraction; |
1817 | 1841 | ||
1818 | // Don't move through focus point | 1842 | // Don't move through focus point |
@@ -1881,7 +1905,7 @@ void LLAgent::cameraOrbitIn(const F32 meters) | |||
1881 | { | 1905 | { |
1882 | LLVector3d camera_offset(mCameraFocusOffsetTarget); | 1906 | LLVector3d camera_offset(mCameraFocusOffsetTarget); |
1883 | LLVector3d camera_offset_unit(mCameraFocusOffsetTarget); | 1907 | LLVector3d camera_offset_unit(mCameraFocusOffsetTarget); |
1884 | F32 current_distance = (F32)camera_offset_unit.normVec(); | 1908 | F32 current_distance = (F32)camera_offset_unit.normalize(); |
1885 | F32 new_distance = current_distance - meters; | 1909 | F32 new_distance = current_distance - meters; |
1886 | F32 min_zoom = LAND_MIN_ZOOM; | 1910 | F32 min_zoom = LAND_MIN_ZOOM; |
1887 | 1911 | ||
@@ -1938,6 +1962,8 @@ void LLAgent::cameraPanIn(F32 meters) | |||
1938 | mFocusGlobal = mFocusTargetGlobal; | 1962 | mFocusGlobal = mFocusTargetGlobal; |
1939 | // don't enforce zoom constraints as this is the only way for users to get past them easily | 1963 | // don't enforce zoom constraints as this is the only way for users to get past them easily |
1940 | updateFocusOffset(); | 1964 | updateFocusOffset(); |
1965 | // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx | ||
1966 | mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); | ||
1941 | } | 1967 | } |
1942 | 1968 | ||
1943 | //----------------------------------------------------------------------------- | 1969 | //----------------------------------------------------------------------------- |
@@ -1956,6 +1982,8 @@ void LLAgent::cameraPanLeft(F32 meters) | |||
1956 | 1982 | ||
1957 | cameraZoomIn(1.f); | 1983 | cameraZoomIn(1.f); |
1958 | updateFocusOffset(); | 1984 | updateFocusOffset(); |
1985 | // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind - Nyx | ||
1986 | mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); | ||
1959 | } | 1987 | } |
1960 | 1988 | ||
1961 | //----------------------------------------------------------------------------- | 1989 | //----------------------------------------------------------------------------- |
@@ -1974,6 +2002,8 @@ void LLAgent::cameraPanUp(F32 meters) | |||
1974 | 2002 | ||
1975 | cameraZoomIn(1.f); | 2003 | cameraZoomIn(1.f); |
1976 | updateFocusOffset(); | 2004 | updateFocusOffset(); |
2005 | // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx | ||
2006 | mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal(); | ||
1977 | } | 2007 | } |
1978 | 2008 | ||
1979 | //----------------------------------------------------------------------------- | 2009 | //----------------------------------------------------------------------------- |
@@ -2246,7 +2276,7 @@ void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::s | |||
2246 | mAutoPilotUseRotation = TRUE; | 2276 | mAutoPilotUseRotation = TRUE; |
2247 | mAutoPilotTargetFacing = LLVector3::x_axis * *target_rotation; | 2277 | mAutoPilotTargetFacing = LLVector3::x_axis * *target_rotation; |
2248 | mAutoPilotTargetFacing.mV[VZ] = 0.f; | 2278 | mAutoPilotTargetFacing.mV[VZ] = 0.f; |
2249 | mAutoPilotTargetFacing.normVec(); | 2279 | mAutoPilotTargetFacing.normalize(); |
2250 | } | 2280 | } |
2251 | else | 2281 | else |
2252 | { | 2282 | { |
@@ -2369,8 +2399,8 @@ void LLAgent::autoPilot(F32 *delta_yaw) | |||
2369 | at.mV[VZ] = 0.f; | 2399 | at.mV[VZ] = 0.f; |
2370 | direction.mV[VZ] = 0.f; | 2400 | direction.mV[VZ] = 0.f; |
2371 | 2401 | ||
2372 | at.normVec(); | 2402 | at.normalize(); |
2373 | F32 xy_distance = direction.normVec(); | 2403 | F32 xy_distance = direction.normalize(); |
2374 | 2404 | ||
2375 | F32 yaw = 0.f; | 2405 | F32 yaw = 0.f; |
2376 | if (mAutoPilotTargetDist > mAutoPilotStopDistance) | 2406 | if (mAutoPilotTargetDist > mAutoPilotStopDistance) |
@@ -3529,7 +3559,7 @@ void LLAgent::setupSitCamera() | |||
3529 | // slam agent coordinate frame to proper parent local version | 3559 | // slam agent coordinate frame to proper parent local version |
3530 | LLVector3 at_axis = mFrameAgent.getAtAxis(); | 3560 | LLVector3 at_axis = mFrameAgent.getAtAxis(); |
3531 | at_axis.mV[VZ] = 0.f; | 3561 | at_axis.mV[VZ] = 0.f; |
3532 | at_axis.normVec(); | 3562 | at_axis.normalize(); |
3533 | resetAxes(at_axis * ~parent_rot); | 3563 | resetAxes(at_axis * ~parent_rot); |
3534 | } | 3564 | } |
3535 | } | 3565 | } |
@@ -3665,7 +3695,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) | |||
3665 | // slam agent coordinate frame to proper parent local version | 3695 | // slam agent coordinate frame to proper parent local version |
3666 | LLVector3 at_axis = mFrameAgent.getAtAxis() * parent_rot; | 3696 | LLVector3 at_axis = mFrameAgent.getAtAxis() * parent_rot; |
3667 | at_axis.mV[VZ] = 0.f; | 3697 | at_axis.mV[VZ] = 0.f; |
3668 | at_axis.normVec(); | 3698 | at_axis.normalize(); |
3669 | resetAxes(at_axis * ~parent_rot); | 3699 | resetAxes(at_axis * ~parent_rot); |
3670 | 3700 | ||
3671 | local_camera_offset = local_camera_offset * mFrameAgent.getQuaternion() * parent_rot; | 3701 | local_camera_offset = local_camera_offset * mFrameAgent.getQuaternion() * parent_rot; |
@@ -3686,7 +3716,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) | |||
3686 | offset_dot_norm = 0.001f; | 3716 | offset_dot_norm = 0.001f; |
3687 | } | 3717 | } |
3688 | 3718 | ||
3689 | camera_distance = local_camera_offset.normVec(); | 3719 | camera_distance = local_camera_offset.normalize(); |
3690 | 3720 | ||
3691 | F32 pos_dot_norm = getPosAgentFromGlobal(frame_center_global + head_offset) * plane_normal; | 3721 | F32 pos_dot_norm = getPosAgentFromGlobal(frame_center_global + head_offset) * plane_normal; |
3692 | 3722 | ||
@@ -3710,7 +3740,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) | |||
3710 | } | 3740 | } |
3711 | else | 3741 | else |
3712 | { | 3742 | { |
3713 | camera_distance = local_camera_offset.normVec(); | 3743 | camera_distance = local_camera_offset.normalize(); |
3714 | } | 3744 | } |
3715 | 3745 | ||
3716 | mTargetCameraDistance = llmax(camera_distance, MIN_CAMERA_DISTANCE); | 3746 | mTargetCameraDistance = llmax(camera_distance, MIN_CAMERA_DISTANCE); |
@@ -3745,7 +3775,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) | |||
3745 | { | 3775 | { |
3746 | LLVector3 frame_at_axis = mFrameAgent.getAtAxis(); | 3776 | LLVector3 frame_at_axis = mFrameAgent.getAtAxis(); |
3747 | frame_at_axis -= projected_vec(frame_at_axis, getReferenceUpVector()); | 3777 | frame_at_axis -= projected_vec(frame_at_axis, getReferenceUpVector()); |
3748 | frame_at_axis.normVec(); | 3778 | frame_at_axis.normalize(); |
3749 | 3779 | ||
3750 | //transition smoothly in air mode, to avoid camera pop | 3780 | //transition smoothly in air mode, to avoid camera pop |
3751 | F32 u = (time_in_air - GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME) / GROUND_TO_AIR_CAMERA_TRANSITION_TIME; | 3781 | F32 u = (time_in_air - GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME) / GROUND_TO_AIR_CAMERA_TRANSITION_TIME; |
@@ -3932,7 +3962,7 @@ void LLAgent::resetCamera() | |||
3932 | // Remove any pitch from the avatar | 3962 | // Remove any pitch from the avatar |
3933 | LLVector3 at = mFrameAgent.getAtAxis(); | 3963 | LLVector3 at = mFrameAgent.getAtAxis(); |
3934 | at.mV[VZ] = 0.f; | 3964 | at.mV[VZ] = 0.f; |
3935 | at.normVec(); | 3965 | at.normalize(); |
3936 | gAgent.resetAxes(at); | 3966 | gAgent.resetAxes(at); |
3937 | // have to explicitly clear field of view zoom now | 3967 | // have to explicitly clear field of view zoom now |
3938 | mCameraFOVZoomFactor = 0.f; | 3968 | mCameraFOVZoomFactor = 0.f; |
@@ -4101,7 +4131,10 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate) | |||
4101 | 4131 | ||
4102 | if (mAvatarObject) | 4132 | if (mAvatarObject) |
4103 | { | 4133 | { |
4104 | mAvatarObject->mPelvisp->setPosition(LLVector3::zero); | 4134 | if (!mAvatarObject->mIsSitting) |
4135 | { | ||
4136 | mAvatarObject->mPelvisp->setPosition(LLVector3::zero); | ||
4137 | } | ||
4105 | mAvatarObject->startMotion( ANIM_AGENT_BODY_NOISE ); | 4138 | mAvatarObject->startMotion( ANIM_AGENT_BODY_NOISE ); |
4106 | mAvatarObject->startMotion( ANIM_AGENT_BREATHE_ROT ); | 4139 | mAvatarObject->startMotion( ANIM_AGENT_BREATHE_ROT ); |
4107 | } | 4140 | } |
@@ -4147,14 +4180,14 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate) | |||
4147 | LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); | 4180 | LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); |
4148 | at_axis = LLViewerCamera::getInstance()->getAtAxis(); | 4181 | at_axis = LLViewerCamera::getInstance()->getAtAxis(); |
4149 | at_axis.mV[VZ] = 0.f; | 4182 | at_axis.mV[VZ] = 0.f; |
4150 | at_axis.normVec(); | 4183 | at_axis.normalize(); |
4151 | resetAxes(at_axis * ~obj_rot); | 4184 | resetAxes(at_axis * ~obj_rot); |
4152 | } | 4185 | } |
4153 | else | 4186 | else |
4154 | { | 4187 | { |
4155 | at_axis = mFrameAgent.getAtAxis(); | 4188 | at_axis = mFrameAgent.getAtAxis(); |
4156 | at_axis.mV[VZ] = 0.f; | 4189 | at_axis.mV[VZ] = 0.f; |
4157 | at_axis.normVec(); | 4190 | at_axis.normalize(); |
4158 | resetAxes(at_axis); | 4191 | resetAxes(at_axis); |
4159 | } | 4192 | } |
4160 | 4193 | ||
@@ -4201,7 +4234,7 @@ void LLAgent::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL camera_ani | |||
4201 | // Remove any pitch from the avatar | 4234 | // Remove any pitch from the avatar |
4202 | //LLVector3 at = mFrameAgent.getAtAxis(); | 4235 | //LLVector3 at = mFrameAgent.getAtAxis(); |
4203 | //at.mV[VZ] = 0.f; | 4236 | //at.mV[VZ] = 0.f; |
4204 | //at.normVec(); | 4237 | //at.normalize(); |
4205 | //gAgent.resetAxes(at); | 4238 | //gAgent.resetAxes(at); |
4206 | 4239 | ||
4207 | if( mCameraMode != CAMERA_MODE_CUSTOMIZE_AVATAR ) | 4240 | if( mCameraMode != CAMERA_MODE_CUSTOMIZE_AVATAR ) |
@@ -4228,7 +4261,7 @@ void LLAgent::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL camera_ani | |||
4228 | // Remove any pitch from the avatar | 4261 | // Remove any pitch from the avatar |
4229 | LLVector3 at = mFrameAgent.getAtAxis(); | 4262 | LLVector3 at = mFrameAgent.getAtAxis(); |
4230 | at.mV[VZ] = 0.f; | 4263 | at.mV[VZ] = 0.f; |
4231 | at.normVec(); | 4264 | at.normalize(); |
4232 | gAgent.resetAxes(at); | 4265 | gAgent.resetAxes(at); |
4233 | 4266 | ||
4234 | sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_START); | 4267 | sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_START); |
@@ -4508,14 +4541,14 @@ void LLAgent::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) | |||
4508 | LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); | 4541 | LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); |
4509 | at_axis = LLViewerCamera::getInstance()->getAtAxis(); | 4542 | at_axis = LLViewerCamera::getInstance()->getAtAxis(); |
4510 | at_axis.mV[VZ] = 0.f; | 4543 | at_axis.mV[VZ] = 0.f; |
4511 | at_axis.normVec(); | 4544 | at_axis.normalize(); |
4512 | resetAxes(at_axis * ~obj_rot); | 4545 | resetAxes(at_axis * ~obj_rot); |
4513 | } | 4546 | } |
4514 | else | 4547 | else |
4515 | { | 4548 | { |
4516 | at_axis = LLViewerCamera::getInstance()->getAtAxis(); | 4549 | at_axis = LLViewerCamera::getInstance()->getAtAxis(); |
4517 | at_axis.mV[VZ] = 0.f; | 4550 | at_axis.mV[VZ] = 0.f; |
4518 | at_axis.normVec(); | 4551 | at_axis.normalize(); |
4519 | resetAxes(at_axis); | 4552 | resetAxes(at_axis); |
4520 | } | 4553 | } |
4521 | } | 4554 | } |
@@ -4578,7 +4611,7 @@ void LLAgent::lookAtLastChat() | |||
4578 | { | 4611 | { |
4579 | delta_pos = chatter->getPositionAgent() - getPositionAgent(); | 4612 | delta_pos = chatter->getPositionAgent() - getPositionAgent(); |
4580 | } | 4613 | } |
4581 | delta_pos.normVec(); | 4614 | delta_pos.normalize(); |
4582 | 4615 | ||
4583 | setControlFlags(AGENT_CONTROL_STOP); | 4616 | setControlFlags(AGENT_CONTROL_STOP); |
4584 | 4617 | ||
@@ -4586,9 +4619,9 @@ void LLAgent::lookAtLastChat() | |||
4586 | 4619 | ||
4587 | LLVector3 new_camera_pos = mAvatarObject->mHeadp->getWorldPosition(); | 4620 | LLVector3 new_camera_pos = mAvatarObject->mHeadp->getWorldPosition(); |
4588 | LLVector3 left = delta_pos % LLVector3::z_axis; | 4621 | LLVector3 left = delta_pos % LLVector3::z_axis; |
4589 | left.normVec(); | 4622 | left.normalize(); |
4590 | LLVector3 up = left % delta_pos; | 4623 | LLVector3 up = left % delta_pos; |
4591 | up.normVec(); | 4624 | up.normalize(); |
4592 | new_camera_pos -= delta_pos * 0.4f; | 4625 | new_camera_pos -= delta_pos * 0.4f; |
4593 | new_camera_pos += left * 0.3f; | 4626 | new_camera_pos += left * 0.3f; |
4594 | new_camera_pos += up * 0.2f; | 4627 | new_camera_pos += up * 0.2f; |
@@ -4607,7 +4640,7 @@ void LLAgent::lookAtLastChat() | |||
4607 | else | 4640 | else |
4608 | { | 4641 | { |
4609 | delta_pos = chatter->getRenderPosition() - getPositionAgent(); | 4642 | delta_pos = chatter->getRenderPosition() - getPositionAgent(); |
4610 | delta_pos.normVec(); | 4643 | delta_pos.normalize(); |
4611 | 4644 | ||
4612 | setControlFlags(AGENT_CONTROL_STOP); | 4645 | setControlFlags(AGENT_CONTROL_STOP); |
4613 | 4646 | ||
@@ -4615,9 +4648,9 @@ void LLAgent::lookAtLastChat() | |||
4615 | 4648 | ||
4616 | LLVector3 new_camera_pos = mAvatarObject->mHeadp->getWorldPosition(); | 4649 | LLVector3 new_camera_pos = mAvatarObject->mHeadp->getWorldPosition(); |
4617 | LLVector3 left = delta_pos % LLVector3::z_axis; | 4650 | LLVector3 left = delta_pos % LLVector3::z_axis; |
4618 | left.normVec(); | 4651 | left.normalize(); |
4619 | LLVector3 up = left % delta_pos; | 4652 | LLVector3 up = left % delta_pos; |
4620 | up.normVec(); | 4653 | up.normalize(); |
4621 | new_camera_pos -= delta_pos * 0.4f; | 4654 | new_camera_pos -= delta_pos * 0.4f; |
4622 | new_camera_pos += left * 0.3f; | 4655 | new_camera_pos += left * 0.3f; |
4623 | new_camera_pos += up * 0.2f; | 4656 | new_camera_pos += up * 0.2f; |
@@ -4631,68 +4664,107 @@ void LLAgent::lookAtLastChat() | |||
4631 | 4664 | ||
4632 | const F32 SIT_POINT_EXTENTS = 0.2f; | 4665 | const F32 SIT_POINT_EXTENTS = 0.2f; |
4633 | 4666 | ||
4634 | // Grabs current position | 4667 | void LLAgent::setStartPosition( U32 location_id ) |
4635 | void LLAgent::setStartPosition(U32 location_id) | 4668 | { |
4636 | { | 4669 | LLViewerObject *object; |
4637 | LLViewerObject *object; | 4670 | |
4638 | 4671 | if ( !(gAgentID == LLUUID::null) ) | |
4639 | if ( !(gAgentID == LLUUID::null) ) | 4672 | { |
4640 | { | 4673 | // we've got an ID for an agent viewerobject |
4641 | // we've got an ID for an agent viewerobject | 4674 | object = gObjectList.findObject(gAgentID); |
4642 | object = gObjectList.findObject(gAgentID); | 4675 | if (object) |
4643 | if (object) | 4676 | { |
4644 | { | 4677 | // we've got the viewer object |
4645 | // we've got the viewer object | 4678 | // Sometimes the agent can be velocity interpolated off of |
4646 | // Sometimes the agent can be velocity interpolated off of | 4679 | // this simulator. Clamp it to the region the agent is |
4647 | // this simulator. Clamp it to the region the agent is | 4680 | // in, a little bit in on each side. |
4648 | // in, a little bit in on each side. | 4681 | const F32 INSET = 0.5f; //meters |
4649 | const F32 INSET = 0.5f; //meters | 4682 | const F32 REGION_WIDTH = LLWorld::getInstance()->getRegionWidthInMeters(); |
4650 | const F32 REGION_WIDTH = LLWorld::getInstance()->getRegionWidthInMeters(); | 4683 | |
4651 | 4684 | LLVector3 agent_pos = getPositionAgent(); | |
4652 | LLVector3 agent_pos = getPositionAgent(); | 4685 | LLVector3 agent_look_at = mFrameAgent.getAtAxis(); |
4653 | 4686 | ||
4654 | if (mAvatarObject) | 4687 | if (mAvatarObject) |
4655 | { | 4688 | { |
4656 | // the z height is at the agent's feet | 4689 | // the z height is at the agent's feet |
4657 | agent_pos.mV[VZ] -= 0.5f * mAvatarObject->mBodySize.mV[VZ]; | 4690 | agent_pos.mV[VZ] -= 0.5f * mAvatarObject->mBodySize.mV[VZ]; |
4658 | } | 4691 | } |
4659 | 4692 | ||
4660 | agent_pos.mV[VX] = llclamp( agent_pos.mV[VX], INSET, REGION_WIDTH - INSET ); | 4693 | agent_pos.mV[VX] = llclamp( agent_pos.mV[VX], INSET, REGION_WIDTH - INSET ); |
4661 | agent_pos.mV[VY] = llclamp( agent_pos.mV[VY], INSET, REGION_WIDTH - INSET ); | 4694 | agent_pos.mV[VY] = llclamp( agent_pos.mV[VY], INSET, REGION_WIDTH - INSET ); |
4662 | 4695 | ||
4663 | // Don't let them go below ground, or too high. | 4696 | // Don't let them go below ground, or too high. |
4664 | agent_pos.mV[VZ] = llclamp( agent_pos.mV[VZ], | 4697 | agent_pos.mV[VZ] = llclamp( agent_pos.mV[VZ], |
4665 | mRegionp->getLandHeightRegion( agent_pos ), | 4698 | mRegionp->getLandHeightRegion( agent_pos ), |
4666 | LLWorld::getInstance()->getRegionMaxHeight() ); | 4699 | LLWorld::getInstance()->getRegionMaxHeight() ); |
4667 | 4700 | // Send the CapReq | |
4668 | LLMessageSystem* msg = gMessageSystem; | 4701 | |
4669 | msg->newMessageFast(_PREHASH_SetStartLocationRequest); | 4702 | LLSD body; |
4670 | msg->nextBlockFast( _PREHASH_AgentData); | 4703 | |
4671 | msg->addUUIDFast(_PREHASH_AgentID, getID()); | 4704 | std::string url = gAgent.getRegion()->getCapability("HomeLocation"); |
4672 | msg->addUUIDFast(_PREHASH_SessionID, getSessionID()); | 4705 | std::ostringstream strBuffer; |
4673 | msg->nextBlockFast( _PREHASH_StartLocationData); | 4706 | if( url.empty() ) |
4674 | // corrected by sim | 4707 | { |
4675 | msg->addStringFast(_PREHASH_SimName, ""); | 4708 | LLMessageSystem* msg = gMessageSystem; |
4676 | msg->addU32Fast(_PREHASH_LocationID, location_id); | 4709 | msg->newMessageFast(_PREHASH_SetStartLocationRequest); |
4677 | msg->addVector3Fast(_PREHASH_LocationPos, agent_pos); | 4710 | msg->nextBlockFast( _PREHASH_AgentData); |
4678 | msg->addVector3Fast(_PREHASH_LocationLookAt,mFrameAgent.getAtAxis()); | 4711 | msg->addUUIDFast(_PREHASH_AgentID, getID()); |
4679 | 4712 | msg->addUUIDFast(_PREHASH_SessionID, getSessionID()); | |
4680 | // Reliable only helps when setting home location. Last | 4713 | msg->nextBlockFast( _PREHASH_StartLocationData); |
4681 | // location is sent on quit, and we don't have time to ack | 4714 | // corrected by sim |
4682 | // the packets. | 4715 | msg->addStringFast(_PREHASH_SimName, ""); |
4683 | msg->sendReliable(mRegionp->getHost()); | 4716 | msg->addU32Fast(_PREHASH_LocationID, location_id); |
4684 | 4717 | msg->addVector3Fast(_PREHASH_LocationPos, agent_pos); | |
4685 | const U32 HOME_INDEX = 1; | 4718 | msg->addVector3Fast(_PREHASH_LocationLookAt,mFrameAgent.getAtAxis()); |
4686 | if( HOME_INDEX == location_id ) | 4719 | |
4687 | { | 4720 | // Reliable only helps when setting home location. Last |
4688 | setHomePosRegion( mRegionp->getHandle(), getPositionAgent() ); | 4721 | // location is sent on quit, and we don't have time to ack |
4689 | } | 4722 | // the packets. |
4690 | } | 4723 | msg->sendReliable(mRegionp->getHost()); |
4691 | else | 4724 | |
4692 | { | 4725 | const U32 HOME_INDEX = 1; |
4693 | llinfos << "setStartPosition - Can't find agent viewerobject id " << gAgentID << llendl; | 4726 | if( HOME_INDEX == location_id ) |
4694 | } | 4727 | { |
4695 | } | 4728 | setHomePosRegion( mRegionp->getHandle(), getPositionAgent() ); |
4729 | } | ||
4730 | } | ||
4731 | else | ||
4732 | { | ||
4733 | strBuffer << location_id; | ||
4734 | body["HomeLocation"]["LocationId"] = strBuffer.str(); | ||
4735 | |||
4736 | strBuffer.str(""); | ||
4737 | strBuffer << agent_pos.mV[VX]; | ||
4738 | body["HomeLocation"]["LocationPos"]["X"] = strBuffer.str(); | ||
4739 | |||
4740 | strBuffer.str(""); | ||
4741 | strBuffer << agent_pos.mV[VY]; | ||
4742 | body["HomeLocation"]["LocationPos"]["Y"] = strBuffer.str(); | ||
4743 | |||
4744 | strBuffer.str(""); | ||
4745 | strBuffer << agent_pos.mV[VZ]; | ||
4746 | body["HomeLocation"]["LocationPos"]["Z"] = strBuffer.str(); | ||
4747 | |||
4748 | strBuffer.str(""); | ||
4749 | strBuffer << agent_look_at.mV[VX]; | ||
4750 | body["HomeLocation"]["LocationLookAt"]["X"] = strBuffer.str(); | ||
4751 | |||
4752 | strBuffer.str(""); | ||
4753 | strBuffer << agent_look_at.mV[VY]; | ||
4754 | body["HomeLocation"]["LocationLookAt"]["Y"] = strBuffer.str(); | ||
4755 | |||
4756 | strBuffer.str(""); | ||
4757 | strBuffer << agent_look_at.mV[VZ]; | ||
4758 | body["HomeLocation"]["LocationLookAt"]["Z"] = strBuffer.str(); | ||
4759 | |||
4760 | LLHTTPClient::post( url, body, new LLHomeLocationResponder() ); | ||
4761 | } | ||
4762 | } | ||
4763 | else | ||
4764 | { | ||
4765 | llinfos << "setStartPosition - Can't find agent viewerobject id " << gAgentID << llendl; | ||
4766 | } | ||
4767 | } | ||
4696 | } | 4768 | } |
4697 | 4769 | ||
4698 | void LLAgent::requestStopMotion( LLMotion* motion ) | 4770 | void LLAgent::requestStopMotion( LLMotion* motion ) |