diff options
author | Jacek Antonelli | 2008-09-06 18:24:57 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-09-06 18:25:07 -0500 |
commit | 798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch) | |
tree | 1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/newview/llviewerdisplay.cpp | |
parent | Second Life viewer sources 1.20.15 (diff) | |
download | meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2 meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz |
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/newview/llviewerdisplay.cpp')
-rw-r--r-- | linden/indra/newview/llviewerdisplay.cpp | 127 |
1 files changed, 61 insertions, 66 deletions
diff --git a/linden/indra/newview/llviewerdisplay.cpp b/linden/indra/newview/llviewerdisplay.cpp index e02ff6f..627609b 100644 --- a/linden/indra/newview/llviewerdisplay.cpp +++ b/linden/indra/newview/llviewerdisplay.cpp | |||
@@ -44,6 +44,7 @@ | |||
44 | #include "lldynamictexture.h" | 44 | #include "lldynamictexture.h" |
45 | #include "lldrawpoolalpha.h" | 45 | #include "lldrawpoolalpha.h" |
46 | #include "llfeaturemanager.h" | 46 | #include "llfeaturemanager.h" |
47 | #include "llfirstuse.h" | ||
47 | #include "llframestats.h" | 48 | #include "llframestats.h" |
48 | #include "llhudmanager.h" | 49 | #include "llhudmanager.h" |
49 | #include "llimagebmp.h" | 50 | #include "llimagebmp.h" |
@@ -68,6 +69,7 @@ | |||
68 | #include "llspatialpartition.h" | 69 | #include "llspatialpartition.h" |
69 | #include "llappviewer.h" | 70 | #include "llappviewer.h" |
70 | #include "llstartup.h" | 71 | #include "llstartup.h" |
72 | #include "llviewershadermgr.h" | ||
71 | #include "llfasttimer.h" | 73 | #include "llfasttimer.h" |
72 | #include "llfloatertools.h" | 74 | #include "llfloatertools.h" |
73 | #include "llviewerimagelist.h" | 75 | #include "llviewerimagelist.h" |
@@ -105,7 +107,7 @@ LLFrameTimer gRecentMemoryTime; | |||
105 | // Rendering stuff | 107 | // Rendering stuff |
106 | void pre_show_depth_buffer(); | 108 | void pre_show_depth_buffer(); |
107 | void post_show_depth_buffer(); | 109 | void post_show_depth_buffer(); |
108 | void render_ui_and_swap(); | 110 | void render_ui(); |
109 | void render_hud_attachments(); | 111 | void render_hud_attachments(); |
110 | void render_ui_3d(); | 112 | void render_ui_3d(); |
111 | void render_ui_2d(); | 113 | void render_ui_2d(); |
@@ -239,6 +241,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
239 | gFrameStats.start(LLFrameStats::REBUILD); | 241 | gFrameStats.start(LLFrameStats::REBUILD); |
240 | gPipeline.rebuildPools(); | 242 | gPipeline.rebuildPools(); |
241 | } | 243 | } |
244 | |||
245 | gViewerWindow->returnEmptyPicks(); | ||
242 | return; | 246 | return; |
243 | } | 247 | } |
244 | 248 | ||
@@ -331,10 +335,10 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
331 | { | 335 | { |
332 | // Give up. Don't keep the UI locked forever. | 336 | // Give up. Don't keep the UI locked forever. |
333 | gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); | 337 | gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); |
334 | gAgent.setTeleportMessage(""); | 338 | gAgent.setTeleportMessage(std::string()); |
335 | } | 339 | } |
336 | 340 | ||
337 | const LLString& message = gAgent.getTeleportMessage(); | 341 | const std::string& message = gAgent.getTeleportMessage(); |
338 | switch( gAgent.getTeleportState() ) | 342 | switch( gAgent.getTeleportState() ) |
339 | { | 343 | { |
340 | case LLAgent::TELEPORT_START: | 344 | case LLAgent::TELEPORT_START: |
@@ -363,7 +367,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
363 | case LLAgent::TELEPORT_START_ARRIVAL: | 367 | case LLAgent::TELEPORT_START_ARRIVAL: |
364 | // Transition to ARRIVING. Viewer has received avatar update, etc., from destination simulator | 368 | // Transition to ARRIVING. Viewer has received avatar update, etc., from destination simulator |
365 | gTeleportArrivalTimer.reset(); | 369 | gTeleportArrivalTimer.reset(); |
366 | gViewerWindow->setProgressCancelButtonVisible(FALSE, "Cancel"); | 370 | gViewerWindow->setProgressCancelButtonVisible(FALSE, std::string("Cancel")); //TODO: Translate |
367 | gViewerWindow->setProgressPercent(75.f); | 371 | gViewerWindow->setProgressPercent(75.f); |
368 | gAgent.setTeleportState( LLAgent::TELEPORT_ARRIVING ); | 372 | gAgent.setTeleportState( LLAgent::TELEPORT_ARRIVING ); |
369 | gAgent.setTeleportMessage( | 373 | gAgent.setTeleportMessage( |
@@ -378,9 +382,10 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
378 | if( arrival_fraction > 1.f ) | 382 | if( arrival_fraction > 1.f ) |
379 | { | 383 | { |
380 | arrival_fraction = 1.f; | 384 | arrival_fraction = 1.f; |
385 | LLFirstUse::useTeleport(); | ||
381 | gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); | 386 | gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); |
382 | } | 387 | } |
383 | gViewerWindow->setProgressCancelButtonVisible(FALSE, "Cancel"); | 388 | gViewerWindow->setProgressCancelButtonVisible(FALSE, std::string("Cancel")); //TODO: Translate |
384 | gViewerWindow->setProgressPercent( arrival_fraction * 25.f + 75.f); | 389 | gViewerWindow->setProgressPercent( arrival_fraction * 25.f + 75.f); |
385 | gViewerWindow->setProgressString(message); | 390 | gViewerWindow->setProgressString(message); |
386 | } | 391 | } |
@@ -455,7 +460,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
455 | if (gDisconnected) | 460 | if (gDisconnected) |
456 | { | 461 | { |
457 | LLAppViewer::instance()->pingMainloopTimeout("Display:Disconnected"); | 462 | LLAppViewer::instance()->pingMainloopTimeout("Display:Disconnected"); |
458 | render_ui_and_swap(); | 463 | render_ui(); |
459 | render_disconnected_background(); | 464 | render_disconnected_background(); |
460 | } | 465 | } |
461 | 466 | ||
@@ -466,12 +471,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
466 | // | 471 | // |
467 | LLAppViewer::instance()->pingMainloopTimeout("Display:RenderSetup"); | 472 | LLAppViewer::instance()->pingMainloopTimeout("Display:RenderSetup"); |
468 | stop_glerror(); | 473 | stop_glerror(); |
469 | if (gSavedSettings.getBOOL("ShowDepthBuffer")) | ||
470 | { | ||
471 | pre_show_depth_buffer(); | ||
472 | } | ||
473 | |||
474 | stop_glerror(); | ||
475 | 474 | ||
476 | /////////////////////////////////////// | 475 | /////////////////////////////////////// |
477 | // | 476 | // |
@@ -531,7 +530,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
531 | 530 | ||
532 | gFrameStats.start(LLFrameStats::UPDATE_CULL); | 531 | gFrameStats.start(LLFrameStats::UPDATE_CULL); |
533 | S32 water_clip = 0; | 532 | S32 water_clip = 0; |
534 | if ((LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_ENVIRONMENT) > 1) && | 533 | if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT) > 1) && |
535 | gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_WATER)) | 534 | gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_WATER)) |
536 | { | 535 | { |
537 | if (LLViewerCamera::getInstance()->cameraUnderWater()) | 536 | if (LLViewerCamera::getInstance()->cameraUnderWater()) |
@@ -759,7 +758,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
759 | 758 | ||
760 | if (!for_snapshot) | 759 | if (!for_snapshot) |
761 | { | 760 | { |
762 | render_ui_and_swap(); | 761 | render_ui(); |
763 | } | 762 | } |
764 | 763 | ||
765 | LLSpatialGroup::sNoDelete = FALSE; | 764 | LLSpatialGroup::sNoDelete = FALSE; |
@@ -797,7 +796,12 @@ void render_hud_attachments() | |||
797 | glh::matrix4f current_proj = glh_get_current_projection(); | 796 | glh::matrix4f current_proj = glh_get_current_projection(); |
798 | glh::matrix4f current_mod = glh_get_current_modelview(); | 797 | glh::matrix4f current_mod = glh_get_current_modelview(); |
799 | 798 | ||
800 | if (LLPipeline::sShowHUDAttachments && !gDisconnected && setup_hud_matrices(FALSE)) | 799 | // clamp target zoom level to reasonable values |
800 | gAgent.mHUDTargetZoom = llclamp(gAgent.mHUDTargetZoom, 0.1f, 1.f); | ||
801 | // smoothly interpolate current zoom level | ||
802 | gAgent.mHUDCurZoom = lerp(gAgent.mHUDCurZoom, gAgent.mHUDTargetZoom, LLCriticalDamp::getInterpolant(0.03f)); | ||
803 | |||
804 | if (LLPipeline::sShowHUDAttachments && !gDisconnected && setup_hud_matrices()) | ||
801 | { | 805 | { |
802 | LLCamera hud_cam = *LLViewerCamera::getInstance(); | 806 | LLCamera hud_cam = *LLViewerCamera::getInstance(); |
803 | LLVector3 origin = hud_cam.getOrigin(); | 807 | LLVector3 origin = hud_cam.getOrigin(); |
@@ -855,52 +859,53 @@ void render_hud_attachments() | |||
855 | glh_set_current_modelview(current_mod); | 859 | glh_set_current_modelview(current_mod); |
856 | } | 860 | } |
857 | 861 | ||
858 | BOOL setup_hud_matrices(BOOL for_select) | 862 | BOOL setup_hud_matrices() |
863 | { | ||
864 | LLRect whole_screen = gViewerWindow->getVirtualWindowRect(); | ||
865 | |||
866 | // apply camera zoom transform (for high res screenshots) | ||
867 | F32 zoom_factor = LLViewerCamera::getInstance()->getZoomFactor(); | ||
868 | S16 sub_region = LLViewerCamera::getInstance()->getZoomSubRegion(); | ||
869 | if (zoom_factor > 1.f) | ||
870 | { | ||
871 | S32 num_horizontal_tiles = llceil(zoom_factor); | ||
872 | S32 tile_width = llround((F32)gViewerWindow->getWindowWidth() / zoom_factor); | ||
873 | S32 tile_height = llround((F32)gViewerWindow->getWindowHeight() / zoom_factor); | ||
874 | int tile_y = sub_region / num_horizontal_tiles; | ||
875 | int tile_x = sub_region - (tile_y * num_horizontal_tiles); | ||
876 | glh::matrix4f mat; | ||
877 | |||
878 | whole_screen.setLeftTopAndSize(tile_x * tile_width, gViewerWindow->getWindowHeight() - (tile_y * tile_height), tile_width, tile_height); | ||
879 | } | ||
880 | |||
881 | return setup_hud_matrices(whole_screen); | ||
882 | } | ||
883 | |||
884 | BOOL setup_hud_matrices(const LLRect& screen_region) | ||
859 | { | 885 | { |
860 | LLVOAvatar* my_avatarp = gAgent.getAvatarObject(); | 886 | LLVOAvatar* my_avatarp = gAgent.getAvatarObject(); |
861 | if (my_avatarp && my_avatarp->hasHUDAttachment()) | 887 | if (my_avatarp && my_avatarp->hasHUDAttachment()) |
862 | { | 888 | { |
863 | if (!for_select) | 889 | F32 zoom_level = gAgent.mHUDCurZoom; |
864 | { | ||
865 | // clamp target zoom level to reasonable values | ||
866 | my_avatarp->mHUDTargetZoom = llclamp(my_avatarp->mHUDTargetZoom, 0.1f, 1.f); | ||
867 | // smoothly interpolate current zoom level | ||
868 | my_avatarp->mHUDCurZoom = lerp(my_avatarp->mHUDCurZoom, my_avatarp->mHUDTargetZoom, LLCriticalDamp::getInterpolant(0.03f)); | ||
869 | } | ||
870 | |||
871 | F32 zoom_level = my_avatarp->mHUDCurZoom; | ||
872 | // clear z buffer and set up transform for hud | ||
873 | if (!for_select) | ||
874 | { | ||
875 | //glClear(GL_DEPTH_BUFFER_BIT); | ||
876 | } | ||
877 | LLBBox hud_bbox = my_avatarp->getHUDBBox(); | 890 | LLBBox hud_bbox = my_avatarp->getHUDBBox(); |
878 | 891 | ||
879 | 892 | // set up transform to keep HUD objects in front of camera | |
880 | // set up transform to encompass bounding box of HUD | ||
881 | glMatrixMode(GL_PROJECTION); | 893 | glMatrixMode(GL_PROJECTION); |
882 | F32 hud_depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f); | 894 | F32 hud_depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f); |
883 | if (for_select) | ||
884 | { | ||
885 | //RN: reset viewport to window extents so ortho screen is calculated with proper reference frame | ||
886 | gViewerWindow->setupViewport(); | ||
887 | } | ||
888 | glh::matrix4f proj = gl_ortho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, hud_depth); | 895 | glh::matrix4f proj = gl_ortho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, hud_depth); |
889 | proj.element(2,2) = -0.01f; | 896 | proj.element(2,2) = -0.01f; |
890 | 897 | ||
891 | // apply camera zoom transform (for high res screenshots) | 898 | F32 aspect_ratio = LLViewerCamera::getInstance()->getAspect(); |
892 | F32 zoom_factor = LLViewerCamera::getInstance()->getZoomFactor(); | 899 | |
893 | S16 sub_region = LLViewerCamera::getInstance()->getZoomSubRegion(); | 900 | glh::matrix4f mat; |
894 | if (zoom_factor > 1.f) | 901 | F32 scale_x = (F32)gViewerWindow->getWindowWidth() / (F32)screen_region.getWidth(); |
895 | { | 902 | F32 scale_y = (F32)gViewerWindow->getWindowHeight() / (F32)screen_region.getHeight(); |
896 | float offset = zoom_factor - 1.f; | 903 | mat.set_scale(glh::vec3f(scale_x, scale_y, 1.f)); |
897 | int pos_y = sub_region / llceil(zoom_factor); | 904 | mat.set_translate( |
898 | int pos_x = sub_region - (pos_y*llceil(zoom_factor)); | 905 | glh::vec3f(clamp_rescale((F32)screen_region.getCenterX(), 0.f, (F32)gViewerWindow->getWindowWidth(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio), |
899 | glh::matrix4f mat; | 906 | clamp_rescale((F32)screen_region.getCenterY(), 0.f, (F32)gViewerWindow->getWindowHeight(), 0.5f * scale_y, -0.5f * scale_y), |
900 | mat.set_scale(glh::vec3f(zoom_factor, zoom_factor, 1.f)); | 907 | 0.f)); |
901 | mat.set_translate(glh::vec3f(LLViewerCamera::getInstance()->getAspect() * 0.5f * (offset - (F32)pos_x * 2.f), 0.5f * (offset - (F32)pos_y * 2.f), 0.f)); | 908 | proj *= mat; |
902 | proj *= mat; | ||
903 | } | ||
904 | 909 | ||
905 | glLoadMatrixf(proj.m); | 910 | glLoadMatrixf(proj.m); |
906 | glh_set_current_projection(proj); | 911 | glh_set_current_projection(proj); |
@@ -908,9 +913,8 @@ BOOL setup_hud_matrices(BOOL for_select) | |||
908 | glMatrixMode(GL_MODELVIEW); | 913 | glMatrixMode(GL_MODELVIEW); |
909 | glh::matrix4f model((GLfloat*) OGL_TO_CFR_ROTATION); | 914 | glh::matrix4f model((GLfloat*) OGL_TO_CFR_ROTATION); |
910 | 915 | ||
911 | glh::matrix4f mat; | ||
912 | mat.set_translate(glh::vec3f(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f)); | ||
913 | mat.set_scale(glh::vec3f(zoom_level, zoom_level, zoom_level)); | 916 | mat.set_scale(glh::vec3f(zoom_level, zoom_level, zoom_level)); |
917 | mat.set_translate(glh::vec3f(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f)); | ||
914 | 918 | ||
915 | model *= mat; | 919 | model *= mat; |
916 | glLoadMatrixf(model.m); | 920 | glLoadMatrixf(model.m); |
@@ -925,7 +929,7 @@ BOOL setup_hud_matrices(BOOL for_select) | |||
925 | } | 929 | } |
926 | 930 | ||
927 | 931 | ||
928 | void render_ui_and_swap() | 932 | void render_ui() |
929 | { | 933 | { |
930 | LLGLState::checkStates(); | 934 | LLGLState::checkStates(); |
931 | 935 | ||
@@ -1078,11 +1082,6 @@ void render_ui_3d() | |||
1078 | 1082 | ||
1079 | // Debugging stuff goes before the UI. | 1083 | // Debugging stuff goes before the UI. |
1080 | 1084 | ||
1081 | if (gSavedSettings.getBOOL("ShowDepthBuffer")) | ||
1082 | { | ||
1083 | post_show_depth_buffer(); | ||
1084 | } | ||
1085 | |||
1086 | // Coordinate axes | 1085 | // Coordinate axes |
1087 | if (gSavedSettings.getBOOL("ShowAxes")) | 1086 | if (gSavedSettings.getBOOL("ShowAxes")) |
1088 | { | 1087 | { |
@@ -1126,14 +1125,14 @@ void render_ui_2d() | |||
1126 | gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); | 1125 | gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); |
1127 | 1126 | ||
1128 | // render outline for HUD | 1127 | // render outline for HUD |
1129 | if (gAgent.getAvatarObject() && gAgent.getAvatarObject()->mHUDCurZoom < 0.98f) | 1128 | if (gAgent.getAvatarObject() && gAgent.mHUDCurZoom < 0.98f) |
1130 | { | 1129 | { |
1131 | glPushMatrix(); | 1130 | glPushMatrix(); |
1132 | S32 half_width = (gViewerWindow->getWindowWidth() / 2); | 1131 | S32 half_width = (gViewerWindow->getWindowWidth() / 2); |
1133 | S32 half_height = (gViewerWindow->getWindowHeight() / 2); | 1132 | S32 half_height = (gViewerWindow->getWindowHeight() / 2); |
1134 | glScalef(LLUI::sGLScaleFactor.mV[0], LLUI::sGLScaleFactor.mV[1], 1.f); | 1133 | glScalef(LLUI::sGLScaleFactor.mV[0], LLUI::sGLScaleFactor.mV[1], 1.f); |
1135 | glTranslatef((F32)half_width, (F32)half_height, 0.f); | 1134 | glTranslatef((F32)half_width, (F32)half_height, 0.f); |
1136 | F32 zoom = gAgent.getAvatarObject()->mHUDCurZoom; | 1135 | F32 zoom = gAgent.mHUDCurZoom; |
1137 | glScalef(zoom,zoom,1.f); | 1136 | glScalef(zoom,zoom,1.f); |
1138 | gGL.color4fv(LLColor4::white.mV); | 1137 | gGL.color4fv(LLColor4::white.mV); |
1139 | gl_rect_2d(-half_width, half_height, half_width, -half_height, FALSE); | 1138 | gl_rect_2d(-half_width, half_height, half_width, -half_height, FALSE); |
@@ -1157,12 +1156,8 @@ void render_disconnected_background() | |||
1157 | { | 1156 | { |
1158 | llinfos << "Loading last bitmap..." << llendl; | 1157 | llinfos << "Loading last bitmap..." << llendl; |
1159 | 1158 | ||
1160 | char temp_str[MAX_PATH]; /* Flawfinder: ignore */ | 1159 | std::string temp_str; |
1161 | strncpy(temp_str, gDirUtilp->getLindenUserDir().c_str(), MAX_PATH -1); /* Flawfinder: ignore */ | 1160 | temp_str = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter() + SCREEN_LAST_FILENAME; |
1162 | temp_str[MAX_PATH -1] = '\0'; | ||
1163 | strncat(temp_str, gDirUtilp->getDirDelimiter().c_str(), MAX_PATH - strlen(temp_str) -1); /* Flawfinder: ignore */ | ||
1164 | |||
1165 | strcat(temp_str, SCREEN_LAST_FILENAME); /* Flawfinder: ignore */ | ||
1166 | 1161 | ||
1167 | LLPointer<LLImageBMP> image_bmp = new LLImageBMP; | 1162 | LLPointer<LLImageBMP> image_bmp = new LLImageBMP; |
1168 | if( !image_bmp->load(temp_str) ) | 1163 | if( !image_bmp->load(temp_str) ) |