diff options
Diffstat (limited to 'linden/indra/newview/llviewerwindow.cpp')
-rw-r--r-- | linden/indra/newview/llviewerwindow.cpp | 363 |
1 files changed, 241 insertions, 122 deletions
diff --git a/linden/indra/newview/llviewerwindow.cpp b/linden/indra/newview/llviewerwindow.cpp index 854d757..017c225 100644 --- a/linden/indra/newview/llviewerwindow.cpp +++ b/linden/indra/newview/llviewerwindow.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -29,13 +29,13 @@ | |||
29 | * $/LicenseInfo$ | 29 | * $/LicenseInfo$ |
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include "llviewerprecompiledheaders.h" | ||
33 | |||
32 | // system library includes | 34 | // system library includes |
33 | #include <stdio.h> | 35 | #include <stdio.h> |
34 | #include <iostream> | 36 | #include <iostream> |
35 | #include <fstream> | 37 | #include <fstream> |
36 | 38 | ||
37 | #include "llviewerprecompiledheaders.h" | ||
38 | |||
39 | #include "llpanellogin.h" | 39 | #include "llpanellogin.h" |
40 | #include "llviewerkeyboard.h" | 40 | #include "llviewerkeyboard.h" |
41 | #include "llviewerwindow.h" | 41 | #include "llviewerwindow.h" |
@@ -168,6 +168,7 @@ | |||
168 | #include "llviewerobjectlist.h" | 168 | #include "llviewerobjectlist.h" |
169 | #include "llviewerparcelmgr.h" | 169 | #include "llviewerparcelmgr.h" |
170 | #include "llviewerregion.h" | 170 | #include "llviewerregion.h" |
171 | #include "llviewershadermgr.h" | ||
171 | #include "llviewerstats.h" | 172 | #include "llviewerstats.h" |
172 | #include "llvoavatar.h" | 173 | #include "llvoavatar.h" |
173 | #include "llvovolume.h" | 174 | #include "llvovolume.h" |
@@ -180,9 +181,9 @@ | |||
180 | #include "llspatialpartition.h" | 181 | #include "llspatialpartition.h" |
181 | #include "llviewerjoystick.h" | 182 | #include "llviewerjoystick.h" |
182 | #include "llviewernetwork.h" | 183 | #include "llviewernetwork.h" |
184 | #include "llpostprocess.h" | ||
183 | 185 | ||
184 | #if LL_WINDOWS | 186 | #if LL_WINDOWS |
185 | #include "llwindebug.h" | ||
186 | #include <tchar.h> // For Unicode conversion methods | 187 | #include <tchar.h> // For Unicode conversion methods |
187 | #endif | 188 | #endif |
188 | 189 | ||
@@ -218,6 +219,7 @@ LLVector3 gDebugRaycastIntersection; | |||
218 | LLVector2 gDebugRaycastTexCoord; | 219 | LLVector2 gDebugRaycastTexCoord; |
219 | LLVector3 gDebugRaycastNormal; | 220 | LLVector3 gDebugRaycastNormal; |
220 | LLVector3 gDebugRaycastBinormal; | 221 | LLVector3 gDebugRaycastBinormal; |
222 | S32 gDebugRaycastFaceHit; | ||
221 | 223 | ||
222 | // HUD display lines in lower right | 224 | // HUD display lines in lower right |
223 | BOOL gDisplayWindInfo = FALSE; | 225 | BOOL gDisplayWindInfo = FALSE; |
@@ -916,7 +918,7 @@ BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK | |||
916 | 918 | ||
917 | // *HACK: this should be rolled into the composite tool logic, not | 919 | // *HACK: this should be rolled into the composite tool logic, not |
918 | // hardcoded at the top level. | 920 | // hardcoded at the top level. |
919 | if (CAMERA_MODE_CUSTOMIZE_AVATAR != gAgent.getCameraMode()) | 921 | if (CAMERA_MODE_CUSTOMIZE_AVATAR != gAgent.getCameraMode() && LLToolMgr::getInstance()->getCurrentTool() != LLToolPie::getInstance()) |
920 | { | 922 | { |
921 | // If the current tool didn't process the click, we should show | 923 | // If the current tool didn't process the click, we should show |
922 | // the pie menu. This can be done by passing the event to the pie | 924 | // the pie menu. This can be done by passing the event to the pie |
@@ -1102,6 +1104,7 @@ void LLViewerWindow::handleQuit(LLWindow *window) | |||
1102 | void LLViewerWindow::handleResize(LLWindow *window, S32 width, S32 height) | 1104 | void LLViewerWindow::handleResize(LLWindow *window, S32 width, S32 height) |
1103 | { | 1105 | { |
1104 | reshape(width, height); | 1106 | reshape(width, height); |
1107 | mResDirty = true; | ||
1105 | } | 1108 | } |
1106 | 1109 | ||
1107 | // The top-level window has gained focus (e.g. via ALT-TAB) | 1110 | // The top-level window has gained focus (e.g. via ALT-TAB) |
@@ -1258,6 +1261,8 @@ BOOL LLViewerWindow::handleActivate(LLWindow *window, BOOL activated) | |||
1258 | 1261 | ||
1259 | BOOL LLViewerWindow::handleActivateApp(LLWindow *window, BOOL activating) | 1262 | BOOL LLViewerWindow::handleActivateApp(LLWindow *window, BOOL activating) |
1260 | { | 1263 | { |
1264 | //if (!activating) gAgent.changeCameraToDefault(); | ||
1265 | |||
1261 | LLViewerJoystick::getInstance()->setNeedsReset(true); | 1266 | LLViewerJoystick::getInstance()->setNeedsReset(true); |
1262 | return FALSE; | 1267 | return FALSE; |
1263 | } | 1268 | } |
@@ -1410,7 +1415,11 @@ LLViewerWindow::LLViewerWindow( | |||
1410 | mHideCursorPermanent( FALSE ), | 1415 | mHideCursorPermanent( FALSE ), |
1411 | mCursorHidden(FALSE), | 1416 | mCursorHidden(FALSE), |
1412 | mIgnoreActivate( FALSE ), | 1417 | mIgnoreActivate( FALSE ), |
1413 | mHoverPick() | 1418 | mHoverPick(), |
1419 | mResDirty(false), | ||
1420 | mStatesDirty(false), | ||
1421 | mIsFullscreenChecked(false), | ||
1422 | mCurrResolutionIndex(0) | ||
1414 | { | 1423 | { |
1415 | // Default to application directory. | 1424 | // Default to application directory. |
1416 | LLViewerWindow::sSnapshotBaseName = "Snapshot"; | 1425 | LLViewerWindow::sSnapshotBaseName = "Snapshot"; |
@@ -1426,12 +1435,12 @@ LLViewerWindow::LLViewerWindow( | |||
1426 | !gNoRender, | 1435 | !gNoRender, |
1427 | ignore_pixel_depth, | 1436 | ignore_pixel_depth, |
1428 | gSavedSettings.getU32("RenderFSAASamples")); | 1437 | gSavedSettings.getU32("RenderFSAASamples")); |
1429 | #if LL_WINDOWS | 1438 | |
1430 | if (!LLWinDebug::checkExceptionHandler()) | 1439 | if (!LLAppViewer::instance()->restoreErrorTrap()) |
1431 | { | 1440 | { |
1432 | LL_WARNS("Window") << " Someone took over my exception handler (post createWindow)!" << LL_ENDL; | 1441 | LL_WARNS("Window") << " Someone took over my signal/exception handler (post createWindow)!" << LL_ENDL; |
1433 | } | 1442 | } |
1434 | #endif | 1443 | |
1435 | 1444 | ||
1436 | if (NULL == mWindow) | 1445 | if (NULL == mWindow) |
1437 | { | 1446 | { |
@@ -1545,7 +1554,7 @@ void LLViewerWindow::initGLDefaults() | |||
1545 | glPixelStorei(GL_PACK_ALIGNMENT,1); | 1554 | glPixelStorei(GL_PACK_ALIGNMENT,1); |
1546 | glPixelStorei(GL_UNPACK_ALIGNMENT,1); | 1555 | glPixelStorei(GL_UNPACK_ALIGNMENT,1); |
1547 | 1556 | ||
1548 | glEnable(GL_TEXTURE_2D); | 1557 | gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); |
1549 | 1558 | ||
1550 | // lights for objects | 1559 | // lights for objects |
1551 | glShadeModel( GL_SMOOTH ); | 1560 | glShadeModel( GL_SMOOTH ); |
@@ -2089,12 +2098,7 @@ void LLViewerWindow::reshape(S32 width, S32 height) | |||
2089 | gSavedSettings.setBOOL("FullScreen", mWantFullscreen); | 2098 | gSavedSettings.setBOOL("FullScreen", mWantFullscreen); |
2090 | 2099 | ||
2091 | // store new settings for the mode we are in, regardless | 2100 | // store new settings for the mode we are in, regardless |
2092 | if (mWindow->getFullscreen()) | 2101 | if (!mWindow->getFullscreen()) |
2093 | { | ||
2094 | gSavedSettings.setS32("FullScreenWidth", width); | ||
2095 | gSavedSettings.setS32("FullScreenHeight", height); | ||
2096 | } | ||
2097 | else | ||
2098 | { | 2102 | { |
2099 | // Only save size if not maximized | 2103 | // Only save size if not maximized |
2100 | BOOL maximized = mWindow->getMaximized(); | 2104 | BOOL maximized = mWindow->getMaximized(); |
@@ -3042,8 +3046,9 @@ BOOL LLViewerWindow::handlePerFrameHover() | |||
3042 | 3046 | ||
3043 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST)) | 3047 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST)) |
3044 | { | 3048 | { |
3045 | gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, | 3049 | gDebugRaycastFaceHit = -1; |
3046 | NULL, | 3050 | gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, |
3051 | &gDebugRaycastFaceHit, | ||
3047 | &gDebugRaycastIntersection, | 3052 | &gDebugRaycastIntersection, |
3048 | &gDebugRaycastTexCoord, | 3053 | &gDebugRaycastTexCoord, |
3049 | &gDebugRaycastNormal, | 3054 | &gDebugRaycastNormal, |
@@ -3184,7 +3189,7 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls, | |||
3184 | // Render light for editing | 3189 | // Render light for editing |
3185 | if (LLSelectMgr::sRenderLightRadius && LLToolMgr::getInstance()->inEdit()) | 3190 | if (LLSelectMgr::sRenderLightRadius && LLToolMgr::getInstance()->inEdit()) |
3186 | { | 3191 | { |
3187 | LLImageGL::unbindTexture(0); | 3192 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
3188 | LLGLEnable gls_blend(GL_BLEND); | 3193 | LLGLEnable gls_blend(GL_BLEND); |
3189 | LLGLEnable gls_cull(GL_CULL_FACE); | 3194 | LLGLEnable gls_cull(GL_CULL_FACE); |
3190 | LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); | 3195 | LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); |
@@ -3398,7 +3403,7 @@ void LLViewerWindow::schedulePick(LLPickInfo& pick_info) | |||
3398 | llassert_always(pick_info.mScreenRegion.notNull()); | 3403 | llassert_always(pick_info.mScreenRegion.notNull()); |
3399 | mPicks.push_back(pick_info); | 3404 | mPicks.push_back(pick_info); |
3400 | 3405 | ||
3401 | S32 scaled_x = llround((F32)pick_info.mMousePt.mX * mDisplayScale.mV[VX]); | 3406 | /*S32 scaled_x = llround((F32)pick_info.mMousePt.mX * mDisplayScale.mV[VX]); |
3402 | S32 scaled_y = llround((F32)pick_info.mMousePt.mY * mDisplayScale.mV[VY]); | 3407 | S32 scaled_y = llround((F32)pick_info.mMousePt.mY * mDisplayScale.mV[VY]); |
3403 | 3408 | ||
3404 | // Default to not hitting anything | 3409 | // Default to not hitting anything |
@@ -3467,7 +3472,7 @@ void LLViewerWindow::schedulePick(LLPickInfo& pick_info) | |||
3467 | 3472 | ||
3468 | setup3DRender(); | 3473 | setup3DRender(); |
3469 | setup2DRender(); | 3474 | setup2DRender(); |
3470 | setupViewport(); | 3475 | setupViewport();*/ |
3471 | 3476 | ||
3472 | // delay further event processing until we receive results of pick | 3477 | // delay further event processing until we receive results of pick |
3473 | mWindow->delayInputProcessing(); | 3478 | mWindow->delayInputProcessing(); |
@@ -3526,9 +3531,33 @@ LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_trans | |||
3526 | return mLastPick; | 3531 | return mLastPick; |
3527 | } | 3532 | } |
3528 | 3533 | ||
3534 | LLHUDIcon* LLViewerWindow::cursorIntersectIcon(S32 mouse_x, S32 mouse_y, F32 depth, | ||
3535 | LLVector3* intersection) | ||
3536 | { | ||
3537 | S32 x = mouse_x; | ||
3538 | S32 y = mouse_y; | ||
3539 | |||
3540 | if ((mouse_x == -1) && (mouse_y == -1)) // use current mouse position | ||
3541 | { | ||
3542 | x = getCurrentMouseX(); | ||
3543 | y = getCurrentMouseY(); | ||
3544 | } | ||
3545 | |||
3546 | // world coordinates of mouse | ||
3547 | LLVector3 mouse_direction_global = mouseDirectionGlobal(x,y); | ||
3548 | LLVector3 mouse_point_global = LLViewerCamera::getInstance()->getOrigin(); | ||
3549 | LLVector3 mouse_world_start = mouse_point_global; | ||
3550 | LLVector3 mouse_world_end = mouse_point_global + mouse_direction_global * depth; | ||
3551 | |||
3552 | return LLHUDIcon::lineSegmentIntersectAll(mouse_world_start, mouse_world_end, intersection); | ||
3553 | |||
3554 | |||
3555 | } | ||
3556 | |||
3529 | LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 depth, | 3557 | LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 depth, |
3530 | LLViewerObject *this_object, | 3558 | LLViewerObject *this_object, |
3531 | S32 this_face, | 3559 | S32 this_face, |
3560 | BOOL pick_transparent, | ||
3532 | S32* face_hit, | 3561 | S32* face_hit, |
3533 | LLVector3 *intersection, | 3562 | LLVector3 *intersection, |
3534 | LLVector2 *uv, | 3563 | LLVector2 *uv, |
@@ -3550,8 +3579,18 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de | |||
3550 | LLVector3 mouse_hud_end = mouse_point_hud + LLVector3(depth, 0, 0); | 3579 | LLVector3 mouse_hud_end = mouse_point_hud + LLVector3(depth, 0, 0); |
3551 | 3580 | ||
3552 | // world coordinates of mouse | 3581 | // world coordinates of mouse |
3553 | LLVector3 mouse_direction_global = mouseDirectionGlobal(x,y); | 3582 | LLVector3 mouse_direction_global = mouseDirectionGlobal(x,y); |
3554 | LLVector3 mouse_point_global = LLViewerCamera::getInstance()->getOrigin(); | 3583 | LLVector3 mouse_point_global = LLViewerCamera::getInstance()->getOrigin(); |
3584 | |||
3585 | //get near clip plane | ||
3586 | LLVector3 n = LLViewerCamera::getInstance()->getAtAxis(); | ||
3587 | LLVector3 p = mouse_point_global + n * LLViewerCamera::getInstance()->getNear(); | ||
3588 | |||
3589 | //project mouse point onto plane | ||
3590 | LLVector3 pos; | ||
3591 | line_plane(mouse_point_global, mouse_direction_global, p, n, pos); | ||
3592 | mouse_point_global = pos; | ||
3593 | |||
3555 | LLVector3 mouse_world_start = mouse_point_global; | 3594 | LLVector3 mouse_world_start = mouse_point_global; |
3556 | LLVector3 mouse_world_end = mouse_point_global + mouse_direction_global * depth; | 3595 | LLVector3 mouse_world_end = mouse_point_global + mouse_direction_global * depth; |
3557 | 3596 | ||
@@ -3562,7 +3601,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de | |||
3562 | { | 3601 | { |
3563 | if (this_object->isHUDAttachment()) // is a HUD object? | 3602 | if (this_object->isHUDAttachment()) // is a HUD object? |
3564 | { | 3603 | { |
3565 | if (this_object->lineSegmentIntersect(mouse_hud_start, mouse_hud_end, this_face, | 3604 | if (this_object->lineSegmentIntersect(mouse_hud_start, mouse_hud_end, this_face, pick_transparent, |
3566 | face_hit, intersection, uv, normal, binormal)) | 3605 | face_hit, intersection, uv, normal, binormal)) |
3567 | { | 3606 | { |
3568 | found = this_object; | 3607 | found = this_object; |
@@ -3571,7 +3610,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de | |||
3571 | 3610 | ||
3572 | else // is a world object | 3611 | else // is a world object |
3573 | { | 3612 | { |
3574 | if (this_object->lineSegmentIntersect(mouse_world_start, mouse_world_end, this_face, | 3613 | if (this_object->lineSegmentIntersect(mouse_world_start, mouse_world_end, this_face, pick_transparent, |
3575 | face_hit, intersection, uv, normal, binormal)) | 3614 | face_hit, intersection, uv, normal, binormal)) |
3576 | { | 3615 | { |
3577 | found = this_object; | 3616 | found = this_object; |
@@ -3581,13 +3620,13 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de | |||
3581 | 3620 | ||
3582 | else // check ALL objects | 3621 | else // check ALL objects |
3583 | { | 3622 | { |
3584 | found = gPipeline.lineSegmentIntersectInHUD(mouse_hud_start, mouse_hud_end, | 3623 | found = gPipeline.lineSegmentIntersectInHUD(mouse_hud_start, mouse_hud_end, pick_transparent, |
3585 | face_hit, intersection, uv, normal, binormal); | 3624 | face_hit, intersection, uv, normal, binormal); |
3586 | 3625 | ||
3587 | if (!found) // if not found in HUD, look in world: | 3626 | if (!found) // if not found in HUD, look in world: |
3588 | 3627 | ||
3589 | { | 3628 | { |
3590 | found = gPipeline.lineSegmentIntersectInWorld(mouse_world_start, mouse_world_end, | 3629 | found = gPipeline.lineSegmentIntersectInWorld(mouse_world_start, mouse_world_end, pick_transparent, |
3591 | face_hit, intersection, uv, normal, binormal); | 3630 | face_hit, intersection, uv, normal, binormal); |
3592 | } | 3631 | } |
3593 | 3632 | ||
@@ -3634,7 +3673,7 @@ LLVector3 LLViewerWindow::mousePointHUD(const S32 x, const S32 y) const | |||
3634 | F32 hud_x = -((F32)x - (F32)width/2.f) / height; | 3673 | F32 hud_x = -((F32)x - (F32)width/2.f) / height; |
3635 | F32 hud_y = ((F32)y - (F32)height/2.f) / height; | 3674 | F32 hud_y = ((F32)y - (F32)height/2.f) / height; |
3636 | 3675 | ||
3637 | return LLVector3(0.f, hud_x, hud_y); | 3676 | return LLVector3(0.f, hud_x/gAgent.mHUDCurZoom, hud_y/gAgent.mHUDCurZoom); |
3638 | } | 3677 | } |
3639 | 3678 | ||
3640 | // Returns unit vector relative to camera in camera space | 3679 | // Returns unit vector relative to camera in camera space |
@@ -3811,9 +3850,8 @@ BOOL LLViewerWindow::saveImageNumbered(LLImageFormatted *image) | |||
3811 | return FALSE; | 3850 | return FALSE; |
3812 | } | 3851 | } |
3813 | 3852 | ||
3814 | std::string extension("." + image->getExtension()); | ||
3815 | |||
3816 | LLFilePicker::ESaveFilter pick_type; | 3853 | LLFilePicker::ESaveFilter pick_type; |
3854 | std::string extension("." + image->getExtension()); | ||
3817 | if (extension == ".j2c") | 3855 | if (extension == ".j2c") |
3818 | pick_type = LLFilePicker::FFSAVE_J2C; | 3856 | pick_type = LLFilePicker::FFSAVE_J2C; |
3819 | else if (extension == ".bmp") | 3857 | else if (extension == ".bmp") |
@@ -3831,7 +3869,8 @@ BOOL LLViewerWindow::saveImageNumbered(LLImageFormatted *image) | |||
3831 | if ( ! isSnapshotLocSet()) | 3869 | if ( ! isSnapshotLocSet()) |
3832 | { | 3870 | { |
3833 | std::string proposed_name( sSnapshotBaseName ); | 3871 | std::string proposed_name( sSnapshotBaseName ); |
3834 | proposed_name.append( extension ); | 3872 | |
3873 | // getSaveFile will append an appropriate extension to the proposed name, based on the ESaveFilter constant passed in. | ||
3835 | 3874 | ||
3836 | // pick a directory in which to save | 3875 | // pick a directory in which to save |
3837 | LLFilePicker& picker = LLFilePicker::instance(); | 3876 | LLFilePicker& picker = LLFilePicker::instance(); |
@@ -4148,7 +4187,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei | |||
4148 | 4187 | ||
4149 | snapshot_width = image_width; | 4188 | snapshot_width = image_width; |
4150 | snapshot_height = image_height; | 4189 | snapshot_height = image_height; |
4151 | target.allocate(snapshot_width, snapshot_height, GL_RGBA, TRUE, GL_TEXTURE_RECTANGLE_ARB, TRUE); | 4190 | target.allocate(snapshot_width, snapshot_height, GL_RGBA, TRUE, LLTexUnit::TT_RECT_TEXTURE, TRUE); |
4152 | window_width = snapshot_width; | 4191 | window_width = snapshot_width; |
4153 | window_height = snapshot_height; | 4192 | window_height = snapshot_height; |
4154 | scale_factor = 1.f; | 4193 | scale_factor = 1.f; |
@@ -4376,7 +4415,7 @@ void LLViewerWindow::drawMouselookInstructions() | |||
4376 | llround(font->getLineHeight() + 2 * INSTRUCTIONS_PAD)); | 4415 | llround(font->getLineHeight() + 2 * INSTRUCTIONS_PAD)); |
4377 | 4416 | ||
4378 | { | 4417 | { |
4379 | LLGLSNoTexture gls_no_texture; | 4418 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
4380 | gGL.color4f( 0.9f, 0.9f, 0.9f, 1.0f ); | 4419 | gGL.color4f( 0.9f, 0.9f, 0.9f, 1.0f ); |
4381 | gl_rect_2d( instructions_rect ); | 4420 | gl_rect_2d( instructions_rect ); |
4382 | } | 4421 | } |
@@ -4502,6 +4541,10 @@ void LLViewerWindow::dumpState() | |||
4502 | 4541 | ||
4503 | void LLViewerWindow::stopGL(BOOL save_state) | 4542 | void LLViewerWindow::stopGL(BOOL save_state) |
4504 | { | 4543 | { |
4544 | //Note: --bao | ||
4545 | //if not necessary, do not change the order of the function calls in this function. | ||
4546 | //if change something, make sure it will not break anything. | ||
4547 | //especially be careful to put anything behind gImageList.destroyGL(save_state); | ||
4505 | if (!gGLManager.mIsDisabled) | 4548 | if (!gGLManager.mIsDisabled) |
4506 | { | 4549 | { |
4507 | llinfos << "Shutting down GL..." << llendl; | 4550 | llinfos << "Shutting down GL..." << llendl; |
@@ -4510,12 +4553,12 @@ void LLViewerWindow::stopGL(BOOL save_state) | |||
4510 | LLAppViewer::getTextureCache()->pause(); | 4553 | LLAppViewer::getTextureCache()->pause(); |
4511 | LLAppViewer::getImageDecodeThread()->pause(); | 4554 | LLAppViewer::getImageDecodeThread()->pause(); |
4512 | LLAppViewer::getTextureFetch()->pause(); | 4555 | LLAppViewer::getTextureFetch()->pause(); |
4513 | 4556 | ||
4514 | gSky.destroyGL(); | 4557 | gSky.destroyGL(); |
4515 | stop_glerror(); | 4558 | stop_glerror(); |
4516 | 4559 | ||
4517 | gImageList.destroyGL(save_state); | 4560 | LLManipTranslate::destroyGL() ; |
4518 | stop_glerror(); | 4561 | stop_glerror(); |
4519 | 4562 | ||
4520 | gBumpImageList.destroyGL(); | 4563 | gBumpImageList.destroyGL(); |
4521 | stop_glerror(); | 4564 | stop_glerror(); |
@@ -4539,6 +4582,14 @@ void LLViewerWindow::stopGL(BOOL save_state) | |||
4539 | gSphere.cleanupGL(); | 4582 | gSphere.cleanupGL(); |
4540 | gCylinder.cleanupGL(); | 4583 | gCylinder.cleanupGL(); |
4541 | 4584 | ||
4585 | if(gPostProcess) | ||
4586 | { | ||
4587 | gPostProcess->invalidate(); | ||
4588 | } | ||
4589 | |||
4590 | gImageList.destroyGL(save_state); | ||
4591 | stop_glerror(); | ||
4592 | |||
4542 | gGLManager.mIsDisabled = TRUE; | 4593 | gGLManager.mIsDisabled = TRUE; |
4543 | stop_glerror(); | 4594 | stop_glerror(); |
4544 | 4595 | ||
@@ -4548,25 +4599,32 @@ void LLViewerWindow::stopGL(BOOL save_state) | |||
4548 | 4599 | ||
4549 | void LLViewerWindow::restoreGL(const std::string& progress_message) | 4600 | void LLViewerWindow::restoreGL(const std::string& progress_message) |
4550 | { | 4601 | { |
4602 | //Note: --bao | ||
4603 | //if not necessary, do not change the order of the function calls in this function. | ||
4604 | //if change something, make sure it will not break anything. | ||
4605 | //especially, be careful to put something before gImageList.restoreGL(); | ||
4551 | if (gGLManager.mIsDisabled) | 4606 | if (gGLManager.mIsDisabled) |
4552 | { | 4607 | { |
4553 | llinfos << "Restoring GL..." << llendl; | 4608 | llinfos << "Restoring GL..." << llendl; |
4554 | gGLManager.mIsDisabled = FALSE; | 4609 | gGLManager.mIsDisabled = FALSE; |
4610 | |||
4611 | initGLDefaults(); | ||
4612 | LLGLState::restoreGL(); | ||
4613 | gImageList.restoreGL(); | ||
4555 | 4614 | ||
4556 | // for future support of non-square pixels, and fonts that are properly stretched | 4615 | // for future support of non-square pixels, and fonts that are properly stretched |
4557 | //LLFontGL::destroyDefaultFonts(); | 4616 | //LLFontGL::destroyDefaultFonts(); |
4558 | initFonts(); | 4617 | initFonts(); |
4559 | initGLDefaults(); | 4618 | |
4560 | LLGLState::restoreGL(); | ||
4561 | gSky.restoreGL(); | 4619 | gSky.restoreGL(); |
4562 | gPipeline.restoreGL(); | 4620 | gPipeline.restoreGL(); |
4563 | LLDrawPoolWater::restoreGL(); | 4621 | LLDrawPoolWater::restoreGL(); |
4564 | LLManipTranslate::restoreGL(); | 4622 | LLManipTranslate::restoreGL(); |
4565 | gImageList.restoreGL(); | 4623 | |
4566 | gBumpImageList.restoreGL(); | 4624 | gBumpImageList.restoreGL(); |
4567 | LLDynamicTexture::restoreGL(); | 4625 | LLDynamicTexture::restoreGL(); |
4568 | LLVOAvatar::restoreGL(); | 4626 | LLVOAvatar::restoreGL(); |
4569 | 4627 | ||
4570 | gResizeScreenTexture = TRUE; | 4628 | gResizeScreenTexture = TRUE; |
4571 | 4629 | ||
4572 | if (gFloaterCustomize && gFloaterCustomize->getVisible()) | 4630 | if (gFloaterCustomize && gFloaterCustomize->getVisible()) |
@@ -4582,12 +4640,10 @@ void LLViewerWindow::restoreGL(const std::string& progress_message) | |||
4582 | setProgressString(progress_message); | 4640 | setProgressString(progress_message); |
4583 | } | 4641 | } |
4584 | llinfos << "...Restoring GL done" << llendl; | 4642 | llinfos << "...Restoring GL done" << llendl; |
4585 | #if LL_WINDOWS | 4643 | if(!LLAppViewer::instance()->restoreErrorTrap()) |
4586 | if(!LLWinDebug::checkExceptionHandler()) | ||
4587 | { | 4644 | { |
4588 | llwarns << " Someone took over my exception handler (post restoreGL)!" << llendl; | 4645 | llwarns << " Someone took over my signal/exception handler (post restoreGL)!" << llendl; |
4589 | } | 4646 | } |
4590 | #endif | ||
4591 | 4647 | ||
4592 | } | 4648 | } |
4593 | } | 4649 | } |
@@ -4617,6 +4673,7 @@ void LLViewerWindow::toggleFullscreen(BOOL show_progress) | |||
4617 | if (mWindow) | 4673 | if (mWindow) |
4618 | { | 4674 | { |
4619 | mWantFullscreen = mWindow->getFullscreen() ? FALSE : TRUE; | 4675 | mWantFullscreen = mWindow->getFullscreen() ? FALSE : TRUE; |
4676 | mIsFullscreenChecked = mWindow->getFullscreen() ? FALSE : TRUE; | ||
4620 | mShowFullscreenProgress = show_progress; | 4677 | mShowFullscreenProgress = show_progress; |
4621 | } | 4678 | } |
4622 | } | 4679 | } |
@@ -4643,37 +4700,89 @@ void LLViewerWindow::getTargetWindow(BOOL& fullscreen, S32& width, S32& height) | |||
4643 | } | 4700 | } |
4644 | } | 4701 | } |
4645 | 4702 | ||
4703 | void LLViewerWindow::requestResolutionUpdate(bool fullscreen_checked) | ||
4704 | { | ||
4705 | mResDirty = true; | ||
4706 | mWantFullscreen = fullscreen_checked; | ||
4707 | mIsFullscreenChecked = fullscreen_checked; | ||
4708 | } | ||
4646 | 4709 | ||
4647 | BOOL LLViewerWindow::checkSettings() | 4710 | BOOL LLViewerWindow::checkSettings() |
4648 | { | 4711 | { |
4649 | BOOL is_fullscreen = mWindow->getFullscreen(); | 4712 | if (mStatesDirty) |
4650 | if (is_fullscreen && !mWantFullscreen) | ||
4651 | { | 4713 | { |
4652 | changeDisplaySettings(FALSE, | 4714 | gGL.refreshState(); |
4653 | LLCoordScreen(gSavedSettings.getS32("WindowWidth"), | 4715 | LLViewerShaderMgr::instance()->setShaders(); |
4654 | gSavedSettings.getS32("WindowHeight")), | 4716 | mStatesDirty = false; |
4655 | TRUE, | ||
4656 | mShowFullscreenProgress); | ||
4657 | return TRUE; | ||
4658 | } | 4717 | } |
4659 | else if (!is_fullscreen && mWantFullscreen) | 4718 | |
4719 | // We want to update the resolution AFTER the states getting refreshed not before. | ||
4720 | if (mResDirty) | ||
4660 | { | 4721 | { |
4661 | if (!LLStartUp::canGoFullscreen()) | 4722 | if (gSavedSettings.getBOOL("FullScreenAutoDetectAspectRatio")) |
4662 | { | 4723 | { |
4663 | return FALSE; | 4724 | getWindow()->setNativeAspectRatio(0.f); |
4725 | } | ||
4726 | else | ||
4727 | { | ||
4728 | getWindow()->setNativeAspectRatio(gSavedSettings.getF32("FullScreenAspectRatio")); | ||
4664 | } | 4729 | } |
4665 | 4730 | ||
4666 | LLGLState::checkStates(); | 4731 | reshape(getWindowDisplayWidth(), getWindowDisplayHeight()); |
4667 | LLGLState::checkTextureChannels(); | 4732 | |
4668 | changeDisplaySettings(TRUE, | 4733 | // force aspect ratio |
4669 | LLCoordScreen(gSavedSettings.getS32("FullScreenWidth"), | 4734 | if (mIsFullscreenChecked) |
4670 | gSavedSettings.getS32("FullScreenHeight")), | 4735 | { |
4671 | gSavedSettings.getBOOL("DisableVerticalSync"), | 4736 | LLViewerCamera::getInstance()->setAspect( getDisplayAspectRatio() ); |
4672 | mShowFullscreenProgress); | 4737 | } |
4673 | 4738 | ||
4674 | LLGLState::checkStates(); | 4739 | mResDirty = false; |
4675 | LLGLState::checkTextureChannels(); | 4740 | // This will force a state update the next frame. |
4676 | return TRUE; | 4741 | mStatesDirty = true; |
4742 | } | ||
4743 | |||
4744 | BOOL is_fullscreen = mWindow->getFullscreen(); | ||
4745 | if(mWantFullscreen) | ||
4746 | { | ||
4747 | LLCoordScreen screen_size; | ||
4748 | LLCoordScreen desired_screen_size(gSavedSettings.getS32("FullScreenWidth"), | ||
4749 | gSavedSettings.getS32("FullScreenHeight")); | ||
4750 | getWindow()->getSize(&screen_size); | ||
4751 | if(!is_fullscreen || | ||
4752 | screen_size.mX != desired_screen_size.mX | ||
4753 | || screen_size.mY != desired_screen_size.mY) | ||
4754 | { | ||
4755 | if (!LLStartUp::canGoFullscreen()) | ||
4756 | { | ||
4757 | return FALSE; | ||
4758 | } | ||
4759 | |||
4760 | LLGLState::checkStates(); | ||
4761 | LLGLState::checkTextureChannels(); | ||
4762 | changeDisplaySettings(TRUE, | ||
4763 | desired_screen_size, | ||
4764 | gSavedSettings.getBOOL("DisableVerticalSync"), | ||
4765 | mShowFullscreenProgress); | ||
4766 | |||
4767 | LLGLState::checkStates(); | ||
4768 | LLGLState::checkTextureChannels(); | ||
4769 | mStatesDirty = true; | ||
4770 | return TRUE; | ||
4771 | } | ||
4772 | } | ||
4773 | else | ||
4774 | { | ||
4775 | if(is_fullscreen) | ||
4776 | { | ||
4777 | // Changing to windowed mode. | ||
4778 | changeDisplaySettings(FALSE, | ||
4779 | LLCoordScreen(gSavedSettings.getS32("WindowWidth"), | ||
4780 | gSavedSettings.getS32("WindowHeight")), | ||
4781 | TRUE, | ||
4782 | mShowFullscreenProgress); | ||
4783 | mStatesDirty = true; | ||
4784 | return TRUE; | ||
4785 | } | ||
4677 | } | 4786 | } |
4678 | return FALSE; | 4787 | return FALSE; |
4679 | } | 4788 | } |
@@ -4704,13 +4813,9 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size, | |||
4704 | BOOL old_fullscreen = mWindow->getFullscreen(); | 4813 | BOOL old_fullscreen = mWindow->getFullscreen(); |
4705 | if (!old_fullscreen && fullscreen && !LLStartUp::canGoFullscreen()) | 4814 | if (!old_fullscreen && fullscreen && !LLStartUp::canGoFullscreen()) |
4706 | { | 4815 | { |
4707 | // we can't do this now, so do it later | 4816 | // Not allowed to switch to fullscreen now, so exit early. |
4708 | 4817 | // *NOTE: This case should never be reached, but just-in-case. | |
4709 | gSavedSettings.setS32("FullScreenWidth", size.mX); | 4818 | return TRUE; |
4710 | gSavedSettings.setS32("FullScreenHeight", size.mY); | ||
4711 | //gSavedSettings.setBOOL("DisableVerticalSync", disable_vsync); | ||
4712 | |||
4713 | return TRUE; // a lie..., because we'll get to it later | ||
4714 | } | 4819 | } |
4715 | 4820 | ||
4716 | U32 fsaa = gSavedSettings.getU32("RenderFSAASamples"); | 4821 | U32 fsaa = gSavedSettings.getU32("RenderFSAASamples"); |
@@ -4797,7 +4902,7 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size, | |||
4797 | #if LL_WINDOWS | 4902 | #if LL_WINDOWS |
4798 | // Only trigger a reshape after switching to fullscreen; otherwise rely on the windows callback | 4903 | // Only trigger a reshape after switching to fullscreen; otherwise rely on the windows callback |
4799 | // (otherwise size is wrong; this is the entire window size, reshape wants the visible window size) | 4904 | // (otherwise size is wrong; this is the entire window size, reshape wants the visible window size) |
4800 | if (fullscreen) | 4905 | if (fullscreen && result_first_try) |
4801 | #endif | 4906 | #endif |
4802 | { | 4907 | { |
4803 | reshape(size.mX, size.mY); | 4908 | reshape(size.mX, size.mY); |
@@ -5099,25 +5204,41 @@ LLPickInfo::~LLPickInfo() | |||
5099 | 5204 | ||
5100 | void LLPickInfo::fetchResults() | 5205 | void LLPickInfo::fetchResults() |
5101 | { | 5206 | { |
5207 | |||
5208 | S32 face_hit = -1; | ||
5209 | LLVector3 intersection, normal, binormal; | ||
5210 | LLVector2 uv; | ||
5211 | |||
5212 | LLHUDIcon* hit_icon = gViewerWindow->cursorIntersectIcon(mMousePt.mX, mMousePt.mY, 512.f, &intersection); | ||
5213 | |||
5214 | F32 icon_dist = 0.f; | ||
5215 | if (hit_icon) | ||
5216 | { | ||
5217 | icon_dist = (LLViewerCamera::getInstance()->getOrigin()-intersection).magVec(); | ||
5218 | } | ||
5219 | LLViewerObject* hit_object = gViewerWindow->cursorIntersect(mMousePt.mX, mMousePt.mY, 512.f, | ||
5220 | NULL, -1, mPickTransparent, &face_hit, | ||
5221 | &intersection, &uv, &normal, &binormal); | ||
5222 | |||
5102 | // read back colors and depth values from buffer | 5223 | // read back colors and depth values from buffer |
5103 | glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, mPickBuffer); | 5224 | //glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, mPickBuffer); |
5104 | glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_DEPTH_COMPONENT, GL_FLOAT, mPickDepthBuffer ); | 5225 | //glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, mPickDepthBuffer ); |
5105 | 5226 | ||
5106 | // find pick region that is fully onscreen | 5227 | // find pick region that is fully onscreen |
5107 | LLCoordGL scaled_pick_point;; | 5228 | LLCoordGL scaled_pick_point;; |
5108 | scaled_pick_point.mX = llclamp(llround((F32)mMousePt.mX * gViewerWindow->getDisplayScale().mV[VX]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayWidth() - PICK_HALF_WIDTH); | 5229 | scaled_pick_point.mX = llclamp(llround((F32)mMousePt.mX * gViewerWindow->getDisplayScale().mV[VX]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayWidth() - PICK_HALF_WIDTH); |
5109 | scaled_pick_point.mY = llclamp(llround((F32)mMousePt.mY * gViewerWindow->getDisplayScale().mV[VY]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayHeight() - PICK_HALF_WIDTH); | 5230 | scaled_pick_point.mY = llclamp(llround((F32)mMousePt.mY * gViewerWindow->getDisplayScale().mV[VY]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayHeight() - PICK_HALF_WIDTH); |
5110 | S32 pixel_index = PICK_HALF_WIDTH * PICK_DIAMETER + PICK_HALF_WIDTH; | 5231 | //S32 pixel_index = PICK_HALF_WIDTH * PICK_DIAMETER + PICK_HALF_WIDTH; |
5111 | S32 pick_id = (U32)mPickBuffer[(pixel_index * 4) + 0] << 16 | (U32)mPickBuffer[(pixel_index * 4) + 1] << 8 | (U32)mPickBuffer[(pixel_index * 4) + 2]; | 5232 | //S32 pick_id = (U32)mPickBuffer[(pixel_index * 4) + 0] << 16 | (U32)mPickBuffer[(pixel_index * 4) + 1] << 8 | (U32)mPickBuffer[(pixel_index * 4) + 2]; |
5112 | F32 depth = mPickDepthBuffer[pixel_index]; | 5233 | //F32 depth = mPickDepthBuffer[pixel_index]; |
5113 | 5234 | ||
5114 | S32 x_offset = mMousePt.mX - llround((F32)scaled_pick_point.mX / gViewerWindow->getDisplayScale().mV[VX]); | 5235 | //S32 x_offset = mMousePt.mX - llround((F32)scaled_pick_point.mX / gViewerWindow->getDisplayScale().mV[VX]); |
5115 | S32 y_offset = mMousePt.mY - llround((F32)scaled_pick_point.mY / gViewerWindow->getDisplayScale().mV[VY]); | 5236 | //S32 y_offset = mMousePt.mY - llround((F32)scaled_pick_point.mY / gViewerWindow->getDisplayScale().mV[VY]); |
5116 | 5237 | ||
5117 | mPickPt = mMousePt; | 5238 | mPickPt = mMousePt; |
5118 | 5239 | ||
5119 | // we hit nothing, scan surrounding pixels for something useful | 5240 | // we hit nothing, scan surrounding pixels for something useful |
5120 | if (!pick_id) | 5241 | /*if (!pick_id) |
5121 | { | 5242 | { |
5122 | S32 closest_distance = 10000; | 5243 | S32 closest_distance = 10000; |
5123 | //S32 closest_pick_name = 0; | 5244 | //S32 closest_pick_name = 0; |
@@ -5138,23 +5259,28 @@ void LLPickInfo::fetchResults() | |||
5138 | } | 5259 | } |
5139 | } | 5260 | } |
5140 | } | 5261 | } |
5141 | } | 5262 | }*/ |
5142 | 5263 | ||
5143 | U32 te_offset = ((U32)pick_id >> 20); | ||
5144 | pick_id &= 0x000fffff; | ||
5145 | 5264 | ||
5146 | //unproject relative clicked coordinate from window coordinate using GL | 5265 | U32 te_offset = face_hit > -1 ? face_hit : 0; |
5147 | GLint viewport[4]; | 5266 | //pick_id &= 0x000fffff; |
5148 | GLdouble modelview[16]; | ||
5149 | GLdouble projection[16]; | ||
5150 | GLfloat winX, winY; | ||
5151 | GLdouble posX, posY, posZ; | ||
5152 | 5267 | ||
5153 | LLViewerObject* objectp = gObjectList.getSelectedObject(pick_id); | 5268 | //unproject relative clicked coordinate from window coordinate using GL |
5269 | |||
5270 | LLViewerObject* objectp = hit_object; | ||
5154 | 5271 | ||
5155 | if (pick_id == (S32)GL_NAME_PARCEL_WALL) | 5272 | //if (pick_id == (S32)GL_NAME_PARCEL_WALL) |
5273 | //{ | ||
5274 | // mPickType = PICK_PARCEL_WALL; | ||
5275 | //} | ||
5276 | if (hit_icon && | ||
5277 | (!objectp || | ||
5278 | icon_dist < (LLViewerCamera::getInstance()->getOrigin()-intersection).magVec())) | ||
5156 | { | 5279 | { |
5157 | mPickType = PICK_PARCEL_WALL; | 5280 | // was this name referring to a hud icon? |
5281 | mHUDIcon = hit_icon; | ||
5282 | mPickType = PICK_ICON; | ||
5283 | mPosGlobal = mHUDIcon->getPositionGlobal(); | ||
5158 | } | 5284 | } |
5159 | else if (objectp) | 5285 | else if (objectp) |
5160 | { | 5286 | { |
@@ -5182,11 +5308,11 @@ void LLPickInfo::fetchResults() | |||
5182 | { | 5308 | { |
5183 | mPickType = PICK_OBJECT; | 5309 | mPickType = PICK_OBJECT; |
5184 | } | 5310 | } |
5185 | mObjectOffset = gAgent.calcFocusOffset(objectp, mPickPt.mX, mPickPt.mY); | 5311 | mObjectOffset = gAgent.calcFocusOffset(objectp, intersection, mPickPt.mX, mPickPt.mY); |
5186 | mObjectID = objectp->mID; | 5312 | mObjectID = objectp->mID; |
5187 | mObjectFace = (te_offset == NO_FACE) ? -1 : (S32)te_offset; | 5313 | mObjectFace = (te_offset == NO_FACE) ? -1 : (S32)te_offset; |
5188 | 5314 | ||
5189 | glh::matrix4f newModel((F32*)LLViewerCamera::getInstance()->getModelview().mMatrix); | 5315 | /*glh::matrix4f newModel((F32*)LLViewerCamera::getInstance()->getModelview().mMatrix); |
5190 | 5316 | ||
5191 | for(U32 i = 0; i < 16; ++i) | 5317 | for(U32 i = 0; i < 16; ++i) |
5192 | { | 5318 | { |
@@ -5198,9 +5324,9 @@ void LLPickInfo::fetchResults() | |||
5198 | winX = ((F32)mPickPt.mX) * gViewerWindow->getDisplayScale().mV[VX]; | 5324 | winX = ((F32)mPickPt.mX) * gViewerWindow->getDisplayScale().mV[VX]; |
5199 | winY = ((F32)mPickPt.mY) * gViewerWindow->getDisplayScale().mV[VY]; | 5325 | winY = ((F32)mPickPt.mY) * gViewerWindow->getDisplayScale().mV[VY]; |
5200 | 5326 | ||
5201 | gluUnProject( winX, winY, depth, modelview, projection, viewport, &posX, &posY, &posZ); | 5327 | gluUnProject( winX, winY, depth, modelview, projection, viewport, &posX, &posY, &posZ);*/ |
5202 | 5328 | ||
5203 | mPosGlobal = gAgent.getPosGlobalFromAgent(LLVector3(posX, posY, posZ)); | 5329 | mPosGlobal = gAgent.getPosGlobalFromAgent(intersection); |
5204 | 5330 | ||
5205 | if (mWantSurfaceInfo) | 5331 | if (mWantSurfaceInfo) |
5206 | { | 5332 | { |
@@ -5208,17 +5334,7 @@ void LLPickInfo::fetchResults() | |||
5208 | } | 5334 | } |
5209 | } | 5335 | } |
5210 | } | 5336 | } |
5211 | else | 5337 | |
5212 | { | ||
5213 | // was this name referring to a hud icon? | ||
5214 | mHUDIcon = LLHUDIcon::handlePick(pick_id); | ||
5215 | if (mHUDIcon) | ||
5216 | { | ||
5217 | mPickType = PICK_ICON; | ||
5218 | mPosGlobal = mHUDIcon->getPositionGlobal(); | ||
5219 | } | ||
5220 | } | ||
5221 | |||
5222 | if (mPickCallback) | 5338 | if (mPickCallback) |
5223 | { | 5339 | { |
5224 | mPickCallback(*this); | 5340 | mPickCallback(*this); |
@@ -5232,16 +5348,19 @@ LLPointer<LLViewerObject> LLPickInfo::getObject() const | |||
5232 | 5348 | ||
5233 | void LLPickInfo::updateXYCoords() | 5349 | void LLPickInfo::updateXYCoords() |
5234 | { | 5350 | { |
5235 | const LLTextureEntry* tep = getObject()->getTE(mObjectFace); | 5351 | if (mObjectFace > -1) |
5236 | LLPointer<LLViewerImage> imagep = gImageList.getImage(tep->getID()); | ||
5237 | if(mUVCoords.mV[VX] >= 0.f && mUVCoords.mV[VY] >= 0.f && imagep.notNull()) | ||
5238 | { | 5352 | { |
5239 | LLCoordGL coords; | 5353 | const LLTextureEntry* tep = getObject()->getTE(mObjectFace); |
5240 | 5354 | LLPointer<LLViewerImage> imagep = gImageList.getImage(tep->getID()); | |
5241 | coords.mX = llround(mUVCoords.mV[VX] * (F32)imagep->getWidth()); | 5355 | if(mUVCoords.mV[VX] >= 0.f && mUVCoords.mV[VY] >= 0.f && imagep.notNull()) |
5242 | coords.mY = llround(mUVCoords.mV[VY] * (F32)imagep->getHeight()); | 5356 | { |
5357 | LLCoordGL coords; | ||
5358 | |||
5359 | coords.mX = llround(mUVCoords.mV[VX] * (F32)imagep->getWidth()); | ||
5360 | coords.mY = llround(mUVCoords.mV[VY] * (F32)imagep->getHeight()); | ||
5243 | 5361 | ||
5244 | gViewerWindow->getWindow()->convertCoords(coords, &mXYCoords); | 5362 | gViewerWindow->getWindow()->convertCoords(coords, &mXYCoords); |
5363 | } | ||
5245 | } | 5364 | } |
5246 | } | 5365 | } |
5247 | 5366 | ||
@@ -5252,7 +5371,7 @@ void LLPickInfo::drawPickBuffer() const | |||
5252 | gGL.pushMatrix(); | 5371 | gGL.pushMatrix(); |
5253 | LLGLDisable no_blend(GL_BLEND); | 5372 | LLGLDisable no_blend(GL_BLEND); |
5254 | LLGLDisable no_alpha_test(GL_ALPHA_TEST); | 5373 | LLGLDisable no_alpha_test(GL_ALPHA_TEST); |
5255 | LLGLSNoTexture no_texture; | 5374 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
5256 | glPixelZoom(10.f, 10.f); | 5375 | glPixelZoom(10.f, 10.f); |
5257 | LLVector2 display_scale = gViewerWindow->getDisplayScale(); | 5376 | LLVector2 display_scale = gViewerWindow->getDisplayScale(); |
5258 | glRasterPos2f(((F32)mMousePt.mX * display_scale.mV[VX] + 10.f), | 5377 | glRasterPos2f(((F32)mMousePt.mX * display_scale.mV[VX] + 10.f), |
@@ -5304,7 +5423,7 @@ void LLPickInfo::getSurfaceInfo() | |||
5304 | if (objectp) | 5423 | if (objectp) |
5305 | { | 5424 | { |
5306 | if (gViewerWindow->cursorIntersect(llround((F32)mMousePt.mX), llround((F32)mMousePt.mY), 1024.f, | 5425 | if (gViewerWindow->cursorIntersect(llround((F32)mMousePt.mX), llround((F32)mMousePt.mY), 1024.f, |
5307 | objectp, -1, | 5426 | objectp, -1, mPickTransparent, |
5308 | &mObjectFace, | 5427 | &mObjectFace, |
5309 | &mIntersection, | 5428 | &mIntersection, |
5310 | &mSTCoords, | 5429 | &mSTCoords, |
@@ -5313,7 +5432,7 @@ void LLPickInfo::getSurfaceInfo() | |||
5313 | { | 5432 | { |
5314 | // if we succeeded with the intersect above, compute the texture coordinates: | 5433 | // if we succeeded with the intersect above, compute the texture coordinates: |
5315 | 5434 | ||
5316 | if (objectp->mDrawable.notNull()) | 5435 | if (objectp->mDrawable.notNull() && mObjectFace > -1) |
5317 | { | 5436 | { |
5318 | LLFace* facep = objectp->mDrawable->getFace(mObjectFace); | 5437 | LLFace* facep = objectp->mDrawable->getFace(mObjectFace); |
5319 | 5438 | ||