aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/pipeline.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/pipeline.cpp295
1 files changed, 163 insertions, 132 deletions
diff --git a/linden/indra/newview/pipeline.cpp b/linden/indra/newview/pipeline.cpp
index e0c2de7..5f45e26 100644
--- a/linden/indra/newview/pipeline.cpp
+++ b/linden/indra/newview/pipeline.cpp
@@ -99,7 +99,7 @@
99#include "llwlparammanager.h" 99#include "llwlparammanager.h"
100#include "llwaterparammanager.h" 100#include "llwaterparammanager.h"
101#include "llspatialpartition.h" 101#include "llspatialpartition.h"
102 102#include "llmutelist.h"
103 103
104#ifdef _DEBUG 104#ifdef _DEBUG
105// Debug indices is disabled for now for debug performance - djs 4/24/02 105// Debug indices is disabled for now for debug performance - djs 4/24/02
@@ -374,7 +374,6 @@ void LLPipeline::cleanup()
374 mBloomImagep = NULL; 374 mBloomImagep = NULL;
375 mBloomImage2p = NULL; 375 mBloomImage2p = NULL;
376 mFaceSelectImagep = NULL; 376 mFaceSelectImagep = NULL;
377 mAlphaSizzleImagep = NULL;
378 377
379 mMovedBridge.clear(); 378 mMovedBridge.clear();
380 379
@@ -573,19 +572,16 @@ void LLPipeline::restoreGL()
573 LLShaderMgr::setShaders(); 572 LLShaderMgr::setShaders();
574 } 573 }
575 574
576 if (gWorldp) 575 for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin();
576 iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
577 { 577 {
578 for (LLWorld::region_list_t::iterator iter = gWorldp->getRegionList().begin(); 578 LLViewerRegion* region = *iter;
579 iter != gWorldp->getRegionList().end(); ++iter) 579 for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
580 { 580 {
581 LLViewerRegion* region = *iter; 581 LLSpatialPartition* part = region->getSpatialPartition(i);
582 for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++) 582 if (part)
583 { 583 {
584 LLSpatialPartition* part = region->getSpatialPartition(i); 584 part->restoreGL();
585 if (part)
586 {
587 part->restoreGL();
588 }
589 } 585 }
590 } 586 }
591 } 587 }
@@ -596,7 +592,7 @@ BOOL LLPipeline::canUseVertexShaders()
596{ 592{
597 if (!gGLManager.mHasVertexShader || 593 if (!gGLManager.mHasVertexShader ||
598 !gGLManager.mHasFragmentShader || 594 !gGLManager.mHasFragmentShader ||
599 !gFeatureManagerp->isFeatureAvailable("VertexShaderEnable") || 595 !LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable") ||
600 (assertInitialized() && mVertexShadersLoaded != 1) ) 596 (assertInitialized() && mVertexShadersLoaded != 1) )
601 { 597 {
602 return FALSE; 598 return FALSE;
@@ -725,20 +721,17 @@ void LLPipeline::dirtyPoolObjectTextures(const std::set<LLViewerImage*>& texture
725 } 721 }
726 } 722 }
727 723
728 if (gWorldp) 724 LLOctreeDirtyTexture dirty(textures);
725 for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin();
726 iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
729 { 727 {
730 LLOctreeDirtyTexture dirty(textures); 728 LLViewerRegion* region = *iter;
731 for (LLWorld::region_list_t::iterator iter = gWorldp->getRegionList().begin(); 729 for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
732 iter != gWorldp->getRegionList().end(); ++iter)
733 { 730 {
734 LLViewerRegion* region = *iter; 731 LLSpatialPartition* part = region->getSpatialPartition(i);
735 for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++) 732 if (part)
736 { 733 {
737 LLSpatialPartition* part = region->getSpatialPartition(i); 734 dirty.traverse(part->mOctree);
738 if (part)
739 {
740 dirty.traverse(part->mOctree);
741 }
742 } 735 }
743 } 736 }
744 } 737 }
@@ -1111,8 +1104,8 @@ void LLPipeline::updateMove()
1111 { 1104 {
1112 LLFastTimer ot(LLFastTimer::FTM_OCTREE_BALANCE); 1105 LLFastTimer ot(LLFastTimer::FTM_OCTREE_BALANCE);
1113 1106
1114 for (LLWorld::region_list_t::iterator iter = gWorldp->getRegionList().begin(); 1107 for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin();
1115 iter != gWorldp->getRegionList().end(); ++iter) 1108 iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
1116 { 1109 {
1117 LLViewerRegion* region = *iter; 1110 LLViewerRegion* region = *iter;
1118 for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++) 1111 for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
@@ -1189,8 +1182,8 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
1189 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 1182 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
1190 LLGLDepthTest depth(GL_TRUE, GL_FALSE); 1183 LLGLDepthTest depth(GL_TRUE, GL_FALSE);
1191 1184
1192 for (LLWorld::region_list_t::iterator iter = gWorldp->getRegionList().begin(); 1185 for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin();
1193 iter != gWorldp->getRegionList().end(); ++iter) 1186 iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
1194 { 1187 {
1195 LLViewerRegion* region = *iter; 1188 LLViewerRegion* region = *iter;
1196 if (water_clip != 0) 1189 if (water_clip != 0)
@@ -1252,6 +1245,10 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
1252 mScreen.flush(); 1245 mScreen.flush();
1253 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1246 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
1254 } 1247 }
1248 else if (LLPipeline::sUseOcclusion > 1)
1249 {
1250 glFlush();
1251 }
1255} 1252}
1256 1253
1257void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera) 1254void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera)
@@ -1339,6 +1336,7 @@ void LLPipeline::doOcclusion(LLCamera& camera)
1339 } 1336 }
1340 1337
1341 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); 1338 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
1339 glFlush();
1342} 1340}
1343 1341
1344BOOL LLPipeline::updateDrawableGeom(LLDrawable* drawablep, BOOL priority) 1342BOOL LLPipeline::updateDrawableGeom(LLDrawable* drawablep, BOOL priority)
@@ -1569,8 +1567,8 @@ void LLPipeline::shiftObjects(const LLVector3 &offset)
1569 } 1567 }
1570 mShiftList.resize(0); 1568 mShiftList.resize(0);
1571 1569
1572 for (LLWorld::region_list_t::iterator iter = gWorldp->getRegionList().begin(); 1570 for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin();
1573 iter != gWorldp->getRegionList().end(); ++iter) 1571 iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
1574 { 1572 {
1575 LLViewerRegion* region = *iter; 1573 LLViewerRegion* region = *iter;
1576 for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++) 1574 for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
@@ -1896,7 +1894,7 @@ void renderPhysicalBeacons(LLDrawable* drawablep)
1896 LLViewerObject *vobj = drawablep->getVObj(); 1894 LLViewerObject *vobj = drawablep->getVObj();
1897 if (vobj 1895 if (vobj
1898 && !vobj->isAvatar() 1896 && !vobj->isAvatar()
1899 && !vobj->getParent() 1897 //&& !vobj->getParent()
1900 && vobj->usePhysics()) 1898 && vobj->usePhysics())
1901 { 1899 {
1902 if (gPipeline.sRenderBeacons) 1900 if (gPipeline.sRenderBeacons)
@@ -2101,7 +2099,7 @@ void LLPipeline::postSort(LLCamera& camera)
2101 mSelectedFaces.clear(); 2099 mSelectedFaces.clear();
2102 2100
2103 // Draw face highlights for selected faces. 2101 // Draw face highlights for selected faces.
2104 if (gSelectMgr->getTEMode()) 2102 if (LLSelectMgr::getInstance()->getTEMode())
2105 { 2103 {
2106 struct f : public LLSelectedTEFunctor 2104 struct f : public LLSelectedTEFunctor
2107 { 2105 {
@@ -2114,7 +2112,7 @@ void LLPipeline::postSort(LLCamera& camera)
2114 return true; 2112 return true;
2115 } 2113 }
2116 } func; 2114 } func;
2117 gSelectMgr->getSelection()->applyToTEs(&func); 2115 LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func);
2118 } 2116 }
2119} 2117}
2120 2118
@@ -2124,8 +2122,6 @@ void render_hud_elements()
2124 LLFastTimer t(LLFastTimer::FTM_RENDER_UI); 2122 LLFastTimer t(LLFastTimer::FTM_RENDER_UI);
2125 gPipeline.disableLights(); 2123 gPipeline.disableLights();
2126 2124
2127 gPipeline.renderDebug();
2128
2129 LLGLDisable fog(GL_FOG); 2125 LLGLDisable fog(GL_FOG);
2130 LLGLSUIDefault gls_ui; 2126 LLGLSUIDefault gls_ui;
2131 2127
@@ -2143,15 +2139,9 @@ void render_hud_elements()
2143 LLTracker::render3D(); 2139 LLTracker::render3D();
2144 2140
2145 // Show the property lines 2141 // Show the property lines
2146 if (gWorldp) 2142 LLWorld::getInstance()->renderPropertyLines();
2147 { 2143 LLViewerParcelMgr::getInstance()->render();
2148 gWorldp->renderPropertyLines(); 2144 LLViewerParcelMgr::getInstance()->renderParcelCollision();
2149 }
2150 if (gParcelMgr)
2151 {
2152 gParcelMgr->render();
2153 gParcelMgr->renderParcelCollision();
2154 }
2155 2145
2156 // Render debugging beacons. 2146 // Render debugging beacons.
2157 gObjectList.renderObjectBeacons(); 2147 gObjectList.renderObjectBeacons();
@@ -2161,7 +2151,7 @@ void render_hud_elements()
2161 else if (gForceRenderLandFence) 2151 else if (gForceRenderLandFence)
2162 { 2152 {
2163 // This is only set when not rendering the UI, for parcel snapshots 2153 // This is only set when not rendering the UI, for parcel snapshots
2164 gParcelMgr->render(); 2154 LLViewerParcelMgr::getInstance()->render();
2165 } 2155 }
2166 else if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) 2156 else if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD))
2167 { 2157 {
@@ -2257,11 +2247,6 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
2257 } 2247 }
2258 } 2248 }
2259 2249
2260 if (!mAlphaSizzleImagep)
2261 {
2262 mAlphaSizzleImagep = gImageList.getImage(LLUUID(gViewerArt.getString("alpha_sizzle.tga")), MIPMAP_TRUE, TRUE);
2263 }
2264
2265 /////////////////////////////////////////// 2250 ///////////////////////////////////////////
2266 // 2251 //
2267 // Sync and verify GL state 2252 // Sync and verify GL state
@@ -2289,15 +2274,6 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
2289 2274
2290 LLVertexBuffer::startRender(); 2275 LLVertexBuffer::startRender();
2291 2276
2292 for (pool_set_t::iterator iter = mPools.begin(); iter != mPools.end(); ++iter)
2293 {
2294 LLDrawPool *poolp = *iter;
2295 if (hasRenderType(poolp->getType()))
2296 {
2297 poolp->prerender();
2298 }
2299 }
2300
2301 //by bao 2277 //by bao
2302 //fake vertex buffer updating 2278 //fake vertex buffer updating
2303 //to guaranttee at least updating one VBO buffer every frame 2279 //to guaranttee at least updating one VBO buffer every frame
@@ -2314,7 +2290,8 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
2314 glMatrixMode(GL_MODELVIEW); 2290 glMatrixMode(GL_MODELVIEW);
2315 2291
2316 LLGLSPipeline gls_pipeline; 2292 LLGLSPipeline gls_pipeline;
2317 2293 LLGLEnable multisample(GL_MULTISAMPLE_ARB);
2294
2318 LLGLState gls_color_material(GL_COLOR_MATERIAL, mLightingDetail < 2); 2295 LLGLState gls_color_material(GL_COLOR_MATERIAL, mLightingDetail < 2);
2319 2296
2320 // Toggle backface culling for debugging 2297 // Toggle backface culling for debugging
@@ -2346,8 +2323,22 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
2346 { 2323 {
2347 gObjectList.renderObjectsForSelect(camera); 2324 gObjectList.renderObjectsForSelect(camera);
2348 } 2325 }
2326 else if (gSavedSettings.getBOOL("RenderDeferred"))
2327 {
2328 renderGeomDeferred();
2329 }
2349 else 2330 else
2350 { 2331 {
2332 for (pool_set_t::iterator iter = mPools.begin(); iter != mPools.end(); ++iter)
2333 {
2334 LLDrawPool *poolp = *iter;
2335 if (hasRenderType(poolp->getType()))
2336 {
2337 poolp->prerender();
2338 }
2339 }
2340
2341
2351 LLFastTimer t(LLFastTimer::FTM_POOLS); 2342 LLFastTimer t(LLFastTimer::FTM_POOLS);
2352 calcNearbyLights(camera); 2343 calcNearbyLights(camera);
2353 setupHWLights(NULL); 2344 setupHWLights(NULL);
@@ -2456,7 +2447,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
2456 // have touch-handlers. 2447 // have touch-handlers.
2457 mHighlightFaces.clear(); 2448 mHighlightFaces.clear();
2458 2449
2459 render_hud_elements(); 2450 renderDebug();
2460 2451
2461 LLVertexBuffer::stopRender(); 2452 LLVertexBuffer::stopRender();
2462 LLVertexBuffer::unbind(); 2453 LLVertexBuffer::unbind();
@@ -2479,6 +2470,19 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
2479#endif 2470#endif
2480} 2471}
2481 2472
2473void LLPipeline::renderGeomDeferred()
2474{
2475 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
2476 glEnableClientState(GL_NORMAL_ARRAY);
2477 glEnableClientState(GL_COLOR_ARRAY);
2478 gDeferredDiffuseProgram.bind();
2479 gPipeline.renderObjects(LLRenderPass::PASS_SIMPLE, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_NORMAL, TRUE);
2480 gDeferredDiffuseProgram.unbind();
2481 glDisableClientState(GL_COLOR_ARRAY);
2482 glDisableClientState(GL_NORMAL_ARRAY);
2483 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
2484}
2485
2482void LLPipeline::addTrianglesDrawn(S32 count) 2486void LLPipeline::addTrianglesDrawn(S32 count)
2483{ 2487{
2484 assertInitialized(); 2488 assertInitialized();
@@ -2512,8 +2516,8 @@ void LLPipeline::renderDebug()
2512 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); 2516 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
2513 2517
2514 // Debug stuff. 2518 // Debug stuff.
2515 for (LLWorld::region_list_t::iterator iter = gWorldp->getRegionList().begin(); 2519 for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin();
2516 iter != gWorldp->getRegionList().end(); ++iter) 2520 iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
2517 { 2521 {
2518 LLViewerRegion* region = *iter; 2522 LLViewerRegion* region = *iter;
2519 for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++) 2523 for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
@@ -2585,7 +2589,7 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects)
2585 2589
2586 for (std::set<LLViewerObject*>::iterator iter = objects.begin(); iter != objects.end(); ++iter) 2590 for (std::set<LLViewerObject*>::iterator iter = objects.begin(); iter != objects.end(); ++iter)
2587 { 2591 {
2588 stateSort((*iter)->mDrawable, *gCamera); 2592 stateSort((*iter)->mDrawable, *LLViewerCamera::getInstance());
2589 } 2593 }
2590 2594
2591 LLMemType mt(LLMemType::MTYPE_PIPELINE); 2595 LLMemType mt(LLMemType::MTYPE_PIPELINE);
@@ -3055,7 +3059,7 @@ void LLPipeline::setupAvatarLights(BOOL for_edit)
3055 { 3059 {
3056 LLColor4 diffuse(0.8f, 0.8f, 0.8f, 0.f); 3060 LLColor4 diffuse(0.8f, 0.8f, 0.8f, 0.f);
3057 LLVector4 light_pos_cam(-8.f, 0.25f, 10.f, 0.f); // w==0 => directional light 3061 LLVector4 light_pos_cam(-8.f, 0.25f, 10.f, 0.f); // w==0 => directional light
3058 LLMatrix4 camera_mat = gCamera->getModelview(); 3062 LLMatrix4 camera_mat = LLViewerCamera::getInstance()->getModelview();
3059 LLMatrix4 camera_rot(camera_mat.getMat3()); 3063 LLMatrix4 camera_rot(camera_mat.getMat3());
3060 camera_rot.invert(); 3064 camera_rot.invert();
3061 LLVector4 light_pos = light_pos_cam * camera_rot; 3065 LLVector4 light_pos = light_pos_cam * camera_rot;
@@ -3161,7 +3165,7 @@ void LLPipeline::calcNearbyLights(LLCamera& camera)
3161 // begin() == the closest light and rbegin() == the farthest light 3165 // begin() == the closest light and rbegin() == the farthest light
3162 const S32 MAX_LOCAL_LIGHTS = 6; 3166 const S32 MAX_LOCAL_LIGHTS = 6;
3163// LLVector3 cam_pos = gAgent.getCameraPositionAgent(); 3167// LLVector3 cam_pos = gAgent.getCameraPositionAgent();
3164 LLVector3 cam_pos = LLViewerJoystick::sOverrideCamera ? 3168 LLVector3 cam_pos = LLViewerJoystick::getInstance()->getOverrideCamera() ?
3165 camera.getOrigin() : 3169 camera.getOrigin() :
3166 gAgent.getPositionAgent(); 3170 gAgent.getPositionAgent();
3167 3171
@@ -3397,7 +3401,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
3397 LLColor4 light_color = LLColor4::white; 3401 LLColor4 light_color = LLColor4::white;
3398 light_color.mV[3] = 0.0f; 3402 light_color.mV[3] = 0.0f;
3399 3403
3400 LLVector3 light_pos(gCamera->getOrigin()); 3404 LLVector3 light_pos(LLViewerCamera::getInstance()->getOrigin());
3401 LLVector4 light_pos_gl(light_pos, 1.0f); 3405 LLVector4 light_pos_gl(light_pos, 1.0f);
3402 3406
3403 F32 light_radius = 16.f; 3407 F32 light_radius = 16.f;
@@ -3958,8 +3962,8 @@ LLViewerObject* LLPipeline::pickObject(const LLVector3 &start, const LLVector3 &
3958{ 3962{
3959 LLDrawable* drawable = NULL; 3963 LLDrawable* drawable = NULL;
3960 3964
3961 for (LLWorld::region_list_t::iterator iter = gWorldp->getRegionList().begin(); 3965 for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin();
3962 iter != gWorldp->getRegionList().end(); ++iter) 3966 iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
3963 { 3967 {
3964 LLViewerRegion* region = *iter; 3968 LLViewerRegion* region = *iter;
3965 LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_VOLUME); 3969 LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_VOLUME);
@@ -4013,19 +4017,16 @@ void LLPipeline::resetVertexBuffers()
4013{ 4017{
4014 sRenderBump = gSavedSettings.getBOOL("RenderObjectBump"); 4018 sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");
4015 4019
4016 if (gWorldp) 4020 for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin();
4021 iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
4017 { 4022 {
4018 for (LLWorld::region_list_t::iterator iter = gWorldp->getRegionList().begin(); 4023 LLViewerRegion* region = *iter;
4019 iter != gWorldp->getRegionList().end(); ++iter) 4024 for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
4020 { 4025 {
4021 LLViewerRegion* region = *iter; 4026 LLSpatialPartition* part = region->getSpatialPartition(i);
4022 for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++) 4027 if (part)
4023 { 4028 {
4024 LLSpatialPartition* part = region->getSpatialPartition(i); 4029 part->resetVertexBuffers();
4025 if (part)
4026 {
4027 part->resetVertexBuffers();
4028 }
4029 } 4030 }
4030 } 4031 }
4031 } 4032 }
@@ -4217,7 +4218,7 @@ void LLPipeline::generateReflectionMap(LLCubeMap* cube_map, LLCamera& cube_cam)
4217 glTranslatef(-origin.mV[0], -origin.mV[1], -origin.mV[2]); 4218 glTranslatef(-origin.mV[0], -origin.mV[1], -origin.mV[2]);
4218 cube_cam.setOrigin(origin); 4219 cube_cam.setOrigin(origin);
4219 LLViewerCamera::updateFrustumPlanes(cube_cam); 4220 LLViewerCamera::updateFrustumPlanes(cube_cam);
4220 cube_cam.setOrigin(gCamera->getOrigin()); 4221 cube_cam.setOrigin(LLViewerCamera::getInstance()->getOrigin());
4221 static LLCullResult result; 4222 static LLCullResult result;
4222 gPipeline.updateCull(cube_cam, result); 4223 gPipeline.updateCull(cube_cam, result);
4223 gPipeline.stateSort(cube_cam, result); 4224 gPipeline.stateSort(cube_cam, result);
@@ -4814,6 +4815,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
4814 4815
4815 mScreen.bindTexture(); 4816 mScreen.bindTexture();
4816 4817
4818 LLGLEnable multisample(GL_MULTISAMPLE_ARB);
4817 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 4819 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
4818 4820
4819 glDisable(GL_TEXTURE_RECTANGLE_ARB); 4821 glDisable(GL_TEXTURE_RECTANGLE_ARB);
@@ -4840,8 +4842,8 @@ void LLPipeline::renderBloom(BOOL for_snapshot)
4840 4842
4841void LLPipeline::processImagery(LLCamera& camera) 4843void LLPipeline::processImagery(LLCamera& camera)
4842{ 4844{
4843 for (LLWorld::region_list_t::iterator iter = gWorldp->getRegionList().begin(); 4845 for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->getRegionList().begin();
4844 iter != gWorldp->getRegionList().end(); ++iter) 4846 iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
4845 { 4847 {
4846 LLViewerRegion* region = *iter; 4848 LLViewerRegion* region = *iter;
4847 LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_VOLUME); 4849 LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_VOLUME);
@@ -4886,7 +4888,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
4886 F32 pd; 4888 F32 pd;
4887 4889
4888 S32 water_clip = 0; 4890 S32 water_clip = 0;
4889 if (!gCamera->cameraUnderWater()) 4891 if (!LLViewerCamera::getInstance()->cameraUnderWater())
4890 { //camera is above water, clip plane points up 4892 { //camera is above water, clip plane points up
4891 pnorm.setVec(0,0,1); 4893 pnorm.setVec(0,0,1);
4892 pd = -height; 4894 pd = -height;
@@ -4903,7 +4905,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
4903 4905
4904 4906
4905 4907
4906 if (!gCamera->cameraUnderWater()) 4908 if (!LLViewerCamera::getInstance()->cameraUnderWater())
4907 { //generate planar reflection map 4909 { //generate planar reflection map
4908 LLViewerImage::unbindTexture(0, GL_TEXTURE_2D); 4910 LLViewerImage::unbindTexture(0, GL_TEXTURE_2D);
4909 glClearColor(0,0,0,0); 4911 glClearColor(0,0,0,0);
@@ -4948,13 +4950,12 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
4948 mRenderTypeMask = tmp; 4950 mRenderTypeMask = tmp;
4949 } 4951 }
4950 4952
4951 if (LLDrawPoolWater::sNeedsReflectionUpdate) 4953 if (LLDrawPoolWater::sNeedsDistortionUpdate)
4952 { 4954 {
4953 mRenderTypeMask &= ~((1<<LLPipeline::RENDER_TYPE_WATER) | 4955 mRenderTypeMask &= ~((1<<LLPipeline::RENDER_TYPE_WATER) |
4954 (1<<LLPipeline::RENDER_TYPE_GROUND) | 4956 (1<<LLPipeline::RENDER_TYPE_GROUND) |
4955 (1<<LLPipeline::RENDER_TYPE_SKY) | 4957 (1<<LLPipeline::RENDER_TYPE_SKY) |
4956 (1<<LLPipeline::RENDER_TYPE_CLOUDS) | 4958 (1<<LLPipeline::RENDER_TYPE_CLOUDS));
4957 (1<<LLPipeline::RENDER_TYPE_WL_SKY));
4958 4959
4959 if (gSavedSettings.getBOOL("RenderWaterReflections")) 4960 if (gSavedSettings.getBOOL("RenderWaterReflections"))
4960 { //mask out selected geometry based on reflection detail 4961 { //mask out selected geometry based on reflection detail
@@ -5000,7 +5001,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
5000 (1<<LLPipeline::RENDER_TYPE_GROUND)); 5001 (1<<LLPipeline::RENDER_TYPE_GROUND));
5001 stop_glerror(); 5002 stop_glerror();
5002 5003
5003 LLPipeline::sUnderWaterRender = gCamera->cameraUnderWater() ? FALSE : TRUE; 5004 LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? FALSE : TRUE;
5004 5005
5005 if (LLPipeline::sUnderWaterRender) 5006 if (LLPipeline::sUnderWaterRender)
5006 { 5007 {
@@ -5034,7 +5035,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
5034 LLPipeline::sUnderWaterRender = FALSE; 5035 LLPipeline::sUnderWaterRender = FALSE;
5035 mWaterDis.flush(); 5036 mWaterDis.flush();
5036 } 5037 }
5037 last_update = LLDrawPoolWater::sNeedsReflectionUpdate; 5038 last_update = LLDrawPoolWater::sNeedsReflectionUpdate && LLDrawPoolWater::sNeedsDistortionUpdate;
5038 5039
5039 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 5040 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
5040 LLPipeline::sReflectionRender = FALSE; 5041 LLPipeline::sReflectionRender = FALSE;
@@ -5048,14 +5049,15 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
5048 gViewerWindow->setupViewport(); 5049 gViewerWindow->setupViewport();
5049 mRenderTypeMask = type_mask; 5050 mRenderTypeMask = type_mask;
5050 LLDrawPoolWater::sNeedsReflectionUpdate = FALSE; 5051 LLDrawPoolWater::sNeedsReflectionUpdate = FALSE;
5051 gCamera->setUserClipPlane(LLPlane(-pnorm, -pd)); 5052 LLDrawPoolWater::sNeedsDistortionUpdate = FALSE;
5053 LLViewerCamera::getInstance()->setUserClipPlane(LLPlane(-pnorm, -pd));
5052 LLPipeline::sUseOcclusion = occlusion; 5054 LLPipeline::sUseOcclusion = occlusion;
5053 } 5055 }
5054} 5056}
5055 5057
5056LLCubeMap* LLPipeline::findReflectionMap(const LLVector3& location) 5058LLCubeMap* LLPipeline::findReflectionMap(const LLVector3& location)
5057{ 5059{
5058 LLViewerRegion* region = gWorldp->getRegionFromPosAgent(location); 5060 LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosAgent(location);
5059 if (region) 5061 if (region)
5060 { 5062 {
5061 LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_VOLUME); 5063 LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_VOLUME);
@@ -5075,10 +5077,6 @@ LLCubeMap* LLPipeline::findReflectionMap(const LLVector3& location)
5075 5077
5076void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL texture) 5078void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL texture)
5077{ 5079{
5078#if !LL_RELEASE_FOR_DOWNLOAD
5079 LLGLState::checkClientArrays(mask);
5080#endif
5081
5082 for (LLCullResult::sg_list_t::iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i) 5080 for (LLCullResult::sg_list_t::iterator i = sCull->beginVisibleGroups(); i != sCull->endVisibleGroups(); ++i)
5083 { 5081 {
5084 LLSpatialGroup* group = *i; 5082 LLSpatialGroup* group = *i;
@@ -5105,22 +5103,23 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
5105 5103
5106 assertInitialized(); 5104 assertInitialized();
5107 5105
5108 if (!avatar->mImpostor.isComplete()) 5106 U32 mask;
5107 BOOL muted = LLMuteList::getInstance()->isMuted(avatar->getID());
5108
5109 if (muted)
5109 { 5110 {
5110 avatar->mImpostor.allocate(128,256,GL_RGBA,TRUE); 5111 mask = 1 << LLPipeline::RENDER_TYPE_AVATAR;
5111 avatar->mImpostor.bindTexture();
5112 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
5113 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
5114 LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
5115 } 5112 }
5116 5113 else
5117 U32 mask = (1<<LLPipeline::RENDER_TYPE_VOLUME) | 5114 {
5115 mask = (1<<LLPipeline::RENDER_TYPE_VOLUME) |
5118 (1<<LLPipeline::RENDER_TYPE_AVATAR) | 5116 (1<<LLPipeline::RENDER_TYPE_AVATAR) |
5119 (1<<LLPipeline::RENDER_TYPE_BUMP) | 5117 (1<<LLPipeline::RENDER_TYPE_BUMP) |
5120 (1<<LLPipeline::RENDER_TYPE_GRASS) | 5118 (1<<LLPipeline::RENDER_TYPE_GRASS) |
5121 (1<<LLPipeline::RENDER_TYPE_SIMPLE) | 5119 (1<<LLPipeline::RENDER_TYPE_SIMPLE) |
5122 (1<<LLPipeline::RENDER_TYPE_ALPHA) | 5120 (1<<LLPipeline::RENDER_TYPE_ALPHA) |
5123 (1<<LLPipeline::RENDER_TYPE_INVISIBLE); 5121 (1<<LLPipeline::RENDER_TYPE_INVISIBLE);
5122 }
5124 5123
5125 mask = mask & gPipeline.getRenderTypeMask(); 5124 mask = mask & gPipeline.getRenderTypeMask();
5126 U32 saved_mask = gPipeline.mRenderTypeMask; 5125 U32 saved_mask = gPipeline.mRenderTypeMask;
@@ -5131,7 +5130,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
5131 sReflectionRender = TRUE; 5130 sReflectionRender = TRUE;
5132 sImpostorRender = TRUE; 5131 sImpostorRender = TRUE;
5133 5132
5134 markVisible(avatar->mDrawable, *gCamera); 5133 markVisible(avatar->mDrawable, *LLViewerCamera::getInstance());
5135 LLVOAvatar::sUseImpostors = FALSE; 5134 LLVOAvatar::sUseImpostors = FALSE;
5136 5135
5137 LLVOAvatar::attachment_map_t::iterator iter; 5136 LLVOAvatar::attachment_map_t::iterator iter;
@@ -5142,36 +5141,18 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
5142 LLViewerObject* object = iter->second->getObject(); 5141 LLViewerObject* object = iter->second->getObject();
5143 if (object) 5142 if (object)
5144 { 5143 {
5145 markVisible(object->mDrawable->getSpatialBridge(), *gCamera); 5144 markVisible(object->mDrawable->getSpatialBridge(), *LLViewerCamera::getInstance());
5146 } 5145 }
5147 } 5146 }
5148 5147
5149 stateSort(*gCamera, result); 5148 stateSort(*LLViewerCamera::getInstance(), result);
5150 5149
5151 glClearColor(0.0f,0.0f,0.0f,0.0f);
5152 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
5153 glStencilMask(0xFFFFFFFF);
5154 glClearStencil(0);
5155
5156 {
5157 LLGLEnable scissor(GL_SCISSOR_TEST);
5158 glScissor(0, 0, 128, 256);
5159 avatar->mImpostor.bindTarget();
5160 avatar->mImpostor.getViewport(gGLViewport);
5161 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
5162 }
5163
5164 LLGLEnable stencil(GL_STENCIL_TEST);
5165
5166 glStencilFunc(GL_ALWAYS, 1, 0xFFFFFFFF);
5167 glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
5168
5169 const LLVector3* ext = avatar->mDrawable->getSpatialExtents(); 5150 const LLVector3* ext = avatar->mDrawable->getSpatialExtents();
5170 LLVector3 pos(avatar->getRenderPosition()+avatar->getImpostorOffset()); 5151 LLVector3 pos(avatar->getRenderPosition()+avatar->getImpostorOffset());
5171 5152
5172 LLCamera camera = *gCamera; 5153 LLCamera camera = *LLViewerCamera::getInstance();
5173 5154
5174 camera.lookAt(gCamera->getOrigin(), pos, gCamera->getUpAxis()); 5155 camera.lookAt(LLViewerCamera::getInstance()->getOrigin(), pos, LLViewerCamera::getInstance()->getUpAxis());
5175 5156
5176 LLVector2 tdim; 5157 LLVector2 tdim;
5177 5158
@@ -5190,9 +5171,13 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
5190 5171
5191 glMatrixMode(GL_PROJECTION); 5172 glMatrixMode(GL_PROJECTION);
5192 glPushMatrix(); 5173 glPushMatrix();
5193 glh::matrix4f ortho = gl_ortho(-tdim.mV[0], tdim.mV[0], -tdim.mV[1], tdim.mV[1], 1.0, 256.0); 5174 //glh::matrix4f ortho = gl_ortho(-tdim.mV[0], tdim.mV[0], -tdim.mV[1], tdim.mV[1], 1.0, 256.0);
5194 glh_set_current_projection(ortho); 5175 F32 distance = (pos-camera.getOrigin()).magVec();
5195 glLoadMatrixf(ortho.m); 5176 F32 fov = atanf(tdim.mV[1]/distance)*2.f*RAD_TO_DEG;
5177 F32 aspect = tdim.mV[0]/tdim.mV[1]; //128.f/256.f;
5178 glh::matrix4f persp = gl_perspective(fov, aspect, 1.f, 256.f);
5179 glh_set_current_projection(persp);
5180 glLoadMatrixf(persp.m);
5196 5181
5197 glMatrixMode(GL_MODELVIEW); 5182 glMatrixMode(GL_MODELVIEW);
5198 glPushMatrix(); 5183 glPushMatrix();
@@ -5204,24 +5189,68 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
5204 glLoadMatrixf(mat.m); 5189 glLoadMatrixf(mat.m);
5205 glh_set_current_modelview(mat); 5190 glh_set_current_modelview(mat);
5206 5191
5192 glClearColor(0.0f,0.0f,0.0f,0.0f);
5193 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
5194 glStencilMask(0xFFFFFFFF);
5195 glClearStencil(0);
5196
5197 // get the number of pixels per angle
5198 F32 pa = gViewerWindow->getWindowDisplayHeight() / (RAD_TO_DEG * LLViewerCamera::getInstance()->getView());
5199
5200 //get resolution based on angle width and height of impostor (double desired resolution to prevent aliasing)
5201 U32 resY = llmin(nhpo2((U32) (fov*pa)), (U32) 512);
5202 U32 resX = llmin(nhpo2((U32) (atanf(tdim.mV[0]/distance)*2.f*RAD_TO_DEG*pa)), (U32) 512);
5203
5204 if (!avatar->mImpostor.isComplete() || resX != avatar->mImpostor.getWidth() ||
5205 resY != avatar->mImpostor.getHeight())
5206 {
5207 avatar->mImpostor.allocate(resX,resY,GL_RGBA,TRUE);
5208 avatar->mImpostor.bindTexture();
5209 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
5210 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
5211 LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
5212 }
5213
5214 {
5215 LLGLEnable scissor(GL_SCISSOR_TEST);
5216 glScissor(0, 0, resX, resY);
5217 avatar->mImpostor.bindTarget();
5218 avatar->mImpostor.getViewport(gGLViewport);
5219 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
5220 }
5221
5222 LLGLEnable stencil(GL_STENCIL_TEST);
5223
5224 glStencilFunc(GL_ALWAYS, 1, 0xFFFFFFFF);
5225 glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
5226
5207 renderGeom(camera); 5227 renderGeom(camera);
5208 5228
5209 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); 5229 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
5210 glStencilFunc(GL_EQUAL, 1, 0xFFFFFF); 5230 glStencilFunc(GL_EQUAL, 1, 0xFFFFFF);
5211 5231
5212 { 5232 {
5213 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
5214 LLVector3 left = camera.getLeftAxis()*tdim.mV[0]*2.f; 5233 LLVector3 left = camera.getLeftAxis()*tdim.mV[0]*2.f;
5215 LLVector3 up = camera.getUpAxis()*tdim.mV[1]*2.f; 5234 LLVector3 up = camera.getUpAxis()*tdim.mV[1]*2.f;
5216 5235
5217 LLGLEnable blend(GL_BLEND); 5236 LLGLEnable blend(muted ? 0 : GL_BLEND);
5237
5238 if (muted)
5239 {
5240 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
5241 }
5242 else
5243 {
5244 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
5245 }
5246
5218 gGL.blendFunc(GL_ONE, GL_ONE); 5247 gGL.blendFunc(GL_ONE, GL_ONE);
5219 LLImageGL::unbindTexture(0, GL_TEXTURE_2D); 5248 LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
5220 5249
5221 LLGLDepthTest depth(GL_FALSE, GL_FALSE); 5250 LLGLDepthTest depth(GL_FALSE, GL_FALSE);
5222 5251
5223 gGL.start(); 5252 gGL.start();
5224 gGL.color4ub(0,0,0,1); 5253 gGL.color4ub(64,64,64,1);
5225 gGL.begin(GL_QUADS); 5254 gGL.begin(GL_QUADS);
5226 gGL.vertex3fv((pos+left-up).mV); 5255 gGL.vertex3fv((pos+left-up).mV);
5227 gGL.vertex3fv((pos-left-up).mV); 5256 gGL.vertex3fv((pos-left-up).mV);
@@ -5230,9 +5259,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
5230 gGL.end(); 5259 gGL.end();
5231 gGL.stop(); 5260 gGL.stop();
5232 5261
5262
5233 gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 5263 gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
5234 } 5264 }
5235 5265
5266
5236 avatar->mImpostor.flush(); 5267 avatar->mImpostor.flush();
5237 5268
5238 avatar->setImpostorDim(tdim); 5269 avatar->setImpostorDim(tdim);