diff options
author | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
commit | cd17687f01420952712a500107e0f93e7ab8d5f8 (patch) | |
tree | ce48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/lldrawpool.cpp | |
parent | Second Life viewer sources 1.19.0.5 (diff) | |
download | meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2 meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz |
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/lldrawpool.cpp')
-rw-r--r-- | linden/indra/newview/lldrawpool.cpp | 240 |
1 files changed, 41 insertions, 199 deletions
diff --git a/linden/indra/newview/lldrawpool.cpp b/linden/indra/newview/lldrawpool.cpp index a3bdfdc..409439a 100644 --- a/linden/indra/newview/lldrawpool.cpp +++ b/linden/indra/newview/lldrawpool.cpp | |||
@@ -32,7 +32,7 @@ | |||
32 | #include "llviewerprecompiledheaders.h" | 32 | #include "llviewerprecompiledheaders.h" |
33 | 33 | ||
34 | #include "lldrawpool.h" | 34 | #include "lldrawpool.h" |
35 | 35 | #include "llglimmediate.h" | |
36 | #include "llfasttimer.h" | 36 | #include "llfasttimer.h" |
37 | #include "llviewercontrol.h" | 37 | #include "llviewercontrol.h" |
38 | 38 | ||
@@ -44,17 +44,18 @@ | |||
44 | #include "lldrawpoolground.h" | 44 | #include "lldrawpoolground.h" |
45 | #include "lldrawpoolsimple.h" | 45 | #include "lldrawpoolsimple.h" |
46 | #include "lldrawpoolsky.h" | 46 | #include "lldrawpoolsky.h" |
47 | #include "lldrawpoolstars.h" | ||
48 | #include "lldrawpooltree.h" | 47 | #include "lldrawpooltree.h" |
49 | #include "lldrawpoolterrain.h" | 48 | #include "lldrawpoolterrain.h" |
50 | #include "lldrawpoolwater.h" | 49 | #include "lldrawpoolwater.h" |
51 | #include "llface.h" | 50 | #include "llface.h" |
52 | #include "llviewerobjectlist.h" // For debug listing. | 51 | #include "llviewerobjectlist.h" // For debug listing. |
53 | #include "pipeline.h" | 52 | #include "pipeline.h" |
53 | #include "llspatialpartition.h" | ||
54 | #include "llviewercamera.h" | ||
55 | #include "lldrawpoolwlsky.h" | ||
54 | 56 | ||
55 | S32 LLDrawPool::sNumDrawPools = 0; | 57 | S32 LLDrawPool::sNumDrawPools = 0; |
56 | 58 | ||
57 | |||
58 | //============================= | 59 | //============================= |
59 | // Draw Pool Implementation | 60 | // Draw Pool Implementation |
60 | //============================= | 61 | //============================= |
@@ -66,15 +67,15 @@ LLDrawPool *LLDrawPool::createPool(const U32 type, LLViewerImage *tex0) | |||
66 | case POOL_SIMPLE: | 67 | case POOL_SIMPLE: |
67 | poolp = new LLDrawPoolSimple(); | 68 | poolp = new LLDrawPoolSimple(); |
68 | break; | 69 | break; |
70 | case POOL_INVISIBLE: | ||
71 | poolp = new LLDrawPoolInvisible(); | ||
72 | break; | ||
69 | case POOL_GLOW: | 73 | case POOL_GLOW: |
70 | poolp = new LLDrawPoolGlow(); | 74 | poolp = new LLDrawPoolGlow(); |
71 | break; | 75 | break; |
72 | case POOL_ALPHA: | 76 | case POOL_ALPHA: |
73 | poolp = new LLDrawPoolAlpha(); | 77 | poolp = new LLDrawPoolAlpha(); |
74 | break; | 78 | break; |
75 | case POOL_ALPHA_POST_WATER: | ||
76 | poolp = new LLDrawPoolAlphaPostWater(); | ||
77 | break; | ||
78 | case POOL_AVATAR: | 79 | case POOL_AVATAR: |
79 | poolp = new LLDrawPoolAvatar(); | 80 | poolp = new LLDrawPoolAvatar(); |
80 | break; | 81 | break; |
@@ -87,9 +88,6 @@ LLDrawPool *LLDrawPool::createPool(const U32 type, LLViewerImage *tex0) | |||
87 | case POOL_SKY: | 88 | case POOL_SKY: |
88 | poolp = new LLDrawPoolSky(); | 89 | poolp = new LLDrawPoolSky(); |
89 | break; | 90 | break; |
90 | case POOL_STARS: | ||
91 | poolp = new LLDrawPoolStars(); | ||
92 | break; | ||
93 | case POOL_WATER: | 91 | case POOL_WATER: |
94 | poolp = new LLDrawPoolWater(); | 92 | poolp = new LLDrawPoolWater(); |
95 | break; | 93 | break; |
@@ -99,6 +97,9 @@ LLDrawPool *LLDrawPool::createPool(const U32 type, LLViewerImage *tex0) | |||
99 | case POOL_BUMP: | 97 | case POOL_BUMP: |
100 | poolp = new LLDrawPoolBump(); | 98 | poolp = new LLDrawPoolBump(); |
101 | break; | 99 | break; |
100 | case POOL_WL_SKY: | ||
101 | poolp = new LLDrawPoolWLSky(); | ||
102 | break; | ||
102 | default: | 103 | default: |
103 | llerrs << "Unknown draw pool type!" << llendl; | 104 | llerrs << "Unknown draw pool type!" << llendl; |
104 | return NULL; | 105 | return NULL; |
@@ -196,7 +197,6 @@ S32 LLFacePool::drawLoop(face_array_t& face_list) | |||
196 | iter != face_list.end(); iter++) | 197 | iter != face_list.end(); iter++) |
197 | { | 198 | { |
198 | LLFace *facep = *iter; | 199 | LLFace *facep = *iter; |
199 | //facep->enableLights(); | ||
200 | res += facep->renderIndexed(); | 200 | res += facep->renderIndexed(); |
201 | } | 201 | } |
202 | } | 202 | } |
@@ -214,7 +214,6 @@ S32 LLFacePool::drawLoopSetTex(face_array_t& face_list, S32 stage) | |||
214 | { | 214 | { |
215 | LLFace *facep = *iter; | 215 | LLFace *facep = *iter; |
216 | facep->bindTexture(stage); | 216 | facep->bindTexture(stage); |
217 | facep->enableLights(); | ||
218 | res += facep->renderIndexed(); | 217 | res += facep->renderIndexed(); |
219 | } | 218 | } |
220 | } | 219 | } |
@@ -236,92 +235,6 @@ void LLFacePool::renderFaceSelected(LLFace *facep, | |||
236 | { | 235 | { |
237 | } | 236 | } |
238 | 237 | ||
239 | void LLFacePool::renderVisibility() | ||
240 | { | ||
241 | if (mDrawFace.empty()) | ||
242 | { | ||
243 | return; | ||
244 | } | ||
245 | |||
246 | // SJB: Note: This may be broken now. If you need it, fix it :) | ||
247 | |||
248 | glLineWidth(1.0); | ||
249 | glMatrixMode(GL_PROJECTION); | ||
250 | glPushMatrix(); | ||
251 | glLoadIdentity(); | ||
252 | glMatrixMode(GL_MODELVIEW); | ||
253 | glPushMatrix(); | ||
254 | glLoadIdentity(); | ||
255 | |||
256 | glTranslatef(-0.4f,-0.3f,0); | ||
257 | |||
258 | float table[7][3] = { | ||
259 | { 1,0,0 }, | ||
260 | { 0,1,0 }, | ||
261 | { 1,1,0 }, | ||
262 | { 0,0,1 }, | ||
263 | { 1,0,1 }, | ||
264 | { 0,1,1 }, | ||
265 | { 1,1,1 } | ||
266 | }; | ||
267 | |||
268 | glColor4f(0,0,0,0.5); | ||
269 | glBegin(GL_POLYGON); | ||
270 | glVertex3f(-0.5f,-0.5f,1.0f); | ||
271 | glVertex3f(+0.5f,-0.5f,1.0f); | ||
272 | glVertex3f(+0.5f,+0.5f,1.0f); | ||
273 | glVertex3f(-0.5f,+0.5f,1.0f); | ||
274 | glVertex3f(-0.5f,-0.5f,1.0f); | ||
275 | glEnd(); | ||
276 | |||
277 | for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); | ||
278 | iter != mDrawFace.end(); iter++) | ||
279 | { | ||
280 | LLFace *face = *iter; | ||
281 | |||
282 | S32 geom_count = face->getGeomCount(); | ||
283 | for (S32 j=0;j<geom_count;j++) | ||
284 | { | ||
285 | LLVector3 p1; | ||
286 | LLVector3 p2; | ||
287 | |||
288 | intptr_t p = ((intptr_t)face*13) % 7; | ||
289 | F32 r = table[p][0]; | ||
290 | F32 g = table[p][1]; | ||
291 | F32 b = table[p][2]; | ||
292 | |||
293 | //p1.mV[1] = y; | ||
294 | //p2.mV[1] = y; | ||
295 | |||
296 | p1.mV[2] = 1.0; | ||
297 | p2.mV[2] = 1.0; | ||
298 | |||
299 | glColor4f(r,g,b,0.5f); | ||
300 | |||
301 | glBegin(GL_LINE_STRIP); | ||
302 | glVertex3fv(p1.mV); | ||
303 | glVertex3fv(p2.mV); | ||
304 | glEnd(); | ||
305 | |||
306 | } | ||
307 | } | ||
308 | |||
309 | glColor4f(1,1,1,1); | ||
310 | glBegin(GL_LINE_STRIP); | ||
311 | glVertex3f(-0.5f,-0.5f,1.0f); | ||
312 | glVertex3f(+0.5f,-0.5f,1.0f); | ||
313 | glVertex3f(+0.5f,+0.5f,1.0f); | ||
314 | glVertex3f(-0.5f,+0.5f,1.0f); | ||
315 | glVertex3f(-0.5f,-0.5f,1.0f); | ||
316 | glEnd(); | ||
317 | |||
318 | glPopMatrix(); | ||
319 | glMatrixMode(GL_PROJECTION); | ||
320 | glPopMatrix(); | ||
321 | glMatrixMode(GL_MODELVIEW); | ||
322 | |||
323 | } | ||
324 | |||
325 | void LLFacePool::enqueue(LLFace* facep) | 238 | void LLFacePool::enqueue(LLFace* facep) |
326 | { | 239 | { |
327 | mDrawFace.push_back(facep); | 240 | mDrawFace.push_back(facep); |
@@ -411,38 +324,17 @@ BOOL LLFacePool::LLOverrideFaceColor::sOverrideFaceColor = FALSE; | |||
411 | 324 | ||
412 | void LLFacePool::LLOverrideFaceColor::setColor(const LLColor4& color) | 325 | void LLFacePool::LLOverrideFaceColor::setColor(const LLColor4& color) |
413 | { | 326 | { |
414 | if (mPool->getVertexShaderLevel() > 0 && mPool->getMaterialAttribIndex() > 0) | 327 | glColor4fv(color.mV); |
415 | { | ||
416 | glVertexAttrib4fvARB(mPool->getMaterialAttribIndex(), color.mV); | ||
417 | } | ||
418 | else | ||
419 | { | ||
420 | glColor4fv(color.mV); | ||
421 | } | ||
422 | } | 328 | } |
423 | 329 | ||
424 | void LLFacePool::LLOverrideFaceColor::setColor(const LLColor4U& color) | 330 | void LLFacePool::LLOverrideFaceColor::setColor(const LLColor4U& color) |
425 | { | 331 | { |
426 | if (mPool->getVertexShaderLevel() > 0 && mPool->getMaterialAttribIndex() > 0) | 332 | glColor4ubv(color.mV); |
427 | { | ||
428 | glVertexAttrib4ubvARB(mPool->getMaterialAttribIndex(), color.mV); | ||
429 | } | ||
430 | else | ||
431 | { | ||
432 | glColor4ubv(color.mV); | ||
433 | } | ||
434 | } | 333 | } |
435 | 334 | ||
436 | void LLFacePool::LLOverrideFaceColor::setColor(F32 r, F32 g, F32 b, F32 a) | 335 | void LLFacePool::LLOverrideFaceColor::setColor(F32 r, F32 g, F32 b, F32 a) |
437 | { | 336 | { |
438 | if (mPool->getVertexShaderLevel() > 0 && mPool->getMaterialAttribIndex() > 0) | 337 | glColor4f(r,g,b,a); |
439 | { | ||
440 | glVertexAttrib4fARB(mPool->getMaterialAttribIndex(), r,g,b,a); | ||
441 | } | ||
442 | else | ||
443 | { | ||
444 | glColor4f(r,g,b,a); | ||
445 | } | ||
446 | } | 338 | } |
447 | 339 | ||
448 | 340 | ||
@@ -483,51 +375,45 @@ void LLRenderPass::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL t | |||
483 | } | 375 | } |
484 | } | 376 | } |
485 | 377 | ||
486 | void LLRenderPass::renderInvisible(U32 mask) | 378 | void LLRenderPass::renderTexture(U32 type, U32 mask) |
379 | { | ||
380 | pushBatches(type, mask, TRUE); | ||
381 | } | ||
382 | |||
383 | void LLRenderPass::pushBatches(U32 type, U32 mask, BOOL texture) | ||
487 | { | 384 | { |
488 | #if !LL_RELEASE_FOR_DOWNLOAD | 385 | #if !LL_RELEASE_FOR_DOWNLOAD |
489 | LLGLState::checkClientArrays(mask); | 386 | LLGLState::checkClientArrays(mask); |
490 | #endif | 387 | #endif |
491 | |||
492 | LLSpatialGroup::drawmap_elem_t& draw_info = gPipeline.mRenderMap[LLRenderPass::PASS_INVISIBLE]; | ||
493 | 388 | ||
494 | for (LLSpatialGroup::drawmap_elem_t::iterator i = draw_info.begin(); i != draw_info.end(); ++i) | 389 | for (LLCullResult::drawinfo_list_t::iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i) |
495 | { | 390 | { |
496 | 391 | LLDrawInfo* pparams = *i; | |
497 | LLDrawInfo *pparams = *i; | 392 | if (pparams) |
498 | if (pparams && pparams->mVertexBuffer.notNull()) { | 393 | { |
499 | LLDrawInfo ¶ms = *pparams; | 394 | pushBatch(*pparams, mask, texture); |
500 | |||
501 | params.mVertexBuffer->setBuffer(mask); | ||
502 | U32 *indices_pointer = | ||
503 | (U32 *) params.mVertexBuffer->getIndicesPointer(); | ||
504 | glDrawRangeElements(GL_TRIANGLES, params.mStart, params.mEnd, | ||
505 | params.mCount, GL_UNSIGNED_INT, | ||
506 | indices_pointer + params.mOffset); | ||
507 | gPipeline.mTrianglesDrawn += params.mCount / 3; | ||
508 | } | 395 | } |
509 | } | 396 | } |
510 | } | 397 | } |
511 | 398 | ||
512 | void LLRenderPass::renderTexture(U32 type, U32 mask) | 399 | void LLRenderPass::applyModelMatrix(LLDrawInfo& params) |
513 | { | 400 | { |
514 | #if !LL_RELEASE_FOR_DOWNLOAD | 401 | if (params.mModelMatrix != gGLLastMatrix) |
515 | LLGLState::checkClientArrays(mask); | ||
516 | #endif | ||
517 | |||
518 | LLSpatialGroup::drawmap_elem_t& draw_info = gPipeline.mRenderMap[type]; | ||
519 | |||
520 | for (LLSpatialGroup::drawmap_elem_t::iterator i = draw_info.begin(); i != draw_info.end(); ++i) | ||
521 | { | 402 | { |
522 | LLDrawInfo* pparams = *i; | 403 | gGLLastMatrix = params.mModelMatrix; |
523 | if (pparams) { | 404 | glLoadMatrixd(gGLModelView); |
524 | pushBatch(*pparams, mask, TRUE); | 405 | if (params.mModelMatrix) |
406 | { | ||
407 | glMultMatrixf((GLfloat*) params.mModelMatrix->mMatrix); | ||
525 | } | 408 | } |
409 | gPipeline.mMatrixOpCount++; | ||
526 | } | 410 | } |
527 | } | 411 | } |
528 | 412 | ||
529 | void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) | 413 | void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) |
530 | { | 414 | { |
415 | applyModelMatrix(params); | ||
416 | |||
531 | if (texture) | 417 | if (texture) |
532 | { | 418 | { |
533 | if (params.mTexture.notNull()) | 419 | if (params.mTexture.notNull()) |
@@ -537,6 +423,7 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) | |||
537 | { | 423 | { |
538 | glMatrixMode(GL_TEXTURE); | 424 | glMatrixMode(GL_TEXTURE); |
539 | glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix); | 425 | glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix); |
426 | gPipeline.mTextureMatrixOps++; | ||
540 | } | 427 | } |
541 | params.mTexture->addTextureStats(params.mVSize); | 428 | params.mTexture->addTextureStats(params.mVSize); |
542 | } | 429 | } |
@@ -545,14 +432,14 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) | |||
545 | LLImageGL::unbindTexture(0); | 432 | LLImageGL::unbindTexture(0); |
546 | } | 433 | } |
547 | } | 434 | } |
548 | 435 | ||
549 | if (params.mVertexBuffer.notNull()) | 436 | if (params.mVertexBuffer.notNull()) |
550 | { | 437 | { |
551 | params.mVertexBuffer->setBuffer(mask); | 438 | params.mVertexBuffer->setBuffer(mask); |
552 | U32* indices_pointer = (U32*) params.mVertexBuffer->getIndicesPointer(); | 439 | U16* indices_pointer = (U16*) params.mVertexBuffer->getIndicesPointer(); |
553 | glDrawRangeElements(GL_TRIANGLES, params.mStart, params.mEnd, params.mCount, | 440 | glDrawRangeElements(GL_TRIANGLES, params.mStart, params.mEnd, params.mCount, |
554 | GL_UNSIGNED_INT, indices_pointer+params.mOffset); | 441 | GL_UNSIGNED_SHORT, indices_pointer+params.mOffset); |
555 | gPipeline.mTrianglesDrawn += params.mCount/3; | 442 | gPipeline.addTrianglesDrawn(params.mCount/3); |
556 | } | 443 | } |
557 | 444 | ||
558 | if (params.mTextureMatrix && texture && params.mTexture.notNull()) | 445 | if (params.mTextureMatrix && texture && params.mTexture.notNull()) |
@@ -562,52 +449,7 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture) | |||
562 | } | 449 | } |
563 | } | 450 | } |
564 | 451 | ||
565 | void LLRenderPass::renderActive(U32 type, U32 mask, BOOL texture) | 452 | void LLRenderPass::renderGroups(U32 type, U32 mask, BOOL texture) |
566 | { | ||
567 | #if !LL_RELEASE_FOR_DOWNLOAD | ||
568 | LLGLState::checkClientArrays(mask); | ||
569 | #endif | ||
570 | |||
571 | LLSpatialBridge* last_bridge = NULL; | ||
572 | glPushMatrix(); | ||
573 | |||
574 | for (LLSpatialGroup::sg_vector_t::iterator i = gPipeline.mActiveGroups.begin(); i != gPipeline.mActiveGroups.end(); ++i) | ||
575 | { | ||
576 | LLSpatialGroup* group = *i; | ||
577 | if (!group->isDead() && | ||
578 | gPipeline.hasRenderType(group->mSpatialPartition->mDrawableType) && | ||
579 | group->mDrawMap.find(type) != group->mDrawMap.end()) | ||
580 | { | ||
581 | LLSpatialBridge* bridge = (LLSpatialBridge*) group->mSpatialPartition; | ||
582 | if (bridge != last_bridge) | ||
583 | { | ||
584 | glPopMatrix(); | ||
585 | glPushMatrix(); | ||
586 | glMultMatrixf((F32*) bridge->mDrawable->getRenderMatrix().mMatrix); | ||
587 | last_bridge = bridge; | ||
588 | } | ||
589 | |||
590 | renderGroup(group,type,mask,texture); | ||
591 | } | ||
592 | } | ||
593 | |||
594 | glPopMatrix(); | ||
595 | } | ||
596 | |||
597 | void LLRenderPass::renderStatic(U32 type, U32 mask, BOOL texture) | ||
598 | { | 453 | { |
599 | #if !LL_RELEASE_FOR_DOWNLOAD | 454 | gPipeline.renderGroups(this, type, mask, texture); |
600 | LLGLState::checkClientArrays(mask); | ||
601 | #endif | ||
602 | |||
603 | for (LLSpatialGroup::sg_vector_t::iterator i = gPipeline.mVisibleGroups.begin(); i != gPipeline.mVisibleGroups.end(); ++i) | ||
604 | { | ||
605 | LLSpatialGroup* group = *i; | ||
606 | if (!group->isDead() && | ||
607 | gPipeline.hasRenderType(group->mSpatialPartition->mDrawableType) && | ||
608 | group->mDrawMap.find(type) != group->mDrawMap.end()) | ||
609 | { | ||
610 | renderGroup(group,type,mask,texture); | ||
611 | } | ||
612 | } | ||
613 | } | 455 | } |