diff options
author | Steven Bennetts <steve@lindenlab.com> | 2008-04-01 17:45:04 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2008-04-01 17:45:04 +0000 |
commit | 941cb9f4124c9ccfd5c845bc94639fa46df12c3d (patch) | |
tree | e0f525e7bd6cc76d89b2df69c6f1554d191561e8 /indra/newview/llagent.cpp | |
parent | ecec626dec93524f7ef5831a5ba344d6449b99bc (diff) |
merge release@83343 skinning-1-merge@83714 -> release
QAR-424
Diffstat (limited to 'indra/newview/llagent.cpp')
-rw-r--r-- | indra/newview/llagent.cpp | 234 |
1 files changed, 103 insertions, 131 deletions
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 4dab653d19..a9d4e8a2f6 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -96,7 +96,6 @@ #include "llstatusbar.h" #include "llimview.h" #include "lltool.h" -#include "lltoolcomp.h" // for gToolGun #include "lltoolfocus.h" #include "lltoolgrab.h" #include "lltoolmgr.h" @@ -432,14 +431,14 @@ void LLAgent::init() { mDrawDistance = gSavedSettings.getF32("RenderFarClip"); - gCamera = new LLViewerCamera(); + // *Note: this is where LLViewerCamera::getInstance() used to be constructed. - gCamera->setView(DEFAULT_FIELD_OF_VIEW); + LLViewerCamera::getInstance()->setView(DEFAULT_FIELD_OF_VIEW); // Leave at 0.1 meters until we have real near clip management - gCamera->setNear(0.1f); - gCamera->setFar(mDrawDistance); // if you want to change camera settings, do so in camera.h - gCamera->setAspect( gViewerWindow->getDisplayAspectRatio() ); // default, overridden in LLViewerWindow::reshape - gCamera->setViewHeightInPixels(768); // default, overridden in LLViewerWindow::reshape + LLViewerCamera::getInstance()->setNear(0.1f); + LLViewerCamera::getInstance()->setFar(mDrawDistance); // if you want to change camera settings, do so in camera.h + LLViewerCamera::getInstance()->setAspect( gViewerWindow->getDisplayAspectRatio() ); // default, overridden in LLViewerWindow::reshape + LLViewerCamera::getInstance()->setViewHeightInPixels(768); // default, overridden in LLViewerWindow::reshape setFlying( gSavedSettings.getBOOL("FlyingAtExit") ); @@ -483,8 +482,7 @@ LLAgent::~LLAgent() delete [] mActiveCacheQueries; mActiveCacheQueries = NULL; - delete gCamera; - gCamera = NULL; + // *Note: this is where LLViewerCamera::getInstance() used to be deleted. } // Change camera back to third person, stop the autopilot, @@ -501,16 +499,16 @@ void LLAgent::resetView(BOOL reset_camera) if (!gNoRender) { - gSelectMgr->unhighlightAll(); + LLSelectMgr::getInstance()->unhighlightAll(); // By popular request, keep land selection while walking around. JC - // gParcelMgr->deselectLand(); + // LLViewerParcelMgr::getInstance()->deselectLand(); // force deselect when walking and attachment is selected // this is so people don't wig out when their avatar moves without animating - if (gSelectMgr->getSelection()->isAttachment()) + if (LLSelectMgr::getInstance()->getSelection()->isAttachment()) { - gSelectMgr->deselectAll(); + LLSelectMgr::getInstance()->deselectAll(); } // Hide all popup menus @@ -547,7 +545,7 @@ void LLAgent::onAppFocusGained() if (CAMERA_MODE_MOUSELOOK == mCameraMode) { changeCameraToDefault(); - gToolMgr->clearSavedTool(); + LLToolMgr::getInstance()->clearSavedTool(); } } @@ -732,12 +730,10 @@ BOOL LLAgent::canFly() { if (isGodlike()) return TRUE; - if (!gParcelMgr) return FALSE; - LLViewerRegion* regionp = getRegion(); if (regionp && regionp->getBlockFly()) return FALSE; - LLParcel* parcel = gParcelMgr->getAgentParcel(); + LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); if (!parcel) return FALSE; // Allow owners to fly on their own land. @@ -772,20 +768,17 @@ void LLAgent::setFlying(BOOL fly) if (fly) { BOOL was_flying = getFlying(); - if (gParcelMgr) + if (!canFly() && !was_flying) { - if (!canFly() && !was_flying) - { - // parcel doesn't let you start fly - // gods can always fly - // and it's OK if you're already flying - make_ui_sound("UISndBadKeystroke"); - return; - } + // parcel doesn't let you start fly + // gods can always fly + // and it's OK if you're already flying + make_ui_sound("UISndBadKeystroke"); + return; } if( !was_flying ) { - gViewerStats->incStat(LLViewerStats::ST_FLY_COUNT); + LLViewerStats::getInstance()->incStat(LLViewerStats::ST_FLY_COUNT); } setControlFlags(AGENT_CONTROL_FLY); gSavedSettings.setBOOL("FlyBtnState", TRUE); @@ -839,12 +832,12 @@ void LLAgent::setRegion(LLViewerRegion *regionp) delta.setVec(regionp->getOriginGlobal() - mRegionp->getOriginGlobal()); setPositionAgent(getPositionAgent() - delta); - LLVector3 camera_position_agent = gCamera->getOrigin(); - - gCamera->setOrigin(camera_position_agent - delta); + + LLVector3 camera_position_agent = LLViewerCamera::getInstance()->getOrigin(); + LLViewerCamera::getInstance()->setOrigin(camera_position_agent - delta); // Update all of the regions. - gWorldPointer->updateAgentOffset(agent_offset_global); + LLWorld::getInstance()->updateAgentOffset(agent_offset_global); // Hack to keep sky in the agent's region, otherwise it may get deleted - DJS 08/02/02 // *TODO: possibly refactor into gSky->setAgentRegion(regionp)? -Brad @@ -868,18 +861,18 @@ void LLAgent::setRegion(LLViewerRegion *regionp) delta.setVec(regionp->getOriginGlobal()); setPositionAgent(getPositionAgent() - delta); - LLVector3 camera_position_agent = gCamera->getOrigin(); - gCamera->setOrigin(camera_position_agent - delta); + LLVector3 camera_position_agent = LLViewerCamera::getInstance()->getOrigin(); + LLViewerCamera::getInstance()->setOrigin(camera_position_agent - delta); // Update all of the regions. - gWorldPointer->updateAgentOffset(mAgentOriginGlobal); + LLWorld::getInstance()->updateAgentOffset(mAgentOriginGlobal); } } mRegionp = regionp; // Must shift hole-covering water object locations because local // coordinate frame changed. - gWorldPointer->updateWaterObjects(); + LLWorld::getInstance()->updateWaterObjects(); // keep a list of regions we've been too // this is just an interesting stat, logged at the dataserver @@ -887,7 +880,7 @@ void LLAgent::setRegion(LLViewerRegion *regionp) U64 handle = regionp->getHandle(); mRegionsVisited.insert(handle); - gSelectMgr->updateSelectionCenter(); + LLSelectMgr::getInstance()->updateSelectionCenter(); } @@ -1301,7 +1294,7 @@ LLVector3d LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) LLVector3 obj_pos = is_avatar ? ((LLVOAvatar*)object)->mPelvisp->getWorldPosition() : object->getRenderPosition(); LLQuaternion inv_obj_rot = ~obj_rot; - LLVector3 obj_dir_abs = obj_pos - gCamera->getOrigin(); + LLVector3 obj_dir_abs = obj_pos - LLViewerCamera::getInstance()->getOrigin(); obj_dir_abs.rotVec(inv_obj_rot); obj_dir_abs.normVec(); obj_dir_abs.abs(); @@ -1335,7 +1328,7 @@ LLVector3d LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) gViewerWindow->mousePointOnPlaneGlobal(focus_pt_global, x, y, gAgent.getPosGlobalFromAgent(obj_pos), normal); LLVector3 focus_pt = gAgent.getPosAgentFromGlobal(focus_pt_global); // find vector from camera to focus point in object coordinates - LLVector3 camera_focus_vec = focus_pt - gCamera->getOrigin(); + LLVector3 camera_focus_vec = focus_pt - LLViewerCamera::getInstance()->getOrigin(); // convert to object-local space camera_focus_vec.rotVec(inv_obj_rot); @@ -1395,7 +1388,6 @@ LLVector3d LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) if (!is_avatar) { //unproject relative clicked coordinate from window coordinate using GL - GLint viewport[4]; GLdouble modelview[16]; GLdouble projection[16]; @@ -1403,14 +1395,14 @@ LLVector3d LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) GLdouble posX, posY, posZ; // convert our matrices to something that has a multiply that works - glh::matrix4f newModel((F32*)gCamera->getModelview().mMatrix); + glh::matrix4f newModel((F32*)LLViewerCamera::getInstance()->getModelview().mMatrix); glh::matrix4f tmpObjMat((F32*)obj_matrix.mMatrix); newModel *= tmpObjMat; for(U32 i = 0; i < 16; ++i) { modelview[i] = newModel.m[i]; - projection[i] = gCamera->getProjection().mMatrix[i/4][i%4]; + projection[i] = LLViewerCamera::getInstance()->getProjection().mMatrix[i/4][i%4]; } glGetIntegerv( GL_VIEWPORT, viewport ); @@ -1429,8 +1421,8 @@ LLVector3d LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) //now that we have the object relative position, we should bias toward the center of the object //based on the distance of the camera to the focus point vs. the distance of the camera to the focus - F32 relDist = llabs(obj_rel * gCamera->getAtAxis()); - F32 viewDist = dist_vec(obj_center + obj_rel, gCamera->getOrigin()); + F32 relDist = llabs(obj_rel * LLViewerCamera::getInstance()->getAtAxis()); + F32 viewDist = dist_vec(obj_center + obj_rel, LLViewerCamera::getInstance()->getOrigin()); LLBBox obj_bbox = object->getBoundingBoxAgent(); @@ -1632,7 +1624,7 @@ BOOL LLAgent::calcCameraMinDistance(F32 &obj_min_distance) // clamp obj distance to diagonal of 10 by 10 cube obj_min_distance = llmin(obj_min_distance, 10.f * F_SQRT3); - obj_min_distance += gCamera->getNear() + (soft_limit ? 0.1f : 0.2f); + obj_min_distance += LLViewerCamera::getInstance()->getNear() + (soft_limit ? 0.1f : 0.2f); return TRUE; } @@ -1641,7 +1633,7 @@ F32 LLAgent::getCameraZoomFraction() { // 0.f -> camera zoomed all the way out // 1.f -> camera zoomed all the way in - LLObjectSelectionHandle selection = gSelectMgr->getSelection(); + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) { // already [0,1] @@ -1660,9 +1652,9 @@ F32 LLAgent::getCameraZoomFraction() { F32 min_zoom; const F32 DIST_FUDGE = 16.f; // meters - F32 max_zoom = gWorldPointer ? llmin(mDrawDistance - DIST_FUDGE, - gWorldPointer->getRegionWidthInMeters() - DIST_FUDGE, - MAX_CAMERA_DISTANCE_FROM_AGENT) : MAX_CAMERA_DISTANCE_FROM_AGENT; + F32 max_zoom = llmin(mDrawDistance - DIST_FUDGE, + LLWorld::getInstance()->getRegionWidthInMeters() - DIST_FUDGE, + MAX_CAMERA_DISTANCE_FROM_AGENT); F32 distance = (F32)mCameraFocusOffsetTarget.magVec(); if (mFocusObject.notNull()) @@ -1689,7 +1681,7 @@ void LLAgent::setCameraZoomFraction(F32 fraction) { // 0.f -> camera zoomed all the way out // 1.f -> camera zoomed all the way in - LLObjectSelectionHandle selection = gSelectMgr->getSelection(); + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) { @@ -1710,7 +1702,7 @@ void LLAgent::setCameraZoomFraction(F32 fraction) F32 min_zoom = LAND_MIN_ZOOM; const F32 DIST_FUDGE = 16.f; // meters F32 max_zoom = llmin(mDrawDistance - DIST_FUDGE, - gWorldPointer->getRegionWidthInMeters() - DIST_FUDGE, + LLWorld::getInstance()->getRegionWidthInMeters() - DIST_FUDGE, MAX_CAMERA_DISTANCE_FROM_AGENT); if (mFocusObject.notNull()) @@ -1741,7 +1733,7 @@ void LLAgent::setCameraZoomFraction(F32 fraction) //----------------------------------------------------------------------------- void LLAgent::cameraOrbitAround(const F32 radians) { - LLObjectSelectionHandle selection = gSelectMgr->getSelection(); + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) { // do nothing for hud selection @@ -1764,7 +1756,7 @@ void LLAgent::cameraOrbitAround(const F32 radians) //----------------------------------------------------------------------------- void LLAgent::cameraOrbitOver(const F32 angle) { - LLObjectSelectionHandle selection = gSelectMgr->getSelection(); + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) { // do nothing for hud selection @@ -1781,7 +1773,7 @@ void LLAgent::cameraOrbitOver(const F32 angle) F32 angle_from_up = acos( camera_offset_unit * getReferenceUpVector() ); LLVector3d left_axis; - left_axis.setVec(gCamera->getLeftAxis()); + left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis()); F32 new_angle = llclamp(angle_from_up - angle, 1.f * DEG_TO_RAD, 179.f * DEG_TO_RAD); mCameraFocusOffsetTarget.rotVec(angle_from_up - new_angle, left_axis); @@ -1799,7 +1791,7 @@ void LLAgent::cameraZoomIn(const F32 fraction) return; } - LLObjectSelectionHandle selection = gSelectMgr->getSelection(); + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD) { // just update hud zoom level @@ -1834,7 +1826,7 @@ void LLAgent::cameraZoomIn(const F32 fraction) // Don't zoom too far back const F32 DIST_FUDGE = 16.f; // meters F32 max_distance = llmin(mDrawDistance - DIST_FUDGE, - gWorldPointer->getRegionWidthInMeters() - DIST_FUDGE ); + LLWorld::getInstance()->getRegionWidthInMeters() - DIST_FUDGE ); if (new_distance > max_distance) { @@ -1902,7 +1894,7 @@ void LLAgent::cameraOrbitIn(const F32 meters) // Don't zoom too far back const F32 DIST_FUDGE = 16.f; // meters F32 max_distance = llmin(mDrawDistance - DIST_FUDGE, - gWorldPointer->getRegionWidthInMeters() - DIST_FUDGE ); + LLWorld::getInstance()->getRegionWidthInMeters() - DIST_FUDGE ); if (new_distance > max_distance) { @@ -1931,7 +1923,7 @@ void LLAgent::cameraOrbitIn(const F32 meters) void LLAgent::cameraPanIn(F32 meters) { LLVector3d at_axis; - at_axis.setVec(gCamera->getAtAxis()); + at_axis.setVec(LLViewerCamera::getInstance()->getAtAxis()); mFocusTargetGlobal += meters * at_axis; mFocusGlobal = mFocusTargetGlobal; @@ -1945,7 +1937,7 @@ void LLAgent::cameraPanIn(F32 meters) void LLAgent::cameraPanLeft(F32 meters) { LLVector3d left_axis; - left_axis.setVec(gCamera->getLeftAxis()); + left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis()); mFocusTargetGlobal += meters * left_axis; mFocusGlobal = mFocusTargetGlobal; @@ -1959,7 +1951,7 @@ void LLAgent::cameraPanLeft(F32 meters) void LLAgent::cameraPanUp(F32 meters) { LLVector3d up_axis; - up_axis.setVec(gCamera->getUpAxis()); + up_axis.setVec(LLViewerCamera::getInstance()->getUpAxis()); mFocusTargetGlobal += meters * up_axis; mFocusGlobal = mFocusTargetGlobal; @@ -2134,10 +2126,7 @@ void LLAgent::setBusy() //*TODO:Translate gBusyMenu->setLabel(LLString("Set Not Busy")); } - if (gFloaterMute) - { - gFloaterMute->updateButtons(); - } + LLFloaterMute::getInstance()->updateButtons(); } //----------------------------------------------------------------------------- @@ -2152,10 +2141,7 @@ void LLAgent::clearBusy() //*TODO:Translate gBusyMenu->setLabel(LLString("Set Busy")); } - if (gFloaterMute) - { - gFloaterMute->updateButtons(); - } + LLFloaterMute::getInstance()->updateButtons(); } //----------------------------------------------------------------------------- @@ -2172,7 +2158,7 @@ BOOL LLAgent::getBusy() const //----------------------------------------------------------------------------- void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::string& behavior_name, const LLQuaternion *target_rotation, void (*finish_callback)(BOOL, void *), void *callback_data, F32 stop_distance, F32 rot_threshold) { - if (!gAgent.getAvatarObject() || !gWorldPointer) + if (!gAgent.getAvatarObject()) { return; } @@ -2192,7 +2178,7 @@ void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::s LLVector3d intersection; LLVector3 normal; LLViewerObject *hit_obj; - F32 heightDelta = gWorldPointer->resolveStepHeightGlobal(NULL, target_global, trace_target, intersection, normal, &hit_obj); + F32 heightDelta = LLWorld::getInstance()->resolveStepHeightGlobal(NULL, target_global, trace_target, intersection, normal, &hit_obj); if (stop_distance > 0.f) { @@ -2232,7 +2218,7 @@ void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::s LLVector3 groundNorm; LLViewerObject *obj; - gWorldPointer->resolveStepHeightGlobal(NULL, target_global, traceEndPt, targetOnGround, groundNorm, &obj); + LLWorld::getInstance()->resolveStepHeightGlobal(NULL, target_global, traceEndPt, targetOnGround, groundNorm, &obj); F64 target_height = llmax((F64)gAgent.getAvatarObject()->getPelvisToFoot(), target_global.mdV[VZ] - targetOnGround.mdV[VZ]); // clamp z value of target to minimum height above ground @@ -2588,7 +2574,7 @@ void LLAgent::updateLookAt(const S32 mouse_x, const S32 mouse_y) // Move head based on cursor position ELookAtType lookAtType = LOOKAT_TARGET_NONE; LLVector3 headLookAxis; - LLCoordFrame frameCamera = *((LLCoordFrame*)gCamera); + LLCoordFrame frameCamera = *((LLCoordFrame*)LLViewerCamera::getInstance()); F32 x_from_center = ((F32) mouse_x / (F32) gViewerWindow->getWindowWidth() ) - 0.5f; F32 y_from_center = ((F32) mouse_y / (F32) gViewerWindow->getWindowHeight() ) - 0.5f; @@ -2644,11 +2630,11 @@ void LLAgent::setAvatarObject(LLVOAvatar *avatar) if (!mLookAt) { - mLookAt = (LLHUDEffectLookAt *)gHUDManager->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT); + mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT); } if (!mPointAt) { - mPointAt = (LLHUDEffectPointAt *)gHUDManager->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT); + mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT); } if (!mLookAt.isNull()) @@ -2749,7 +2735,7 @@ void LLAgent::clearRenderState(U8 clearstate) //----------------------------------------------------------------------------- U8 LLAgent::getRenderState() { - if (gNoRender || gToolMgr == NULL || gSelectMgr == NULL || gKeyboard == NULL) + if (gNoRender || gKeyboard == NULL) { return 0; } @@ -2761,8 +2747,8 @@ U8 LLAgent::getRenderState() stopTyping(); } - if ((!gSelectMgr->getSelection()->isEmpty() && gSelectMgr->shouldShowSelection()) - || gToolMgr->getCurrentTool()->isEditing() ) + if ((!LLSelectMgr::getInstance()->getSelection()->isEmpty() && LLSelectMgr::getInstance()->shouldShowSelection()) + || LLToolMgr::getInstance()->getCurrentTool()->isEditing() ) { setRenderState(AGENT_STATE_EDITING); } @@ -2804,7 +2790,7 @@ void LLAgent::endAnimationUpdateUI() gMenuBarView->setVisible(TRUE); gStatusBar->setVisibleForMouselook(true); - gToolMgr->setCurrentToolset(gBasicToolset); + LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); // Only pop if we have pushed... if (TRUE == mViewsPushed) @@ -2852,7 +2838,7 @@ void LLAgent::endAnimationUpdateUI() { // make sure we ask to save changes - gToolMgr->setCurrentToolset(gBasicToolset); + LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); // HACK: If we're quitting, and we were in customize avatar, don't // let the mini-map go visible again. JC @@ -2895,7 +2881,7 @@ void LLAgent::endAnimationUpdateUI() // JC - Added for always chat in third person option gFocusMgr.setKeyboardFocus(NULL); - gToolMgr->setCurrentToolset(gMouselookToolset); + LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset); mViewsPushed = TRUE; @@ -2937,7 +2923,7 @@ void LLAgent::endAnimationUpdateUI() } if (mAvatarObject->getParent()) { - LLVector3 at_axis = gCamera->getAtAxis(); + LLVector3 at_axis = LLViewerCamera::getInstance()->getAtAxis(); LLViewerObject* root_object = (LLViewerObject*)mAvatarObject->getRoot(); if (root_object->flagCameraDecoupled()) { @@ -2953,7 +2939,7 @@ void LLAgent::endAnimationUpdateUI() } else if (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR) { - gToolMgr->setCurrentToolset(gFaceEditToolset); + LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset); gFloaterMap->pushVisible(FALSE); /* @@ -3076,7 +3062,7 @@ void LLAgent::updateCamera() { F32 input_rate = mOrbitInKey - mOrbitOutKey; - LLVector3d to_focus = gAgent.getPosGlobalFromAgent(gCamera->getOrigin()) - calcFocusPositionTargetGlobal(); + LLVector3d to_focus = gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()) - calcFocusPositionTargetGlobal(); F32 distance_to_focus = (F32)to_focus.magVec(); // Move at distance (in meters) meters per second cameraOrbitIn( input_rate * distance_to_focus / gFPSClamped ); @@ -3278,15 +3264,15 @@ void LLAgent::updateCamera() // Move the camera //Ventrella - gCamera->updateCameraLocation(mCameraPositionAgent, mCameraUpVector, focus_agent); - //gCamera->updateCameraLocation(mCameraPositionAgent, camera_skyward, focus_agent); + LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, mCameraUpVector, focus_agent); + //LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, camera_skyward, focus_agent); //end Ventrella //RN: translate UI offset after camera is oriented properly - gCamera->translate(gCamera->getLeftAxis() * ui_offset); + LLViewerCamera::getInstance()->translate(LLViewerCamera::getInstance()->getLeftAxis() * ui_offset); // Change FOV - gCamera->setView(gCamera->getDefaultFOV() / (1.f + mCameraCurrentFOVZoomFactor)); + LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / (1.f + mCameraCurrentFOVZoomFactor)); // follow camera when in customize mode if (cameraCustomizeAvatar()) @@ -3298,11 +3284,11 @@ void LLAgent::updateCamera() if(gVoiceClient && getRegion()) { LLMatrix3 rot; - rot.setRows(gCamera->getAtAxis(), gCamera->getLeftAxis (), gCamera->getUpAxis()); + rot.setRows(LLViewerCamera::getInstance()->getAtAxis(), LLViewerCamera::getInstance()->getLeftAxis (), LLViewerCamera::getInstance()->getUpAxis()); // MBW -- XXX -- Setting velocity to 0 for now. May figure it out later... gVoiceClient->setCameraPosition( - getRegion()->getPosGlobalFromRegion(gCamera->getOrigin()),// position + getRegion()->getPosGlobalFromRegion(LLViewerCamera::getInstance()->getOrigin()),// position LLVector3::zero, // velocity rot); // rotation matrix } @@ -3404,7 +3390,7 @@ F32 LLAgent::calcCustomizeAvatarUIOffset( const LLVector3d& camera_pos_global ) // Move the camera so that the avatar isn't covered up by this floater. F32 fraction_of_fov = 0.5f - (0.5f * (1.f - llmin(1.f, ((F32)rect.getWidth() / (F32)gViewerWindow->getWindowWidth())))); - F32 apparent_angle = fraction_of_fov * gCamera->getView() * gCamera->getAspect(); // radians + F32 apparent_angle = fraction_of_fov * LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect(); // radians F32 offset = tan(apparent_angle); if( rect.mLeft < (gViewerWindow->getWindowWidth() - rect.mRight) ) @@ -3544,7 +3530,7 @@ void LLAgent::setupSitCamera() //----------------------------------------------------------------------------- const LLVector3 &LLAgent::getCameraPositionAgent() const { - return gCamera->getOrigin(); + return LLViewerCamera::getInstance()->getOrigin(); } //----------------------------------------------------------------------------- @@ -3552,14 +3538,7 @@ const LLVector3 &LLAgent::getCameraPositionAgent() const //----------------------------------------------------------------------------- LLVector3d LLAgent::getCameraPositionGlobal() const { - if (gCamera) - { - return getPosGlobalFromAgent(gCamera->getOrigin()); - } - else - { - return (LLVector3d::zero); - } + return getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()); } //----------------------------------------------------------------------------- @@ -3809,7 +3788,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) if (!gSavedSettings.getBOOL("DisableCameraConstraints") && !gAgent.isGodlike()) { - LLViewerRegion* regionp = gWorldPointer->getRegionFromPosGlobal( + LLViewerRegion* regionp = LLWorld::getInstance()->getRegionFromPosGlobal( camera_position_global); bool constrain = true; if(regionp && regionp->canManageEstate()) @@ -3834,7 +3813,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) } // JC - Could constrain camera based on parcel stuff here. -// LLViewerRegion *regionp = gWorldPointer->getRegionFromPosGlobal(camera_position_global); +// LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global); // // if (regionp && !regionp->mParcelOverlay->isBuildCameraAllowed(regionp->getPosRegionFromGlobal(camera_position_global))) // { @@ -3847,14 +3826,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) // Don't let camera go underground F32 camera_min_off_ground = getCameraMinOffGround(); - if (gWorldPointer) - { - camera_land_height = gWorldPointer->resolveLandHeightGlobal(camera_position_global); - } - else - { - camera_land_height = 0.f; - } + camera_land_height = LLWorld::getInstance()->resolveLandHeightGlobal(camera_position_global); if (camera_position_global.mdV[VZ] < camera_land_height + camera_min_off_ground) { @@ -3890,7 +3862,7 @@ void LLAgent::handleScrollWheel(S32 clicks) } else { - LLObjectSelectionHandle selection = gSelectMgr->getSelection(); + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); const F32 ROOT_ROOT_TWO = sqrt(F_SQRT2); // Block if camera is animating @@ -3970,7 +3942,7 @@ void LLAgent::changeCameraToMouselook(BOOL animate) // unpause avatar animation mPauseRequest = NULL; - gToolMgr->setCurrentToolset(gMouselookToolset); + LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset); gSavedSettings.setBOOL("FirstPersonBtnState", FALSE); gSavedSettings.setBOOL("MouselookBtnState", TRUE); @@ -3984,7 +3956,7 @@ void LLAgent::changeCameraToMouselook(BOOL animate) } //gViewerWindow->stopGrab(); - gSelectMgr->deselectAll(); + LLSelectMgr::getInstance()->deselectAll(); gViewerWindow->hideCursor(); gViewerWindow->moveCursorToCenter(); @@ -4048,11 +4020,11 @@ void LLAgent::changeCameraToFollow(BOOL animate) mCameraMode = CAMERA_MODE_FOLLOW; // bang-in the current focus, position, and up vector of the follow cam - mFollowCam.reset( mCameraPositionAgent, gCamera->getPointOfInterest(), LLVector3::z_axis ); + mFollowCam.reset( mCameraPositionAgent, LLViewerCamera::getInstance()->getPointOfInterest(), LLVector3::z_axis ); if (gBasicToolset) { - gToolMgr->setCurrentToolset(gBasicToolset); + LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); } if (mAvatarObject) @@ -4121,7 +4093,7 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate) { if (gBasicToolset) { - gToolMgr->setCurrentToolset(gBasicToolset); + LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); } mCameraLag.clearVec(); @@ -4146,7 +4118,7 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate) if (!mAvatarObject.isNull() && mAvatarObject->getParent()) { LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); - at_axis = gCamera->getAtAxis(); + at_axis = LLViewerCamera::getInstance()->getAtAxis(); at_axis.mV[VZ] = 0.f; at_axis.normVec(); resetAxes(at_axis * ~obj_rot); @@ -4181,7 +4153,7 @@ void LLAgent::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL camera_ani if (gFaceEditToolset) { - gToolMgr->setCurrentToolset(gFaceEditToolset); + LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset); } gSavedSettings.setBOOL("FirstPersonBtnState", FALSE); @@ -4401,11 +4373,11 @@ void LLAgent::setCameraPosAndFocusGlobal(const LLVector3d& camera_pos, const LLV if( CAMERA_MODE_CUSTOMIZE_AVATAR == mCameraMode ) { // Compensate for the fact that the camera has already been offset to make room for LLFloaterCustomize. - mAnimationCameraStartGlobal -= LLVector3d(gCamera->getLeftAxis() * calcCustomizeAvatarUIOffset( mAnimationCameraStartGlobal )); + mAnimationCameraStartGlobal -= LLVector3d(LLViewerCamera::getInstance()->getLeftAxis() * calcCustomizeAvatarUIOffset( mAnimationCameraStartGlobal )); } } - //gCamera->setOrigin( gAgent.getPosAgentFromGlobal( camera_pos ) ); + //LLViewerCamera::getInstance()->setOrigin( gAgent.getPosAgentFromGlobal( camera_pos ) ); setFocusObject(gObjectList.findObject(object_id)); mFocusTargetGlobal = focus; mCameraFocusOffsetTarget = camera_pos - focus; @@ -4496,14 +4468,14 @@ void LLAgent::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) if (!mAvatarObject.isNull() && mAvatarObject->getParent()) { LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); - at_axis = gCamera->getAtAxis(); + at_axis = LLViewerCamera::getInstance()->getAtAxis(); at_axis.mV[VZ] = 0.f; at_axis.normVec(); resetAxes(at_axis * ~obj_rot); } else { - at_axis = gCamera->getAtAxis(); + at_axis = LLViewerCamera::getInstance()->getAtAxis(); at_axis.mV[VZ] = 0.f; at_axis.normVec(); resetAxes(at_axis); @@ -4521,7 +4493,7 @@ void LLAgent::heardChat(const LLUUID& id) { // log text and voice chat to speaker mgr // for keeping track of active speakers, etc. - gLocalSpeakerMgr->speakerChatted(id); + LLLocalSpeakerMgr::getInstance()->speakerChatted(id); // don't respond to your own voice if (id == getID()) return; @@ -4631,7 +4603,7 @@ void LLAgent::setStartPosition(U32 location_id) // this simulator. Clamp it to the region the agent is // in, a little bit in on each side. const F32 INSET = 0.5f; //meters - const F32 REGION_WIDTH = gWorldPointer->getRegionWidthInMeters(); + const F32 REGION_WIDTH = LLWorld::getInstance()->getRegionWidthInMeters(); LLVector3 agent_pos = getPositionAgent(); @@ -4647,7 +4619,7 @@ void LLAgent::setStartPosition(U32 location_id) // Don't let them go below ground, or too high. agent_pos.mV[VZ] = llclamp( agent_pos.mV[VZ], mRegionp->getLandHeightRegion( agent_pos ), - gWorldPointer->getRegionMaxHeight() ); + LLWorld::getInstance()->getRegionMaxHeight() ); LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_SetStartLocationRequest); @@ -4937,7 +4909,7 @@ void LLAgent::buildLocationString(std::string& str) // create a defult name and description for the landmark std::string buffer; - if( gParcelMgr->getAgentParcelName().empty() ) + if( LLViewerParcelMgr::getInstance()->getAgentParcelName().empty() ) { // the parcel doesn't have a name buffer = llformat("%.32s (%d, %d, %d)", @@ -4948,7 +4920,7 @@ void LLAgent::buildLocationString(std::string& str) { // the parcel has a name, so include it in the landmark name buffer = llformat("%.32s, %.32s (%d, %d, %d)", - gParcelMgr->getAgentParcelName().c_str(), + LLViewerParcelMgr::getInstance()->getAgentParcelName().c_str(), getRegion()->getName().c_str(), pos_x, pos_y, pos_z); } @@ -4968,7 +4940,7 @@ LLQuaternion LLAgent::getHeadRotation() } // We must be in mouselook - LLVector3 look_dir( gCamera->getAtAxis() ); + LLVector3 look_dir( LLViewerCamera::getInstance()->getAtAxis() ); LLVector3 up = look_dir % mFrameAgent.getLeftAxis(); LLVector3 left = up % look_dir; @@ -5209,7 +5181,7 @@ void LLAgent::processAgentDropGroup(LLMessageSystem *msg, void **) // refresh all group information gAgent.sendAgentDataUpdateRequest(); - gGroupMgr->clearGroupData(group_id); + LLGroupMgr::getInstance()->clearGroupData(group_id); // close the floater for this group, if any. LLFloaterGroupInfo::closeGroup(group_id); // refresh the group panel of the search window, if necessary. @@ -5288,7 +5260,7 @@ class LLAgentDropGroupViewerNode : public LLHTTPNode // refresh all group information gAgent.sendAgentDataUpdateRequest(); - gGroupMgr->clearGroupData(group_id); + LLGroupMgr::getInstance()->clearGroupData(group_id); // close the floater for this group, if any. LLFloaterGroupInfo::closeGroup(group_id); // refresh the group panel of the search window, @@ -5749,14 +5721,14 @@ bool LLAgent::teleportCore(bool is_local) LLFloaterWorldMap::hide(NULL); LLFloaterDirectory::hide(NULL); - gParcelMgr->deselectLand(); + LLViewerParcelMgr::getInstance()->deselectLand(); // Close all pie menus, deselect land, etc. // Don't change the camera until we know teleport succeeded. JC resetView(FALSE); // local logic - gViewerStats->incStat(LLViewerStats::ST_TELEPORT_COUNT); + LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TELEPORT_COUNT); if (!is_local) { gTeleportDisplay = TRUE; @@ -5864,7 +5836,7 @@ void LLAgent::teleportCancel() void LLAgent::teleportViaLocation(const LLVector3d& pos_global) { LLViewerRegion* regionp = getRegion(); - LLSimInfo* info = gWorldMap->simInfoFromPosGlobal(pos_global); + LLSimInfo* info = LLWorldMap::getInstance()->simInfoFromPosGlobal(pos_global); if(regionp && info) { U32 x_pos; |