aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewerwindow.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:42 -0500
committerJacek Antonelli2008-08-15 23:45:42 -0500
commitce28e056c20bf2723f565bbf464b87781ec248a2 (patch)
treeef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/newview/llviewerwindow.cpp
parentSecond Life viewer sources 1.19.1.4b (diff)
downloadmeta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz
Second Life viewer sources 1.20.2
Diffstat (limited to 'linden/indra/newview/llviewerwindow.cpp')
-rw-r--r--linden/indra/newview/llviewerwindow.cpp756
1 files changed, 386 insertions, 370 deletions
diff --git a/linden/indra/newview/llviewerwindow.cpp b/linden/indra/newview/llviewerwindow.cpp
index a82b162..a14a3b3 100644
--- a/linden/indra/newview/llviewerwindow.cpp
+++ b/linden/indra/newview/llviewerwindow.cpp
@@ -32,6 +32,7 @@
32#include "llviewerprecompiledheaders.h" 32#include "llviewerprecompiledheaders.h"
33 33
34#include "llpanellogin.h" 34#include "llpanellogin.h"
35#include "llviewerkeyboard.h"
35#include "llviewerwindow.h" 36#include "llviewerwindow.h"
36 37
37// system library includes 38// system library includes
@@ -76,7 +77,6 @@
76#include "llagent.h" 77#include "llagent.h"
77#include "llalertdialog.h" 78#include "llalertdialog.h"
78#include "llbox.h" 79#include "llbox.h"
79#include "llcameraview.h"
80#include "llchatbar.h" 80#include "llchatbar.h"
81#include "llconsole.h" 81#include "llconsole.h"
82#include "llviewercontrol.h" 82#include "llviewercontrol.h"
@@ -95,6 +95,7 @@
95#include "llfloateractivespeakers.h" 95#include "llfloateractivespeakers.h"
96#include "llfloaterbuildoptions.h" 96#include "llfloaterbuildoptions.h"
97#include "llfloaterbuyland.h" 97#include "llfloaterbuyland.h"
98#include "llfloatercamera.h"
98#include "llfloaterchat.h" 99#include "llfloaterchat.h"
99#include "llfloaterchatterbox.h" 100#include "llfloaterchatterbox.h"
100#include "llfloatercustomize.h" 101#include "llfloatercustomize.h"
@@ -102,7 +103,6 @@
102#include "llfloaterland.h" 103#include "llfloaterland.h"
103#include "llfloaterinspect.h" 104#include "llfloaterinspect.h"
104#include "llfloatermap.h" 105#include "llfloatermap.h"
105#include "llfloatermute.h"
106#include "llfloaternamedesc.h" 106#include "llfloaternamedesc.h"
107#include "llfloaterpreference.h" 107#include "llfloaterpreference.h"
108#include "llfloatersnapshot.h" 108#include "llfloatersnapshot.h"
@@ -132,7 +132,7 @@
132#include "llresmgr.h" 132#include "llresmgr.h"
133#include "llrootview.h" 133#include "llrootview.h"
134#include "llselectmgr.h" 134#include "llselectmgr.h"
135#include "llsphere.h" 135#include "llrendersphere.h"
136#include "llstartup.h" 136#include "llstartup.h"
137#include "llstatusbar.h" 137#include "llstatusbar.h"
138#include "llstatview.h" 138#include "llstatview.h"
@@ -155,10 +155,9 @@
155#include "lltoolmorph.h" 155#include "lltoolmorph.h"
156#include "lltoolpie.h" 156#include "lltoolpie.h"
157#include "lltoolplacer.h" 157#include "lltoolplacer.h"
158#include "lltoolselect.h"
159#include "lltoolselectland.h" 158#include "lltoolselectland.h"
160#include "lltoolview.h" 159#include "lltoolview.h"
161#include "llvieweruictrlfactory.h" 160#include "lluictrlfactory.h"
162#include "lluploaddialog.h" 161#include "lluploaddialog.h"
163#include "llurldispatcher.h" // SLURL from other app instance 162#include "llurldispatcher.h" // SLURL from other app instance
164#include "llvieweraudio.h" 163#include "llvieweraudio.h"
@@ -177,12 +176,12 @@
177#include "llvovolume.h" 176#include "llvovolume.h"
178#include "llworld.h" 177#include "llworld.h"
179#include "llworldmapview.h" 178#include "llworldmapview.h"
180#include "moviemaker.h"
181#include "pipeline.h" 179#include "pipeline.h"
182#include "llappviewer.h" 180#include "llappviewer.h"
183#include "llurlsimstring.h" 181#include "llurlsimstring.h"
184#include "llviewerdisplay.h" 182#include "llviewerdisplay.h"
185#include "llspatialpartition.h" 183#include "llspatialpartition.h"
184#include "llviewerjoystick.h"
186 185
187#if LL_WINDOWS 186#if LL_WINDOWS
188#include "llwindebug.h" 187#include "llwindebug.h"
@@ -241,11 +240,6 @@ BOOL gPickTransparent = TRUE;
241 240
242BOOL gDebugFastUIRender = FALSE; 241BOOL gDebugFastUIRender = FALSE;
243 242
244BOOL gbCapturing = FALSE;
245#if !LL_SOLARIS
246MovieMaker gMovieMaker;
247#endif
248
249// HUD display lines in lower right 243// HUD display lines in lower right
250BOOL gDisplayWindInfo = FALSE; 244BOOL gDisplayWindInfo = FALSE;
251BOOL gDisplayCameraPos = FALSE; 245BOOL gDisplayCameraPos = FALSE;
@@ -268,7 +262,6 @@ const S32 PICK_DIAMETER = 2 * PICK_HALF_WIDTH+1;
268const F32 MIN_DISPLAY_SCALE = 0.85f; 262const F32 MIN_DISPLAY_SCALE = 0.85f;
269 263
270const S32 CONSOLE_BOTTOM_PAD = 40; 264const S32 CONSOLE_BOTTOM_PAD = 40;
271
272#ifdef SABINRIG 265#ifdef SABINRIG
273/// ALL RIG STUFF 266/// ALL RIG STUFF
274bool rigControl = false; 267bool rigControl = false;
@@ -486,7 +479,7 @@ public:
486 camera_center_text = llformat("CameraCenter %f %f %f", 479 camera_center_text = llformat("CameraCenter %f %f %f",
487 (F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ])); 480 (F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ]));
488 481
489 tvector = LLVector4(gCamera->getAtAxis()); 482 tvector = LLVector4(LLViewerCamera::getInstance()->getAtAxis());
490 camera_view_text = llformat("CameraAtAxis %f %f %f", 483 camera_view_text = llformat("CameraAtAxis %f %f %f",
491 (F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ])); 484 (F32)(tvector.mdV[VX]), (F32)(tvector.mdV[VY]), (F32)(tvector.mdV[VZ]));
492 485
@@ -520,9 +513,16 @@ public:
520 } 513 }
521 if (gDisplayFOV) 514 if (gDisplayFOV)
522 { 515 {
523 addText(xpos, ypos, llformat("FOV: %2.1f deg", RAD_TO_DEG * gCamera->getView())); 516 addText(xpos, ypos, llformat("FOV: %2.1f deg", RAD_TO_DEG * LLViewerCamera::getInstance()->getView()));
524 ypos += y_inc; 517 ypos += y_inc;
525 } 518 }
519
520 if (LLViewerJoystick::getInstance()->getOverrideCamera())
521 {
522 addText(xpos + 200, ypos, llformat("Flycam"));
523 ypos += y_inc;
524 }
525
526 if (gSavedSettings.getBOOL("DebugShowRenderInfo")) 526 if (gSavedSettings.getBOOL("DebugShowRenderInfo"))
527 { 527 {
528 if (gPipeline.getUseVertexShaders() == 0) 528 if (gPipeline.getUseVertexShaders() == 0)
@@ -698,13 +698,10 @@ BOOL LLViewerWindow::handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask
698 gHoverView->cancelHover(); 698 gHoverView->cancelHover();
699 } 699 }
700 700
701 if (gToolMgr) 701 // Don't let the user move the mouse out of the window until mouse up.
702 if( LLToolMgr::getInstance()->getCurrentTool()->clipMouseWhenDown() )
702 { 703 {
703 // Don't let the user move the mouse out of the window until mouse up. 704 mWindow->setMouseClipping(TRUE);
704 if( gToolMgr->getCurrentTool()->clipMouseWhenDown() )
705 {
706 mWindow->setMouseClipping(TRUE);
707 }
708 } 705 }
709 706
710 LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture(); 707 LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture();
@@ -756,16 +753,13 @@ BOOL LLViewerWindow::handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask
756 return FALSE; 753 return FALSE;
757 } 754 }
758 755
759 if (gToolMgr) 756 if(LLToolMgr::getInstance()->getCurrentTool()->handleMouseDown( x, y, mask ) )
760 { 757 {
761 if(gToolMgr->getCurrentTool()->handleMouseDown( x, y, mask ) ) 758 // This is necessary to force clicks in the world to cause edit
762 { 759 // boxes that might have keyboard focus to relinquish it, and hence
763 // This is necessary to force clicks in the world to cause edit 760 // cause a commit to update their value. JC
764 // boxes that might have keyboard focus to relinquish it, and hence 761 gFocusMgr.setKeyboardFocus(NULL);
765 // cause a commit to update their value. JC 762 return TRUE;
766 gFocusMgr.setKeyboardFocus(NULL);
767 return TRUE;
768 }
769 } 763 }
770 764
771 return FALSE; 765 return FALSE;
@@ -842,12 +836,9 @@ BOOL LLViewerWindow::handleDoubleClick(LLWindow *window, LLCoordGL pos, MASK ma
842 return TRUE; 836 return TRUE;
843 } 837 }
844 838
845 if (gToolMgr) 839 if(LLToolMgr::getInstance()->getCurrentTool()->handleDoubleClick( x, y, mask ) )
846 { 840 {
847 if(gToolMgr->getCurrentTool()->handleDoubleClick( x, y, mask ) ) 841 return TRUE;
848 {
849 return TRUE;
850 }
851 } 842 }
852 843
853 // if we got this far and nothing handled a double click, pass a normal mouse down 844 // if we got this far and nothing handled a double click, pass a normal mouse down
@@ -886,15 +877,11 @@ BOOL LLViewerWindow::handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask)
886 877
887 mWindow->releaseMouse(); 878 mWindow->releaseMouse();
888 879
889 LLTool *tool = NULL; 880 LLTool *tool = LLToolMgr::getInstance()->getCurrentTool();
890 if (gToolMgr)
891 {
892 tool = gToolMgr->getCurrentTool();
893 881
894 if( tool->clipMouseWhenDown() ) 882 if( tool->clipMouseWhenDown() )
895 { 883 {
896 mWindow->setMouseClipping(FALSE); 884 mWindow->setMouseClipping(FALSE);
897 }
898 } 885 }
899 886
900 LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture(); 887 LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture();
@@ -986,13 +973,10 @@ BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK
986 gHoverView->cancelHover(); 973 gHoverView->cancelHover();
987 } 974 }
988 975
989 if (gToolMgr) 976 // Don't let the user move the mouse out of the window until mouse up.
977 if( LLToolMgr::getInstance()->getCurrentTool()->clipMouseWhenDown() )
990 { 978 {
991 // Don't let the user move the mouse out of the window until mouse up. 979 mWindow->setMouseClipping(TRUE);
992 if( gToolMgr->getCurrentTool()->clipMouseWhenDown() )
993 {
994 mWindow->setMouseClipping(TRUE);
995 }
996 } 980 }
997 981
998 LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture(); 982 LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture();
@@ -1036,26 +1020,23 @@ BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK
1036 llinfos << "Right Mouse Down not handled by view" << llendl; 1020 llinfos << "Right Mouse Down not handled by view" << llendl;
1037 } 1021 }
1038 1022
1039 if (gToolMgr) 1023 if(LLToolMgr::getInstance()->getCurrentTool()->handleRightMouseDown( x, y, mask ) )
1040 { 1024 {
1041 if(gToolMgr->getCurrentTool()->handleRightMouseDown( x, y, mask ) ) 1025 // This is necessary to force clicks in the world to cause edit
1042 { 1026 // boxes that might have keyboard focus to relinquish it, and hence
1043 // This is necessary to force clicks in the world to cause edit 1027 // cause a commit to update their value. JC
1044 // boxes that might have keyboard focus to relinquish it, and hence 1028 gFocusMgr.setKeyboardFocus(NULL);
1045 // cause a commit to update their value. JC 1029 return TRUE;
1046 gFocusMgr.setKeyboardFocus(NULL);
1047 return TRUE;
1048 }
1049 } 1030 }
1050 1031
1051 // *HACK: this should be rolled into the composite tool logic, not 1032 // *HACK: this should be rolled into the composite tool logic, not
1052 // hardcoded at the top level. 1033 // hardcoded at the top level.
1053 if (gToolPie && (CAMERA_MODE_CUSTOMIZE_AVATAR != gAgent.getCameraMode()) ) 1034 if (CAMERA_MODE_CUSTOMIZE_AVATAR != gAgent.getCameraMode())
1054 { 1035 {
1055 // If the current tool didn't process the click, we should show 1036 // If the current tool didn't process the click, we should show
1056 // the pie menu. This can be done by passing the event to the pie 1037 // the pie menu. This can be done by passing the event to the pie
1057 // menu tool. 1038 // menu tool.
1058 gToolPie->handleRightMouseDown(x, y, mask); 1039 LLToolPie::getInstance()->handleRightMouseDown(x, y, mask);
1059 // show_context_menu( x, y, mask ); 1040 // show_context_menu( x, y, mask );
1060 } 1041 }
1061 1042
@@ -1095,15 +1076,11 @@ BOOL LLViewerWindow::handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK m
1095 1076
1096 mWindow->releaseMouse(); 1077 mWindow->releaseMouse();
1097 1078
1098 LLTool *tool = NULL; 1079 LLTool *tool = LLToolMgr::getInstance()->getCurrentTool();
1099 if (gToolMgr)
1100 {
1101 tool = gToolMgr->getCurrentTool();
1102 1080
1103 if( tool->clipMouseWhenDown() ) 1081 if( tool->clipMouseWhenDown() )
1104 { 1082 {
1105 mWindow->setMouseClipping(FALSE); 1083 mWindow->setMouseClipping(FALSE);
1106 }
1107 } 1084 }
1108 1085
1109 LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture(); 1086 LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture();
@@ -1252,10 +1229,7 @@ void LLViewerWindow::handleFocus(LLWindow *window)
1252 LLModalDialog::onAppFocusGained(); 1229 LLModalDialog::onAppFocusGained();
1253 1230
1254 gAgent.onAppFocusGained(); 1231 gAgent.onAppFocusGained();
1255 if (gToolMgr) 1232 LLToolMgr::getInstance()->onAppFocusGained();
1256 {
1257 gToolMgr->onAppFocusGained();
1258 }
1259 1233
1260 gShowTextEditCursor = TRUE; 1234 gShowTextEditCursor = TRUE;
1261 1235
@@ -1275,10 +1249,7 @@ void LLViewerWindow::handleFocusLost(LLWindow *window)
1275{ 1249{
1276 gFocusMgr.setAppHasFocus(FALSE); 1250 gFocusMgr.setAppHasFocus(FALSE);
1277 //LLModalDialog::onAppFocusLost(); 1251 //LLModalDialog::onAppFocusLost();
1278 if( gToolMgr ) 1252 LLToolMgr::getInstance()->onAppFocusLost();
1279 {
1280 gToolMgr->onAppFocusLost();
1281 }
1282 gFocusMgr.setMouseCapture( NULL ); 1253 gFocusMgr.setMouseCapture( NULL );
1283 1254
1284 if (gMenuBarView) 1255 if (gMenuBarView)
@@ -1340,6 +1311,7 @@ BOOL LLViewerWindow::handleTranslatedKeyUp(KEY key, MASK mask)
1340 1311
1341void LLViewerWindow::handleScanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level) 1312void LLViewerWindow::handleScanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level)
1342{ 1313{
1314 LLViewerJoystick::getInstance()->setCameraNeedsUpdate(true);
1343 return gViewerKeyboard.scanKey(key, key_down, key_up, key_level); 1315 return gViewerKeyboard.scanKey(key, key_down, key_up, key_level);
1344} 1316}
1345 1317
@@ -1402,6 +1374,12 @@ BOOL LLViewerWindow::handleActivate(LLWindow *window, BOOL activated)
1402 return TRUE; 1374 return TRUE;
1403} 1375}
1404 1376
1377BOOL LLViewerWindow::handleActivateApp(LLWindow *window, BOOL activating)
1378{
1379 LLViewerJoystick::getInstance()->setNeedsReset(true);
1380 return FALSE;
1381}
1382
1405 1383
1406void LLViewerWindow::handleMenuSelect(LLWindow *window, S32 menu_item) 1384void LLViewerWindow::handleMenuSelect(LLWindow *window, S32 menu_item)
1407{ 1385{
@@ -1434,9 +1412,9 @@ BOOL LLViewerWindow::handlePaint(LLWindow *window, S32 x, S32 y, S32 width, S
1434 char temp_str[255]; /* Flawfinder: ignore */ 1412 char temp_str[255]; /* Flawfinder: ignore */
1435 snprintf(temp_str, sizeof(temp_str), "%s FPS %3.1f Phy FPS %2.1f Time Dil %1.3f", /* Flawfinder: ignore */ 1413 snprintf(temp_str, sizeof(temp_str), "%s FPS %3.1f Phy FPS %2.1f Time Dil %1.3f", /* Flawfinder: ignore */
1436 name_str.c_str(), 1414 name_str.c_str(),
1437 gViewerStats->mFPSStat.getMeanPerSec(), 1415 LLViewerStats::getInstance()->mFPSStat.getMeanPerSec(),
1438 gViewerStats->mSimPhysicsFPS.getPrev(0), 1416 LLViewerStats::getInstance()->mSimPhysicsFPS.getPrev(0),
1439 gViewerStats->mSimTimeDilation.getPrev(0)); 1417 LLViewerStats::getInstance()->mSimTimeDilation.getPrev(0));
1440 len = strlen(temp_str); /* Flawfinder: ignore */ 1418 len = strlen(temp_str); /* Flawfinder: ignore */
1441 TextOutA(hdc, 0, 0, temp_str, len); 1419 TextOutA(hdc, 0, 0, temp_str, len);
1442 1420
@@ -1488,6 +1466,26 @@ void LLViewerWindow::handleDataCopy(LLWindow *window, S32 data_type, void *data)
1488 } 1466 }
1489} 1467}
1490 1468
1469BOOL LLViewerWindow::handleTimerEvent(LLWindow *window)
1470{
1471 if (LLViewerJoystick::getInstance()->getOverrideCamera())
1472 {
1473 LLViewerJoystick::getInstance()->updateStatus();
1474 return TRUE;
1475 }
1476 return FALSE;
1477}
1478
1479BOOL LLViewerWindow::handleDeviceChange(LLWindow *window)
1480{
1481 // give a chance to use a joystick after startup (hot-plugging)
1482 if (!LLViewerJoystick::getInstance()->isJoystickInitialized() )
1483 {
1484 LLViewerJoystick::getInstance()->init(true);
1485 return TRUE;
1486 }
1487 return FALSE;
1488}
1491 1489
1492// 1490//
1493// Classes 1491// Classes
@@ -1528,7 +1526,8 @@ LLViewerWindow::LLViewerWindow(
1528 gNoRender, 1526 gNoRender,
1529 gSavedSettings.getBOOL("DisableVerticalSync"), 1527 gSavedSettings.getBOOL("DisableVerticalSync"),
1530 !gNoRender, 1528 !gNoRender,
1531 ignore_pixel_depth); 1529 ignore_pixel_depth,
1530 gSavedSettings.getU32("RenderFSAASamples"));
1532#if LL_WINDOWS 1531#if LL_WINDOWS
1533 if (!LLWinDebug::setupExceptionHandler()) 1532 if (!LLWinDebug::setupExceptionHandler())
1534 { 1533 {
@@ -1572,21 +1571,21 @@ LLViewerWindow::LLViewerWindow(
1572 // 1571 //
1573 llinfos << "Loading feature tables." << llendl; 1572 llinfos << "Loading feature tables." << llendl;
1574 1573
1575 gFeatureManagerp->init(); 1574 LLFeatureManager::getInstance()->init();
1576 1575
1577 // Initialize OpenGL Renderer 1576 // Initialize OpenGL Renderer
1578 if (!gFeatureManagerp->isFeatureAvailable("RenderVBOEnable") || 1577 if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") ||
1579 !gGLManager.mHasVertexBufferObject) 1578 !gGLManager.mHasVertexBufferObject)
1580 { 1579 {
1581 gSavedSettings.setBOOL("RenderVBOEnable", FALSE); 1580 gSavedSettings.setBOOL("RenderVBOEnable", FALSE);
1582 } 1581 }
1583 LLVertexBuffer::initClass(gSavedSettings.getBOOL("RenderVBOEnable")); 1582 LLVertexBuffer::initClass(gSavedSettings.getBOOL("RenderVBOEnable"));
1584 1583
1585 if (gFeatureManagerp->isSafe() 1584 if (LLFeatureManager::getInstance()->isSafe()
1586 || (gSavedSettings.getS32("LastFeatureVersion") != gFeatureManagerp->getVersion()) 1585 || (gSavedSettings.getS32("LastFeatureVersion") != LLFeatureManager::getInstance()->getVersion())
1587 || (gSavedSettings.getBOOL("ProbeHardwareOnStartup"))) 1586 || (gSavedSettings.getBOOL("ProbeHardwareOnStartup")))
1588 { 1587 {
1589 gFeatureManagerp->applyRecommendedSettings(); 1588 LLFeatureManager::getInstance()->applyRecommendedSettings();
1590 gSavedSettings.setBOOL("ProbeHardwareOnStartup", FALSE); 1589 gSavedSettings.setBOOL("ProbeHardwareOnStartup", FALSE);
1591 } 1590 }
1592 1591
@@ -1594,7 +1593,7 @@ LLViewerWindow::LLViewerWindow(
1594 if (gSavedSettings.getBOOL("RenderInitError")) 1593 if (gSavedSettings.getBOOL("RenderInitError"))
1595 { 1594 {
1596 mInitAlert = "DisplaySettingsNoShaders"; 1595 mInitAlert = "DisplaySettingsNoShaders";
1597 gFeatureManagerp->setGraphicsLevel(0, false); 1596 LLFeatureManager::getInstance()->setGraphicsLevel(0, false);
1598 gSavedSettings.setU32("RenderQualityPerformance", 0); 1597 gSavedSettings.setU32("RenderQualityPerformance", 0);
1599 1598
1600 } 1599 }
@@ -1617,9 +1616,6 @@ LLViewerWindow::LLViewerWindow(
1617 initFonts(); 1616 initFonts();
1618 } 1617 }
1619 1618
1620 // Init Resource Manager
1621 gResMgr = new LLResMgr();
1622
1623 // Make avatar head look forward at start 1619 // Make avatar head look forward at start
1624 mCurrentMousePoint.mX = getWindowWidth() / 2; 1620 mCurrentMousePoint.mX = getWindowWidth() / 2;
1625 mCurrentMousePoint.mY = getWindowHeight() / 2; 1621 mCurrentMousePoint.mY = getWindowHeight() / 2;
@@ -1790,6 +1786,19 @@ void adjust_rect_top_left(const LLString& control, const LLRect& window)
1790 } 1786 }
1791} 1787}
1792 1788
1789void adjust_rect_top_center(const LLString& control, const LLRect& window)
1790{
1791 LLRect r = gSavedSettings.getRect(control);
1792 if (r.mLeft == 0 && r.mBottom == 0)
1793 {
1794 r.setLeftTopAndSize( window.getWidth()/2 - r.getWidth()/2,
1795 window.getHeight(),
1796 r.getWidth(),
1797 r.getHeight() );
1798 gSavedSettings.setRect(control, r);
1799 }
1800}
1801
1793void adjust_rect_top_right(const LLString& control, const LLRect& window) 1802void adjust_rect_top_right(const LLString& control, const LLRect& window)
1794{ 1803{
1795 LLRect r = gSavedSettings.getRect(control); 1804 LLRect r = gSavedSettings.getRect(control);
@@ -1808,9 +1817,11 @@ void adjust_rect_bottom_center(const LLString& control, const LLRect& window)
1808 LLRect r = gSavedSettings.getRect(control); 1817 LLRect r = gSavedSettings.getRect(control);
1809 if (r.mLeft == 0 && r.mBottom == 0) 1818 if (r.mLeft == 0 && r.mBottom == 0)
1810 { 1819 {
1820 // *TODO: Adjust based on XUI XML
1821 const S32 TOOLBAR_HEIGHT = 64;
1811 r.setOriginAndSize( 1822 r.setOriginAndSize(
1812 window.getWidth()/2 - r.getWidth()/2, 1823 window.getWidth()/2 - r.getWidth()/2,
1813 0, 1824 TOOLBAR_HEIGHT,
1814 r.getWidth(), 1825 r.getWidth(),
1815 r.getHeight()); 1826 r.getHeight());
1816 gSavedSettings.setRect(control, r); 1827 gSavedSettings.setRect(control, r);
@@ -1844,24 +1855,24 @@ void LLViewerWindow::adjustRectanglesForFirstUse(const LLRect& window)
1844{ 1855{
1845 LLRect r; 1856 LLRect r;
1846 1857
1847 adjust_rect_bottom_center("FloaterMoveRect", window); 1858 adjust_rect_bottom_center("FloaterMoveRect2", window);
1848 1859
1849 adjust_rect_bottom_center("FloaterCameraRect", window); 1860 adjust_rect_top_center("FloaterCameraRect3", window);
1850 1861
1851 adjust_rect_top_left("FloaterCustomizeAppearanceRect", window); 1862 adjust_rect_top_left("FloaterCustomizeAppearanceRect", window);
1852 1863
1853 adjust_rect_top_left("FloaterLandRect5", window); 1864 adjust_rect_top_left("FloaterLandRect5", window);
1854 1865
1866 adjust_rect_top_left("FloaterHUDRect", window);
1867
1855 adjust_rect_top_left("FloaterFindRect2", window); 1868 adjust_rect_top_left("FloaterFindRect2", window);
1856 1869
1857 adjust_rect_top_left("FloaterGestureRect", window); 1870 adjust_rect_top_left("FloaterGestureRect2", window);
1858 1871
1859 adjust_rect_top_right("FloaterMiniMapRect", window); 1872 adjust_rect_top_right("FloaterMiniMapRect", window);
1860 1873
1861 adjust_rect_top_right("FloaterLagMeter", window); 1874 adjust_rect_top_right("FloaterLagMeter", window);
1862 1875
1863 adjust_rect_top_right("FloaterLagMeter", window);
1864
1865 adjust_rect_top_left("FloaterBuildOptionsRect", window); 1876 adjust_rect_top_left("FloaterBuildOptionsRect", window);
1866 1877
1867 // bottom-right 1878 // bottom-right
@@ -1921,7 +1932,7 @@ void LLViewerWindow::initWorldUI()
1921 mRootView->addChild(gMorphView); 1932 mRootView->addChild(gMorphView);
1922 gMorphView->setVisible(FALSE); 1933 gMorphView->setVisible(FALSE);
1923 1934
1924 gFloaterMute = LLFloaterMute::getInstance(); 1935 // *Note: this is where gFloaterMute used to be initialized.
1925 1936
1926 LLWorldMapView::initClass(); 1937 LLWorldMapView::initClass();
1927 1938
@@ -1981,15 +1992,12 @@ LLViewerWindow::~LLViewerWindow()
1981 // Automatically deleted as children of mRootView. Fix the globals. 1992 // Automatically deleted as children of mRootView. Fix the globals.
1982 gFloaterTools = NULL; 1993 gFloaterTools = NULL;
1983 gStatusBar = NULL; 1994 gStatusBar = NULL;
1984 gFloaterCamera = NULL;
1985 gIMMgr = NULL; 1995 gIMMgr = NULL;
1986 gHoverView = NULL; 1996 gHoverView = NULL;
1987 1997
1988 gFloaterView = NULL; 1998 gFloaterView = NULL;
1989 gMorphView = NULL; 1999 gMorphView = NULL;
1990 2000
1991 gFloaterMute = NULL;
1992
1993 gFloaterMap = NULL; 2001 gFloaterMap = NULL;
1994 gHUDView = NULL; 2002 gHUDView = NULL;
1995 2003
@@ -1997,9 +2005,6 @@ LLViewerWindow::~LLViewerWindow()
1997 2005
1998 delete mToolTip; 2006 delete mToolTip;
1999 mToolTip = NULL; 2007 mToolTip = NULL;
2000
2001 delete gResMgr;
2002 gResMgr = NULL;
2003 2008
2004 //-------------------------------------------------------- 2009 //--------------------------------------------------------
2005 // Shutdown GL cleanly. Order is very important here. 2010 // Shutdown GL cleanly. Order is very important here.
@@ -2028,11 +2033,8 @@ LLViewerWindow::~LLViewerWindow()
2028 delete[] mPickBuffer; 2033 delete[] mPickBuffer;
2029 mPickBuffer = NULL; 2034 mPickBuffer = NULL;
2030 2035
2031 if (gSelectMgr) 2036 llinfos << "Cleaning up select manager" << llendl;
2032 { 2037 LLSelectMgr::getInstance()->cleanup();
2033 llinfos << "Cleaning up select manager" << llendl;
2034 gSelectMgr->cleanup();
2035 }
2036 2038
2037 LLVertexBuffer::cleanupClass(); 2039 LLVertexBuffer::cleanupClass();
2038 2040
@@ -2106,17 +2108,17 @@ void LLViewerWindow::reshape(S32 width, S32 height)
2106 2108
2107 glViewport(0, 0, width, height ); 2109 glViewport(0, 0, width, height );
2108 2110
2109 if (height > 0 && gCamera) 2111 if (height > 0)
2110 { 2112 {
2111 gCamera->setViewHeightInPixels( height ); 2113 LLViewerCamera::getInstance()->setViewHeightInPixels( height );
2112 if (mWindow->getFullscreen()) 2114 if (mWindow->getFullscreen())
2113 { 2115 {
2114 // force to 4:3 aspect for odd resolutions 2116 // force to 4:3 aspect for odd resolutions
2115 gCamera->setAspect( getDisplayAspectRatio() ); 2117 LLViewerCamera::getInstance()->setAspect( getDisplayAspectRatio() );
2116 } 2118 }
2117 else 2119 else
2118 { 2120 {
2119 gCamera->setAspect( width / (F32) height); 2121 LLViewerCamera::getInstance()->setAspect( width / (F32) height);
2120 } 2122 }
2121 } 2123 }
2122 2124
@@ -2173,8 +2175,8 @@ void LLViewerWindow::reshape(S32 width, S32 height)
2173 } 2175 }
2174 } 2176 }
2175 2177
2176 gViewerStats->setStat(LLViewerStats::ST_WINDOW_WIDTH, (F64)width); 2178 LLViewerStats::getInstance()->setStat(LLViewerStats::ST_WINDOW_WIDTH, (F64)width);
2177 gViewerStats->setStat(LLViewerStats::ST_WINDOW_HEIGHT, (F64)height); 2179 LLViewerStats::getInstance()->setStat(LLViewerStats::ST_WINDOW_HEIGHT, (F64)height);
2178 gResizeScreenTexture = TRUE; 2180 gResizeScreenTexture = TRUE;
2179 } 2181 }
2180} 2182}
@@ -2285,7 +2287,7 @@ void LLViewerWindow::draw()
2285 glLoadIdentity(); 2287 glLoadIdentity();
2286 2288
2287 microsecondsToTimecodeString(gFrameTime,text); 2289 microsecondsToTimecodeString(gFrameTime,text);
2288 const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF ); 2290 const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF );
2289 font->renderUTF8(text, 0, 2291 font->renderUTF8(text, 0,
2290 llround((getWindowWidth()/2)-100.f), 2292 llround((getWindowWidth()/2)-100.f),
2291 llround((getWindowHeight()-60.f)), 2293 llround((getWindowHeight()-60.f)),
@@ -2302,30 +2304,24 @@ void LLViewerWindow::draw()
2302 glScalef(mDisplayScale.mV[VX], mDisplayScale.mV[VY], 1.f); 2304 glScalef(mDisplayScale.mV[VX], mDisplayScale.mV[VY], 1.f);
2303 2305
2304 LLVector2 old_scale_factor = LLUI::sGLScaleFactor; 2306 LLVector2 old_scale_factor = LLUI::sGLScaleFactor;
2305 if (gCamera) 2307 // apply camera zoom transform (for high res screenshots)
2308 F32 zoom_factor = LLViewerCamera::getInstance()->getZoomFactor();
2309 S16 sub_region = LLViewerCamera::getInstance()->getZoomSubRegion();
2310 if (zoom_factor > 1.f)
2306 { 2311 {
2307 // apply camera zoom transform (for high res screenshots) 2312 //decompose subregion number to x and y values
2308 F32 zoom_factor = gCamera->getZoomFactor(); 2313 int pos_y = sub_region / llceil(zoom_factor);
2309 S16 sub_region = gCamera->getZoomSubRegion(); 2314 int pos_x = sub_region - (pos_y*llceil(zoom_factor));
2310 if (zoom_factor > 1.f) 2315 // offset for this tile
2311 { 2316 glTranslatef((F32)gViewerWindow->getWindowWidth() * -(F32)pos_x,
2312 //decompose subregion number to x and y values 2317 (F32)gViewerWindow->getWindowHeight() * -(F32)pos_y,
2313 int pos_y = sub_region / llceil(zoom_factor); 2318 0.f);
2314 int pos_x = sub_region - (pos_y*llceil(zoom_factor)); 2319 glScalef(zoom_factor, zoom_factor, 1.f);
2315 // offset for this tile 2320 LLUI::sGLScaleFactor *= zoom_factor;
2316 glTranslatef((F32)gViewerWindow->getWindowWidth() * -(F32)pos_x,
2317 (F32)gViewerWindow->getWindowHeight() * -(F32)pos_y,
2318 0.f);
2319 glScalef(zoom_factor, zoom_factor, 1.f);
2320 LLUI::sGLScaleFactor *= zoom_factor;
2321 }
2322 } 2321 }
2323 2322
2324 if (gToolMgr) 2323 // Draw tool specific overlay on world
2325 { 2324 LLToolMgr::getInstance()->getCurrentTool()->draw();
2326 // Draw tool specific overlay on world
2327 gToolMgr->getCurrentTool()->draw();
2328 }
2329 2325
2330 if( gAgent.cameraMouselook() ) 2326 if( gAgent.cameraMouselook() )
2331 { 2327 {
@@ -2401,7 +2397,9 @@ void LLViewerWindow::draw()
2401// Takes a single keydown event, usually when UI is visible 2397// Takes a single keydown event, usually when UI is visible
2402BOOL LLViewerWindow::handleKey(KEY key, MASK mask) 2398BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
2403{ 2399{
2404 if (gFocusMgr.getKeyboardFocus() && !(mask & (MASK_CONTROL | MASK_ALT))) 2400 if (gFocusMgr.getKeyboardFocus()
2401 && !(mask & (MASK_CONTROL | MASK_ALT))
2402 && !gFocusMgr.getKeystrokesOnly())
2405 { 2403 {
2406 // We have keyboard focus, and it's not an accelerator 2404 // We have keyboard focus, and it's not an accelerator
2407 2405
@@ -2415,7 +2413,7 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
2415 // HACK look for UI editing keys 2413 // HACK look for UI editing keys
2416 if (LLView::sEditingUI) 2414 if (LLView::sEditingUI)
2417 { 2415 {
2418 if (LLFloaterEditUI::handleKeyEditUI(key, mask)) 2416 if (LLFloaterEditUI::processKeystroke(key, mask))
2419 { 2417 {
2420 return TRUE; 2418 return TRUE;
2421 } 2419 }
@@ -2547,12 +2545,9 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
2547 } 2545 }
2548 } 2546 }
2549 2547
2550 if (gToolMgr) 2548 if( LLToolMgr::getInstance()->getCurrentTool()->handleKey(key, mask) )
2551 { 2549 {
2552 if( gToolMgr->getCurrentTool()->handleKey(key, mask) ) 2550 return TRUE;
2553 {
2554 return TRUE;
2555 }
2556 } 2551 }
2557 2552
2558 // Try for a new-format gesture 2553 // Try for a new-format gesture
@@ -2570,14 +2565,14 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
2570 2565
2571 // Topmost view gets a chance before the hierarchy 2566 // Topmost view gets a chance before the hierarchy
2572 // *FIX: get rid of this? 2567 // *FIX: get rid of this?
2573 LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl(); 2568 //LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl();
2574 if (top_ctrl) 2569 //if (top_ctrl)
2575 { 2570 //{
2576 if( top_ctrl->handleKey( key, mask, TRUE ) ) 2571 // if( top_ctrl->handleKey( key, mask, TRUE ) )
2577 { 2572 // {
2578 return TRUE; 2573 // return TRUE;
2579 } 2574 // }
2580 } 2575 //}
2581 2576
2582 // give floaters first chance to handle TAB key 2577 // give floaters first chance to handle TAB key
2583 // so frontmost floater gets focus 2578 // so frontmost floater gets focus
@@ -2651,12 +2646,12 @@ BOOL LLViewerWindow::handleUnicodeChar(llwchar uni_char, MASK mask)
2651 return TRUE; 2646 return TRUE;
2652 } 2647 }
2653 2648
2654 // Topmost view gets a chance before the hierarchy 2649 //// Topmost view gets a chance before the hierarchy
2655 LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl(); 2650 //LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl();
2656 if (top_ctrl && top_ctrl->handleUnicodeChar( uni_char, FALSE ) ) 2651 //if (top_ctrl && top_ctrl->handleUnicodeChar( uni_char, FALSE ) )
2657 { 2652 //{
2658 return TRUE; 2653 // return TRUE;
2659 } 2654 //}
2660 2655
2661 return TRUE; 2656 return TRUE;
2662 } 2657 }
@@ -2713,11 +2708,8 @@ void LLViewerWindow::handleScrollWheel(S32 clicks)
2713 llinfos << "Scroll Wheel not handled by view" << llendl; 2708 llinfos << "Scroll Wheel not handled by view" << llendl;
2714 } 2709 }
2715 2710
2716 if (gWorldPointer) 2711 // Zoom the camera in and out behavior
2717 { 2712 gAgent.handleScrollWheel(clicks);
2718 // Zoom the camera in and out behavior
2719 gAgent.handleScrollWheel(clicks);
2720 }
2721 2713
2722 return; 2714 return;
2723} 2715}
@@ -2904,9 +2896,9 @@ BOOL LLViewerWindow::handlePerFrameHover()
2904 // *NOTE: sometimes tools handle the mouse as a captor, so this 2896 // *NOTE: sometimes tools handle the mouse as a captor, so this
2905 // logic is a little confusing 2897 // logic is a little confusing
2906 LLTool *tool = NULL; 2898 LLTool *tool = NULL;
2907 if (gToolMgr && gHoverView && gCamera) 2899 if (gHoverView)
2908 { 2900 {
2909 tool = gToolMgr->getCurrentTool(); 2901 tool = LLToolMgr::getInstance()->getCurrentTool();
2910 2902
2911 if(!handled && tool) 2903 if(!handled && tool)
2912 { 2904 {
@@ -2926,8 +2918,8 @@ BOOL LLViewerWindow::handlePerFrameHover()
2926 // Suppress the toolbox view if our source tool was the pie tool, 2918 // Suppress the toolbox view if our source tool was the pie tool,
2927 // and we've overridden to something else. 2919 // and we've overridden to something else.
2928 mSuppressToolbox = 2920 mSuppressToolbox =
2929 (gToolMgr->getBaseTool() == gToolPie) && 2921 (LLToolMgr::getInstance()->getBaseTool() == LLToolPie::getInstance()) &&
2930 (gToolMgr->getCurrentTool() != gToolPie); 2922 (LLToolMgr::getInstance()->getCurrentTool() != LLToolPie::getInstance());
2931 2923
2932 } 2924 }
2933 2925
@@ -2978,19 +2970,19 @@ BOOL LLViewerWindow::handlePerFrameHover()
2978 } 2970 }
2979 } 2971 }
2980 2972
2981 if (tool && tool != gToolNull && tool != gToolInspect && tool != gToolDragAndDrop && !gSavedSettings.getBOOL("FreezeTime")) 2973 if (tool && tool != gToolNull && tool != LLToolCompInspect::getInstance() && tool != LLToolDragAndDrop::getInstance() && !gSavedSettings.getBOOL("FreezeTime"))
2982 { 2974 {
2983 LLMouseHandler *captor = gFocusMgr.getMouseCapture(); 2975 LLMouseHandler *captor = gFocusMgr.getMouseCapture();
2984 // With the null, inspect, or drag and drop tool, don't muck 2976 // With the null, inspect, or drag and drop tool, don't muck
2985 // with visibility. 2977 // with visibility.
2986 2978
2987 if (gFloaterTools->isMinimized() || 2979 if (gFloaterTools->isMinimized() ||
2988 (tool != gToolPie // not default tool 2980 (tool != LLToolPie::getInstance() // not default tool
2989 && tool != gToolGun // not coming out of mouselook 2981 && tool != LLToolCompGun::getInstance() // not coming out of mouselook
2990 && !mSuppressToolbox // not override in third person 2982 && !mSuppressToolbox // not override in third person
2991 && gToolMgr->getCurrentToolset() != gFaceEditToolset // not special mode 2983 && LLToolMgr::getInstance()->getCurrentToolset() != gFaceEditToolset // not special mode
2992 && gToolMgr->getCurrentToolset() != gMouselookToolset 2984 && LLToolMgr::getInstance()->getCurrentToolset() != gMouselookToolset
2993 && (!captor || captor->isView())) // not dragging 2985 && (!captor || captor->isView())) // not dragging
2994 ) 2986 )
2995 { 2987 {
2996 // Force floater tools to be visible (unless minimized) 2988 // Force floater tools to be visible (unless minimized)
@@ -3049,7 +3041,7 @@ BOOL LLViewerWindow::handlePerFrameHover()
3049 3041
3050 // snap floaters to top of chat bar/button strip 3042 // snap floaters to top of chat bar/button strip
3051 LLView* chatbar_and_buttons = gOverlayBar->getChild<LLView>("chatbar_and_buttons", TRUE); 3043 LLView* chatbar_and_buttons = gOverlayBar->getChild<LLView>("chatbar_and_buttons", TRUE);
3052 // find top of chatbar and strate buttons, if either are visible 3044 // find top of chatbar and state buttons, if either are visible
3053 if (chatbar_and_buttons && !chatbar_and_buttons->getLocalBoundingRect().isNull()) 3045 if (chatbar_and_buttons && !chatbar_and_buttons->getLocalBoundingRect().isNull())
3054 { 3046 {
3055 // convert top/left corner of chatbar/buttons container to gFloaterView-relative coordinates 3047 // convert top/left corner of chatbar/buttons container to gFloaterView-relative coordinates
@@ -3088,9 +3080,9 @@ BOOL LLViewerWindow::handlePerFrameHover()
3088 mLastMousePoint = mCurrentMousePoint; 3080 mLastMousePoint = mCurrentMousePoint;
3089 3081
3090 // last ditch force of edit menu to selection manager 3082 // last ditch force of edit menu to selection manager
3091 if (LLEditMenuHandler::gEditMenuHandler == NULL && gSelectMgr && gSelectMgr->getSelection()->getObjectCount()) 3083 if (LLEditMenuHandler::gEditMenuHandler == NULL && LLSelectMgr::getInstance()->getSelection()->getObjectCount())
3092 { 3084 {
3093 LLEditMenuHandler::gEditMenuHandler = gSelectMgr; 3085 LLEditMenuHandler::gEditMenuHandler = LLSelectMgr::getInstance();
3094 } 3086 }
3095 3087
3096 if (gFloaterView->getCycleMode()) 3088 if (gFloaterView->getCycleMode())
@@ -3119,20 +3111,23 @@ BOOL LLViewerWindow::handlePerFrameHover()
3119 gFloaterView->syncFloaterTabOrder(); 3111 gFloaterView->syncFloaterTabOrder();
3120 } 3112 }
3121 3113
3122 if (gSavedSettings.getBOOL("ChatBarStealsFocus") && gChatBar && gFocusMgr.getKeyboardFocus() == NULL && gChatBar->getVisible()) 3114 if (gSavedSettings.getBOOL("ChatBarStealsFocus")
3115 && gChatBar
3116 && gFocusMgr.getKeyboardFocus() == NULL
3117 && gChatBar->isInVisibleChain())
3123 { 3118 {
3124 gChatBar->startChat(NULL); 3119 gChatBar->startChat(NULL);
3125 } 3120 }
3126 3121
3127 // cleanup unused selections when no modal dialogs are open 3122 // cleanup unused selections when no modal dialogs are open
3128 if (gParcelMgr && LLModalDialog::activeCount() == 0) 3123 if (LLModalDialog::activeCount() == 0)
3129 { 3124 {
3130 gParcelMgr->deselectUnused(); 3125 LLViewerParcelMgr::getInstance()->deselectUnused();
3131 } 3126 }
3132 3127
3133 if (gSelectMgr && LLModalDialog::activeCount() == 0) 3128 if (LLModalDialog::activeCount() == 0)
3134 { 3129 {
3135 gSelectMgr->deselectUnused(); 3130 LLSelectMgr::getInstance()->deselectUnused();
3136 } 3131 }
3137 3132
3138 return handled; 3133 return handled;
@@ -3179,12 +3174,12 @@ void LLViewerWindow::saveLastMouse(const LLCoordGL &point)
3179// render_hud_elements: FALSE, FALSE, FALSE 3174// render_hud_elements: FALSE, FALSE, FALSE
3180void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, BOOL for_hud ) 3175void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, BOOL for_hud )
3181{ 3176{
3182 LLObjectSelectionHandle selection = gSelectMgr->getSelection(); 3177 LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
3183 3178
3184 if (!for_hud && !for_gl_pick) 3179 if (!for_hud && !for_gl_pick)
3185 { 3180 {
3186 // Call this once and only once 3181 // Call this once and only once
3187 gSelectMgr->updateSilhouettes(); 3182 LLSelectMgr::getInstance()->updateSilhouettes();
3188 } 3183 }
3189 3184
3190 // Draw fence around land selections 3185 // Draw fence around land selections
@@ -3192,18 +3187,18 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls,
3192 { 3187 {
3193 if (pick_parcel_walls) 3188 if (pick_parcel_walls)
3194 { 3189 {
3195 gParcelMgr->renderParcelCollision(); 3190 LLViewerParcelMgr::getInstance()->renderParcelCollision();
3196 } 3191 }
3197 } 3192 }
3198 else if (( for_hud && selection->getSelectType() == SELECT_TYPE_HUD) || 3193 else if (( for_hud && selection->getSelectType() == SELECT_TYPE_HUD) ||
3199 (!for_hud && selection->getSelectType() != SELECT_TYPE_HUD)) 3194 (!for_hud && selection->getSelectType() != SELECT_TYPE_HUD))
3200 { 3195 {
3201 gSelectMgr->renderSilhouettes(for_hud); 3196 LLSelectMgr::getInstance()->renderSilhouettes(for_hud);
3202 3197
3203 stop_glerror(); 3198 stop_glerror();
3204 3199
3205 // setup HUD render 3200 // setup HUD render
3206 if (selection->getSelectType() == SELECT_TYPE_HUD && gSelectMgr->getSelection()->getObjectCount()) 3201 if (selection->getSelectType() == SELECT_TYPE_HUD && LLSelectMgr::getInstance()->getSelection()->getObjectCount())
3207 { 3202 {
3208 LLBBox hud_bbox = gAgent.getAvatarObject()->getHUDBBox(); 3203 LLBBox hud_bbox = gAgent.getAvatarObject()->getHUDBBox();
3209 3204
@@ -3212,7 +3207,7 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls,
3212 glPushMatrix(); 3207 glPushMatrix();
3213 glLoadIdentity(); 3208 glLoadIdentity();
3214 F32 depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f); 3209 F32 depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f);
3215 glOrtho(-0.5f * gCamera->getAspect(), 0.5f * gCamera->getAspect(), -0.5f, 0.5f, 0.f, depth); 3210 glOrtho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, depth);
3216 3211
3217 glMatrixMode(GL_MODELVIEW); 3212 glMatrixMode(GL_MODELVIEW);
3218 glPushMatrix(); 3213 glPushMatrix();
@@ -3222,7 +3217,7 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls,
3222 } 3217 }
3223 3218
3224 // Render light for editing 3219 // Render light for editing
3225 if (LLSelectMgr::sRenderLightRadius && gToolMgr->inEdit()) 3220 if (LLSelectMgr::sRenderLightRadius && LLToolMgr::getInstance()->inEdit())
3226 { 3221 {
3227 LLImageGL::unbindTexture(0); 3222 LLImageGL::unbindTexture(0);
3228 LLGLEnable gls_blend(GL_BLEND); 3223 LLGLEnable gls_blend(GL_BLEND);
@@ -3268,7 +3263,7 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls,
3268 return true; 3263 return true;
3269 } 3264 }
3270 } func; 3265 } func;
3271 gSelectMgr->getSelection()->applyToObjects(&func); 3266 LLSelectMgr::getInstance()->getSelection()->applyToObjects(&func);
3272 3267
3273 glPopMatrix(); 3268 glPopMatrix();
3274 } 3269 }
@@ -3277,7 +3272,7 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls,
3277 // not be recalculated at this time. If they are, then group rotations will break. 3272 // not be recalculated at this time. If they are, then group rotations will break.
3278 3273
3279 // Draw arrows at average center of all selected objects 3274 // Draw arrows at average center of all selected objects
3280 LLTool* tool = gToolMgr->getCurrentTool(); 3275 LLTool* tool = LLToolMgr::getInstance()->getCurrentTool();
3281 if (tool) 3276 if (tool)
3282 { 3277 {
3283 if(tool->isAlwaysRendered()) 3278 if(tool->isAlwaysRendered())
@@ -3286,15 +3281,15 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls,
3286 } 3281 }
3287 else 3282 else
3288 { 3283 {
3289 if( !gSelectMgr->getSelection()->isEmpty() ) 3284 if( !LLSelectMgr::getInstance()->getSelection()->isEmpty() )
3290 { 3285 {
3291 BOOL moveable_object_selected = FALSE; 3286 BOOL moveable_object_selected = FALSE;
3292 BOOL all_selected_objects_move = TRUE; 3287 BOOL all_selected_objects_move = TRUE;
3293 BOOL all_selected_objects_modify = TRUE; 3288 BOOL all_selected_objects_modify = TRUE;
3294 BOOL selecting_linked_set = !gSavedSettings.getBOOL("EditLinkedParts"); 3289 BOOL selecting_linked_set = !gSavedSettings.getBOOL("EditLinkedParts");
3295 3290
3296 for (LLObjectSelection::iterator iter = gSelectMgr->getSelection()->begin(); 3291 for (LLObjectSelection::iterator iter = LLSelectMgr::getInstance()->getSelection()->begin();
3297 iter != gSelectMgr->getSelection()->end(); iter++) 3292 iter != LLSelectMgr::getInstance()->getSelection()->end(); iter++)
3298 { 3293 {
3299 LLSelectNode* nodep = *iter; 3294 LLSelectNode* nodep = *iter;
3300 LLViewerObject* object = nodep->getObject(); 3295 LLViewerObject* object = nodep->getObject();
@@ -3310,17 +3305,17 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls,
3310 3305
3311 BOOL draw_handles = TRUE; 3306 BOOL draw_handles = TRUE;
3312 3307
3313 if (tool == gToolTranslate && (!moveable_object_selected || !all_selected_objects_move)) 3308 if (tool == LLToolCompTranslate::getInstance() && (!moveable_object_selected || !all_selected_objects_move))
3314 { 3309 {
3315 draw_handles = FALSE; 3310 draw_handles = FALSE;
3316 } 3311 }
3317 3312
3318 if (tool == gToolRotate && (!moveable_object_selected || !all_selected_objects_move)) 3313 if (tool == LLToolCompRotate::getInstance() && (!moveable_object_selected || !all_selected_objects_move))
3319 { 3314 {
3320 draw_handles = FALSE; 3315 draw_handles = FALSE;
3321 } 3316 }
3322 3317
3323 if ( !all_selected_objects_modify && tool == gToolStretch ) 3318 if ( !all_selected_objects_modify && tool == LLToolCompScale::getInstance() )
3324 { 3319 {
3325 draw_handles = FALSE; 3320 draw_handles = FALSE;
3326 } 3321 }
@@ -3424,13 +3419,13 @@ void LLViewerWindow::hitObjectOrLandGlobalAsync(S32 x, S32 y_from_bot, MASK mask
3424 gLastHitParcelWall = FALSE; 3419 gLastHitParcelWall = FALSE;
3425 3420
3426 LLCamera pick_camera; 3421 LLCamera pick_camera;
3427 pick_camera.setOrigin(gCamera->getOrigin()); 3422 pick_camera.setOrigin(LLViewerCamera::getInstance()->getOrigin());
3428 pick_camera.setOriginAndLookAt(gCamera->getOrigin(), 3423 pick_camera.setOriginAndLookAt(LLViewerCamera::getInstance()->getOrigin(),
3429 gCamera->getUpAxis(), 3424 LLViewerCamera::getInstance()->getUpAxis(),
3430 gCamera->getOrigin() + mouseDirectionGlobal(x, y_from_bot)); 3425 LLViewerCamera::getInstance()->getOrigin() + mouseDirectionGlobal(x, y_from_bot));
3431 pick_camera.setView(0.5f*DEG_TO_RAD); 3426 pick_camera.setView(0.5f*DEG_TO_RAD);
3432 pick_camera.setNear(gCamera->getNear()); 3427 pick_camera.setNear(LLViewerCamera::getInstance()->getNear());
3433 pick_camera.setFar(gCamera->getFar()); 3428 pick_camera.setFar(LLViewerCamera::getInstance()->getFar());
3434 pick_camera.setAspect(1.f); 3429 pick_camera.setAspect(1.f);
3435 3430
3436 // save our drawing state 3431 // save our drawing state
@@ -3447,8 +3442,7 @@ void LLViewerWindow::hitObjectOrLandGlobalAsync(S32 x, S32 y_from_bot, MASK mask
3447 // build perspective transform and picking viewport 3442 // build perspective transform and picking viewport
3448 // Perform pick on a PICK_DIAMETER x PICK_DIAMETER pixel region around cursor point. 3443 // Perform pick on a PICK_DIAMETER x PICK_DIAMETER pixel region around cursor point.
3449 // Don't limit the select distance for this pick. 3444 // Don't limit the select distance for this pick.
3450 // make viewport big enough to handle antialiased frame buffers 3445 LLViewerCamera::getInstance()->setPerspective(FOR_SELECTION, scaled_x - (PICK_HALF_WIDTH + 2), scaled_y - (PICK_HALF_WIDTH + 2), PICK_DIAMETER + 4, PICK_DIAMETER + 4, FALSE);
3451 gCamera->setPerspective(FOR_SELECTION, scaled_x - (PICK_HALF_WIDTH + 2), scaled_y - (PICK_HALF_WIDTH + 2), PICK_DIAMETER + 4, PICK_DIAMETER + 4, FALSE);
3452 // make viewport big enough to handle antialiased frame buffers 3446 // make viewport big enough to handle antialiased frame buffers
3453 gGLViewport[0] = scaled_x - (PICK_HALF_WIDTH + 2); 3447 gGLViewport[0] = scaled_x - (PICK_HALF_WIDTH + 2);
3454 gGLViewport[1] = scaled_y - (PICK_HALF_WIDTH + 2); 3448 gGLViewport[1] = scaled_y - (PICK_HALF_WIDTH + 2);
@@ -3519,13 +3513,13 @@ void LLViewerWindow::hitUIElementAsync(S32 x, S32 y_from_bot, MASK mask, void (*
3519 gLastHitUIElement = 0; 3513 gLastHitUIElement = 0;
3520 3514
3521 LLCamera pick_camera; 3515 LLCamera pick_camera;
3522 pick_camera.setOrigin(gCamera->getOrigin()); 3516 pick_camera.setOrigin(LLViewerCamera::getInstance()->getOrigin());
3523 pick_camera.setOriginAndLookAt(gCamera->getOrigin(), 3517 pick_camera.setOriginAndLookAt(LLViewerCamera::getInstance()->getOrigin(),
3524 gCamera->getUpAxis(), 3518 LLViewerCamera::getInstance()->getUpAxis(),
3525 gCamera->getOrigin() + mouseDirectionGlobal(x, y_from_bot)); 3519 LLViewerCamera::getInstance()->getOrigin() + mouseDirectionGlobal(x, y_from_bot));
3526 pick_camera.setView(0.5f*DEG_TO_RAD); 3520 pick_camera.setView(0.5f*DEG_TO_RAD);
3527 pick_camera.setNear(gCamera->getNear()); 3521 pick_camera.setNear(LLViewerCamera::getInstance()->getNear());
3528 pick_camera.setFar(gCamera->getFar()); 3522 pick_camera.setFar(LLViewerCamera::getInstance()->getFar());
3529 pick_camera.setAspect(1.f); 3523 pick_camera.setAspect(1.f);
3530 3524
3531 // save our drawing state 3525 // save our drawing state
@@ -3755,7 +3749,7 @@ LLViewerObject* LLViewerWindow::getObjectUnderCursor(const F32 depth)
3755 S32 y = getCurrentMouseY(); 3749 S32 y = getCurrentMouseY();
3756 3750
3757 LLVector3 mouse_direction_global = mouseDirectionGlobal(x,y); 3751 LLVector3 mouse_direction_global = mouseDirectionGlobal(x,y);
3758 LLVector3 camera_pos_global = gCamera->getOrigin(); 3752 LLVector3 camera_pos_global = LLViewerCamera::getInstance()->getOrigin();
3759 LLVector3 pick_end = camera_pos_global + mouse_direction_global * depth; 3753 LLVector3 pick_end = camera_pos_global + mouse_direction_global * depth;
3760 LLVector3 collision_point; 3754 LLVector3 collision_point;
3761 return gPipeline.pickObject(camera_pos_global, pick_end, collision_point); 3755 return gPipeline.pickObject(camera_pos_global, pick_end, collision_point);
@@ -3841,7 +3835,7 @@ void LLViewerWindow::analyzeHit(
3841 U8 uv_pick_buffer[UV_PICK_WIDTH * UV_PICK_WIDTH * 4]; 3835 U8 uv_pick_buffer[UV_PICK_WIDTH * UV_PICK_WIDTH * 4];
3842 S32 pick_face = face; 3836 S32 pick_face = face;
3843 LLFace* facep = objectp->mDrawable->getFace(pick_face); 3837 LLFace* facep = objectp->mDrawable->getFace(pick_face);
3844 gCamera->setPerspective(FOR_SELECTION, scaled_x - UV_PICK_HALF_WIDTH, scaled_y - UV_PICK_HALF_WIDTH, UV_PICK_WIDTH, UV_PICK_WIDTH, FALSE); 3838 LLViewerCamera::getInstance()->setPerspective(FOR_SELECTION, scaled_x - UV_PICK_HALF_WIDTH, scaled_y - UV_PICK_HALF_WIDTH, UV_PICK_WIDTH, UV_PICK_WIDTH, FALSE);
3845 glViewport(scaled_x - UV_PICK_HALF_WIDTH, scaled_y - UV_PICK_HALF_WIDTH, UV_PICK_WIDTH, UV_PICK_WIDTH); 3839 glViewport(scaled_x - UV_PICK_HALF_WIDTH, scaled_y - UV_PICK_HALF_WIDTH, UV_PICK_WIDTH, UV_PICK_WIDTH);
3846 gPipeline.renderFaceForUVSelect(facep); 3840 gPipeline.renderFaceForUVSelect(facep);
3847 3841
@@ -3875,7 +3869,7 @@ void LLViewerWindow::analyzeHit(
3875LLVector3 LLViewerWindow::mouseDirectionGlobal(const S32 x, const S32 y) const 3869LLVector3 LLViewerWindow::mouseDirectionGlobal(const S32 x, const S32 y) const
3876{ 3870{
3877 // find vertical field of view 3871 // find vertical field of view
3878 F32 fov = gCamera->getView(); 3872 F32 fov = LLViewerCamera::getInstance()->getView();
3879 3873
3880 // find screen resolution 3874 // find screen resolution
3881 S32 height = getWindowHeight(); 3875 S32 height = getWindowHeight();
@@ -3889,9 +3883,9 @@ LLVector3 LLViewerWindow::mouseDirectionGlobal(const S32 x, const S32 y) const
3889 F32 click_y = y - height / 2.f; 3883 F32 click_y = y - height / 2.f;
3890 3884
3891 // compute mouse vector 3885 // compute mouse vector
3892 LLVector3 mouse_vector = distance * gCamera->getAtAxis() 3886 LLVector3 mouse_vector = distance * LLViewerCamera::getInstance()->getAtAxis()
3893 - click_x * gCamera->getLeftAxis() 3887 - click_x * LLViewerCamera::getInstance()->getLeftAxis()
3894 + click_y * gCamera->getUpAxis(); 3888 + click_y * LLViewerCamera::getInstance()->getUpAxis();
3895 3889
3896 mouse_vector.normVec(); 3890 mouse_vector.normVec();
3897 3891
@@ -3904,8 +3898,8 @@ LLVector3 LLViewerWindow::mouseDirectionGlobal(const S32 x, const S32 y) const
3904LLVector3 LLViewerWindow::mouseDirectionCamera(const S32 x, const S32 y) const 3898LLVector3 LLViewerWindow::mouseDirectionCamera(const S32 x, const S32 y) const
3905{ 3899{
3906 // find vertical field of view 3900 // find vertical field of view
3907 F32 fov_height = gCamera->getView(); 3901 F32 fov_height = LLViewerCamera::getInstance()->getView();
3908 F32 fov_width = fov_height * gCamera->getAspect(); 3902 F32 fov_width = fov_height * LLViewerCamera::getInstance()->getAspect();
3909 3903
3910 // find screen resolution 3904 // find screen resolution
3911 S32 height = getWindowHeight(); 3905 S32 height = getWindowHeight();
@@ -3982,7 +3976,7 @@ BOOL LLViewerWindow::mousePointOnLandGlobal(const S32 x, const S32 y, LLVector3d
3982 mouse_direction_global_d.setVec(mouse_direction_global * mouse_dir_scale); 3976 mouse_direction_global_d.setVec(mouse_direction_global * mouse_dir_scale);
3983 probe_point_global = camera_pos_global + mouse_direction_global_d; 3977 probe_point_global = camera_pos_global + mouse_direction_global_d;
3984 3978
3985 regionp = gWorldPointer->resolveRegionGlobal(probe_point_region, probe_point_global); 3979 regionp = LLWorld::getInstance()->resolveRegionGlobal(probe_point_region, probe_point_global);
3986 3980
3987 if (!regionp) 3981 if (!regionp)
3988 { 3982 {
@@ -4029,7 +4023,7 @@ BOOL LLViewerWindow::mousePointOnLandGlobal(const S32 x, const S32 y, LLVector3d
4029 mouse_direction_global_d.setVec(mouse_direction_global * mouse_dir_scale); 4023 mouse_direction_global_d.setVec(mouse_direction_global * mouse_dir_scale);
4030 probe_point_global = camera_pos_global + mouse_direction_global_d; 4024 probe_point_global = camera_pos_global + mouse_direction_global_d;
4031 4025
4032 regionp = gWorldPointer->resolveRegionGlobal(probe_point_region, probe_point_global); 4026 regionp = LLWorld::getInstance()->resolveRegionGlobal(probe_point_region, probe_point_global);
4033 4027
4034 if (!regionp) 4028 if (!regionp)
4035 { 4029 {
@@ -4179,108 +4173,6 @@ BOOL LLViewerWindow::saveImageNumbered(LLImageRaw *raw, const LLString& extensio
4179 return success; 4173 return success;
4180} 4174}
4181 4175
4182void LLViewerWindow::saveMovieNumbered(void*)
4183{
4184 if (!gbCapturing)
4185 {
4186 // Get a directory if this is the first time.
4187 if (strlen(sSnapshotDir) == 0) /* Flawfinder: ignore */
4188 {
4189 LLString proposed_name( sMovieBaseName );
4190#if LL_DARWIN
4191 proposed_name.append( ".mov" );
4192#else
4193 proposed_name.append( ".avi" );
4194#endif
4195
4196 // pick a directory in which to save
4197 LLFilePicker &picker = LLFilePicker::instance();
4198 if (!picker.getSaveFile(LLFilePicker::FFSAVE_AVI, proposed_name.c_str()))
4199 {
4200 // Clicked cancel
4201 return;
4202 }
4203
4204 // Copy the directory + file name
4205 char directory[LL_MAX_PATH]; /* Flawfinder: ignore */
4206 strncpy(directory, picker.getFirstFile(), LL_MAX_PATH -1); /* Flawfinder: ignore */
4207 directory[LL_MAX_PATH -1] = '\0';
4208
4209 // Smash the file extension
4210 S32 length = strlen(directory); /* Flawfinder: ignore */
4211 S32 index = length;
4212
4213 // Back up over ".bmp"
4214 index -= 4;
4215 if (index >= 0 && directory[index] == '.')
4216 {
4217 directory[index] = '\0';
4218 }
4219 else
4220 {
4221 index = length;
4222 }
4223
4224 // Find trailing backslash
4225 while (index >= 0 && directory[index] != gDirUtilp->getDirDelimiter()[0])
4226 {
4227 index--;
4228 }
4229
4230 // If we found one, truncate the string there
4231 if (index >= 0)
4232 {
4233 if (index + 1 <= length)
4234 {
4235 strncpy(LLViewerWindow::sMovieBaseName, directory + index + 1, LL_MAX_PATH -1); /* Flawfinder: ignore */
4236 LLViewerWindow::sMovieBaseName[LL_MAX_PATH -1] = '\0';
4237 }
4238
4239 index++;
4240 directory[index] = '\0';
4241 strncpy(LLViewerWindow::sSnapshotDir, directory, LL_MAX_PATH -1); /* Flawfinder: ignore */
4242 LLViewerWindow::sSnapshotDir[LL_MAX_PATH -1] = '\0';
4243 }
4244 }
4245
4246 // Look for an unused file name
4247 LLString filepath;
4248 S32 i = 1;
4249 S32 err = 0;
4250
4251 do
4252 {
4253 char extension[100]; /* Flawfinder: ignore */
4254#if LL_DARWIN
4255 snprintf( extension, sizeof(extension), "_%.3d.mov", i ); /* Flawfinder: ignore */
4256#else
4257 snprintf( extension, sizeof(extension), "_%.3d.avi", i ); /* Flawfinder: ignore */
4258#endif
4259 filepath.assign( sSnapshotDir );
4260 filepath.append( sMovieBaseName );
4261 filepath.append( extension );
4262
4263 struct stat stat_info;
4264 err = gViewerWindow->mWindow->stat( filepath.c_str(), &stat_info );
4265 i++;
4266 }
4267 while( -1 != err ); // search until the file is not found (i.e., stat() gives an error).
4268 S32 x = gViewerWindow->getWindowWidth();
4269 S32 y = gViewerWindow->getWindowHeight();
4270
4271 gbCapturing = TRUE;
4272#if !LL_SOLARIS
4273 gMovieMaker.StartCapture((char *)filepath.c_str(), x, y);
4274#endif
4275 }
4276 else
4277 {
4278#if !LL_SOLARIS
4279 gMovieMaker.EndCapture();
4280#endif
4281 gbCapturing = FALSE;
4282 }
4283}
4284 4176
4285static S32 BORDERHEIGHT = 0; 4177static S32 BORDERHEIGHT = 0;
4286static S32 BORDERWIDTH = 0; 4178static S32 BORDERWIDTH = 0;
@@ -4348,16 +4240,147 @@ void LLViewerWindow::playSnapshotAnimAndSound()
4348 send_sound_trigger(LLUUID(gSavedSettings.getString("UISndSnapshot")), 1.0f); 4240 send_sound_trigger(LLUUID(gSavedSettings.getString("UISndSnapshot")), 1.0f);
4349} 4241}
4350 4242
4243BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 preview_height, BOOL show_ui, BOOL do_rebuild, ESnapshotType type)
4244{
4245 if ((!raw) || preview_width < 10 || preview_height < 10)
4246 {
4247 return FALSE;
4248 }
4249
4250 if(gResizeScreenTexture) //the window is resizing
4251 {
4252 return FALSE ;
4253 }
4254
4255 setCursor(UI_CURSOR_WAIT);
4256
4257 // Hide all the UI widgets first and draw a frame
4258 BOOL prev_draw_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI);
4259
4260 if ( prev_draw_ui != show_ui)
4261 {
4262 LLPipeline::toggleRenderDebugFeature((void*)LLPipeline::RENDER_DEBUG_FEATURE_UI);
4263 }
4264
4265 BOOL hide_hud = !gSavedSettings.getBOOL("RenderHUDInSnapshot") && LLPipeline::sShowHUDAttachments;
4266 if (hide_hud)
4267 {
4268 LLPipeline::sShowHUDAttachments = FALSE;
4269 }
4270
4271 S32 render_name = gSavedSettings.getS32("RenderName");
4272 gSavedSettings.setS32("RenderName", 0);
4273 LLVOAvatar::updateFreezeCounter(1) ; //pause avatar updating for one frame
4274
4275 S32 w = preview_width ;
4276 S32 h = preview_height ;
4277 LLVector2 display_scale = mDisplayScale ;
4278 mDisplayScale.setVec((F32)w / mWindowRect.getWidth(), (F32)h / mWindowRect.getHeight()) ;
4279 LLRect window_rect = mWindowRect;
4280 mWindowRect.set(0, h, w, 0);
4281
4282 gDisplaySwapBuffers = FALSE;
4283 glClearColor(0.f, 0.f, 0.f, 0.f);
4284 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
4285 setup3DRender();
4286 setupViewport();
4287
4288 LLFontGL::setFontDisplay(FALSE) ;
4289 LLHUDText::setDisplayText(FALSE) ;
4290 if (type == SNAPSHOT_TYPE_OBJECT_ID)
4291 {
4292 gPickTransparent = FALSE;
4293 gObjectList.renderObjectsForSelect(*LLViewerCamera::getInstance(), FALSE, FALSE);
4294 }
4295 else
4296 {
4297 display(do_rebuild, 1.0f, 0, TRUE);
4298 render_ui_and_swap();
4299 }
4300
4301 S32 glformat, gltype, glpixel_length ;
4302 if(SNAPSHOT_TYPE_DEPTH == type)
4303 {
4304 glpixel_length = 4 ;
4305 glformat = GL_DEPTH_COMPONENT ;
4306 gltype = GL_FLOAT ;
4307 }
4308 else
4309 {
4310 glpixel_length = 3 ;
4311 glformat = GL_RGB ;
4312 gltype = GL_UNSIGNED_BYTE ;
4313 }
4314
4315 raw->resize(w, h, glpixel_length);
4316 glReadPixels(0, 0, w, h, glformat, gltype, raw->getData());
4317
4318 if(SNAPSHOT_TYPE_DEPTH == type)
4319 {
4320 LLViewerCamera* camerap = LLViewerCamera::getInstance();
4321 F32 depth_conversion_factor_1 = (camerap->getFar() + camerap->getNear()) / (2.f * camerap->getFar() * camerap->getNear());
4322 F32 depth_conversion_factor_2 = (camerap->getFar() - camerap->getNear()) / (2.f * camerap->getFar() * camerap->getNear());
4323
4324 //calculate the depth
4325 for (S32 y = 0 ; y < h ; y++)
4326 {
4327 for(S32 x = 0 ; x < w ; x++)
4328 {
4329 S32 i = (w * y + x) << 2 ;
4330
4331 F32 depth_float_i = *(F32*)(raw->getData() + i);
4332
4333 F32 linear_depth_float = 1.f / (depth_conversion_factor_1 - (depth_float_i * depth_conversion_factor_2));
4334 U8 depth_byte = F32_to_U8(linear_depth_float, camerap->getNear(), camerap->getFar());
4335 *(raw->getData() + i + 0) = depth_byte;
4336 *(raw->getData() + i + 1) = depth_byte;
4337 *(raw->getData() + i + 2) = depth_byte;
4338 *(raw->getData() + i + 3) = 255;
4339 }
4340 }
4341 }
4342
4343 LLFontGL::setFontDisplay(TRUE) ;
4344 LLHUDText::setDisplayText(TRUE) ;
4345 mDisplayScale.setVec(display_scale) ;
4346 mWindowRect = window_rect;
4347 setup3DRender();
4348 setupViewport();
4349 gDisplaySwapBuffers = FALSE;
4350
4351 // POST SNAPSHOT
4352 if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
4353 {
4354 LLPipeline::toggleRenderDebugFeature((void*)LLPipeline::RENDER_DEBUG_FEATURE_UI);
4355 }
4356
4357 if (hide_hud)
4358 {
4359 LLPipeline::sShowHUDAttachments = TRUE;
4360 }
4361
4362 setCursor(UI_CURSOR_ARROW);
4363
4364 if (do_rebuild)
4365 {
4366 // If we had to do a rebuild, that means that the lists of drawables to be rendered
4367 // was empty before we started.
4368 // Need to reset these, otherwise we call state sort on it again when render gets called the next time
4369 // and we stand a good chance of crashing on rebuild because the render drawable arrays have multiple copies of
4370 // objects on them.
4371 gPipeline.resetDrawOrders();
4372 }
4373
4374 gSavedSettings.setS32("RenderName", render_name);
4375
4376 return TRUE;
4377}
4351 4378
4352// Saves the image from the screen to the specified filename and path. 4379// Saves the image from the screen to the specified filename and path.
4353BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, 4380BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height,
4354 BOOL keep_window_aspect, BOOL is_texture, BOOL show_ui, BOOL do_rebuild, ESnapshotType type, S32 max_size) 4381 BOOL keep_window_aspect, BOOL is_texture, BOOL show_ui, BOOL do_rebuild, ESnapshotType type, S32 max_size)
4355{ 4382{
4356 //F32 image_aspect_ratio = ((F32)image_width) / ((F32)image_height); 4383 if (!raw)
4357 //F32 window_aspect_ratio = ((F32)getWindowWidth()) / ((F32)getWindowHeight());
4358
4359 if ((!gWorldPointer) ||
4360 (!raw))
4361 { 4384 {
4362 return FALSE; 4385 return FALSE;
4363 } 4386 }
@@ -4388,43 +4411,22 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
4388 // from window 4411 // from window
4389 S32 snapshot_width = mWindowRect.getWidth(); 4412 S32 snapshot_width = mWindowRect.getWidth();
4390 S32 snapshot_height = mWindowRect.getHeight(); 4413 S32 snapshot_height = mWindowRect.getHeight();
4391 F32 scale_factor = 1.0f ;
4392 if (keep_window_aspect || is_texture) //map the entire window to snapshot
4393 {
4394 }
4395 else //scale or crop
4396 {
4397 if(snapshot_width > image_width) //crop
4398 {
4399 snapshot_width = image_width ;
4400 }
4401 if(snapshot_height > image_height)//crop
4402 {
4403 snapshot_height = image_height ;
4404 }
4405
4406 //if (image_aspect_ratio > window_aspect_ratio)
4407 //{
4408 // snapshot_height = llround((F32)snapshot_width / image_aspect_ratio);
4409 //}
4410 //else if (image_aspect_ratio < window_aspect_ratio)
4411 //{
4412 // snapshot_width = llround((F32)snapshot_height * image_aspect_ratio);
4413 //}
4414 }
4415
4416 LLRenderTarget target;
4417
4418 scale_factor = llmax(1.f, (F32)image_width / snapshot_width, (F32)image_height / snapshot_height);
4419
4420 // SNAPSHOT 4414 // SNAPSHOT
4421 S32 window_width = mWindowRect.getWidth(); 4415 S32 window_width = mWindowRect.getWidth();
4422 S32 window_height = mWindowRect.getHeight(); 4416 S32 window_height = mWindowRect.getHeight();
4423
4424 LLRect window_rect = mWindowRect; 4417 LLRect window_rect = mWindowRect;
4425
4426 BOOL use_fbo = FALSE; 4418 BOOL use_fbo = FALSE;
4427 4419
4420 F32 scale_factor = 1.0f ;
4421 if(!keep_window_aspect) //image cropping
4422 {
4423 F32 ratio = llmin( (F32)window_width / image_width , (F32)window_height / image_height) ;
4424 snapshot_width = (S32)(ratio * image_width) ;
4425 snapshot_height = (S32)(ratio * image_height) ;
4426 scale_factor = llmax(1.0f, 1.0f / ratio) ;
4427 }
4428
4429 LLRenderTarget target;
4428 if (gGLManager.mHasFramebufferObject && 4430 if (gGLManager.mHasFramebufferObject &&
4429 (image_width > window_width || 4431 (image_width > window_width ||
4430 image_height > window_height) && 4432 image_height > window_height) &&
@@ -4445,9 +4447,14 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
4445 window_height = snapshot_height; 4447 window_height = snapshot_height;
4446 scale_factor = 1.f; 4448 scale_factor = 1.f;
4447 mWindowRect.set(0, 0, snapshot_width, snapshot_height); 4449 mWindowRect.set(0, 0, snapshot_width, snapshot_height);
4448 target.bindTarget(); 4450 target.bindTarget();
4449 4451 }
4450 4452 else //tiling
4453 {
4454 F32 ratio = llmin( (F32)window_width / image_width , (F32)window_height / image_height) ;
4455 snapshot_width = (S32)(ratio * image_width) ;
4456 snapshot_height = (S32)(ratio * image_height) ;
4457 scale_factor = llmax(1.0f, 1.0f / ratio) ;
4451 } 4458 }
4452 } 4459 }
4453 4460
@@ -4479,8 +4486,8 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
4479 4486
4480 S32 output_buffer_offset_y = 0; 4487 S32 output_buffer_offset_y = 0;
4481 4488
4482 F32 depth_conversion_factor_1 = (gCamera->getFar() + gCamera->getNear()) / (2.f * gCamera->getFar() * gCamera->getNear()); 4489 F32 depth_conversion_factor_1 = (LLViewerCamera::getInstance()->getFar() + LLViewerCamera::getInstance()->getNear()) / (2.f * LLViewerCamera::getInstance()->getFar() * LLViewerCamera::getInstance()->getNear());
4483 F32 depth_conversion_factor_2 = (gCamera->getFar() - gCamera->getNear()) / (2.f * gCamera->getFar() * gCamera->getNear()); 4490 F32 depth_conversion_factor_2 = (LLViewerCamera::getInstance()->getFar() - LLViewerCamera::getInstance()->getNear()) / (2.f * LLViewerCamera::getInstance()->getFar() * LLViewerCamera::getInstance()->getNear());
4484 4491
4485 for (int subimage_y = 0; subimage_y < scale_factor; ++subimage_y) 4492 for (int subimage_y = 0; subimage_y < scale_factor; ++subimage_y)
4486 { 4493 {
@@ -4498,12 +4505,12 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
4498 glClearColor(0.f, 0.f, 0.f, 0.f); 4505 glClearColor(0.f, 0.f, 0.f, 0.f);
4499 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 4506 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
4500 4507
4501 gCamera->setZoomParameters(scale_factor, subimage_x+(subimage_y*llceil(scale_factor))); 4508 LLViewerCamera::getInstance()->setZoomParameters(scale_factor, subimage_x+(subimage_y*llceil(scale_factor)));
4502 setup3DRender(); 4509 setup3DRender();
4503 setupViewport(); 4510 setupViewport();
4504 BOOL first_time_through = (subimage_x + subimage_y == 0); 4511 BOOL first_time_through = (subimage_x + subimage_y == 0);
4505 gPickTransparent = FALSE; 4512 gPickTransparent = FALSE;
4506 gObjectList.renderObjectsForSelect(*gCamera, FALSE, !first_time_through); 4513 gObjectList.renderObjectsForSelect(*LLViewerCamera::getInstance(), FALSE, !first_time_through);
4507 } 4514 }
4508 else 4515 else
4509 { 4516 {
@@ -4555,7 +4562,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
4555 F32 depth_float = *(F32*)(raw->getData() + i); 4562 F32 depth_float = *(F32*)(raw->getData() + i);
4556 4563
4557 F32 linear_depth_float = 1.f / (depth_conversion_factor_1 - (depth_float * depth_conversion_factor_2)); 4564 F32 linear_depth_float = 1.f / (depth_conversion_factor_1 - (depth_float * depth_conversion_factor_2));
4558 U8 depth_byte = F32_to_U8(linear_depth_float, gCamera->getNear(), gCamera->getFar()); 4565 U8 depth_byte = F32_to_U8(linear_depth_float, LLViewerCamera::getInstance()->getNear(), LLViewerCamera::getInstance()->getFar());
4559 *(raw->getData() + i + 0) = depth_byte; 4566 *(raw->getData() + i + 0) = depth_byte;
4560 *(raw->getData() + i + 1) = depth_byte; 4567 *(raw->getData() + i + 1) = depth_byte;
4561 *(raw->getData() + i + 2) = depth_byte; 4568 *(raw->getData() + i + 2) = depth_byte;
@@ -4643,7 +4650,7 @@ void LLViewerWindow::drawMouselookInstructions()
4643{ 4650{
4644 // Draw instructions for mouselook ("Press ESC to leave Mouselook" in a box at the top of the screen.) 4651 // Draw instructions for mouselook ("Press ESC to leave Mouselook" in a box at the top of the screen.)
4645 const char* instructions = "Press ESC to leave Mouselook."; 4652 const char* instructions = "Press ESC to leave Mouselook.";
4646 const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF ); 4653 const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF );
4647 4654
4648 const S32 INSTRUCTIONS_PAD = 5; 4655 const S32 INSTRUCTIONS_PAD = 5;
4649 LLRect instructions_rect; 4656 LLRect instructions_rect;
@@ -4747,7 +4754,7 @@ void LLViewerWindow::setupViewport(S32 x_offset, S32 y_offset)
4747 4754
4748void LLViewerWindow::setup3DRender() 4755void LLViewerWindow::setup3DRender()
4749{ 4756{
4750 gCamera->setPerspective(NOT_FOR_SELECTION, 0, 0, mWindowRect.getWidth(), mWindowRect.getHeight(), FALSE, gCamera->getNear(), MAX_FAR_CLIP*2.f); 4757 LLViewerCamera::getInstance()->setPerspective(NOT_FOR_SELECTION, 0, 0, mWindowRect.getWidth(), mWindowRect.getHeight(), FALSE, LLViewerCamera::getInstance()->getNear(), MAX_FAR_CLIP*2.f);
4751} 4758}
4752 4759
4753void LLViewerWindow::setup2DRender() 4760void LLViewerWindow::setup2DRender()
@@ -5064,6 +5071,8 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size,
5064 return TRUE; // a lie..., because we'll get to it later 5071 return TRUE; // a lie..., because we'll get to it later
5065 } 5072 }
5066 5073
5074 U32 fsaa = gSavedSettings.getU32("RenderFSAASamples");
5075 U32 old_fsaa = mWindow->getFSAASamples();
5067 // going from windowed to windowed 5076 // going from windowed to windowed
5068 if (!old_fullscreen && !fullscreen) 5077 if (!old_fullscreen && !fullscreen)
5069 { 5078 {
@@ -5072,7 +5081,11 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size,
5072 { 5081 {
5073 mWindow->setSize(size); 5082 mWindow->setSize(size);
5074 } 5083 }
5075 return TRUE; 5084
5085 if (fsaa == old_fsaa)
5086 {
5087 return TRUE;
5088 }
5076 } 5089 }
5077 5090
5078 // Close floaters that don't handle settings change 5091 // Close floaters that don't handle settings change
@@ -5098,10 +5111,13 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size,
5098 gSavedSettings.setS32("WindowY", old_pos.mY); 5111 gSavedSettings.setS32("WindowY", old_pos.mY);
5099 } 5112 }
5100 5113
5114 mWindow->setFSAASamples(fsaa);
5115
5101 result_first_try = mWindow->switchContext(fullscreen, size, disable_vsync); 5116 result_first_try = mWindow->switchContext(fullscreen, size, disable_vsync);
5102 if (!result_first_try) 5117 if (!result_first_try)
5103 { 5118 {
5104 // try to switch back 5119 // try to switch back
5120 mWindow->setFSAASamples(old_fsaa);
5105 result_second_try = mWindow->switchContext(old_fullscreen, old_size, disable_vsync); 5121 result_second_try = mWindow->switchContext(old_fullscreen, old_size, disable_vsync);
5106 5122
5107 if (!result_second_try) 5123 if (!result_second_try)
@@ -5378,7 +5394,7 @@ LLBottomPanel::LLBottomPanel(const LLRect &rect) :
5378 mFactoryMap["toolbar"] = LLCallbackMap(createToolBar, NULL); 5394 mFactoryMap["toolbar"] = LLCallbackMap(createToolBar, NULL);
5379 mFactoryMap["overlay"] = LLCallbackMap(createOverlayBar, NULL); 5395 mFactoryMap["overlay"] = LLCallbackMap(createOverlayBar, NULL);
5380 mFactoryMap["hud"] = LLCallbackMap(createHUD, NULL); 5396 mFactoryMap["hud"] = LLCallbackMap(createHUD, NULL);
5381 gUICtrlFactory->buildPanel(this, "panel_bars.xml", &getFactoryMap()); 5397 LLUICtrlFactory::getInstance()->buildPanel(this, "panel_bars.xml", &getFactoryMap());
5382 5398
5383 setOrigin(rect.mLeft, rect.mBottom); 5399 setOrigin(rect.mLeft, rect.mBottom);
5384 reshape(rect.getWidth(), rect.getHeight()); 5400 reshape(rect.getWidth(), rect.getHeight());