diff options
Diffstat (limited to 'linden/indra/newview/pipeline.cpp')
-rw-r--r-- | linden/indra/newview/pipeline.cpp | 230 |
1 files changed, 148 insertions, 82 deletions
diff --git a/linden/indra/newview/pipeline.cpp b/linden/indra/newview/pipeline.cpp index cd546d4..f232fdf 100644 --- a/linden/indra/newview/pipeline.cpp +++ b/linden/indra/newview/pipeline.cpp | |||
@@ -93,7 +93,7 @@ | |||
93 | #include "llworld.h" | 93 | #include "llworld.h" |
94 | #include "llcubemap.h" | 94 | #include "llcubemap.h" |
95 | #include "lldebugmessagebox.h" | 95 | #include "lldebugmessagebox.h" |
96 | #include "llglslshader.h" | 96 | #include "llviewershadermgr.h" |
97 | #include "llviewerjoystick.h" | 97 | #include "llviewerjoystick.h" |
98 | #include "llviewerdisplay.h" | 98 | #include "llviewerdisplay.h" |
99 | #include "llwlparammanager.h" | 99 | #include "llwlparammanager.h" |
@@ -139,6 +139,24 @@ const LLMatrix4* gGLLastMatrix = NULL; | |||
139 | 139 | ||
140 | //---------------------------------------- | 140 | //---------------------------------------- |
141 | 141 | ||
142 | std::string gPoolNames[] = | ||
143 | { | ||
144 | // Correspond to LLDrawpool enum render type | ||
145 | "NONE", | ||
146 | "POOL_SIMPLE", | ||
147 | "POOL_TERRAIN", | ||
148 | "POOL_TREE", | ||
149 | "POOL_SKY", | ||
150 | "POOL_WL_SKY", | ||
151 | "POOL_GROUND", | ||
152 | "POOL_BUMP", | ||
153 | "POOL_INVISIBLE", | ||
154 | "POOL_AVATAR", | ||
155 | "POOL_WATER", | ||
156 | "POOL_GLOW", | ||
157 | "POOL_ALPHA", | ||
158 | }; | ||
159 | |||
142 | U32 nhpo2(U32 v) | 160 | U32 nhpo2(U32 v) |
143 | { | 161 | { |
144 | U32 r = 1; | 162 | U32 r = 1; |
@@ -197,6 +215,7 @@ glh::matrix4f gl_ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, | |||
197 | return ret; | 215 | return ret; |
198 | } | 216 | } |
199 | 217 | ||
218 | void display_update_camera(); | ||
200 | //---------------------------------------- | 219 | //---------------------------------------- |
201 | 220 | ||
202 | S32 LLPipeline::sCompiles = 0; | 221 | S32 LLPipeline::sCompiles = 0; |
@@ -210,7 +229,6 @@ BOOL LLPipeline::sRenderParticleBeacons = FALSE; | |||
210 | BOOL LLPipeline::sRenderSoundBeacons = FALSE; | 229 | BOOL LLPipeline::sRenderSoundBeacons = FALSE; |
211 | BOOL LLPipeline::sRenderBeacons = FALSE; | 230 | BOOL LLPipeline::sRenderBeacons = FALSE; |
212 | BOOL LLPipeline::sRenderHighlight = TRUE; | 231 | BOOL LLPipeline::sRenderHighlight = TRUE; |
213 | BOOL LLPipeline::sRenderProcessBeacons = FALSE; | ||
214 | S32 LLPipeline::sUseOcclusion = 0; | 232 | S32 LLPipeline::sUseOcclusion = 0; |
215 | BOOL LLPipeline::sFastAlpha = TRUE; | 233 | BOOL LLPipeline::sFastAlpha = TRUE; |
216 | BOOL LLPipeline::sDisableShaders = FALSE; | 234 | BOOL LLPipeline::sDisableShaders = FALSE; |
@@ -224,6 +242,8 @@ BOOL LLPipeline::sImpostorRender = FALSE; | |||
224 | BOOL LLPipeline::sUnderWaterRender = FALSE; | 242 | BOOL LLPipeline::sUnderWaterRender = FALSE; |
225 | BOOL LLPipeline::sTextureBindTest = FALSE; | 243 | BOOL LLPipeline::sTextureBindTest = FALSE; |
226 | BOOL LLPipeline::sRenderFrameTest = FALSE; | 244 | BOOL LLPipeline::sRenderFrameTest = FALSE; |
245 | BOOL LLPipeline::sRenderAttachedLights = TRUE; | ||
246 | BOOL LLPipeline::sRenderAttachedParticles = TRUE; | ||
227 | 247 | ||
228 | static LLCullResult* sCull = NULL; | 248 | static LLCullResult* sCull = NULL; |
229 | 249 | ||
@@ -240,10 +260,30 @@ static const U32 gl_cube_face[] = | |||
240 | void validate_framebuffer_object(); | 260 | void validate_framebuffer_object(); |
241 | 261 | ||
242 | LLPipeline::LLPipeline() : | 262 | LLPipeline::LLPipeline() : |
263 | mBackfaceCull(FALSE), | ||
264 | mBatchCount(0), | ||
265 | mMatrixOpCount(0), | ||
266 | mTextureMatrixOps(0), | ||
267 | mMaxBatchSize(0), | ||
268 | mMinBatchSize(0), | ||
269 | mMeanBatchSize(0), | ||
270 | mTrianglesDrawn(0), | ||
271 | mNumVisibleNodes(0), | ||
272 | mVerticesRelit(0), | ||
273 | mLightingChanges(0), | ||
274 | mGeometryChanges(0), | ||
275 | mNumVisibleFaces(0), | ||
276 | |||
243 | mCubeBuffer(NULL), | 277 | mCubeBuffer(NULL), |
278 | mCubeFrameBuffer(0), | ||
279 | mCubeDepth(0), | ||
244 | mInitialized(FALSE), | 280 | mInitialized(FALSE), |
245 | mVertexShadersEnabled(FALSE), | 281 | mVertexShadersEnabled(FALSE), |
246 | mVertexShadersLoaded(0), | 282 | mVertexShadersLoaded(0), |
283 | mRenderTypeMask(0), | ||
284 | mRenderDebugFeatureMask(0), | ||
285 | mRenderDebugMask(0), | ||
286 | mOldRenderDebugMask(0), | ||
247 | mLastRebuildPool(NULL), | 287 | mLastRebuildPool(NULL), |
248 | mAlphaPool(NULL), | 288 | mAlphaPool(NULL), |
249 | mSkyPool(NULL), | 289 | mSkyPool(NULL), |
@@ -256,15 +296,11 @@ LLPipeline::LLPipeline() : | |||
256 | mBumpPool(NULL), | 296 | mBumpPool(NULL), |
257 | mWLSkyPool(NULL), | 297 | mWLSkyPool(NULL), |
258 | mLightMask(0), | 298 | mLightMask(0), |
259 | mLightMovingMask(0) | 299 | mLightMovingMask(0), |
300 | mLightingDetail(0) | ||
260 | { | 301 | { |
261 | //mFramebuffer[0] = mFramebuffer[1] = mFramebuffer[2] = mFramebuffer[3] = 0; | ||
262 | mBlurCubeBuffer[0] = mBlurCubeBuffer[1] = mBlurCubeBuffer[2] = 0; | 302 | mBlurCubeBuffer[0] = mBlurCubeBuffer[1] = mBlurCubeBuffer[2] = 0; |
263 | mBlurCubeTexture[0] = mBlurCubeTexture[1] = mBlurCubeTexture[2] = 0; | 303 | mBlurCubeTexture[0] = mBlurCubeTexture[1] = mBlurCubeTexture[2] = 0; |
264 | |||
265 | //mDepthbuffer[0] = mDepthbuffer[1] = 0; | ||
266 | mCubeFrameBuffer = 0; | ||
267 | mCubeDepth = 0; | ||
268 | } | 304 | } |
269 | 305 | ||
270 | void LLPipeline::init() | 306 | void LLPipeline::init() |
@@ -273,6 +309,8 @@ void LLPipeline::init() | |||
273 | 309 | ||
274 | sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD"); | 310 | sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD"); |
275 | sRenderBump = gSavedSettings.getBOOL("RenderObjectBump"); | 311 | sRenderBump = gSavedSettings.getBOOL("RenderObjectBump"); |
312 | sRenderAttachedLights = gSavedSettings.getBOOL("RenderAttachedLights"); | ||
313 | sRenderAttachedParticles = gSavedSettings.getBOOL("RenderAttachedParticles"); | ||
276 | 314 | ||
277 | mInitialized = TRUE; | 315 | mInitialized = TRUE; |
278 | 316 | ||
@@ -300,7 +338,7 @@ void LLPipeline::init() | |||
300 | 338 | ||
301 | // Enable features | 339 | // Enable features |
302 | 340 | ||
303 | LLShaderMgr::setShaders(); | 341 | LLViewerShaderMgr::instance()->setShaders(); |
304 | 342 | ||
305 | stop_glerror(); | 343 | stop_glerror(); |
306 | } | 344 | } |
@@ -439,12 +477,6 @@ void LLPipeline::releaseGLBuffers() | |||
439 | mCubeDepth = mCubeFrameBuffer = 0; | 477 | mCubeDepth = mCubeFrameBuffer = 0; |
440 | } | 478 | } |
441 | 479 | ||
442 | /*if (mFramebuffer[0]) | ||
443 | { | ||
444 | glDeleteFramebuffersEXT(4, mFramebuffer); | ||
445 | mFramebuffer[0] = mFramebuffer[1] = mFramebuffer[2] = mFramebuffer[3] = 0; | ||
446 | }*/ | ||
447 | |||
448 | if (mBlurCubeBuffer[0]) | 480 | if (mBlurCubeBuffer[0]) |
449 | { | 481 | { |
450 | glDeleteFramebuffersEXT(3, mBlurCubeBuffer); | 482 | glDeleteFramebuffersEXT(3, mBlurCubeBuffer); |
@@ -539,7 +571,6 @@ void LLPipeline::createGLBuffers() | |||
539 | #endif | 571 | #endif |
540 | } | 572 | } |
541 | 573 | ||
542 | |||
543 | stop_glerror(); | 574 | stop_glerror(); |
544 | 575 | ||
545 | if (LLPipeline::sRenderGlow) | 576 | if (LLPipeline::sRenderGlow) |
@@ -551,12 +582,12 @@ void LLPipeline::createGLBuffers() | |||
551 | { | 582 | { |
552 | mGlow[i].allocate(512,glow_res,GL_RGBA,FALSE); | 583 | mGlow[i].allocate(512,glow_res,GL_RGBA,FALSE); |
553 | } | 584 | } |
585 | |||
586 | GLuint resX = gViewerWindow->getWindowDisplayWidth(); | ||
587 | GLuint resY = gViewerWindow->getWindowDisplayHeight(); | ||
588 | |||
589 | mScreen.allocate(resX, resY, GL_RGBA, TRUE, GL_TEXTURE_RECTANGLE_ARB); | ||
554 | } | 590 | } |
555 | |||
556 | GLuint resX = gViewerWindow->getWindowDisplayWidth(); | ||
557 | GLuint resY = gViewerWindow->getWindowDisplayHeight(); | ||
558 | |||
559 | mScreen.allocate(resX, resY, GL_RGBA, TRUE, GL_TEXTURE_RECTANGLE_ARB); | ||
560 | } | 591 | } |
561 | 592 | ||
562 | void LLPipeline::restoreGL() | 593 | void LLPipeline::restoreGL() |
@@ -565,7 +596,7 @@ void LLPipeline::restoreGL() | |||
565 | 596 | ||
566 | if (mVertexShadersEnabled) | 597 | if (mVertexShadersEnabled) |
567 | { | 598 | { |
568 | LLShaderMgr::setShaders(); | 599 | LLViewerShaderMgr::instance()->setShaders(); |
569 | } | 600 | } |
570 | 601 | ||
571 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); | 602 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); |
@@ -603,18 +634,18 @@ BOOL LLPipeline::canUseWindLightShaders() const | |||
603 | { | 634 | { |
604 | return (!LLPipeline::sDisableShaders && | 635 | return (!LLPipeline::sDisableShaders && |
605 | gWLSkyProgram.mProgramObject != 0 && | 636 | gWLSkyProgram.mProgramObject != 0 && |
606 | LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_WINDLIGHT) > 1); | 637 | LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WINDLIGHT) > 1); |
607 | } | 638 | } |
608 | 639 | ||
609 | BOOL LLPipeline::canUseWindLightShadersOnObjects() const | 640 | BOOL LLPipeline::canUseWindLightShadersOnObjects() const |
610 | { | 641 | { |
611 | return (canUseWindLightShaders() | 642 | return (canUseWindLightShaders() |
612 | && LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_OBJECT) > 0); | 643 | && LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 0); |
613 | } | 644 | } |
614 | 645 | ||
615 | void LLPipeline::unloadShaders() | 646 | void LLPipeline::unloadShaders() |
616 | { | 647 | { |
617 | LLShaderMgr::unloadShaders(); | 648 | LLViewerShaderMgr::instance()->unloadShaders(); |
618 | 649 | ||
619 | mVertexShadersLoaded = 0; | 650 | mVertexShadersLoaded = 0; |
620 | } | 651 | } |
@@ -660,7 +691,7 @@ S32 LLPipeline::setLightingDetail(S32 level) | |||
660 | 691 | ||
661 | if (mVertexShadersLoaded == 1) | 692 | if (mVertexShadersLoaded == 1) |
662 | { | 693 | { |
663 | LLShaderMgr::setShaders(); | 694 | LLViewerShaderMgr::instance()->setShaders(); |
664 | } | 695 | } |
665 | } | 696 | } |
666 | return mLightingDetail; | 697 | return mLightingDetail; |
@@ -870,7 +901,7 @@ void LLPipeline::allocDrawable(LLViewerObject *vobj) | |||
870 | 901 | ||
871 | //encompass completely sheared objects by taking | 902 | //encompass completely sheared objects by taking |
872 | //the most extreme point possible (<1,1,0.5>) | 903 | //the most extreme point possible (<1,1,0.5>) |
873 | drawable->setRadius(LLVector3(1,1,0.5f).scaleVec(vobj->getScale()).magVec()); | 904 | drawable->setRadius(LLVector3(1,1,0.5f).scaleVec(vobj->getScale()).length()); |
874 | if (vobj->isOrphaned()) | 905 | if (vobj->isOrphaned()) |
875 | { | 906 | { |
876 | drawable->setState(LLDrawable::FORCE_INVISIBLE); | 907 | drawable->setState(LLDrawable::FORCE_INVISIBLE); |
@@ -1133,7 +1164,7 @@ void LLPipeline::updateMove() | |||
1133 | F32 LLPipeline::calcPixelArea(LLVector3 center, LLVector3 size, LLCamera &camera) | 1164 | F32 LLPipeline::calcPixelArea(LLVector3 center, LLVector3 size, LLCamera &camera) |
1134 | { | 1165 | { |
1135 | LLVector3 lookAt = center - camera.getOrigin(); | 1166 | LLVector3 lookAt = center - camera.getOrigin(); |
1136 | F32 dist = lookAt.magVec(); | 1167 | F32 dist = lookAt.length(); |
1137 | 1168 | ||
1138 | //ramp down distance for nearby objects | 1169 | //ramp down distance for nearby objects |
1139 | if (dist < 16.f) | 1170 | if (dist < 16.f) |
@@ -1144,7 +1175,7 @@ F32 LLPipeline::calcPixelArea(LLVector3 center, LLVector3 size, LLCamera &camera | |||
1144 | } | 1175 | } |
1145 | 1176 | ||
1146 | //get area of circle around node | 1177 | //get area of circle around node |
1147 | F32 app_angle = atanf(size.magVec()/dist); | 1178 | F32 app_angle = atanf(size.length()/dist); |
1148 | F32 radius = app_angle*LLDrawable::sCurPixelAngle; | 1179 | F32 radius = app_angle*LLDrawable::sCurPixelAngle; |
1149 | return radius*radius * 3.14159f; | 1180 | return radius*radius * 3.14159f; |
1150 | } | 1181 | } |
@@ -1582,6 +1613,9 @@ void LLPipeline::shiftObjects(const LLVector3 &offset) | |||
1582 | } | 1613 | } |
1583 | } | 1614 | } |
1584 | } | 1615 | } |
1616 | |||
1617 | LLHUDText::shiftAll(offset); | ||
1618 | display_update_camera(); | ||
1585 | } | 1619 | } |
1586 | 1620 | ||
1587 | void LLPipeline::markTextured(LLDrawable *drawablep) | 1621 | void LLPipeline::markTextured(LLDrawable *drawablep) |
@@ -1766,6 +1800,12 @@ void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera) | |||
1766 | { | 1800 | { |
1767 | return; | 1801 | return; |
1768 | } | 1802 | } |
1803 | |||
1804 | LLVOAvatar* avatarp = (LLVOAvatar*) drawablep->getVObj().get(); | ||
1805 | if (!avatarp->isVisible()) | ||
1806 | { | ||
1807 | return; | ||
1808 | } | ||
1769 | } | 1809 | } |
1770 | 1810 | ||
1771 | assertInitialized(); | 1811 | assertInitialized(); |
@@ -1795,7 +1835,7 @@ void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera) | |||
1795 | else if (drawablep->isAvatar()) | 1835 | else if (drawablep->isAvatar()) |
1796 | { | 1836 | { |
1797 | drawablep->updateDistance(camera); // calls vobj->updateLOD() which calls LLVOAvatar::updateVisibility() | 1837 | drawablep->updateDistance(camera); // calls vobj->updateLOD() which calls LLVOAvatar::updateVisibility() |
1798 | } | 1838 | } |
1799 | } | 1839 | } |
1800 | } | 1840 | } |
1801 | 1841 | ||
@@ -2060,8 +2100,8 @@ void LLPipeline::postSort(LLCamera& camera) | |||
2060 | std::sort(sCull->beginAlphaGroups(), sCull->endAlphaGroups(), LLSpatialGroup::CompareDepthGreater()); | 2100 | std::sort(sCull->beginAlphaGroups(), sCull->endAlphaGroups(), LLSpatialGroup::CompareDepthGreater()); |
2061 | } | 2101 | } |
2062 | 2102 | ||
2063 | // only render if the flag is set. The flag is only set if the right key is pressed, we are in edit mode or the toggle is set in the menus | 2103 | // only render if the flag is set. The flag is only set if we are in edit mode or the toggle is set in the menus |
2064 | if (sRenderProcessBeacons) | 2104 | if (gSavedSettings.getBOOL("BeaconAlwaysOn")) |
2065 | { | 2105 | { |
2066 | if (sRenderScriptedTouchBeacons) | 2106 | if (sRenderScriptedTouchBeacons) |
2067 | { | 2107 | { |
@@ -2132,6 +2172,8 @@ void LLPipeline::postSort(LLCamera& camera) | |||
2132 | } func; | 2172 | } func; |
2133 | LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func); | 2173 | LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func); |
2134 | } | 2174 | } |
2175 | |||
2176 | LLSpatialGroup::sNoDelete = FALSE; | ||
2135 | } | 2177 | } |
2136 | 2178 | ||
2137 | 2179 | ||
@@ -2151,6 +2193,7 @@ void render_hud_elements() | |||
2151 | gGL.color4f(1,1,1,1); | 2193 | gGL.color4f(1,1,1,1); |
2152 | if (!LLPipeline::sReflectionRender && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) | 2194 | if (!LLPipeline::sReflectionRender && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) |
2153 | { | 2195 | { |
2196 | LLGLEnable multisample(GL_MULTISAMPLE_ARB); | ||
2154 | gViewerWindow->renderSelections(FALSE, FALSE, FALSE); // For HUD version in render_ui_3d() | 2197 | gViewerWindow->renderSelections(FALSE, FALSE, FALSE); // For HUD version in render_ui_3d() |
2155 | 2198 | ||
2156 | // Draw the tracking overlays | 2199 | // Draw the tracking overlays |
@@ -2186,14 +2229,15 @@ void LLPipeline::renderHighlights() | |||
2186 | 2229 | ||
2187 | // Draw 3D UI elements here (before we clear the Z buffer in POOL_HUD) | 2230 | // Draw 3D UI elements here (before we clear the Z buffer in POOL_HUD) |
2188 | // Render highlighted faces. | 2231 | // Render highlighted faces. |
2232 | LLGLSPipelineAlpha gls_pipeline_alpha; | ||
2189 | LLColor4 color(1.f, 1.f, 1.f, 0.5f); | 2233 | LLColor4 color(1.f, 1.f, 1.f, 0.5f); |
2190 | LLGLEnable color_mat(GL_COLOR_MATERIAL); | 2234 | LLGLEnable color_mat(GL_COLOR_MATERIAL); |
2191 | disableLights(); | 2235 | disableLights(); |
2192 | 2236 | ||
2193 | if ((LLShaderMgr::sVertexShaderLevel[LLShaderMgr::SHADER_INTERFACE] > 0)) | 2237 | if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) |
2194 | { | 2238 | { |
2195 | gHighlightProgram.bind(); | 2239 | gHighlightProgram.bind(); |
2196 | gHighlightProgram.vertexAttrib4f(LLShaderMgr::MATERIAL_COLOR,1,1,1,0.5f); | 2240 | gHighlightProgram.vertexAttrib4f(LLViewerShaderMgr::MATERIAL_COLOR,1,1,1,0.5f); |
2197 | } | 2241 | } |
2198 | 2242 | ||
2199 | if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED)) | 2243 | if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED)) |
@@ -2223,9 +2267,9 @@ void LLPipeline::renderHighlights() | |||
2223 | { | 2267 | { |
2224 | // Paint 'em red! | 2268 | // Paint 'em red! |
2225 | color.setVec(1.f, 0.f, 0.f, 0.5f); | 2269 | color.setVec(1.f, 0.f, 0.f, 0.5f); |
2226 | if ((LLShaderMgr::sVertexShaderLevel[LLShaderMgr::SHADER_INTERFACE] > 0)) | 2270 | if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) |
2227 | { | 2271 | { |
2228 | gHighlightProgram.vertexAttrib4f(LLShaderMgr::MATERIAL_COLOR,1,0,0,0.5f); | 2272 | gHighlightProgram.vertexAttrib4f(LLViewerShaderMgr::MATERIAL_COLOR,1,0,0,0.5f); |
2229 | } | 2273 | } |
2230 | int count = mHighlightFaces.size(); | 2274 | int count = mHighlightFaces.size(); |
2231 | for (S32 i = 0; i < count; i++) | 2275 | for (S32 i = 0; i < count; i++) |
@@ -2239,7 +2283,7 @@ void LLPipeline::renderHighlights() | |||
2239 | // have touch-handlers. | 2283 | // have touch-handlers. |
2240 | mHighlightFaces.clear(); | 2284 | mHighlightFaces.clear(); |
2241 | 2285 | ||
2242 | if (LLShaderMgr::sVertexShaderLevel[LLShaderMgr::SHADER_INTERFACE] > 0) | 2286 | if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0) |
2243 | { | 2287 | { |
2244 | gHighlightProgram.unbind(); | 2288 | gHighlightProgram.unbind(); |
2245 | } | 2289 | } |
@@ -2339,7 +2383,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) | |||
2339 | 2383 | ||
2340 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PICKING)) | 2384 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PICKING)) |
2341 | { | 2385 | { |
2342 | gObjectList.renderObjectsForSelect(camera); | 2386 | gObjectList.renderObjectsForSelect(camera, gViewerWindow->getVirtualWindowRect()); |
2343 | } | 2387 | } |
2344 | else if (gSavedSettings.getBOOL("RenderDeferred")) | 2388 | else if (gSavedSettings.getBOOL("RenderDeferred")) |
2345 | { | 2389 | { |
@@ -2407,9 +2451,10 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) | |||
2407 | { | 2451 | { |
2408 | llerrs << "GL matrix stack corrupted!" << llendl; | 2452 | llerrs << "GL matrix stack corrupted!" << llendl; |
2409 | } | 2453 | } |
2410 | LLGLState::checkStates(); | 2454 | std::string msg = llformat("%s pass %d", gPoolNames[cur_type].c_str(), i); |
2411 | LLGLState::checkTextureChannels(); | 2455 | LLGLState::checkStates(msg); |
2412 | LLGLState::checkClientArrays(); | 2456 | LLGLState::checkTextureChannels(msg); |
2457 | LLGLState::checkClientArrays(msg); | ||
2413 | } | 2458 | } |
2414 | } | 2459 | } |
2415 | } | 2460 | } |
@@ -2589,7 +2634,7 @@ void LLPipeline::renderDebug() | |||
2589 | gGL.flush(); | 2634 | gGL.flush(); |
2590 | } | 2635 | } |
2591 | 2636 | ||
2592 | void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects) | 2637 | void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects, BOOL render_transparent, const LLRect& screen_rect) |
2593 | { | 2638 | { |
2594 | assertInitialized(); | 2639 | assertInitialized(); |
2595 | 2640 | ||
@@ -2642,7 +2687,7 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects) | |||
2642 | } | 2687 | } |
2643 | 2688 | ||
2644 | LLGLEnable alpha_test(GL_ALPHA_TEST); | 2689 | LLGLEnable alpha_test(GL_ALPHA_TEST); |
2645 | if (gPickTransparent) | 2690 | if (render_transparent) |
2646 | { | 2691 | { |
2647 | gGL.setAlphaRejectSettings(LLRender::CF_GREATER_EQUAL, 0.f); | 2692 | gGL.setAlphaRejectSettings(LLRender::CF_GREATER_EQUAL, 0.f); |
2648 | } | 2693 | } |
@@ -2687,14 +2732,7 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects) | |||
2687 | glh::matrix4f save_proj(glh_get_current_projection()); | 2732 | glh::matrix4f save_proj(glh_get_current_projection()); |
2688 | glh::matrix4f save_model(glh_get_current_modelview()); | 2733 | glh::matrix4f save_model(glh_get_current_modelview()); |
2689 | 2734 | ||
2690 | U32 viewport[4]; | 2735 | setup_hud_matrices(screen_rect); |
2691 | |||
2692 | for (U32 i = 0; i < 4; i++) | ||
2693 | { | ||
2694 | viewport[i] = gGLViewport[i]; | ||
2695 | } | ||
2696 | |||
2697 | setup_hud_matrices(TRUE); | ||
2698 | for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); | 2736 | for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); |
2699 | iter != avatarp->mAttachmentPoints.end(); ) | 2737 | iter != avatarp->mAttachmentPoints.end(); ) |
2700 | { | 2738 | { |
@@ -2721,12 +2759,15 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects) | |||
2721 | } | 2759 | } |
2722 | 2760 | ||
2723 | //render child faces | 2761 | //render child faces |
2724 | for (U32 k = 0; k < drawable->getChildCount(); ++k) | 2762 | LLViewerObject::const_child_list_t& child_list = objectp->getChildren(); |
2763 | for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); | ||
2764 | iter != child_list.end(); iter++) | ||
2725 | { | 2765 | { |
2726 | LLDrawable* child = drawable->getChild(k); | 2766 | LLViewerObject* child = *iter; |
2727 | for (S32 l = 0; l < child->getNumFaces(); ++l) | 2767 | LLDrawable* child_drawable = child->mDrawable; |
2768 | for (S32 l = 0; l < child_drawable->getNumFaces(); ++l) | ||
2728 | { | 2769 | { |
2729 | LLFace* facep = child->getFace(l); | 2770 | LLFace* facep = child_drawable->getFace(l); |
2730 | if (!facep->getPool()) | 2771 | if (!facep->getPool()) |
2731 | { | 2772 | { |
2732 | facep->renderForSelect(prim_mask); | 2773 | facep->renderForSelect(prim_mask); |
@@ -2746,11 +2787,6 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects) | |||
2746 | glh_set_current_modelview(save_model); | 2787 | glh_set_current_modelview(save_model); |
2747 | 2788 | ||
2748 | 2789 | ||
2749 | for (U32 i = 0; i < 4; i++) | ||
2750 | { | ||
2751 | gGLViewport[i] = viewport[i]; | ||
2752 | } | ||
2753 | glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); | ||
2754 | } | 2790 | } |
2755 | 2791 | ||
2756 | gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); | 2792 | gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); |
@@ -2760,11 +2796,6 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects) | |||
2760 | gGL.setColorMask(true, true); | 2796 | gGL.setColorMask(true, true); |
2761 | } | 2797 | } |
2762 | 2798 | ||
2763 | void LLPipeline::renderFaceForUVSelect(LLFace* facep) | ||
2764 | { | ||
2765 | if (facep) facep->renderSelectedUV(); | ||
2766 | } | ||
2767 | |||
2768 | void LLPipeline::rebuildPools() | 2799 | void LLPipeline::rebuildPools() |
2769 | { | 2800 | { |
2770 | LLMemType mt(LLMemType::MTYPE_PIPELINE); | 2801 | LLMemType mt(LLMemType::MTYPE_PIPELINE); |
@@ -3129,7 +3160,7 @@ static F32 calc_light_dist(LLVOVolume* light, const LLVector3& cam_pos, F32 max_ | |||
3129 | F32 radius = light->getLightRadius(); | 3160 | F32 radius = light->getLightRadius(); |
3130 | BOOL selected = light->isSelected(); | 3161 | BOOL selected = light->isSelected(); |
3131 | LLVector3 dpos = light->getRenderPosition() - cam_pos; | 3162 | LLVector3 dpos = light->getRenderPosition() - cam_pos; |
3132 | F32 dist2 = dpos.magVecSquared(); | 3163 | F32 dist2 = dpos.lengthSquared(); |
3133 | if (!selected && dist2 > (max_dist + radius)*(max_dist + radius)) | 3164 | if (!selected && dist2 > (max_dist + radius)*(max_dist + radius)) |
3134 | { | 3165 | { |
3135 | return max_dist; | 3166 | return max_dist; |
@@ -3188,12 +3219,16 @@ void LLPipeline::calcNearbyLights(LLCamera& camera) | |||
3188 | if (light->fade <= -LIGHT_FADE_TIME) | 3219 | if (light->fade <= -LIGHT_FADE_TIME) |
3189 | { | 3220 | { |
3190 | drawable->clearState(LLDrawable::NEARBY_LIGHT); | 3221 | drawable->clearState(LLDrawable::NEARBY_LIGHT); |
3222 | continue; | ||
3191 | } | 3223 | } |
3192 | else | 3224 | if (!sRenderAttachedLights && volight && volight->isAttachment()) |
3193 | { | 3225 | { |
3194 | F32 dist = calc_light_dist(volight, cam_pos, max_dist); | 3226 | drawable->clearState(LLDrawable::NEARBY_LIGHT); |
3195 | cur_nearby_lights.insert(Light(drawable, dist, light->fade)); | 3227 | continue; |
3196 | } | 3228 | } |
3229 | |||
3230 | F32 dist = calc_light_dist(volight, cam_pos, max_dist); | ||
3231 | cur_nearby_lights.insert(Light(drawable, dist, light->fade)); | ||
3197 | } | 3232 | } |
3198 | mNearbyLights = cur_nearby_lights; | 3233 | mNearbyLights = cur_nearby_lights; |
3199 | } | 3234 | } |
@@ -3951,13 +3986,47 @@ BOOL LLPipeline::getRenderHighlights(void*) | |||
3951 | return sRenderHighlight; | 3986 | return sRenderHighlight; |
3952 | } | 3987 | } |
3953 | 3988 | ||
3954 | // static | 3989 | LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start, const LLVector3& end, |
3955 | BOOL LLPipeline::getProcessBeacons(void* data) | 3990 | S32* face_hit, |
3991 | LLVector3* intersection, // return the intersection point | ||
3992 | LLVector2* tex_coord, // return the texture coordinates of the intersection point | ||
3993 | LLVector3* normal, // return the surface normal at the intersection point | ||
3994 | LLVector3* bi_normal // return the surface bi-normal at the intersection point | ||
3995 | ) | ||
3956 | { | 3996 | { |
3957 | return sRenderProcessBeacons; | 3997 | LLDrawable* drawable = NULL; |
3998 | |||
3999 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin(); | ||
4000 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) | ||
4001 | { | ||
4002 | LLViewerRegion* region = *iter; | ||
4003 | |||
4004 | for (U32 j = 0; j < LLViewerRegion::NUM_PARTITIONS; j++) | ||
4005 | { | ||
4006 | if ((j == LLViewerRegion::PARTITION_VOLUME) || (j == LLViewerRegion::PARTITION_BRIDGE)) // only check these partitions for now | ||
4007 | { | ||
4008 | LLSpatialPartition* part = region->getSpatialPartition(j); | ||
4009 | if (part) | ||
4010 | { | ||
4011 | LLDrawable* hit = part->lineSegmentIntersect(start, end, face_hit, intersection, tex_coord, normal, bi_normal); | ||
4012 | if (hit) | ||
4013 | { | ||
4014 | drawable = hit; | ||
4015 | } | ||
4016 | } | ||
4017 | } | ||
4018 | } | ||
4019 | } | ||
4020 | return drawable ? drawable->getVObj().get() : NULL; | ||
3958 | } | 4021 | } |
3959 | 4022 | ||
3960 | LLViewerObject* LLPipeline::pickObject(const LLVector3 &start, const LLVector3 &end, LLVector3 &collision) | 4023 | LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector3& start, const LLVector3& end, |
4024 | S32* face_hit, | ||
4025 | LLVector3* intersection, // return the intersection point | ||
4026 | LLVector2* tex_coord, // return the texture coordinates of the intersection point | ||
4027 | LLVector3* normal, // return the surface normal at the intersection point | ||
4028 | LLVector3* bi_normal // return the surface bi-normal at the intersection point | ||
4029 | ) | ||
3961 | { | 4030 | { |
3962 | LLDrawable* drawable = NULL; | 4031 | LLDrawable* drawable = NULL; |
3963 | 4032 | ||
@@ -3965,10 +4034,11 @@ LLViewerObject* LLPipeline::pickObject(const LLVector3 &start, const LLVector3 & | |||
3965 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) | 4034 | iter != LLWorld::getInstance()->getRegionList().end(); ++iter) |
3966 | { | 4035 | { |
3967 | LLViewerRegion* region = *iter; | 4036 | LLViewerRegion* region = *iter; |
3968 | LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_VOLUME); | 4037 | |
4038 | LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_HUD); | ||
3969 | if (part) | 4039 | if (part) |
3970 | { | 4040 | { |
3971 | LLDrawable* hit = part->pickDrawable(start, end, collision); | 4041 | LLDrawable* hit = part->lineSegmentIntersect(start, end, face_hit, intersection, tex_coord, normal, bi_normal); |
3972 | if (hit) | 4042 | if (hit) |
3973 | { | 4043 | { |
3974 | drawable = hit; | 4044 | drawable = hit; |
@@ -3999,11 +4069,6 @@ void LLPipeline::resetVertexBuffers(LLDrawable* drawable) | |||
3999 | return; | 4069 | return; |
4000 | } | 4070 | } |
4001 | 4071 | ||
4002 | if (!drawable) | ||
4003 | { | ||
4004 | return; | ||
4005 | } | ||
4006 | |||
4007 | for (S32 i = 0; i < drawable->getNumFaces(); i++) | 4072 | for (S32 i = 0; i < drawable->getNumFaces(); i++) |
4008 | { | 4073 | { |
4009 | LLFace* facep = drawable->getFace(i); | 4074 | LLFace* facep = drawable->getFace(i); |
@@ -4455,6 +4520,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot) | |||
4455 | return; | 4520 | return; |
4456 | } | 4521 | } |
4457 | 4522 | ||
4523 | LLVertexBuffer::unbind(); | ||
4458 | LLGLState::checkStates(); | 4524 | LLGLState::checkStates(); |
4459 | LLGLState::checkTextureChannels(); | 4525 | LLGLState::checkTextureChannels(); |
4460 | 4526 | ||
@@ -5119,7 +5185,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) | |||
5119 | glMatrixMode(GL_PROJECTION); | 5185 | glMatrixMode(GL_PROJECTION); |
5120 | glPushMatrix(); | 5186 | glPushMatrix(); |
5121 | //glh::matrix4f ortho = gl_ortho(-tdim.mV[0], tdim.mV[0], -tdim.mV[1], tdim.mV[1], 1.0, 256.0); | 5187 | //glh::matrix4f ortho = gl_ortho(-tdim.mV[0], tdim.mV[0], -tdim.mV[1], tdim.mV[1], 1.0, 256.0); |
5122 | F32 distance = (pos-camera.getOrigin()).magVec(); | 5188 | F32 distance = (pos-camera.getOrigin()).length(); |
5123 | F32 fov = atanf(tdim.mV[1]/distance)*2.f*RAD_TO_DEG; | 5189 | F32 fov = atanf(tdim.mV[1]/distance)*2.f*RAD_TO_DEG; |
5124 | F32 aspect = tdim.mV[0]/tdim.mV[1]; //128.f/256.f; | 5190 | F32 aspect = tdim.mV[0]/tdim.mV[1]; //128.f/256.f; |
5125 | glh::matrix4f persp = gl_perspective(fov, aspect, 1.f, 256.f); | 5191 | glh::matrix4f persp = gl_perspective(fov, aspect, 1.f, 256.f); |
@@ -5197,7 +5263,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) | |||
5197 | LLGLDepthTest depth(GL_FALSE, GL_FALSE); | 5263 | LLGLDepthTest depth(GL_FALSE, GL_FALSE); |
5198 | 5264 | ||
5199 | gGL.color4f(1,1,1,1); | 5265 | gGL.color4f(1,1,1,1); |
5200 | gGL.color4ub(64,64,64,1); | 5266 | gGL.color4ub(64,64,64,255); |
5201 | gGL.begin(LLVertexBuffer::QUADS); | 5267 | gGL.begin(LLVertexBuffer::QUADS); |
5202 | gGL.vertex3fv((pos+left-up).mV); | 5268 | gGL.vertex3fv((pos+left-up).mV); |
5203 | gGL.vertex3fv((pos-left-up).mV); | 5269 | gGL.vertex3fv((pos-left-up).mV); |