diff options
Diffstat (limited to 'indra/newview/llviewerwindow.cpp')
-rw-r--r-- | indra/newview/llviewerwindow.cpp | 383 |
1 files changed, 166 insertions, 217 deletions
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index d48e3cc4f3..afd1e48921 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -102,7 +102,6 @@ #include "llfloaterland.h" #include "llfloaterinspect.h" #include "llfloatermap.h" -#include "llfloatermute.h" #include "llfloaternamedesc.h" #include "llfloaterpreference.h" #include "llfloatersnapshot.h" @@ -155,10 +154,9 @@ #include "lltoolmorph.h" #include "lltoolpie.h" #include "lltoolplacer.h" -#include "lltoolselect.h" #include "lltoolselectland.h" #include "lltoolview.h" -#include "llvieweruictrlfactory.h" +#include "lluictrlfactory.h" #include "lluploaddialog.h" #include "llurldispatcher.h" // SLURL from other app instance #include "llvieweraudio.h" @@ -262,7 +260,6 @@ const S32 PICK_DIAMETER = 2 * PICK_HALF_WIDTH+1; const F32 MIN_DISPLAY_SCALE = 0.85f; const S32 CONSOLE_BOTTOM_PAD = 40; - #ifdef SABINRIG /// ALL RIG STUFF bool rigControl = false; @@ -480,7 +477,7 @@ public: camera_center_text = llformat("CameraCenter %f %f %f", (F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ])); - tvector = LLVector4(gCamera->getAtAxis()); + tvector = LLVector4(LLViewerCamera::getInstance()->getAtAxis()); camera_view_text = llformat("CameraAtAxis %f %f %f", (F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ])); @@ -514,7 +511,7 @@ public: } if (gDisplayFOV) { - addText(xpos, ypos, llformat("FOV: %2.1f deg", RAD_TO_DEG * gCamera->getView())); + addText(xpos, ypos, llformat("FOV: %2.1f deg", RAD_TO_DEG * LLViewerCamera::getInstance()->getView())); ypos += y_inc; } if (gSavedSettings.getBOOL("DebugShowRenderInfo")) @@ -692,13 +689,10 @@ BOOL LLViewerWindow::handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask gHoverView->cancelHover(); } - if (gToolMgr) + // Don't let the user move the mouse out of the window until mouse up. + if( LLToolMgr::getInstance()->getCurrentTool()->clipMouseWhenDown() ) { - // Don't let the user move the mouse out of the window until mouse up. - if( gToolMgr->getCurrentTool()->clipMouseWhenDown() ) - { - mWindow->setMouseClipping(TRUE); - } + mWindow->setMouseClipping(TRUE); } LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture(); @@ -750,16 +744,13 @@ BOOL LLViewerWindow::handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask return FALSE; } - if (gToolMgr) + if(LLToolMgr::getInstance()->getCurrentTool()->handleMouseDown( x, y, mask ) ) { - if(gToolMgr->getCurrentTool()->handleMouseDown( x, y, mask ) ) - { - // This is necessary to force clicks in the world to cause edit - // boxes that might have keyboard focus to relinquish it, and hence - // cause a commit to update their value. JC - gFocusMgr.setKeyboardFocus(NULL); - return TRUE; - } + // This is necessary to force clicks in the world to cause edit + // boxes that might have keyboard focus to relinquish it, and hence + // cause a commit to update their value. JC + gFocusMgr.setKeyboardFocus(NULL); + return TRUE; } return FALSE; @@ -836,12 +827,9 @@ BOOL LLViewerWindow::handleDoubleClick(LLWindow *window, LLCoordGL pos, MASK ma return TRUE; } - if (gToolMgr) + if(LLToolMgr::getInstance()->getCurrentTool()->handleDoubleClick( x, y, mask ) ) { - if(gToolMgr->getCurrentTool()->handleDoubleClick( x, y, mask ) ) - { - return TRUE; - } + return TRUE; } // if we got this far and nothing handled a double click, pass a normal mouse down @@ -880,15 +868,11 @@ BOOL LLViewerWindow::handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask) mWindow->releaseMouse(); - LLTool *tool = NULL; - if (gToolMgr) - { - tool = gToolMgr->getCurrentTool(); + LLTool *tool = LLToolMgr::getInstance()->getCurrentTool(); - if( tool->clipMouseWhenDown() ) - { - mWindow->setMouseClipping(FALSE); - } + if( tool->clipMouseWhenDown() ) + { + mWindow->setMouseClipping(FALSE); } LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture(); @@ -980,13 +964,10 @@ BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK gHoverView->cancelHover(); } - if (gToolMgr) + // Don't let the user move the mouse out of the window until mouse up. + if( LLToolMgr::getInstance()->getCurrentTool()->clipMouseWhenDown() ) { - // Don't let the user move the mouse out of the window until mouse up. - if( gToolMgr->getCurrentTool()->clipMouseWhenDown() ) - { - mWindow->setMouseClipping(TRUE); - } + mWindow->setMouseClipping(TRUE); } LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture(); @@ -1030,26 +1011,23 @@ BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK llinfos << "Right Mouse Down not handled by view" << llendl; } - if (gToolMgr) + if(LLToolMgr::getInstance()->getCurrentTool()->handleRightMouseDown( x, y, mask ) ) { - if(gToolMgr->getCurrentTool()->handleRightMouseDown( x, y, mask ) ) - { - // This is necessary to force clicks in the world to cause edit - // boxes that might have keyboard focus to relinquish it, and hence - // cause a commit to update their value. JC - gFocusMgr.setKeyboardFocus(NULL); - return TRUE; - } + // This is necessary to force clicks in the world to cause edit + // boxes that might have keyboard focus to relinquish it, and hence + // cause a commit to update their value. JC + gFocusMgr.setKeyboardFocus(NULL); + return TRUE; } // *HACK: this should be rolled into the composite tool logic, not // hardcoded at the top level. - if (gToolPie && (CAMERA_MODE_CUSTOMIZE_AVATAR != gAgent.getCameraMode()) ) + if (CAMERA_MODE_CUSTOMIZE_AVATAR != gAgent.getCameraMode()) { // If the current tool didn't process the click, we should show // the pie menu. This can be done by passing the event to the pie // menu tool. - gToolPie->handleRightMouseDown(x, y, mask); + LLToolPie::getInstance()->handleRightMouseDown(x, y, mask); // show_context_menu( x, y, mask ); } @@ -1089,15 +1067,11 @@ BOOL LLViewerWindow::handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK m mWindow->releaseMouse(); - LLTool *tool = NULL; - if (gToolMgr) - { - tool = gToolMgr->getCurrentTool(); + LLTool *tool = LLToolMgr::getInstance()->getCurrentTool(); - if( tool->clipMouseWhenDown() ) - { - mWindow->setMouseClipping(FALSE); - } + if( tool->clipMouseWhenDown() ) + { + mWindow->setMouseClipping(FALSE); } LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture(); @@ -1246,10 +1220,7 @@ void LLViewerWindow::handleFocus(LLWindow *window) LLModalDialog::onAppFocusGained(); gAgent.onAppFocusGained(); - if (gToolMgr) - { - gToolMgr->onAppFocusGained(); - } + LLToolMgr::getInstance()->onAppFocusGained(); gShowTextEditCursor = TRUE; @@ -1269,10 +1240,7 @@ void LLViewerWindow::handleFocusLost(LLWindow *window) { gFocusMgr.setAppHasFocus(FALSE); //LLModalDialog::onAppFocusLost(); - if( gToolMgr ) - { - gToolMgr->onAppFocusLost(); - } + LLToolMgr::getInstance()->onAppFocusLost(); gFocusMgr.setMouseCapture( NULL ); if (gMenuBarView) @@ -1428,9 +1396,9 @@ BOOL LLViewerWindow::handlePaint(LLWindow *window, S32 x, S32 y, S32 width, S char temp_str[255]; /* Flawfinder: ignore */ snprintf(temp_str, sizeof(temp_str), "%s FPS %3.1f Phy FPS %2.1f Time Dil %1.3f", /* Flawfinder: ignore */ name_str.c_str(), - gViewerStats->mFPSStat.getMeanPerSec(), - gViewerStats->mSimPhysicsFPS.getPrev(0), - gViewerStats->mSimTimeDilation.getPrev(0)); + LLViewerStats::getInstance()->mFPSStat.getMeanPerSec(), + LLViewerStats::getInstance()->mSimPhysicsFPS.getPrev(0), + LLViewerStats::getInstance()->mSimTimeDilation.getPrev(0)); len = strlen(temp_str); /* Flawfinder: ignore */ TextOutA(hdc, 0, 0, temp_str, len); @@ -1567,21 +1535,21 @@ LLViewerWindow::LLViewerWindow( // llinfos << "Loading feature tables." << llendl; - gFeatureManagerp->init(); + LLFeatureManager::getInstance()->init(); // Initialize OpenGL Renderer - if (!gFeatureManagerp->isFeatureAvailable("RenderVBOEnable") || + if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") || !gGLManager.mHasVertexBufferObject) { gSavedSettings.setBOOL("RenderVBOEnable", FALSE); } LLVertexBuffer::initClass(gSavedSettings.getBOOL("RenderVBOEnable")); - if (gFeatureManagerp->isSafe() - || (gSavedSettings.getS32("LastFeatureVersion") != gFeatureManagerp->getVersion()) + if (LLFeatureManager::getInstance()->isSafe() + || (gSavedSettings.getS32("LastFeatureVersion") != LLFeatureManager::getInstance()->getVersion()) || (gSavedSettings.getBOOL("ProbeHardwareOnStartup"))) { - gFeatureManagerp->applyRecommendedSettings(); + LLFeatureManager::getInstance()->applyRecommendedSettings(); gSavedSettings.setBOOL("ProbeHardwareOnStartup", FALSE); } @@ -1589,7 +1557,7 @@ LLViewerWindow::LLViewerWindow( if (gSavedSettings.getBOOL("RenderInitError")) { mInitAlert = "DisplaySettingsNoShaders"; - gFeatureManagerp->setGraphicsLevel(0, false); + LLFeatureManager::getInstance()->setGraphicsLevel(0, false); gSavedSettings.setU32("RenderQualityPerformance", 0); } @@ -1612,9 +1580,6 @@ LLViewerWindow::LLViewerWindow( initFonts(); } - // Init Resource Manager - gResMgr = new LLResMgr(); - // Make avatar head look forward at start mCurrentMousePoint.mX = getWindowWidth() / 2; mCurrentMousePoint.mY = getWindowHeight() / 2; @@ -1918,7 +1883,7 @@ void LLViewerWindow::initWorldUI() mRootView->addChild(gMorphView); gMorphView->setVisible(FALSE); - gFloaterMute = LLFloaterMute::getInstance(); + // *Note: this is where gFloaterMute used to be initialized. LLWorldMapView::initClass(); @@ -1985,8 +1950,6 @@ LLViewerWindow::~LLViewerWindow() gFloaterView = NULL; gMorphView = NULL; - gFloaterMute = NULL; - gFloaterMap = NULL; gHUDView = NULL; @@ -1994,9 +1957,6 @@ LLViewerWindow::~LLViewerWindow() delete mToolTip; mToolTip = NULL; - - delete gResMgr; - gResMgr = NULL; //-------------------------------------------------------- // Shutdown GL cleanly. Order is very important here. @@ -2025,11 +1985,8 @@ LLViewerWindow::~LLViewerWindow() delete[] mPickBuffer; mPickBuffer = NULL; - if (gSelectMgr) - { - llinfos << "Cleaning up select manager" << llendl; - gSelectMgr->cleanup(); - } + llinfos << "Cleaning up select manager" << llendl; + LLSelectMgr::getInstance()->cleanup(); LLVertexBuffer::cleanupClass(); @@ -2103,17 +2060,17 @@ void LLViewerWindow::reshape(S32 width, S32 height) glViewport(0, 0, width, height ); - if (height > 0 && gCamera) + if (height > 0) { - gCamera->setViewHeightInPixels( height ); + LLViewerCamera::getInstance()->setViewHeightInPixels( height ); if (mWindow->getFullscreen()) { // force to 4:3 aspect for odd resolutions - gCamera->setAspect( getDisplayAspectRatio() ); + LLViewerCamera::getInstance()->setAspect( getDisplayAspectRatio() ); } else { - gCamera->setAspect( width / (F32) height); + LLViewerCamera::getInstance()->setAspect( width / (F32) height); } } @@ -2170,8 +2127,8 @@ void LLViewerWindow::reshape(S32 width, S32 height) } } - gViewerStats->setStat(LLViewerStats::ST_WINDOW_WIDTH, (F64)width); - gViewerStats->setStat(LLViewerStats::ST_WINDOW_HEIGHT, (F64)height); + LLViewerStats::getInstance()->setStat(LLViewerStats::ST_WINDOW_WIDTH, (F64)width); + LLViewerStats::getInstance()->setStat(LLViewerStats::ST_WINDOW_HEIGHT, (F64)height); gResizeScreenTexture = TRUE; } } @@ -2282,7 +2239,7 @@ void LLViewerWindow::draw() glLoadIdentity(); microsecondsToTimecodeString(gFrameTime,text); - const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF ); + const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ); font->renderUTF8(text, 0, llround((getWindowWidth()/2)-100.f), llround((getWindowHeight()-60.f)), @@ -2299,30 +2256,24 @@ void LLViewerWindow::draw() glScalef(mDisplayScale.mV[VX], mDisplayScale.mV[VY], 1.f); LLVector2 old_scale_factor = LLUI::sGLScaleFactor; - if (gCamera) + // apply camera zoom transform (for high res screenshots) + F32 zoom_factor = LLViewerCamera::getInstance()->getZoomFactor(); + S16 sub_region = LLViewerCamera::getInstance()->getZoomSubRegion(); + if (zoom_factor > 1.f) { - // apply camera zoom transform (for high res screenshots) - F32 zoom_factor = gCamera->getZoomFactor(); - S16 sub_region = gCamera->getZoomSubRegion(); - if (zoom_factor > 1.f) - { - //decompose subregion number to x and y values - int pos_y = sub_region / llceil(zoom_factor); - int pos_x = sub_region - (pos_y*llceil(zoom_factor)); - // offset for this tile - glTranslatef((F32)gViewerWindow->getWindowWidth() * -(F32)pos_x, - (F32)gViewerWindow->getWindowHeight() * -(F32)pos_y, - 0.f); - glScalef(zoom_factor, zoom_factor, 1.f); - LLUI::sGLScaleFactor *= zoom_factor; - } + //decompose subregion number to x and y values + int pos_y = sub_region / llceil(zoom_factor); + int pos_x = sub_region - (pos_y*llceil(zoom_factor)); + // offset for this tile + glTranslatef((F32)gViewerWindow->getWindowWidth() * -(F32)pos_x, + (F32)gViewerWindow->getWindowHeight() * -(F32)pos_y, + 0.f); + glScalef(zoom_factor, zoom_factor, 1.f); + LLUI::sGLScaleFactor *= zoom_factor; } - if (gToolMgr) - { - // Draw tool specific overlay on world - gToolMgr->getCurrentTool()->draw(); - } + // Draw tool specific overlay on world + LLToolMgr::getInstance()->getCurrentTool()->draw(); if( gAgent.cameraMouselook() ) { @@ -2398,7 +2349,9 @@ void LLViewerWindow::draw() // Takes a single keydown event, usually when UI is visible BOOL LLViewerWindow::handleKey(KEY key, MASK mask) { - if (gFocusMgr.getKeyboardFocus() && !(mask & (MASK_CONTROL | MASK_ALT))) + if (gFocusMgr.getKeyboardFocus() + && !(mask & (MASK_CONTROL | MASK_ALT)) + && !gFocusMgr.getKeystrokesOnly()) { // We have keyboard focus, and it's not an accelerator @@ -2412,7 +2365,7 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) // HACK look for UI editing keys if (LLView::sEditingUI) { - if (LLFloaterEditUI::handleKey(key, mask)) + if (LLFloaterEditUI::processKeystroke(key, mask)) { return TRUE; } @@ -2544,12 +2497,9 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) } } - if (gToolMgr) + if( LLToolMgr::getInstance()->getCurrentTool()->handleKey(key, mask) ) { - if( gToolMgr->getCurrentTool()->handleKey(key, mask) ) - { - return TRUE; - } + return TRUE; } // Try for a new-format gesture @@ -2567,14 +2517,14 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) // Topmost view gets a chance before the hierarchy // *FIX: get rid of this? - LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl(); - if (top_ctrl) - { - if( top_ctrl->handleKey( key, mask, TRUE ) ) - { - return TRUE; - } - } + //LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl(); + //if (top_ctrl) + //{ + // if( top_ctrl->handleKey( key, mask, TRUE ) ) + // { + // return TRUE; + // } + //} // give floaters first chance to handle TAB key // so frontmost floater gets focus @@ -2648,12 +2598,12 @@ BOOL LLViewerWindow::handleUnicodeChar(llwchar uni_char, MASK mask) return TRUE; } - // Topmost view gets a chance before the hierarchy - LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl(); - if (top_ctrl && top_ctrl->handleUnicodeChar( uni_char, FALSE ) ) - { - return TRUE; - } + //// Topmost view gets a chance before the hierarchy + //LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl(); + //if (top_ctrl && top_ctrl->handleUnicodeChar( uni_char, FALSE ) ) + //{ + // return TRUE; + //} return TRUE; } @@ -2710,11 +2660,8 @@ void LLViewerWindow::handleScrollWheel(S32 clicks) llinfos << "Scroll Wheel not handled by view" << llendl; } - if (gWorldPointer) - { - // Zoom the camera in and out behavior - gAgent.handleScrollWheel(clicks); - } + // Zoom the camera in and out behavior + gAgent.handleScrollWheel(clicks); return; } @@ -2901,9 +2848,9 @@ BOOL LLViewerWindow::handlePerFrameHover() // *NOTE: sometimes tools handle the mouse as a captor, so this // logic is a little confusing LLTool *tool = NULL; - if (gToolMgr && gHoverView && gCamera) + if (gHoverView) { - tool = gToolMgr->getCurrentTool(); + tool = LLToolMgr::getInstance()->getCurrentTool(); if(!handled && tool) { @@ -2923,8 +2870,8 @@ BOOL LLViewerWindow::handlePerFrameHover() // Suppress the toolbox view if our source tool was the pie tool, // and we've overridden to something else. mSuppressToolbox = - (gToolMgr->getBaseTool() == gToolPie) && - (gToolMgr->getCurrentTool() != gToolPie); + (LLToolMgr::getInstance()->getBaseTool() == LLToolPie::getInstance()) && + (LLToolMgr::getInstance()->getCurrentTool() != LLToolPie::getInstance()); } @@ -2975,19 +2922,19 @@ BOOL LLViewerWindow::handlePerFrameHover() } } - if (tool && tool != gToolNull && tool != gToolInspect && tool != gToolDragAndDrop && !gSavedSettings.getBOOL("FreezeTime")) + if (tool && tool != gToolNull && tool != LLToolCompInspect::getInstance() && tool != LLToolDragAndDrop::getInstance() && !gSavedSettings.getBOOL("FreezeTime")) { LLMouseHandler *captor = gFocusMgr.getMouseCapture(); // With the null, inspect, or drag and drop tool, don't muck // with visibility. if (gFloaterTools->isMinimized() || - (tool != gToolPie // not default tool - && tool != gToolGun // not coming out of mouselook - && !mSuppressToolbox // not override in third person - && gToolMgr->getCurrentToolset() != gFaceEditToolset // not special mode - && gToolMgr->getCurrentToolset() != gMouselookToolset - && (!captor || captor->isView())) // not dragging + (tool != LLToolPie::getInstance() // not default tool + && tool != LLToolCompGun::getInstance() // not coming out of mouselook + && !mSuppressToolbox // not override in third person + && LLToolMgr::getInstance()->getCurrentToolset() != gFaceEditToolset // not special mode + && LLToolMgr::getInstance()->getCurrentToolset() != gMouselookToolset + && (!captor || captor->isView())) // not dragging ) { // Force floater tools to be visible (unless minimized) @@ -3046,7 +2993,7 @@ BOOL LLViewerWindow::handlePerFrameHover() // snap floaters to top of chat bar/button strip LLView* chatbar_and_buttons = gOverlayBar->getChild<LLView>("chatbar_and_buttons", TRUE); - // find top of chatbar and strate buttons, if either are visible + // find top of chatbar and state buttons, if either are visible if (chatbar_and_buttons && !chatbar_and_buttons->getLocalBoundingRect().isNull()) { // convert top/left corner of chatbar/buttons container to gFloaterView-relative coordinates @@ -3085,9 +3032,9 @@ BOOL LLViewerWindow::handlePerFrameHover() mLastMousePoint = mCurrentMousePoint; // last ditch force of edit menu to selection manager - if (LLEditMenuHandler::gEditMenuHandler == NULL && gSelectMgr && gSelectMgr->getSelection()->getObjectCount()) + if (LLEditMenuHandler::gEditMenuHandler == NULL && LLSelectMgr::getInstance()->getSelection()->getObjectCount()) { - LLEditMenuHandler::gEditMenuHandler = gSelectMgr; + LLEditMenuHandler::gEditMenuHandler = LLSelectMgr::getInstance(); } if (gFloaterView->getCycleMode()) @@ -3116,20 +3063,23 @@ BOOL LLViewerWindow::handlePerFrameHover() gFloaterView->syncFloaterTabOrder(); } - if (gSavedSettings.getBOOL("ChatBarStealsFocus") && gChatBar && gFocusMgr.getKeyboardFocus() == NULL && gChatBar->getVisible()) + if (gSavedSettings.getBOOL("ChatBarStealsFocus") + && gChatBar + && gFocusMgr.getKeyboardFocus() == NULL + && gChatBar->isInVisibleChain()) { gChatBar->startChat(NULL); } // cleanup unused selections when no modal dialogs are open - if (gParcelMgr && LLModalDialog::activeCount() == 0) + if (LLModalDialog::activeCount() == 0) { - gParcelMgr->deselectUnused(); + LLViewerParcelMgr::getInstance()->deselectUnused(); } - if (gSelectMgr && LLModalDialog::activeCount() == 0) + if (LLModalDialog::activeCount() == 0) { - gSelectMgr->deselectUnused(); + LLSelectMgr::getInstance()->deselectUnused(); } return handled; @@ -3176,12 +3126,12 @@ void LLViewerWindow::saveLastMouse(const LLCoordGL &point) // render_hud_elements: FALSE, FALSE, FALSE void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, BOOL for_hud ) { - LLObjectSelectionHandle selection = gSelectMgr->getSelection(); + LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); if (!for_hud && !for_gl_pick) { // Call this once and only once - gSelectMgr->updateSilhouettes(); + LLSelectMgr::getInstance()->updateSilhouettes(); } // Draw fence around land selections @@ -3189,18 +3139,18 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, { if (pick_parcel_walls) { - gParcelMgr->renderParcelCollision(); + LLViewerParcelMgr::getInstance()->renderParcelCollision(); } } else if (( for_hud && selection->getSelectType() == SELECT_TYPE_HUD) || (!for_hud && selection->getSelectType() != SELECT_TYPE_HUD)) { - gSelectMgr->renderSilhouettes(for_hud); + LLSelectMgr::getInstance()->renderSilhouettes(for_hud); stop_glerror(); // setup HUD render - if (selection->getSelectType() == SELECT_TYPE_HUD && gSelectMgr->getSelection()->getObjectCount()) + if (selection->getSelectType() == SELECT_TYPE_HUD && LLSelectMgr::getInstance()->getSelection()->getObjectCount()) { LLBBox hud_bbox = gAgent.getAvatarObject()->getHUDBBox(); @@ -3209,7 +3159,7 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, glPushMatrix(); glLoadIdentity(); F32 depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f); - glOrtho(-0.5f * gCamera->getAspect(), 0.5f * gCamera->getAspect(), -0.5f, 0.5f, 0.f, depth); + glOrtho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, depth); glMatrixMode(GL_MODELVIEW); glPushMatrix(); @@ -3219,7 +3169,7 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, } // Render light for editing - if (LLSelectMgr::sRenderLightRadius && gToolMgr->inEdit()) + if (LLSelectMgr::sRenderLightRadius && LLToolMgr::getInstance()->inEdit()) { LLImageGL::unbindTexture(0); LLGLEnable gls_blend(GL_BLEND); @@ -3265,7 +3215,7 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, return true; } } func; - gSelectMgr->getSelection()->applyToObjects(&func); + LLSelectMgr::getInstance()->getSelection()->applyToObjects(&func); glPopMatrix(); } @@ -3274,7 +3224,7 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, // not be recalculated at this time. If they are, then group rotations will break. // Draw arrows at average center of all selected objects - LLTool* tool = gToolMgr->getCurrentTool(); + LLTool* tool = LLToolMgr::getInstance()->getCurrentTool(); if (tool) { if(tool->isAlwaysRendered()) @@ -3283,15 +3233,15 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, } else { - if( !gSelectMgr->getSelection()->isEmpty() ) + if( !LLSelectMgr::getInstance()->getSelection()->isEmpty() ) { BOOL moveable_object_selected = FALSE; BOOL all_selected_objects_move = TRUE; BOOL all_selected_objects_modify = TRUE; BOOL selecting_linked_set = !gSavedSettings.getBOOL("EditLinkedParts"); - for (LLObjectSelection::iterator iter = gSelectMgr->getSelection()->begin(); - iter != gSelectMgr->getSelection()->end(); iter++) + for (LLObjectSelection::iterator iter = LLSelectMgr::getInstance()->getSelection()->begin(); + iter != LLSelectMgr::getInstance()->getSelection()->end(); iter++) { LLSelectNode* nodep = *iter; LLViewerObject* object = nodep->getObject(); @@ -3307,17 +3257,17 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, BOOL draw_handles = TRUE; - if (tool == gToolTranslate && (!moveable_object_selected || !all_selected_objects_move)) + if (tool == LLToolCompTranslate::getInstance() && (!moveable_object_selected || !all_selected_objects_move)) { draw_handles = FALSE; } - if (tool == gToolRotate && (!moveable_object_selected || !all_selected_objects_move)) + if (tool == LLToolCompRotate::getInstance() && (!moveable_object_selected || !all_selected_objects_move)) { draw_handles = FALSE; } - if ( !all_selected_objects_modify && tool == gToolStretch ) + if ( !all_selected_objects_modify && tool == LLToolCompScale::getInstance() ) { draw_handles = FALSE; } @@ -3421,13 +3371,13 @@ void LLViewerWindow::hitObjectOrLandGlobalAsync(S32 x, S32 y_from_bot, MASK mask gLastHitParcelWall = FALSE; LLCamera pick_camera; - pick_camera.setOrigin(gCamera->getOrigin()); - pick_camera.setOriginAndLookAt(gCamera->getOrigin(), - gCamera->getUpAxis(), - gCamera->getOrigin() + mouseDirectionGlobal(x, y_from_bot)); + pick_camera.setOrigin(LLViewerCamera::getInstance()->getOrigin()); + pick_camera.setOriginAndLookAt(LLViewerCamera::getInstance()->getOrigin(), + LLViewerCamera::getInstance()->getUpAxis(), + LLViewerCamera::getInstance()->getOrigin() + mouseDirectionGlobal(x, y_from_bot)); pick_camera.setView(0.5f*DEG_TO_RAD); - pick_camera.setNear(gCamera->getNear()); - pick_camera.setFar(gCamera->getFar()); + pick_camera.setNear(LLViewerCamera::getInstance()->getNear()); + pick_camera.setFar(LLViewerCamera::getInstance()->getFar()); pick_camera.setAspect(1.f); // save our drawing state @@ -3444,8 +3394,7 @@ void LLViewerWindow::hitObjectOrLandGlobalAsync(S32 x, S32 y_from_bot, MASK mask // build perspective transform and picking viewport // Perform pick on a PICK_DIAMETER x PICK_DIAMETER pixel region around cursor point. // Don't limit the select distance for this pick. - // make viewport big enough to handle antialiased frame buffers - gCamera->setPerspective(FOR_SELECTION, scaled_x - (PICK_HALF_WIDTH + 2), scaled_y - (PICK_HALF_WIDTH + 2), PICK_DIAMETER + 4, PICK_DIAMETER + 4, FALSE); + LLViewerCamera::getInstance()->setPerspective(FOR_SELECTION, scaled_x - (PICK_HALF_WIDTH + 2), scaled_y - (PICK_HALF_WIDTH + 2), PICK_DIAMETER + 4, PICK_DIAMETER + 4, FALSE); // make viewport big enough to handle antialiased frame buffers gGLViewport[0] = scaled_x - (PICK_HALF_WIDTH + 2); gGLViewport[1] = scaled_y - (PICK_HALF_WIDTH + 2); @@ -3516,13 +3465,13 @@ void LLViewerWindow::hitUIElementAsync(S32 x, S32 y_from_bot, MASK mask, void (* gLastHitUIElement = 0; LLCamera pick_camera; - pick_camera.setOrigin(gCamera->getOrigin()); - pick_camera.setOriginAndLookAt(gCamera->getOrigin(), - gCamera->getUpAxis(), - gCamera->getOrigin() + mouseDirectionGlobal(x, y_from_bot)); + pick_camera.setOrigin(LLViewerCamera::getInstance()->getOrigin()); + pick_camera.setOriginAndLookAt(LLViewerCamera::getInstance()->getOrigin(), + LLViewerCamera::getInstance()->getUpAxis(), + LLViewerCamera::getInstance()->getOrigin() + mouseDirectionGlobal(x, y_from_bot)); pick_camera.setView(0.5f*DEG_TO_RAD); - pick_camera.setNear(gCamera->getNear()); - pick_camera.setFar(gCamera->getFar()); + pick_camera.setNear(LLViewerCamera::getInstance()->getNear()); + pick_camera.setFar(LLViewerCamera::getInstance()->getFar()); pick_camera.setAspect(1.f); // save our drawing state @@ -3752,7 +3701,7 @@ LLViewerObject* LLViewerWindow::getObjectUnderCursor(const F32 depth) S32 y = getCurrentMouseY(); LLVector3 mouse_direction_global = mouseDirectionGlobal(x,y); - LLVector3 camera_pos_global = gCamera->getOrigin(); + LLVector3 camera_pos_global = LLViewerCamera::getInstance()->getOrigin(); LLVector3 pick_end = camera_pos_global + mouse_direction_global * depth; LLVector3 collision_point; return gPipeline.pickObject(camera_pos_global, pick_end, collision_point); @@ -3838,7 +3787,7 @@ void LLViewerWindow::analyzeHit( U8 uv_pick_buffer[UV_PICK_WIDTH * UV_PICK_WIDTH * 4]; S32 pick_face = face; LLFace* facep = objectp->mDrawable->getFace(pick_face); - gCamera->setPerspective(FOR_SELECTION, scaled_x - UV_PICK_HALF_WIDTH, scaled_y - UV_PICK_HALF_WIDTH, UV_PICK_WIDTH, UV_PICK_WIDTH, FALSE); + LLViewerCamera::getInstance()->setPerspective(FOR_SELECTION, scaled_x - UV_PICK_HALF_WIDTH, scaled_y - UV_PICK_HALF_WIDTH, UV_PICK_WIDTH, UV_PICK_WIDTH, FALSE); glViewport(scaled_x - UV_PICK_HALF_WIDTH, scaled_y - UV_PICK_HALF_WIDTH, UV_PICK_WIDTH, UV_PICK_WIDTH); gPipeline.renderFaceForUVSelect(facep); @@ -3872,7 +3821,7 @@ void LLViewerWindow::analyzeHit( LLVector3 LLViewerWindow::mouseDirectionGlobal(const S32 x, const S32 y) const { // find vertical field of view - F32 fov = gCamera->getView(); + F32 fov = LLViewerCamera::getInstance()->getView(); // find screen resolution S32 height = getWindowHeight(); @@ -3886,9 +3835,9 @@ LLVector3 LLViewerWindow::mouseDirectionGlobal(const S32 x, const S32 y) const F32 click_y = y - height / 2.f; // compute mouse vector - LLVector3 mouse_vector = distance * gCamera->getAtAxis() - - click_x * gCamera->getLeftAxis() - + click_y * gCamera->getUpAxis(); + LLVector3 mouse_vector = distance * LLViewerCamera::getInstance()->getAtAxis() + - click_x * LLViewerCamera::getInstance()->getLeftAxis() + + click_y * LLViewerCamera::getInstance()->getUpAxis(); mouse_vector.normVec(); @@ -3901,8 +3850,8 @@ LLVector3 LLViewerWindow::mouseDirectionGlobal(const S32 x, const S32 y) const LLVector3 LLViewerWindow::mouseDirectionCamera(const S32 x, const S32 y) const { // find vertical field of view - F32 fov_height = gCamera->getView(); - F32 fov_width = fov_height * gCamera->getAspect(); + F32 fov_height = LLViewerCamera::getInstance()->getView(); + F32 fov_width = fov_height * LLViewerCamera::getInstance()->getAspect(); // find screen resolution S32 height = getWindowHeight(); @@ -3979,7 +3928,7 @@ BOOL LLViewerWindow::mousePointOnLandGlobal(const S32 x, const S32 y, LLVector3d mouse_direction_global_d.setVec(mouse_direction_global * mouse_dir_scale); probe_point_global = camera_pos_global + mouse_direction_global_d; - regionp = gWorldPointer->resolveRegionGlobal(probe_point_region, probe_point_global); + regionp = LLWorld::getInstance()->resolveRegionGlobal(probe_point_region, probe_point_global); if (!regionp) { @@ -4026,7 +3975,7 @@ BOOL LLViewerWindow::mousePointOnLandGlobal(const S32 x, const S32 y, LLVector3d mouse_direction_global_d.setVec(mouse_direction_global * mouse_dir_scale); probe_point_global = camera_pos_global + mouse_direction_global_d; - regionp = gWorldPointer->resolveRegionGlobal(probe_point_region, probe_point_global); + regionp = LLWorld::getInstance()->resolveRegionGlobal(probe_point_region, probe_point_global); if (!regionp) { @@ -4245,7 +4194,7 @@ void LLViewerWindow::playSnapshotAnimAndSound() BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 preview_height, BOOL show_ui, BOOL do_rebuild, ESnapshotType type) { - if ((!gWorldPointer) || (!raw) || preview_width < 10 || preview_height < 10) + if ((!raw) || preview_width < 10 || preview_height < 10) { return FALSE; } @@ -4293,7 +4242,7 @@ BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 p if (type == SNAPSHOT_TYPE_OBJECT_ID) { gPickTransparent = FALSE; - gObjectList.renderObjectsForSelect(*gCamera, FALSE, FALSE); + gObjectList.renderObjectsForSelect(*LLViewerCamera::getInstance(), FALSE, FALSE); } else { @@ -4320,8 +4269,9 @@ BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 p if(SNAPSHOT_TYPE_DEPTH == type) { - F32 depth_conversion_factor_1 = (gCamera->getFar() + gCamera->getNear()) / (2.f * gCamera->getFar() * gCamera->getNear()); - F32 depth_conversion_factor_2 = (gCamera->getFar() - gCamera->getNear()) / (2.f * gCamera->getFar() * gCamera->getNear()); + LLViewerCamera* camerap = LLViewerCamera::getInstance(); + F32 depth_conversion_factor_1 = (camerap->getFar() + camerap->getNear()) / (2.f * camerap->getFar() * camerap->getNear()); + F32 depth_conversion_factor_2 = (camerap->getFar() - camerap->getNear()) / (2.f * camerap->getFar() * camerap->getNear()); //calculate the depth for (S32 y = 0 ; y < h ; y++) @@ -4333,7 +4283,7 @@ BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 p F32 depth_float_i = *(F32*)(raw->getData() + i); F32 linear_depth_float = 1.f / (depth_conversion_factor_1 - (depth_float_i * depth_conversion_factor_2)); - U8 depth_byte = F32_to_U8(linear_depth_float, gCamera->getNear(), gCamera->getFar()); + U8 depth_byte = F32_to_U8(linear_depth_float, camerap->getNear(), camerap->getFar()); *(raw->getData() + i + 0) = depth_byte; *(raw->getData() + i + 1) = depth_byte; *(raw->getData() + i + 2) = depth_byte; @@ -4382,8 +4332,7 @@ BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 p BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, BOOL keep_window_aspect, BOOL is_texture, BOOL show_ui, BOOL do_rebuild, ESnapshotType type, S32 max_size) { - if ((!gWorldPointer) || - (!raw)) + if (!raw) { return FALSE; } @@ -4486,8 +4435,8 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei S32 output_buffer_offset_y = 0; - F32 depth_conversion_factor_1 = (gCamera->getFar() + gCamera->getNear()) / (2.f * gCamera->getFar() * gCamera->getNear()); - F32 depth_conversion_factor_2 = (gCamera->getFar() - gCamera->getNear()) / (2.f * gCamera->getFar() * gCamera->getNear()); + F32 depth_conversion_factor_1 = (LLViewerCamera::getInstance()->getFar() + LLViewerCamera::getInstance()->getNear()) / (2.f * LLViewerCamera::getInstance()->getFar() * LLViewerCamera::getInstance()->getNear()); + F32 depth_conversion_factor_2 = (LLViewerCamera::getInstance()->getFar() - LLViewerCamera::getInstance()->getNear()) / (2.f * LLViewerCamera::getInstance()->getFar() * LLViewerCamera::getInstance()->getNear()); for (int subimage_y = 0; subimage_y < scale_factor; ++subimage_y) { @@ -4505,12 +4454,12 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - gCamera->setZoomParameters(scale_factor, subimage_x+(subimage_y*llceil(scale_factor))); + LLViewerCamera::getInstance()->setZoomParameters(scale_factor, subimage_x+(subimage_y*llceil(scale_factor))); setup3DRender(); setupViewport(); BOOL first_time_through = (subimage_x + subimage_y == 0); gPickTransparent = FALSE; - gObjectList.renderObjectsForSelect(*gCamera, FALSE, !first_time_through); + gObjectList.renderObjectsForSelect(*LLViewerCamera::getInstance(), FALSE, !first_time_through); } else { @@ -4562,7 +4511,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei F32 depth_float = *(F32*)(raw->getData() + i); F32 linear_depth_float = 1.f / (depth_conversion_factor_1 - (depth_float * depth_conversion_factor_2)); - U8 depth_byte = F32_to_U8(linear_depth_float, gCamera->getNear(), gCamera->getFar()); + U8 depth_byte = F32_to_U8(linear_depth_float, LLViewerCamera::getInstance()->getNear(), LLViewerCamera::getInstance()->getFar()); *(raw->getData() + i + 0) = depth_byte; *(raw->getData() + i + 1) = depth_byte; *(raw->getData() + i + 2) = depth_byte; @@ -4650,7 +4599,7 @@ void LLViewerWindow::drawMouselookInstructions() { // Draw instructions for mouselook ("Press ESC to leave Mouselook" in a box at the top of the screen.) const char* instructions = "Press ESC to leave Mouselook."; - const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF ); + const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ); const S32 INSTRUCTIONS_PAD = 5; LLRect instructions_rect; @@ -4754,7 +4703,7 @@ void LLViewerWindow::setupViewport(S32 x_offset, S32 y_offset) void LLViewerWindow::setup3DRender() { - gCamera->setPerspective(NOT_FOR_SELECTION, 0, 0, mWindowRect.getWidth(), mWindowRect.getHeight(), FALSE, gCamera->getNear(), MAX_FAR_CLIP*2.f); + LLViewerCamera::getInstance()->setPerspective(NOT_FOR_SELECTION, 0, 0, mWindowRect.getWidth(), mWindowRect.getHeight(), FALSE, LLViewerCamera::getInstance()->getNear(), MAX_FAR_CLIP*2.f); } void LLViewerWindow::setup2DRender() @@ -5394,7 +5343,7 @@ LLBottomPanel::LLBottomPanel(const LLRect &rect) : mFactoryMap["toolbar"] = LLCallbackMap(createToolBar, NULL); mFactoryMap["overlay"] = LLCallbackMap(createOverlayBar, NULL); mFactoryMap["hud"] = LLCallbackMap(createHUD, NULL); - gUICtrlFactory->buildPanel(this, "panel_bars.xml", &getFactoryMap()); + LLUICtrlFactory::getInstance()->buildPanel(this, "panel_bars.xml", &getFactoryMap()); setOrigin(rect.mLeft, rect.mBottom); reshape(rect.getWidth(), rect.getHeight()); |