aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvovolume.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llvovolume.cpp422
1 files changed, 112 insertions, 310 deletions
diff --git a/linden/indra/newview/llvovolume.cpp b/linden/indra/newview/llvovolume.cpp
index 77c9c33..13a0704 100644
--- a/linden/indra/newview/llvovolume.cpp
+++ b/linden/indra/newview/llvovolume.cpp
@@ -54,7 +54,6 @@
54#include "llspatialpartition.h" 54#include "llspatialpartition.h"
55#include "llhudmanager.h" 55#include "llhudmanager.h"
56#include "llflexibleobject.h" 56#include "llflexibleobject.h"
57
58#include "llsky.h" 57#include "llsky.h"
59#include "lltexturefetch.h" 58#include "lltexturefetch.h"
60#include "llviewercamera.h" 59#include "llviewercamera.h"
@@ -68,9 +67,6 @@
68const S32 MIN_QUIET_FRAMES_COALESCE = 30; 67const S32 MIN_QUIET_FRAMES_COALESCE = 30;
69const F32 FORCE_SIMPLE_RENDER_AREA = 512.f; 68const F32 FORCE_SIMPLE_RENDER_AREA = 512.f;
70const F32 FORCE_CULL_AREA = 8.f; 69const F32 FORCE_CULL_AREA = 8.f;
71const F32 MAX_LOD_DISTANCE = 24.f;
72const S32 MAX_SCULPT_REZ = 128;
73
74 70
75BOOL gAnimateTextures = TRUE; 71BOOL gAnimateTextures = TRUE;
76extern BOOL gHideSelectedObjects; 72extern BOOL gHideSelectedObjects;
@@ -95,7 +91,6 @@ LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *re
95 mNumFaces = 0; 91 mNumFaces = 0;
96 mLODChanged = FALSE; 92 mLODChanged = FALSE;
97 mSculptChanged = FALSE; 93 mSculptChanged = FALSE;
98 mSpotLightPriority = 0.f;
99} 94}
100 95
101LLVOVolume::~LLVOVolume() 96LLVOVolume::~LLVOVolume()
@@ -219,7 +214,7 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys,
219 std::string mask; 214 std::string mask;
220 mask = gDirUtilp->getDirDelimiter() + "*.slc"; 215 mask = gDirUtilp->getDirDelimiter() + "*.slc";
221 gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""), mask); 216 gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""), mask);
222// llwarns << "Bogus TE data in " << getID() << ", crashing!" << llendl; 217// llerrs << "Bogus TE data in " << getID() << ", crashing!" << llendl;
223 llwarns << "Bogus TE data in " << getID() << llendl; 218 llwarns << "Bogus TE data in " << getID() << llendl;
224 } 219 }
225 else if (res2 & (TEM_CHANGE_TEXTURE|TEM_CHANGE_COLOR)) 220 else if (res2 & (TEM_CHANGE_TEXTURE|TEM_CHANGE_COLOR))
@@ -319,6 +314,11 @@ void LLVOVolume::animateTextures()
319 te->getScale(&scale_s, &scale_t); 314 te->getScale(&scale_s, &scale_t);
320 } 315 }
321 316
317 LLVector3 scale(scale_s, scale_t, 1.f);
318 LLVector3 trans(off_s+0.5f, off_t+0.5f, 0.f);
319 LLQuaternion quat;
320 quat.setQuat(rot, 0, 0, -1.f);
321
322 if (!facep->mTextureMatrix) 322 if (!facep->mTextureMatrix)
323 { 323 {
324 facep->mTextureMatrix = new LLMatrix4(); 324 facep->mTextureMatrix = new LLMatrix4();
@@ -326,43 +326,7 @@ void LLVOVolume::animateTextures()
326 326
327 LLMatrix4& tex_mat = *facep->mTextureMatrix; 327 LLMatrix4& tex_mat = *facep->mTextureMatrix;
328 tex_mat.setIdentity(); 328 tex_mat.setIdentity();
329 LLVector3 trans ; 329 tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f));
330
331 if(facep->isAtlasInUse())
332 {
333 //
334 //if use atlas for animated texture
335 //apply the following transform to the animation matrix.
336 //
337
338 F32 tcoord_xoffset = 0.f ;
339 F32 tcoord_yoffset = 0.f ;
340 F32 tcoord_xscale = 1.f ;
341 F32 tcoord_yscale = 1.f ;
342 if(facep->isAtlasInUse())
343 {
344 const LLVector2* tmp = facep->getTexCoordOffset() ;
345 tcoord_xoffset = tmp->mV[0] ;
346 tcoord_yoffset = tmp->mV[1] ;
347
348 tmp = facep->getTexCoordScale() ;
349 tcoord_xscale = tmp->mV[0] ;
350 tcoord_yscale = tmp->mV[1] ;
351 }
352 trans.set(LLVector3(tcoord_xoffset + tcoord_xscale * (off_s+0.5f), tcoord_yoffset + tcoord_yscale * (off_t+0.5f), 0.f));
353
354 tex_mat.translate(LLVector3(-(tcoord_xoffset + tcoord_xscale * 0.5f), -(tcoord_yoffset + tcoord_yscale * 0.5f), 0.f));
355 }
356 else //non atlas
357 {
358 trans.set(LLVector3(off_s+0.5f, off_t+0.5f, 0.f));
359 tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f));
360 }
361
362 LLVector3 scale(scale_s, scale_t, 1.f);
363 LLQuaternion quat;
364 quat.setQuat(rot, 0, 0, -1.f);
365
366 tex_mat.rotate(quat); 330 tex_mat.rotate(quat);
367 331
368 LLMatrix4 mat; 332 LLMatrix4 mat;
@@ -439,28 +403,30 @@ BOOL LLVOVolume::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
439 return TRUE; 403 return TRUE;
440} 404}
441 405
442void LLVOVolume::updateTextures(LLAgent &agent) // KL sd 406void LLVOVolume::updateTextures()
443{ 407{
444 const F32 TEXTURE_AREA_REFRESH_TIME = 5.f; // seconds 408 const F32 TEXTURE_AREA_REFRESH_TIME = 5.f; // seconds
445 if (mDrawable.notNull() && mTextureUpdateTimer.getElapsedTimeF32() > TEXTURE_AREA_REFRESH_TIME) 409 if (mTextureUpdateTimer.getElapsedTimeF32() > TEXTURE_AREA_REFRESH_TIME)
446 { 410 {
447 if (mDrawable->isVisible()) 411 updateTextureVirtualSize();
448 {
449 updateTextures();
450 }
451 } 412 }
452} 413}
453 414
454void LLVOVolume::updateTextures() 415void LLVOVolume::updateTextureVirtualSize()
455{ 416{
456 // Update the pixel area of all faces 417 // Update the pixel area of all faces
457 418
419 if(mDrawable.isNull() || !mDrawable->isVisible())
420 {
421 return ;
422 }
423
458 if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SIMPLE)) 424 if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SIMPLE))
459 { 425 {
460 return; 426 return;
461 } 427 }
462 428
463 if (LLViewerImage::sDontLoadVolumeTextures || mDrawable.isNull()) // || !mDrawable->isVisible()) 429 if (LLViewerImage::sDontLoadVolumeTextures || LLAppViewer::getTextureFetch()->mDebugPause)
464 { 430 {
465 return; 431 return;
466 } 432 }
@@ -477,14 +443,15 @@ void LLVOVolume::updateTextures()
477 LLFace* face = mDrawable->getFace(i); 443 LLFace* face = mDrawable->getFace(i);
478 const LLTextureEntry *te = face->getTextureEntry(); 444 const LLTextureEntry *te = face->getTextureEntry();
479 LLViewerImage *imagep = face->getTexture(); 445 LLViewerImage *imagep = face->getTexture();
480 if (!imagep || !te || 446 if (!imagep || !te ||
481 face->mExtents[0] == face->mExtents[1]) 447 face->mExtents[0] == face->mExtents[1])
482 { 448 {
483 continue; 449 continue;
484 } 450 }
485 451
486 F32 vsize; 452 F32 vsize;
487 453 F32 old_size = face->getVirtualSize();
454
488 if (isHUDAttachment()) 455 if (isHUDAttachment())
489 { 456 {
490 F32 area = (F32) LLViewerCamera::getInstance()->getScreenPixelArea(); 457 F32 area = (F32) LLViewerCamera::getInstance()->getScreenPixelArea();
@@ -494,24 +461,21 @@ void LLVOVolume::updateTextures()
494 } 461 }
495 else 462 else
496 { 463 {
497 vsize = getTextureVirtualSize(face); 464 vsize = face->getTextureVirtualSize();
498 } 465 }
499 466
500 mPixelArea = llmax(mPixelArea, face->getPixelArea()); 467 mPixelArea = llmax(mPixelArea, face->getPixelArea());
501
502 F32 old_size = face->getVirtualSize();
503 468
504 if (face->mTextureMatrix != NULL) 469 if (face->mTextureMatrix != NULL)
505 { 470 {
506 if (vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE || 471 if ((vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE) ||
507 vsize > MIN_TEX_ANIM_SIZE && old_size < MIN_TEX_ANIM_SIZE) 472 (vsize > MIN_TEX_ANIM_SIZE && old_size < MIN_TEX_ANIM_SIZE))
508 { 473 {
509 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD, FALSE); 474 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD, FALSE);
510 } 475 }
511 } 476 }
512 477
513 face->setVirtualSize(vsize); 478 face->setVirtualSize(vsize);
514 // imagep->addTextureStats(vsize);
515 if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA)) 479 if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA))
516 { 480 {
517 if (vsize < min_vsize) min_vsize = vsize; 481 if (vsize < min_vsize) min_vsize = vsize;
@@ -539,46 +503,46 @@ void LLVOVolume::updateTextures()
539 mSculptTexture = gImageList.getImage(id); 503 mSculptTexture = gImageList.getImage(id);
540 if (mSculptTexture.notNull()) 504 if (mSculptTexture.notNull())
541 { 505 {
542 S32 lod = llmin(mLOD, 3);
543 F32 lodf = ((F32)(lod + 1.0f)/4.f);
544 F32 tex_size = lodf * MAX_SCULPT_REZ;
545 mSculptTexture->addTextureStats(2.f * tex_size * tex_size);
546 mSculptTexture->setBoostLevel(llmax((S32)mSculptTexture->getBoostLevel(), 506 mSculptTexture->setBoostLevel(llmax((S32)mSculptTexture->getBoostLevel(),
547 (S32)LLViewerImageBoostLevel::BOOST_SCULPTED)); 507 (S32)LLViewerImageBoostLevel::BOOST_SCULPTED));
548 } 508 mSculptTexture->setForSculpt() ;
549 509
550 S32 texture_discard = mSculptTexture->getDiscardLevel(); //try to match the texture 510 if(!mSculptTexture->isCachedRawImageReady())
551 S32 current_discard = mSculptLevel; 511 {
512 S32 lod = llmin(mLOD, 3);
513 F32 lodf = ((F32)(lod + 1.0f)/4.f);
514 F32 tex_size = lodf * LLViewerImage::sMaxSculptRez ;
515 mSculptTexture->addTextureStats(2.f * tex_size * tex_size, FALSE);
516
517 //if the sculpty very close to the view point, load first
518 {
519 LLVector3 lookAt = getPositionAgent() - LLViewerCamera::getInstance()->getOrigin();
520 F32 dist = lookAt.normVec() ;
521 F32 cos_angle_to_view_dir = lookAt * LLViewerCamera::getInstance()->getXAxis() ;
522 mSculptTexture->setAdditionalDecodePriority(0.8f * LLFace::calcImportanceToCamera(cos_angle_to_view_dir, dist)) ;
523 }
524 }
525
526 S32 texture_discard = mSculptTexture->getCachedRawImageLevel(); //try to match the texture
527 S32 current_discard = mSculptLevel;
552 528
553 if (texture_discard >= 0 && //texture has some data available 529 if (texture_discard >= 0 && //texture has some data available
554 (texture_discard < current_discard || //texture has more data than last rebuild 530 (texture_discard < current_discard || //texture has more data than last rebuild
555 current_discard < 0)) //no previous rebuild 531 current_discard < 0)) //no previous rebuild
556 { 532 {
557 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE); 533 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE);
558 mSculptChanged = TRUE; 534 mSculptChanged = TRUE;
559 } 535 }
560 536
561 if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SCULPTED)) 537 if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SCULPTED))
562 { 538 {
563 setDebugText(llformat("T%d C%d V%d\n%dx%d", 539 setDebugText(llformat("T%d C%d V%d\n%dx%d",
564 texture_discard, current_discard, getVolume()->getSculptLevel(), 540 texture_discard, current_discard, getVolume()->getSculptLevel(),
565 mSculptTexture->getHeight(), mSculptTexture->getWidth())); 541 mSculptTexture->getHeight(), mSculptTexture->getWidth()));
566 } 542 }
543 }
567 } 544 }
568 545
569 if (getLightTextureID().notNull())
570 {
571 LLLightImageParams* params = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE);
572 LLUUID id = params->getLightTexture();
573 mLightTexture = gImageList.getImage(id);
574 if (mLightTexture.notNull())
575 {
576 F32 rad = getLightRadius();
577 mLightTexture->addTextureStats(gPipeline.calcPixelArea(getPositionAgent(),
578 LLVector3(rad,rad,rad),
579 *LLViewerCamera::getInstance()));
580 }
581 }
582 546
583 if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA)) 547 if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA))
584 { 548 {
@@ -599,36 +563,6 @@ void LLVOVolume::updateTextures()
599 } 563 }
600} 564}
601 565
602F32 LLVOVolume::getTextureVirtualSize(LLFace* face)
603{
604 //get area of circle around face
605 LLVector3 center = face->getPositionAgent();
606 LLVector3 size = (face->mExtents[1] - face->mExtents[0]) * 0.5f;
607
608 F32 face_area = LLPipeline::calcPixelArea(center, size, *LLViewerCamera::getInstance());
609
610 face->setPixelArea(face_area);
611
612 if (face_area <= 0)
613 {
614 return 0.f;
615 }
616
617 //get area of circle in texture space
618 LLVector2 tdim = face->mTexExtents[1] - face->mTexExtents[0];
619 F32 texel_area = (tdim * 0.5f).lengthSquared()*3.14159f;
620 if (texel_area <= 0)
621 {
622 // Probably animated, use default
623 texel_area = 1.f;
624 }
625
626 //apply texel area to face area to get accurate ratio
627 face_area /= llclamp(texel_area, 1.f/64.f, 16.f);
628
629 return face_area;
630}
631
632BOOL LLVOVolume::isActive() const 566BOOL LLVOVolume::isActive() const
633{ 567{
634 return !mStatic || mTextureAnimp || (mVolumeImpl && mVolumeImpl->isActive()); 568 return !mStatic || mTextureAnimp || (mVolumeImpl && mVolumeImpl->isActive());
@@ -765,31 +699,21 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &volume_params, const S32 detail
765 699
766// sculpt replaces generate() for sculpted surfaces 700// sculpt replaces generate() for sculpted surfaces
767void LLVOVolume::sculpt() 701void LLVOVolume::sculpt()
768{ 702{
769 U16 sculpt_height = 0;
770 U16 sculpt_width = 0;
771 S8 sculpt_components = 0;
772 const U8* sculpt_data = NULL;
773
774 if (mSculptTexture.notNull()) 703 if (mSculptTexture.notNull())
775 { 704 {
776 S32 discard_level; 705 U16 sculpt_height = 0;
777 S32 desired_discard = 0; // lower discard levels have MUCH less resolution 706 U16 sculpt_width = 0;
778 707 S8 sculpt_components = 0;
779 discard_level = desired_discard; 708 const U8* sculpt_data = NULL;
709
710 S32 discard_level = mSculptTexture->getCachedRawImageLevel() ;
711 LLImageRaw* raw_image = mSculptTexture->getCachedRawImage() ;
780 712
781 S32 max_discard = mSculptTexture->getMaxDiscardLevel(); 713 S32 max_discard = mSculptTexture->getMaxDiscardLevel();
782 if (discard_level > max_discard) 714 if (discard_level > max_discard)
783 discard_level = max_discard; // clamp to the best we can do 715 discard_level = max_discard; // clamp to the best we can do
784 716
785 S32 best_discard = mSculptTexture->getDiscardLevel();
786 if (discard_level < best_discard)
787 discard_level = best_discard; // clamp to what we have
788
789 if (best_discard == -1)
790 discard_level = -1; // and if we have nothing, set to nothing
791
792
793 S32 current_discard = getVolume()->getSculptLevel(); 717 S32 current_discard = getVolume()->getSculptLevel();
794 if(current_discard < -2) 718 if(current_discard < -2)
795 { 719 {
@@ -811,28 +735,17 @@ void LLVOVolume::sculpt()
811 if (current_discard == discard_level) // no work to do here 735 if (current_discard == discard_level) // no work to do here
812 return; 736 return;
813 737
814 LLPointer<LLImageRaw> raw_image = new LLImageRaw(); 738 if(!raw_image)
815 BOOL is_valid = mSculptTexture->readBackRaw(discard_level, raw_image, FALSE);
816
817 sculpt_height = raw_image->getHeight();
818 sculpt_width = raw_image->getWidth();
819 sculpt_components = raw_image->getComponents();
820
821 if(is_valid)
822 {
823 is_valid = mSculptTexture->isValidForSculpt(discard_level, sculpt_width, sculpt_height, sculpt_components) ;
824 }
825 if(!is_valid)
826 { 739 {
827 sculpt_width = 0; 740 sculpt_width = 0;
828 sculpt_height = 0; 741 sculpt_height = 0;
829 sculpt_data = NULL ; 742 sculpt_data = NULL ;
830 } 743 }
831 else 744 else
832 { 745 {
833 if (raw_image->getDataSize() < sculpt_height * sculpt_width * sculpt_components) 746 sculpt_height = raw_image->getHeight();
834 llwarns << "Sculpt: image data size = " << raw_image->getDataSize() 747 sculpt_width = raw_image->getWidth();
835 << " < " << sculpt_height << " x " << sculpt_width << " x " <<sculpt_components << llendl; 748 sculpt_components = raw_image->getComponents();
836 749
837 sculpt_data = raw_image->getData(); 750 sculpt_data = raw_image->getData();
838 } 751 }
@@ -864,7 +777,7 @@ BOOL LLVOVolume::calcLOD()
864 } 777 }
865 778
866 //update face texture sizes on lod calculation 779 //update face texture sizes on lod calculation
867 // updateTextureVirtualSize(); 780 updateTextureVirtualSize();
868 781
869 S32 cur_detail = 0; 782 S32 cur_detail = 0;
870 783
@@ -1318,15 +1231,28 @@ S32 LLVOVolume::setTEColor(const U8 te, const LLColor3& color)
1318 1231
1319S32 LLVOVolume::setTEColor(const U8 te, const LLColor4& color) 1232S32 LLVOVolume::setTEColor(const U8 te, const LLColor4& color)
1320{ 1233{
1321 S32 res = LLViewerObject::setTEColor(te, color); 1234 S32 retval = 0;
1322 if (res && mDrawable.notNull()) 1235 const LLTextureEntry *tep = getTE(te);
1236 if (!tep)
1323 { 1237 {
1324 //gPipeline.markTextured(mDrawable); 1238 llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl;
1325 mDrawable->setState(LLDrawable::REBUILD_COLOR);
1326 dirtyMesh();
1327 //mFaceMappingChanged = TRUE;
1328 } 1239 }
1329 return res; 1240 else if (color != tep->getColor())
1241 {
1242 if (color.mV[3] != tep->getColor().mV[3])
1243 {
1244 gPipeline.markTextured(mDrawable);
1245 }
1246 retval = LLPrimitive::setTEColor(te, color);
1247 if (mDrawable.notNull() && retval)
1248 {
1249 // These should only happen on updates which are not the initial update.
1250 mDrawable->setState(LLDrawable::REBUILD_COLOR);
1251 dirtyMesh();
1252 }
1253 }
1254
1255 return retval;
1330} 1256}
1331 1257
1332S32 LLVOVolume::setTEBumpmap(const U8 te, const U8 bumpmap) 1258S32 LLVOVolume::setTEBumpmap(const U8 te, const U8 bumpmap)
@@ -1392,7 +1318,7 @@ S32 LLVOVolume::setTEBumpShinyFullbright(const U8 te, const U8 bump)
1392 gPipeline.markTextured(mDrawable); 1318 gPipeline.markTextured(mDrawable);
1393 mFaceMappingChanged = TRUE; 1319 mFaceMappingChanged = TRUE;
1394 } 1320 }
1395 return res; 1321 return res;
1396} 1322}
1397 1323
1398S32 LLVOVolume::setTEMediaFlags(const U8 te, const U8 media_flags) 1324S32 LLVOVolume::setTEMediaFlags(const U8 te, const U8 media_flags)
@@ -1461,40 +1387,6 @@ void LLVOVolume::updateTEData()
1461 1387
1462//---------------------------------------------------------------------------- 1388//----------------------------------------------------------------------------
1463 1389
1464void LLVOVolume::setLightTextureID(LLUUID id)
1465{
1466 if (id.notNull())
1467 {
1468 if (!hasLightTexture())
1469 {
1470 setParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE, TRUE, true);
1471 }
1472 LLLightImageParams* param_block = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE);
1473 if (param_block && param_block->getLightTexture() != id)
1474 {
1475 param_block->setLightTexture(id);
1476 parameterChanged(LLNetworkData::PARAMS_LIGHT_IMAGE, true);
1477 }
1478 }
1479 else
1480 {
1481 if (hasLightTexture())
1482 {
1483 setParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE, FALSE, true);
1484 }
1485 }
1486}
1487
1488void LLVOVolume::setSpotLightParams(LLVector3 params)
1489{
1490 LLLightImageParams* param_block = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE);
1491 if (param_block && param_block->getParams() != params)
1492 {
1493 param_block->setParams(params);
1494 parameterChanged(LLNetworkData::PARAMS_LIGHT_IMAGE, true);
1495 }
1496}
1497
1498void LLVOVolume::setIsLight(BOOL is_light) 1390void LLVOVolume::setIsLight(BOOL is_light)
1499{ 1391{
1500 if (is_light != getIsLight()) 1392 if (is_light != getIsLight())
@@ -1621,77 +1513,6 @@ LLColor3 LLVOVolume::getLightColor() const
1621 } 1513 }
1622} 1514}
1623 1515
1624LLUUID LLVOVolume::getLightTextureID() const
1625{
1626 const LLLightImageParams *param_block = (const LLLightImageParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE);
1627 if (param_block)
1628 {
1629 return param_block->getLightTexture();
1630 }
1631
1632 return LLUUID::null;
1633}
1634
1635
1636LLVector3 LLVOVolume::getSpotLightParams() const
1637{
1638 const LLLightImageParams *param_block = (const LLLightImageParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE);
1639 if (param_block)
1640 {
1641 return param_block->getParams();
1642 }
1643
1644 return LLVector3();
1645}
1646
1647F32 LLVOVolume::getSpotLightPriority() const
1648{
1649 return mSpotLightPriority;
1650}
1651
1652void LLVOVolume::updateSpotLightPriority()
1653{
1654 LLVector3 pos = mDrawable->getPositionAgent();
1655 LLVector3 at(0,0,-1);
1656 at *= getRenderRotation();
1657
1658 F32 r = getLightRadius()*0.5f;
1659
1660 pos += at * r;
1661
1662 at = LLViewerCamera::getInstance()->getAtAxis();
1663
1664 pos -= at * r;
1665
1666 mSpotLightPriority = gPipeline.calcPixelArea(pos, LLVector3(r,r,r), *LLViewerCamera::getInstance());
1667 // KL needed for S19?
1668 if (mLightTexture.notNull())
1669 {
1670 mLightTexture->addTextureStats(mSpotLightPriority);
1671 mLightTexture->setBoostLevel(LLViewerImageBoostLevel::BOOST_CLOUDS);
1672 }
1673}
1674
1675
1676LLViewerImage* LLVOVolume::getLightTexture()
1677{
1678 LLUUID id = getLightTextureID();
1679
1680 if (id.notNull())
1681 {
1682 if (mLightTexture.isNull() || id != mLightTexture->getID())
1683 {
1684 mLightTexture = gImageList.getImage(id);
1685 }
1686 }
1687 else
1688 {
1689 mLightTexture = NULL;
1690 }
1691
1692 return mLightTexture;
1693}
1694
1695F32 LLVOVolume::getLightIntensity() const 1516F32 LLVOVolume::getLightIntensity() const
1696{ 1517{
1697 const LLLightParams *param_block = (const LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT); 1518 const LLLightParams *param_block = (const LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT);
@@ -1783,16 +1604,6 @@ BOOL LLVOVolume::isSculpted() const
1783 return FALSE; 1604 return FALSE;
1784} 1605}
1785 1606
1786BOOL LLVOVolume::hasLightTexture() const
1787{
1788 if (getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE))
1789 {
1790 return TRUE;
1791 }
1792
1793 return FALSE;
1794}
1795
1796BOOL LLVOVolume::isVolumeGlobal() const 1607BOOL LLVOVolume::isVolumeGlobal() const
1797{ 1608{
1798 if (mVolumeImpl) 1609 if (mVolumeImpl)
@@ -2245,9 +2056,9 @@ U32 LLVOVolume::getPartitionType() const
2245} 2056}
2246 2057
2247LLVolumePartition::LLVolumePartition() 2058LLVolumePartition::LLVolumePartition()
2248: LLSpatialPartition(LLVOVolume::VERTEX_DATA_MASK, TRUE, GL_DYNAMIC_DRAW_ARB) // KL 2059: LLSpatialPartition(LLVOVolume::VERTEX_DATA_MASK, FALSE)
2249{ 2060{
2250 mLODPeriod = 32; // KL 32 in SD 2061 mLODPeriod = 16;
2251 mDepthMask = FALSE; 2062 mDepthMask = FALSE;
2252 mDrawableType = LLPipeline::RENDER_TYPE_VOLUME; 2063 mDrawableType = LLPipeline::RENDER_TYPE_VOLUME;
2253 mPartitionType = LLViewerRegion::PARTITION_VOLUME; 2064 mPartitionType = LLViewerRegion::PARTITION_VOLUME;
@@ -2256,10 +2067,10 @@ LLVolumePartition::LLVolumePartition()
2256} 2067}
2257 2068
2258LLVolumeBridge::LLVolumeBridge(LLDrawable* drawablep) 2069LLVolumeBridge::LLVolumeBridge(LLDrawable* drawablep)
2259: LLSpatialBridge(drawablep, TRUE, LLVOVolume::VERTEX_DATA_MASK) // KL SD 2070: LLSpatialBridge(drawablep, LLVOVolume::VERTEX_DATA_MASK)
2260{ 2071{
2261 mDepthMask = FALSE; 2072 mDepthMask = FALSE;
2262 mLODPeriod = 32; // KL 32 in SD 2073 mLODPeriod = 16;
2263 mDrawableType = LLPipeline::RENDER_TYPE_VOLUME; 2074 mDrawableType = LLPipeline::RENDER_TYPE_VOLUME;
2264 mPartitionType = LLViewerRegion::PARTITION_BRIDGE; 2075 mPartitionType = LLViewerRegion::PARTITION_BRIDGE;
2265 2076
@@ -2314,7 +2125,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
2314 2125
2315 U8 bump = (type == LLRenderPass::PASS_BUMP ? facep->getTextureEntry()->getBumpmap() : 0); 2126 U8 bump = (type == LLRenderPass::PASS_BUMP ? facep->getTextureEntry()->getBumpmap() : 0);
2316 2127
2317 LLImageGL* tex = facep->getGLTexture(); // LLViewerImage* tex = facep->getTexture(); // KL SD 2128 LLViewerImage* tex = facep->getTexture();
2318 2129
2319 U8 glow = 0; 2130 U8 glow = 0;
2320 2131
@@ -2325,7 +2136,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
2325 2136
2326 if (facep->mVertexBuffer.isNull()) 2137 if (facep->mVertexBuffer.isNull())
2327 { 2138 {
2328 llwarns << "WTF?" << llendl; 2139 llerrs << "WTF?" << llendl;
2329 } 2140 }
2330 2141
2331 if (idx >= 0 && 2142 if (idx >= 0 &&
@@ -2356,7 +2167,6 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
2356 U32 offset = facep->getIndicesStart(); 2167 U32 offset = facep->getIndicesStart();
2357 U32 count = facep->getIndicesCount(); 2168 U32 count = facep->getIndicesCount();
2358 LLPointer<LLDrawInfo> draw_info = new LLDrawInfo(start,end,count,offset,tex, 2169 LLPointer<LLDrawInfo> draw_info = new LLDrawInfo(start,end,count,offset,tex,
2359 (LLImageGL*)facep->getTexture() == tex ? facep->getTexture() : NULL,
2360 facep->mVertexBuffer, fullbright, bump); 2170 facep->mVertexBuffer, fullbright, bump);
2361 draw_info->mGroup = group; 2171 draw_info->mGroup = group;
2362 draw_info->mVSize = facep->getVirtualSize(); 2172 draw_info->mVSize = facep->getVirtualSize();
@@ -2449,11 +2259,9 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2449 2259
2450 LLVOVolume* vobj = drawablep->getVOVolume(); 2260 LLVOVolume* vobj = drawablep->getVOVolume();
2451 llassert_always(vobj); 2261 llassert_always(vobj);
2452 vobj->updateTextures(); 2262 vobj->updateTextureVirtualSize();
2453 vobj->preRebuild(); 2263 vobj->preRebuild();
2454 2264
2455 drawablep->clearState(LLDrawable::HAS_ALPHA); // KL SD
2456
2457 //for each face 2265 //for each face
2458 for (S32 i = 0; i < drawablep->getNumFaces(); i++) 2266 for (S32 i = 0; i < drawablep->getNumFaces(); i++)
2459 { 2267 {
@@ -2522,7 +2330,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2522 } 2330 }
2523 else 2331 else
2524 { 2332 {
2525 drawablep->setState(LLDrawable::HAS_ALPHA); // KL SD
2526 alpha_faces.push_back(facep); 2333 alpha_faces.push_back(facep);
2527 } 2334 }
2528 } 2335 }
@@ -2546,7 +2353,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2546 } 2353 }
2547 else 2354 else
2548 { //doesn't need normal 2355 { //doesn't need normal
2549 //facep->setState(LLFace::FULLBRIGHT); 2356 facep->setState(LLFace::FULLBRIGHT);
2550 fullbright_faces.push_back(facep); 2357 fullbright_faces.push_back(facep);
2551 } 2358 }
2552 } 2359 }
@@ -2556,14 +2363,14 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2556 { //needs normal + binormal 2363 { //needs normal + binormal
2557 bump_faces.push_back(facep); 2364 bump_faces.push_back(facep);
2558 } 2365 }
2559 else if (te->getShiny() && LLPipeline::sRenderBump || 2366 else if ((te->getShiny() && LLPipeline::sRenderBump) ||
2560 !te->getFullbright()) 2367 !te->getFullbright())
2561 { //needs normal 2368 { //needs normal
2562 simple_faces.push_back(facep); 2369 simple_faces.push_back(facep);
2563 } 2370 }
2564 else 2371 else
2565 { //doesn't need normal 2372 { //doesn't need normal
2566 // facep->setState(LLFace::FULLBRIGHT); 2373 facep->setState(LLFace::FULLBRIGHT);
2567 fullbright_faces.push_back(facep); 2374 fullbright_faces.push_back(facep);
2568 } 2375 }
2569 } 2376 }
@@ -2611,7 +2418,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2611 2418
2612 if (LLPipeline::sDelayVBUpdate) 2419 if (LLPipeline::sDelayVBUpdate)
2613 { 2420 {
2614 group->setState(LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO); // KL SD 2421 group->setState(LLSpatialGroup::MESH_DIRTY);
2615 } 2422 }
2616 2423
2617 mFaceList.clear(); 2424 mFaceList.clear();
@@ -2619,7 +2426,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2619 2426
2620void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) 2427void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
2621{ 2428{
2622 if (group->isState(LLSpatialGroup::MESH_DIRTY) && !group->isState(LLSpatialGroup::GEOM_DIRTY)) // KL SD 2429 if (group->isState(LLSpatialGroup::MESH_DIRTY))
2623 { 2430 {
2624 S32 num_mapped_veretx_buffer = LLVertexBuffer::sMappedCount ; 2431 S32 num_mapped_veretx_buffer = LLVertexBuffer::sMappedCount ;
2625 2432
@@ -2697,7 +2504,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
2697 } 2504 }
2698 } 2505 }
2699 2506
2700 group->clearState(LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO); // KL SD 2507 group->clearState(LLSpatialGroup::MESH_DIRTY);
2701 } 2508 }
2702} 2509}
2703 2510
@@ -2723,7 +2530,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2723 2530
2724 LLSpatialGroup::buffer_map_t buffer_map; 2531 LLSpatialGroup::buffer_map_t buffer_map;
2725 2532
2726 LLImageGL* last_tex = NULL;// LLViewerImage* last_tex = NULL; // KL SD 2533 LLViewerImage* last_tex = NULL;
2727 S32 buffer_index = 0; 2534 S32 buffer_index = 0;
2728 2535
2729 if (distance_sort) 2536 if (distance_sort)
@@ -2735,7 +2542,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2735 { 2542 {
2736 //pull off next face 2543 //pull off next face
2737 LLFace* facep = *face_iter; 2544 LLFace* facep = *face_iter;
2738 LLImageGL* tex = facep->getGLTexture(); // LLViewerImage* tex = facep->getTexture(); // KL SD 2545 LLViewerImage* tex = facep->getTexture();
2739 2546
2740 if (distance_sort) 2547 if (distance_sort)
2741 { 2548 {
@@ -2760,7 +2567,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2760 ++i; 2567 ++i;
2761 2568
2762 while (i != faces.end() && 2569 while (i != faces.end() &&
2763 (LLPipeline::sTextureBindTest || (distance_sort || (*i)->getGLTexture() == tex))) // KL SD getTexture 2570 (LLPipeline::sTextureBindTest || (distance_sort || (*i)->getTexture() == tex)))
2764 { 2571 {
2765 facep = *i; 2572 facep = *i;
2766 2573
@@ -2843,11 +2650,6 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2843 2650
2844 BOOL force_simple = facep->mPixelArea < FORCE_SIMPLE_RENDER_AREA; 2651 BOOL force_simple = facep->mPixelArea < FORCE_SIMPLE_RENDER_AREA;
2845 BOOL fullbright = facep->isState(LLFace::FULLBRIGHT); 2652 BOOL fullbright = facep->isState(LLFace::FULLBRIGHT);
2846 if ((mask & LLVertexBuffer::MAP_NORMAL) == 0) // KL SD
2847 { //paranoia check to make sure GL doesn't try to read non-existant normals
2848 fullbright = TRUE;
2849 }
2850
2851 const LLTextureEntry* te = facep->getTextureEntry(); 2653 const LLTextureEntry* te = facep->getTextureEntry();
2852 2654
2853 BOOL is_alpha = facep->getPoolType() == LLDrawPool::POOL_ALPHA ? TRUE : FALSE; 2655 BOOL is_alpha = facep->getPoolType() == LLDrawPool::POOL_ALPHA ? TRUE : FALSE;
@@ -2899,7 +2701,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2899 } 2701 }
2900 else 2702 else
2901 { 2703 {
2902 // llassert(mask & LLVertexBuffer::MAP_NORMAL); 2704 llassert(mask & LLVertexBuffer::MAP_NORMAL);
2903 registerFace(group, facep, LLRenderPass::PASS_SIMPLE); 2705 registerFace(group, facep, LLRenderPass::PASS_SIMPLE);
2904 } 2706 }
2905 } 2707 }
@@ -2930,7 +2732,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2930 } 2732 }
2931 else 2733 else
2932 { 2734 {
2933 // llassert(mask & LLVertexBuffer::MAP_NORMAL); 2735 llassert(mask & LLVertexBuffer::MAP_NORMAL);
2934 registerFace(group, facep, LLRenderPass::PASS_SIMPLE); 2736 registerFace(group, facep, LLRenderPass::PASS_SIMPLE);
2935 } 2737 }
2936 } 2738 }
@@ -2943,8 +2745,8 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2943 2745
2944 if (!is_alpha && !LLPipeline::sRenderDeferred) 2746 if (!is_alpha && !LLPipeline::sRenderDeferred)
2945 { 2747 {
2946 // llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright); 2748 llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright);
2947 facep->setPoolType(LLDrawPool::POOL_SIMPLE); // facep->setPoolType((fullbright) ? LLDrawPool::POOL_FULLBRIGHT : LLDrawPool::POOL_SIMPLE); 2749 facep->setPoolType((fullbright) ? LLDrawPool::POOL_FULLBRIGHT : LLDrawPool::POOL_SIMPLE);
2948 2750
2949 if (!force_simple && te->getBumpmap()) 2751 if (!force_simple && te->getBumpmap())
2950 { 2752 {
@@ -3023,7 +2825,7 @@ LLHUDPartition::LLHUDPartition()
3023 mPartitionType = LLViewerRegion::PARTITION_HUD; 2825 mPartitionType = LLViewerRegion::PARTITION_HUD;
3024 mDrawableType = LLPipeline::RENDER_TYPE_HUD; 2826 mDrawableType = LLPipeline::RENDER_TYPE_HUD;
3025 mSlopRatio = 0.f; 2827 mSlopRatio = 0.f;
3026 mLODPeriod = 32; // KL 32 in SD 2828 mLODPeriod = 1;
3027} 2829}
3028 2830
3029void LLHUDPartition::shift(const LLVector3 &offset) 2831void LLHUDPartition::shift(const LLVector3 &offset)