aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvosurfacepatch.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llvosurfacepatch.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-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/llvosurfacepatch.cpp')
-rw-r--r--linden/indra/newview/llvosurfacepatch.cpp94
1 files changed, 30 insertions, 64 deletions
diff --git a/linden/indra/newview/llvosurfacepatch.cpp b/linden/indra/newview/llvosurfacepatch.cpp
index 677a8be..3665ec7 100644
--- a/linden/indra/newview/llvosurfacepatch.cpp
+++ b/linden/indra/newview/llvosurfacepatch.cpp
@@ -46,6 +46,9 @@
46#include "llvlcomposition.h" 46#include "llvlcomposition.h"
47#include "llvovolume.h" 47#include "llvovolume.h"
48#include "pipeline.h" 48#include "pipeline.h"
49#include "llspatialpartition.h"
50
51F32 LLVOSurfacePatch::sLODFactor = 1.f;
49 52
50//============================================================================ 53//============================================================================
51 54
@@ -187,6 +190,8 @@ BOOL LLVOSurfacePatch::updateGeometry(LLDrawable *drawable)
187{ 190{
188 LLFastTimer ftm(LLFastTimer::FTM_UPDATE_TERRAIN); 191 LLFastTimer ftm(LLFastTimer::FTM_UPDATE_TERRAIN);
189 192
193 dirtySpatialGroup();
194
190 S32 min_comp, max_comp, range; 195 S32 min_comp, max_comp, range;
191 min_comp = lltrunc(mPatchp->getMinComposition()); 196 min_comp = lltrunc(mPatchp->getMinComposition());
192 max_comp = lltrunc(ceil(mPatchp->getMaxComposition())); 197 max_comp = lltrunc(ceil(mPatchp->getMaxComposition()));
@@ -271,8 +276,6 @@ void LLVOSurfacePatch::updateFaceSize(S32 idx)
271 276
272BOOL LLVOSurfacePatch::updateLOD() 277BOOL LLVOSurfacePatch::updateLOD()
273{ 278{
274 //mDrawable->updateLightSet();
275 mDrawable->setState(LLDrawable::LIGHTING_BUILT);
276 return TRUE; 279 return TRUE;
277} 280}
278 281
@@ -281,7 +284,7 @@ void LLVOSurfacePatch::getGeometry(LLStrider<LLVector3> &verticesp,
281 LLStrider<LLColor4U> &colorsp, 284 LLStrider<LLColor4U> &colorsp,
282 LLStrider<LLVector2> &texCoords0p, 285 LLStrider<LLVector2> &texCoords0p,
283 LLStrider<LLVector2> &texCoords1p, 286 LLStrider<LLVector2> &texCoords1p,
284 LLStrider<U32> &indicesp) 287 LLStrider<U16> &indicesp)
285{ 288{
286 LLFace* facep = mDrawable->getFace(0); 289 LLFace* facep = mDrawable->getFace(0);
287 290
@@ -319,7 +322,7 @@ void LLVOSurfacePatch::updateMainGeometry(LLFace *facep,
319 LLStrider<LLColor4U> &colorsp, 322 LLStrider<LLColor4U> &colorsp,
320 LLStrider<LLVector2> &texCoords0p, 323 LLStrider<LLVector2> &texCoords0p,
321 LLStrider<LLVector2> &texCoords1p, 324 LLStrider<LLVector2> &texCoords1p,
322 LLStrider<U32> &indicesp, 325 LLStrider<U16> &indicesp,
323 U32 &index_offset) 326 U32 &index_offset)
324{ 327{
325 S32 i, j, x, y; 328 S32 i, j, x, y;
@@ -355,10 +358,9 @@ void LLVOSurfacePatch::updateMainGeometry(LLFace *facep,
355 x = i * render_stride; 358 x = i * render_stride;
356 y = j * render_stride; 359 y = j * render_stride;
357 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); 360 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get());
358 calcColor(verticesp.get(), normalsp.get(), colorsp.get()); 361 *colorsp++ = LLColor4U::white;
359 verticesp++; 362 verticesp++;
360 normalsp++; 363 normalsp++;
361 colorsp++;
362 texCoords0p++; 364 texCoords0p++;
363 texCoords1p++; 365 texCoords1p++;
364 } 366 }
@@ -424,7 +426,7 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep,
424 LLStrider<LLColor4U> &colorsp, 426 LLStrider<LLColor4U> &colorsp,
425 LLStrider<LLVector2> &texCoords0p, 427 LLStrider<LLVector2> &texCoords0p,
426 LLStrider<LLVector2> &texCoords1p, 428 LLStrider<LLVector2> &texCoords1p,
427 LLStrider<U32> &indicesp, 429 LLStrider<U16> &indicesp,
428 U32 &index_offset) 430 U32 &index_offset)
429{ 431{
430 S32 vertex_count = 0; 432 S32 vertex_count = 0;
@@ -459,10 +461,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep,
459 y = 16 - render_stride; 461 y = 16 - render_stride;
460 462
461 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); 463 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get());
462 calcColor(verticesp.get(), normalsp.get(), colorsp.get()); 464 *colorsp++ = LLColor4U::white;
463 verticesp++; 465 verticesp++;
464 normalsp++; 466 normalsp++;
465 colorsp++;
466 texCoords0p++; 467 texCoords0p++;
467 texCoords1p++; 468 texCoords1p++;
468 vertex_count++; 469 vertex_count++;
@@ -474,10 +475,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep,
474 x = i * render_stride; 475 x = i * render_stride;
475 y = 16; 476 y = 16;
476 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); 477 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get());
477 calcColor(verticesp.get(), normalsp.get(), colorsp.get());
478 verticesp++; 478 verticesp++;
479 normalsp++; 479 normalsp++;
480 colorsp++; 480 *colorsp++ = LLColor4U::white;
481 texCoords0p++; 481 texCoords0p++;
482 texCoords1p++; 482 texCoords1p++;
483 vertex_count++; 483 vertex_count++;
@@ -514,10 +514,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep,
514 y = 16 - render_stride; 514 y = 16 - render_stride;
515 515
516 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); 516 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get());
517 calcColor(verticesp.get(), normalsp.get(), colorsp.get());
518 verticesp++; 517 verticesp++;
519 normalsp++; 518 normalsp++;
520 colorsp++; 519 *colorsp++ = LLColor4U::white;
521 texCoords0p++; 520 texCoords0p++;
522 texCoords1p++; 521 texCoords1p++;
523 vertex_count++; 522 vertex_count++;
@@ -530,10 +529,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep,
530 y = 16; 529 y = 16;
531 530
532 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); 531 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get());
533 calcColor(verticesp.get(), normalsp.get(), colorsp.get());
534 verticesp++; 532 verticesp++;
535 normalsp++; 533 normalsp++;
536 colorsp++; 534 *colorsp++ = LLColor4U::white;
537 texCoords0p++; 535 texCoords0p++;
538 texCoords1p++; 536 texCoords1p++;
539 vertex_count++; 537 vertex_count++;
@@ -577,10 +575,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep,
577 y = 16 - render_stride; 575 y = 16 - render_stride;
578 576
579 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); 577 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get());
580 calcColor(verticesp.get(), normalsp.get(), colorsp.get()); 578 *colorsp++ = LLColor4U::white;
581 verticesp++; 579 verticesp++;
582 normalsp++; 580 normalsp++;
583 colorsp++;
584 texCoords0p++; 581 texCoords0p++;
585 texCoords1p++; 582 texCoords1p++;
586 vertex_count++; 583 vertex_count++;
@@ -593,10 +590,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep,
593 y = 16; 590 y = 16;
594 591
595 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); 592 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get());
596 calcColor(verticesp.get(), normalsp.get(), colorsp.get());
597 verticesp++; 593 verticesp++;
598 normalsp++; 594 normalsp++;
599 colorsp++; 595 *colorsp++ = LLColor4U::white;
600 texCoords0p++; 596 texCoords0p++;
601 texCoords1p++; 597 texCoords1p++;
602 vertex_count++; 598 vertex_count++;
@@ -637,7 +633,7 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep,
637 LLStrider<LLColor4U> &colorsp, 633 LLStrider<LLColor4U> &colorsp,
638 LLStrider<LLVector2> &texCoords0p, 634 LLStrider<LLVector2> &texCoords0p,
639 LLStrider<LLVector2> &texCoords1p, 635 LLStrider<LLVector2> &texCoords1p,
640 LLStrider<U32> &indicesp, 636 LLStrider<U16> &indicesp,
641 U32 &index_offset) 637 U32 &index_offset)
642{ 638{
643 S32 i, x, y; 639 S32 i, x, y;
@@ -666,10 +662,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep,
666 y = i * render_stride; 662 y = i * render_stride;
667 663
668 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); 664 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get());
669 calcColor(verticesp.get(), normalsp.get(), colorsp.get());
670 verticesp++; 665 verticesp++;
671 normalsp++; 666 normalsp++;
672 colorsp++; 667 *colorsp++ = LLColor4U::white;
673 texCoords0p++; 668 texCoords0p++;
674 texCoords1p++; 669 texCoords1p++;
675 } 670 }
@@ -680,10 +675,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep,
680 x = 16; 675 x = 16;
681 y = i * render_stride; 676 y = i * render_stride;
682 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); 677 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get());
683 calcColor(verticesp.get(), normalsp.get(), colorsp.get());
684 verticesp++; 678 verticesp++;
685 normalsp++; 679 normalsp++;
686 colorsp++; 680 *colorsp++ = LLColor4U::white;
687 texCoords0p++; 681 texCoords0p++;
688 texCoords1p++; 682 texCoords1p++;
689 } 683 }
@@ -719,10 +713,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep,
719 y = i * render_stride; 713 y = i * render_stride;
720 714
721 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); 715 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get());
722 calcColor(verticesp.get(), normalsp.get(), colorsp.get());
723 verticesp++; 716 verticesp++;
724 normalsp++; 717 normalsp++;
725 colorsp++; 718 *colorsp++ = LLColor4U::white;
726 texCoords0p++; 719 texCoords0p++;
727 texCoords1p++; 720 texCoords1p++;
728 } 721 }
@@ -733,10 +726,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep,
733 y = i * render_stride; 726 y = i * render_stride;
734 727
735 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); 728 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get());
736 calcColor(verticesp.get(), normalsp.get(), colorsp.get());
737 verticesp++; 729 verticesp++;
738 normalsp++; 730 normalsp++;
739 colorsp++; 731 *colorsp++ = LLColor4U::white;
740 texCoords0p++; 732 texCoords0p++;
741 texCoords1p++; 733 texCoords1p++;
742 } 734 }
@@ -778,10 +770,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep,
778 y = i * east_stride; 770 y = i * east_stride;
779 771
780 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); 772 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get());
781 calcColor(verticesp.get(), normalsp.get(), colorsp.get());
782 verticesp++; 773 verticesp++;
783 normalsp++; 774 normalsp++;
784 colorsp++; 775 *colorsp++ = LLColor4U::white;
785 texCoords0p++; 776 texCoords0p++;
786 texCoords1p++; 777 texCoords1p++;
787 } 778 }
@@ -792,10 +783,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep,
792 y = i * east_stride; 783 y = i * east_stride;
793 784
794 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); 785 mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get());
795 calcColor(verticesp.get(), normalsp.get(), colorsp.get());
796 verticesp++; 786 verticesp++;
797 normalsp++; 787 normalsp++;
798 colorsp++; 788 *colorsp++ = LLColor4U::white;
799 texCoords0p++; 789 texCoords0p++;
800 texCoords1p++; 790 texCoords1p++;
801 } 791 }
@@ -829,35 +819,6 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep,
829 index_offset += num_vertices; 819 index_offset += num_vertices;
830} 820}
831 821
832void LLVOSurfacePatch::calcColor(const LLVector3* vertex, const LLVector3* normal, LLColor4U* colorp)
833{
834 LLColor4 color(0,0,0,0);
835 if (gPipeline.getLightingDetail() >= 2)
836 {
837 for (LLDrawable::drawable_set_t::iterator iter = mDrawable->mLightSet.begin();
838 iter != mDrawable->mLightSet.end(); ++iter)
839 {
840 LLDrawable* light_drawable = *iter;
841 LLVOVolume* light = light_drawable->getVOVolume();
842 if (!light)
843 {
844 continue;
845 }
846 LLColor4 light_color;
847 light->calcLightAtPoint(*vertex, *normal, light_color);
848 color += light_color;
849 }
850
851 color.mV[3] = 1.0f;
852 }
853 colorp->setVecScaleClamp(color);
854}
855
856BOOL LLVOSurfacePatch::updateShadows(BOOL use_shadow_factor)
857{
858 return FALSE; //terrain updates its shadows during standard relight
859}
860
861void LLVOSurfacePatch::setPatch(LLSurfacePatch *patchp) 822void LLVOSurfacePatch::setPatch(LLSurfacePatch *patchp)
862{ 823{
863 mPatchp = patchp; 824 mPatchp = patchp;
@@ -966,16 +927,18 @@ void LLVOSurfacePatch::updateSpatialExtents(LLVector3& newMin, LLVector3 &newMax
966 927
967U32 LLVOSurfacePatch::getPartitionType() const 928U32 LLVOSurfacePatch::getPartitionType() const
968{ 929{
969 return LLPipeline::PARTITION_TERRAIN; 930 return LLViewerRegion::PARTITION_TERRAIN;
970} 931}
971 932
972LLTerrainPartition::LLTerrainPartition() 933LLTerrainPartition::LLTerrainPartition()
973: LLSpatialPartition(LLDrawPoolTerrain::VERTEX_DATA_MASK) 934: LLSpatialPartition(LLDrawPoolTerrain::VERTEX_DATA_MASK)
974{ 935{
936 mOcclusionEnabled = FALSE;
975 mRenderByGroup = FALSE; 937 mRenderByGroup = FALSE;
938 mInfiniteFarClip = FALSE;
976 mBufferUsage = GL_DYNAMIC_DRAW_ARB; 939 mBufferUsage = GL_DYNAMIC_DRAW_ARB;
977 mDrawableType = LLPipeline::RENDER_TYPE_TERRAIN; 940 mDrawableType = LLPipeline::RENDER_TYPE_TERRAIN;
978 mPartitionType = LLPipeline::PARTITION_TERRAIN; 941 mPartitionType = LLViewerRegion::PARTITION_TERRAIN;
979} 942}
980 943
981LLVertexBuffer* LLTerrainPartition::createVertexBuffer(U32 type_mask, U32 usage) 944LLVertexBuffer* LLTerrainPartition::createVertexBuffer(U32 type_mask, U32 usage)
@@ -985,6 +948,8 @@ LLVertexBuffer* LLTerrainPartition::createVertexBuffer(U32 type_mask, U32 usage)
985 948
986void LLTerrainPartition::getGeometry(LLSpatialGroup* group) 949void LLTerrainPartition::getGeometry(LLSpatialGroup* group)
987{ 950{
951 LLFastTimer ftm(LLFastTimer::FTM_REBUILD_TERRAIN_VB);
952
988 LLVertexBuffer* buffer = group->mVertexBuffer; 953 LLVertexBuffer* buffer = group->mVertexBuffer;
989 954
990 //get vertex buffer striders 955 //get vertex buffer striders
@@ -993,7 +958,7 @@ void LLTerrainPartition::getGeometry(LLSpatialGroup* group)
993 LLStrider<LLVector2> texcoords2; 958 LLStrider<LLVector2> texcoords2;
994 LLStrider<LLVector2> texcoords; 959 LLStrider<LLVector2> texcoords;
995 LLStrider<LLColor4U> colors; 960 LLStrider<LLColor4U> colors;
996 LLStrider<U32> indices; 961 LLStrider<U16> indices;
997 962
998 buffer->getVertexStrider(vertices); 963 buffer->getVertexStrider(vertices);
999 buffer->getNormalStrider(normals); 964 buffer->getNormalStrider(normals);
@@ -1020,6 +985,7 @@ void LLTerrainPartition::getGeometry(LLSpatialGroup* group)
1020 index_offset += facep->getGeomCount(); 985 index_offset += facep->getGeomCount();
1021 } 986 }
1022 987
988 buffer->setBuffer(0);
1023 mFaceList.clear(); 989 mFaceList.clear();
1024} 990}
1025 991