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 0c43b59..443bbd5 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 | } |
@@ -4638,6 +4694,7 @@ void LLViewerWindow::toggleFullscreen(BOOL show_progress) | |||
4638 | if (mWindow) | 4694 | if (mWindow) |
4639 | { | 4695 | { |
4640 | mWantFullscreen = mWindow->getFullscreen() ? FALSE : TRUE; | 4696 | mWantFullscreen = mWindow->getFullscreen() ? FALSE : TRUE; |
4697 | mIsFullscreenChecked = mWindow->getFullscreen() ? FALSE : TRUE; | ||
4641 | mShowFullscreenProgress = show_progress; | 4698 | mShowFullscreenProgress = show_progress; |
4642 | } | 4699 | } |
4643 | } | 4700 | } |
@@ -4664,37 +4721,89 @@ void LLViewerWindow::getTargetWindow(BOOL& fullscreen, S32& width, S32& height) | |||
4664 | } | 4721 | } |
4665 | } | 4722 | } |
4666 | 4723 | ||
4724 | void LLViewerWindow::requestResolutionUpdate(bool fullscreen_checked) | ||
4725 | { | ||
4726 | mResDirty = true; | ||
4727 | mWantFullscreen = fullscreen_checked; | ||
4728 | mIsFullscreenChecked = fullscreen_checked; | ||
4729 | } | ||
4667 | 4730 | ||
4668 | BOOL LLViewerWindow::checkSettings() | 4731 | BOOL LLViewerWindow::checkSettings() |
4669 | { | 4732 | { |
4670 | BOOL is_fullscreen = mWindow->getFullscreen(); | 4733 | if (mStatesDirty) |
4671 | if (is_fullscreen && !mWantFullscreen) | ||
4672 | { | 4734 | { |
4673 | changeDisplaySettings(FALSE, | 4735 | gGL.refreshState(); |
4674 | LLCoordScreen(gSavedSettings.getS32("WindowWidth"), | 4736 | LLViewerShaderMgr::instance()->setShaders(); |
4675 | gSavedSettings.getS32("WindowHeight")), | 4737 | mStatesDirty = false; |
4676 | TRUE, | ||
4677 | mShowFullscreenProgress); | ||
4678 | return TRUE; | ||
4679 | } | 4738 | } |
4680 | else if (!is_fullscreen && mWantFullscreen) | 4739 | |
4740 | // We want to update the resolution AFTER the states getting refreshed not before. | ||
4741 | if (mResDirty) | ||
4681 | { | 4742 | { |
4682 | if (!LLStartUp::canGoFullscreen()) | 4743 | if (gSavedSettings.getBOOL("FullScreenAutoDetectAspectRatio")) |
4683 | { | 4744 | { |
4684 | return FALSE; | 4745 | getWindow()->setNativeAspectRatio(0.f); |
4746 | } | ||
4747 | else | ||
4748 | { | ||
4749 | getWindow()->setNativeAspectRatio(gSavedSettings.getF32("FullScreenAspectRatio")); | ||
4685 | } | 4750 | } |
4686 | 4751 | ||
4687 | LLGLState::checkStates(); | 4752 | reshape(getWindowDisplayWidth(), getWindowDisplayHeight()); |
4688 | LLGLState::checkTextureChannels(); | 4753 | |
4689 | changeDisplaySettings(TRUE, | 4754 | // force aspect ratio |
4690 | LLCoordScreen(gSavedSettings.getS32("FullScreenWidth"), | 4755 | if (mIsFullscreenChecked) |
4691 | gSavedSettings.getS32("FullScreenHeight")), | 4756 | { |
4692 | gSavedSettings.getBOOL("DisableVerticalSync"), | 4757 | LLViewerCamera::getInstance()->setAspect( getDisplayAspectRatio() ); |
4693 | mShowFullscreenProgress); | 4758 | } |
4694 | 4759 | ||
4695 | LLGLState::checkStates(); | 4760 | mResDirty = false; |
4696 | LLGLState::checkTextureChannels(); | 4761 | // This will force a state update the next frame. |
4697 | return TRUE; | 4762 | mStatesDirty = true; |
4763 | } | ||
4764 | |||
4765 | BOOL is_fullscreen = mWindow->getFullscreen(); | ||
4766 | if(mWantFullscreen) | ||
4767 | { | ||
4768 | LLCoordScreen screen_size; | ||
4769 | LLCoordScreen desired_screen_size(gSavedSettings.getS32("FullScreenWidth"), | ||
4770 | gSavedSettings.getS32("FullScreenHeight")); | ||
4771 | getWindow()->getSize(&screen_size); | ||
4772 | if(!is_fullscreen || | ||
4773 | screen_size.mX != desired_screen_size.mX | ||
4774 | || screen_size.mY != desired_screen_size.mY) | ||
4775 | { | ||
4776 | if (!LLStartUp::canGoFullscreen()) | ||
4777 | { | ||
4778 | return FALSE; | ||
4779 | } | ||
4780 | |||
4781 | LLGLState::checkStates(); | ||
4782 | LLGLState::checkTextureChannels(); | ||
4783 | changeDisplaySettings(TRUE, | ||
4784 | desired_screen_size, | ||
4785 | gSavedSettings.getBOOL("DisableVerticalSync"), | ||
4786 | mShowFullscreenProgress); | ||
4787 | |||
4788 | LLGLState::checkStates(); | ||
4789 | LLGLState::checkTextureChannels(); | ||
4790 | mStatesDirty = true; | ||
4791 | return TRUE; | ||
4792 | } | ||
4793 | } | ||
4794 | else | ||
4795 | { | ||
4796 | if(is_fullscreen) | ||
4797 | { | ||
4798 | // Changing to windowed mode. | ||
4799 | changeDisplaySettings(FALSE, | ||
4800 | LLCoordScreen(gSavedSettings.getS32("WindowWidth"), | ||
4801 | gSavedSettings.getS32("WindowHeight")), | ||
4802 | TRUE, | ||
4803 | mShowFullscreenProgress); | ||
4804 | mStatesDirty = true; | ||
4805 | return TRUE; | ||
4806 | } | ||
4698 | } | 4807 | } |
4699 | return FALSE; | 4808 | return FALSE; |
4700 | } | 4809 | } |
@@ -4725,13 +4834,9 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size, | |||
4725 | BOOL old_fullscreen = mWindow->getFullscreen(); | 4834 | BOOL old_fullscreen = mWindow->getFullscreen(); |
4726 | if (!old_fullscreen && fullscreen && !LLStartUp::canGoFullscreen()) | 4835 | if (!old_fullscreen && fullscreen && !LLStartUp::canGoFullscreen()) |
4727 | { | 4836 | { |
4728 | // we can't do this now, so do it later | 4837 | // Not allowed to switch to fullscreen now, so exit early. |
4729 | 4838 | // *NOTE: This case should never be reached, but just-in-case. | |
4730 | gSavedSettings.setS32("FullScreenWidth", size.mX); | 4839 | return TRUE; |
4731 | gSavedSettings.setS32("FullScreenHeight", size.mY); | ||
4732 | //gSavedSettings.setBOOL("DisableVerticalSync", disable_vsync); | ||
4733 | |||
4734 | return TRUE; // a lie..., because we'll get to it later | ||
4735 | } | 4840 | } |
4736 | 4841 | ||
4737 | U32 fsaa = gSavedSettings.getU32("RenderFSAASamples"); | 4842 | U32 fsaa = gSavedSettings.getU32("RenderFSAASamples"); |
@@ -4818,7 +4923,7 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size, | |||
4818 | #if LL_WINDOWS | 4923 | #if LL_WINDOWS |
4819 | // Only trigger a reshape after switching to fullscreen; otherwise rely on the windows callback | 4924 | // Only trigger a reshape after switching to fullscreen; otherwise rely on the windows callback |
4820 | // (otherwise size is wrong; this is the entire window size, reshape wants the visible window size) | 4925 | // (otherwise size is wrong; this is the entire window size, reshape wants the visible window size) |
4821 | if (fullscreen) | 4926 | if (fullscreen && result_first_try) |
4822 | #endif | 4927 | #endif |
4823 | { | 4928 | { |
4824 | reshape(size.mX, size.mY); | 4929 | reshape(size.mX, size.mY); |
@@ -5120,25 +5225,41 @@ LLPickInfo::~LLPickInfo() | |||
5120 | 5225 | ||
5121 | void LLPickInfo::fetchResults() | 5226 | void LLPickInfo::fetchResults() |
5122 | { | 5227 | { |
5228 | |||
5229 | S32 face_hit = -1; | ||
5230 | LLVector3 intersection, normal, binormal; | ||
5231 | LLVector2 uv; | ||
5232 | |||
5233 | LLHUDIcon* hit_icon = gViewerWindow->cursorIntersectIcon(mMousePt.mX, mMousePt.mY, 512.f, &intersection); | ||
5234 | |||
5235 | F32 icon_dist = 0.f; | ||
5236 | if (hit_icon) | ||
5237 | { | ||
5238 | icon_dist = (LLViewerCamera::getInstance()->getOrigin()-intersection).magVec(); | ||
5239 | } | ||
5240 | LLViewerObject* hit_object = gViewerWindow->cursorIntersect(mMousePt.mX, mMousePt.mY, 512.f, | ||
5241 | NULL, -1, mPickTransparent, &face_hit, | ||
5242 | &intersection, &uv, &normal, &binormal); | ||
5243 | |||
5123 | // read back colors and depth values from buffer | 5244 | // read back colors and depth values from buffer |
5124 | glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, mPickBuffer); | 5245 | //glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, mPickBuffer); |
5125 | glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_DEPTH_COMPONENT, GL_FLOAT, mPickDepthBuffer ); | 5246 | //glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, mPickDepthBuffer ); |
5126 | 5247 | ||
5127 | // find pick region that is fully onscreen | 5248 | // find pick region that is fully onscreen |
5128 | LLCoordGL scaled_pick_point;; | 5249 | LLCoordGL scaled_pick_point;; |
5129 | scaled_pick_point.mX = llclamp(llround((F32)mMousePt.mX * gViewerWindow->getDisplayScale().mV[VX]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayWidth() - PICK_HALF_WIDTH); | 5250 | scaled_pick_point.mX = llclamp(llround((F32)mMousePt.mX * gViewerWindow->getDisplayScale().mV[VX]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayWidth() - PICK_HALF_WIDTH); |
5130 | scaled_pick_point.mY = llclamp(llround((F32)mMousePt.mY * gViewerWindow->getDisplayScale().mV[VY]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayHeight() - PICK_HALF_WIDTH); | 5251 | scaled_pick_point.mY = llclamp(llround((F32)mMousePt.mY * gViewerWindow->getDisplayScale().mV[VY]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayHeight() - PICK_HALF_WIDTH); |
5131 | S32 pixel_index = PICK_HALF_WIDTH * PICK_DIAMETER + PICK_HALF_WIDTH; | 5252 | //S32 pixel_index = PICK_HALF_WIDTH * PICK_DIAMETER + PICK_HALF_WIDTH; |
5132 | S32 pick_id = (U32)mPickBuffer[(pixel_index * 4) + 0] << 16 | (U32)mPickBuffer[(pixel_index * 4) + 1] << 8 | (U32)mPickBuffer[(pixel_index * 4) + 2]; | 5253 | //S32 pick_id = (U32)mPickBuffer[(pixel_index * 4) + 0] << 16 | (U32)mPickBuffer[(pixel_index * 4) + 1] << 8 | (U32)mPickBuffer[(pixel_index * 4) + 2]; |
5133 | F32 depth = mPickDepthBuffer[pixel_index]; | 5254 | //F32 depth = mPickDepthBuffer[pixel_index]; |
5134 | 5255 | ||
5135 | S32 x_offset = mMousePt.mX - llround((F32)scaled_pick_point.mX / gViewerWindow->getDisplayScale().mV[VX]); | 5256 | //S32 x_offset = mMousePt.mX - llround((F32)scaled_pick_point.mX / gViewerWindow->getDisplayScale().mV[VX]); |
5136 | S32 y_offset = mMousePt.mY - llround((F32)scaled_pick_point.mY / gViewerWindow->getDisplayScale().mV[VY]); | 5257 | //S32 y_offset = mMousePt.mY - llround((F32)scaled_pick_point.mY / gViewerWindow->getDisplayScale().mV[VY]); |
5137 | 5258 | ||
5138 | mPickPt = mMousePt; | 5259 | mPickPt = mMousePt; |
5139 | 5260 | ||
5140 | // we hit nothing, scan surrounding pixels for something useful | 5261 | // we hit nothing, scan surrounding pixels for something useful |
5141 | if (!pick_id) | 5262 | /*if (!pick_id) |
5142 | { | 5263 | { |
5143 | S32 closest_distance = 10000; | 5264 | S32 closest_distance = 10000; |
5144 | //S32 closest_pick_name = 0; | 5265 | //S32 closest_pick_name = 0; |
@@ -5159,23 +5280,28 @@ void LLPickInfo::fetchResults() | |||
5159 | } | 5280 | } |
5160 | } | 5281 | } |
5161 | } | 5282 | } |
5162 | } | 5283 | }*/ |
5163 | 5284 | ||
5164 | U32 te_offset = ((U32)pick_id >> 20); | ||
5165 | pick_id &= 0x000fffff; | ||
5166 | 5285 | ||
5167 | //unproject relative clicked coordinate from window coordinate using GL | 5286 | U32 te_offset = face_hit > -1 ? face_hit : 0; |
5168 | GLint viewport[4]; | 5287 | //pick_id &= 0x000fffff; |
5169 | GLdouble modelview[16]; | ||
5170 | GLdouble projection[16]; | ||
5171 | GLfloat winX, winY; | ||
5172 | GLdouble posX, posY, posZ; | ||
5173 | 5288 | ||
5174 | LLViewerObject* objectp = gObjectList.getSelectedObject(pick_id); | 5289 | //unproject relative clicked coordinate from window coordinate using GL |
5290 | |||
5291 | LLViewerObject* objectp = hit_object; | ||
5175 | 5292 | ||
5176 | if (pick_id == (S32)GL_NAME_PARCEL_WALL) | 5293 | //if (pick_id == (S32)GL_NAME_PARCEL_WALL) |
5294 | //{ | ||
5295 | // mPickType = PICK_PARCEL_WALL; | ||
5296 | //} | ||
5297 | if (hit_icon && | ||
5298 | (!objectp || | ||
5299 | icon_dist < (LLViewerCamera::getInstance()->getOrigin()-intersection).magVec())) | ||
5177 | { | 5300 | { |
5178 | mPickType = PICK_PARCEL_WALL; | 5301 | // was this name referring to a hud icon? |
5302 | mHUDIcon = hit_icon; | ||
5303 | mPickType = PICK_ICON; | ||
5304 | mPosGlobal = mHUDIcon->getPositionGlobal(); | ||
5179 | } | 5305 | } |
5180 | else if (objectp) | 5306 | else if (objectp) |
5181 | { | 5307 | { |
@@ -5203,11 +5329,11 @@ void LLPickInfo::fetchResults() | |||
5203 | { | 5329 | { |
5204 | mPickType = PICK_OBJECT; | 5330 | mPickType = PICK_OBJECT; |
5205 | } | 5331 | } |
5206 | mObjectOffset = gAgent.calcFocusOffset(objectp, mPickPt.mX, mPickPt.mY); | 5332 | mObjectOffset = gAgent.calcFocusOffset(objectp, intersection, mPickPt.mX, mPickPt.mY); |
5207 | mObjectID = objectp->mID; | 5333 | mObjectID = objectp->mID; |
5208 | mObjectFace = (te_offset == NO_FACE) ? -1 : (S32)te_offset; | 5334 | mObjectFace = (te_offset == NO_FACE) ? -1 : (S32)te_offset; |
5209 | 5335 | ||
5210 | glh::matrix4f newModel((F32*)LLViewerCamera::getInstance()->getModelview().mMatrix); | 5336 | /*glh::matrix4f newModel((F32*)LLViewerCamera::getInstance()->getModelview().mMatrix); |
5211 | 5337 | ||
5212 | for(U32 i = 0; i < 16; ++i) | 5338 | for(U32 i = 0; i < 16; ++i) |
5213 | { | 5339 | { |
@@ -5219,9 +5345,9 @@ void LLPickInfo::fetchResults() | |||
5219 | winX = ((F32)mPickPt.mX) * gViewerWindow->getDisplayScale().mV[VX]; | 5345 | winX = ((F32)mPickPt.mX) * gViewerWindow->getDisplayScale().mV[VX]; |
5220 | winY = ((F32)mPickPt.mY) * gViewerWindow->getDisplayScale().mV[VY]; | 5346 | winY = ((F32)mPickPt.mY) * gViewerWindow->getDisplayScale().mV[VY]; |
5221 | 5347 | ||
5222 | gluUnProject( winX, winY, depth, modelview, projection, viewport, &posX, &posY, &posZ); | 5348 | gluUnProject( winX, winY, depth, modelview, projection, viewport, &posX, &posY, &posZ);*/ |
5223 | 5349 | ||
5224 | mPosGlobal = gAgent.getPosGlobalFromAgent(LLVector3(posX, posY, posZ)); | 5350 | mPosGlobal = gAgent.getPosGlobalFromAgent(intersection); |
5225 | 5351 | ||
5226 | if (mWantSurfaceInfo) | 5352 | if (mWantSurfaceInfo) |
5227 | { | 5353 | { |
@@ -5229,17 +5355,7 @@ void LLPickInfo::fetchResults() | |||
5229 | } | 5355 | } |
5230 | } | 5356 | } |
5231 | } | 5357 | } |
5232 | else | 5358 | |
5233 | { | ||
5234 | // was this name referring to a hud icon? | ||
5235 | mHUDIcon = LLHUDIcon::handlePick(pick_id); | ||
5236 | if (mHUDIcon) | ||
5237 | { | ||
5238 | mPickType = PICK_ICON; | ||
5239 | mPosGlobal = mHUDIcon->getPositionGlobal(); | ||
5240 | } | ||
5241 | } | ||
5242 | |||
5243 | if (mPickCallback) | 5359 | if (mPickCallback) |
5244 | { | 5360 | { |
5245 | mPickCallback(*this); | 5361 | mPickCallback(*this); |
@@ -5253,16 +5369,19 @@ LLPointer<LLViewerObject> LLPickInfo::getObject() const | |||
5253 | 5369 | ||
5254 | void LLPickInfo::updateXYCoords() | 5370 | void LLPickInfo::updateXYCoords() |
5255 | { | 5371 | { |
5256 | const LLTextureEntry* tep = getObject()->getTE(mObjectFace); | 5372 | if (mObjectFace > -1) |
5257 | LLPointer<LLViewerImage> imagep = gImageList.getImage(tep->getID()); | ||
5258 | if(mUVCoords.mV[VX] >= 0.f && mUVCoords.mV[VY] >= 0.f && imagep.notNull()) | ||
5259 | { | 5373 | { |
5260 | LLCoordGL coords; | 5374 | const LLTextureEntry* tep = getObject()->getTE(mObjectFace); |
5261 | 5375 | LLPointer<LLViewerImage> imagep = gImageList.getImage(tep->getID()); | |
5262 | coords.mX = llround(mUVCoords.mV[VX] * (F32)imagep->getWidth()); | 5376 | if(mUVCoords.mV[VX] >= 0.f && mUVCoords.mV[VY] >= 0.f && imagep.notNull()) |
5263 | coords.mY = llround(mUVCoords.mV[VY] * (F32)imagep->getHeight()); | 5377 | { |
5378 | LLCoordGL coords; | ||
5379 | |||
5380 | coords.mX = llround(mUVCoords.mV[VX] * (F32)imagep->getWidth()); | ||
5381 | coords.mY = llround(mUVCoords.mV[VY] * (F32)imagep->getHeight()); | ||
5264 | 5382 | ||
5265 | gViewerWindow->getWindow()->convertCoords(coords, &mXYCoords); | 5383 | gViewerWindow->getWindow()->convertCoords(coords, &mXYCoords); |
5384 | } | ||
5266 | } | 5385 | } |
5267 | } | 5386 | } |
5268 | 5387 | ||
@@ -5273,7 +5392,7 @@ void LLPickInfo::drawPickBuffer() const | |||
5273 | gGL.pushMatrix(); | 5392 | gGL.pushMatrix(); |
5274 | LLGLDisable no_blend(GL_BLEND); | 5393 | LLGLDisable no_blend(GL_BLEND); |
5275 | LLGLDisable no_alpha_test(GL_ALPHA_TEST); | 5394 | LLGLDisable no_alpha_test(GL_ALPHA_TEST); |
5276 | LLGLSNoTexture no_texture; | 5395 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
5277 | glPixelZoom(10.f, 10.f); | 5396 | glPixelZoom(10.f, 10.f); |
5278 | LLVector2 display_scale = gViewerWindow->getDisplayScale(); | 5397 | LLVector2 display_scale = gViewerWindow->getDisplayScale(); |
5279 | glRasterPos2f(((F32)mMousePt.mX * display_scale.mV[VX] + 10.f), | 5398 | glRasterPos2f(((F32)mMousePt.mX * display_scale.mV[VX] + 10.f), |
@@ -5325,7 +5444,7 @@ void LLPickInfo::getSurfaceInfo() | |||
5325 | if (objectp) | 5444 | if (objectp) |
5326 | { | 5445 | { |
5327 | if (gViewerWindow->cursorIntersect(llround((F32)mMousePt.mX), llround((F32)mMousePt.mY), 1024.f, | 5446 | if (gViewerWindow->cursorIntersect(llround((F32)mMousePt.mX), llround((F32)mMousePt.mY), 1024.f, |
5328 | objectp, -1, | 5447 | objectp, -1, mPickTransparent, |
5329 | &mObjectFace, | 5448 | &mObjectFace, |
5330 | &mIntersection, | 5449 | &mIntersection, |
5331 | &mSTCoords, | 5450 | &mSTCoords, |
@@ -5334,7 +5453,7 @@ void LLPickInfo::getSurfaceInfo() | |||
5334 | { | 5453 | { |
5335 | // if we succeeded with the intersect above, compute the texture coordinates: | 5454 | // if we succeeded with the intersect above, compute the texture coordinates: |
5336 | 5455 | ||
5337 | if (objectp->mDrawable.notNull()) | 5456 | if (objectp->mDrawable.notNull() && mObjectFace > -1) |
5338 | { | 5457 | { |
5339 | LLFace* facep = objectp->mDrawable->getFace(mObjectFace); | 5458 | LLFace* facep = objectp->mDrawable->getFace(mObjectFace); |
5340 | 5459 | ||