aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvovolume.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llvovolume.cpp424
1 files changed, 311 insertions, 113 deletions
diff --git a/linden/indra/newview/llvovolume.cpp b/linden/indra/newview/llvovolume.cpp
index bed3e13..77c9c33 100644
--- a/linden/indra/newview/llvovolume.cpp
+++ b/linden/indra/newview/llvovolume.cpp
@@ -54,6 +54,7 @@
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
57#include "llsky.h" 58#include "llsky.h"
58#include "lltexturefetch.h" 59#include "lltexturefetch.h"
59#include "llviewercamera.h" 60#include "llviewercamera.h"
@@ -67,6 +68,9 @@
67const S32 MIN_QUIET_FRAMES_COALESCE = 30; 68const S32 MIN_QUIET_FRAMES_COALESCE = 30;
68const F32 FORCE_SIMPLE_RENDER_AREA = 512.f; 69const F32 FORCE_SIMPLE_RENDER_AREA = 512.f;
69const F32 FORCE_CULL_AREA = 8.f; 70const F32 FORCE_CULL_AREA = 8.f;
71const F32 MAX_LOD_DISTANCE = 24.f;
72const S32 MAX_SCULPT_REZ = 128;
73
70 74
71BOOL gAnimateTextures = TRUE; 75BOOL gAnimateTextures = TRUE;
72extern BOOL gHideSelectedObjects; 76extern BOOL gHideSelectedObjects;
@@ -91,6 +95,7 @@ LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *re
91 mNumFaces = 0; 95 mNumFaces = 0;
92 mLODChanged = FALSE; 96 mLODChanged = FALSE;
93 mSculptChanged = FALSE; 97 mSculptChanged = FALSE;
98 mSpotLightPriority = 0.f;
94} 99}
95 100
96LLVOVolume::~LLVOVolume() 101LLVOVolume::~LLVOVolume()
@@ -214,7 +219,7 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys,
214 std::string mask; 219 std::string mask;
215 mask = gDirUtilp->getDirDelimiter() + "*.slc"; 220 mask = gDirUtilp->getDirDelimiter() + "*.slc";
216 gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""), mask); 221 gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""), mask);
217// llerrs << "Bogus TE data in " << getID() << ", crashing!" << llendl; 222// llwarns << "Bogus TE data in " << getID() << ", crashing!" << llendl;
218 llwarns << "Bogus TE data in " << getID() << llendl; 223 llwarns << "Bogus TE data in " << getID() << llendl;
219 } 224 }
220 else if (res2 & (TEM_CHANGE_TEXTURE|TEM_CHANGE_COLOR)) 225 else if (res2 & (TEM_CHANGE_TEXTURE|TEM_CHANGE_COLOR))
@@ -314,11 +319,6 @@ void LLVOVolume::animateTextures()
314 te->getScale(&scale_s, &scale_t); 319 te->getScale(&scale_s, &scale_t);
315 } 320 }
316 321
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,7 +326,43 @@ 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 tex_mat.translate(LLVector3(-0.5f, -0.5f, 0.f)); 329 LLVector3 trans ;
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
330 tex_mat.rotate(quat); 366 tex_mat.rotate(quat);
331 367
332 LLMatrix4 mat; 368 LLMatrix4 mat;
@@ -403,30 +439,28 @@ BOOL LLVOVolume::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
403 return TRUE; 439 return TRUE;
404} 440}
405 441
406void LLVOVolume::updateTextures() 442void LLVOVolume::updateTextures(LLAgent &agent) // KL sd
407{ 443{
408 const F32 TEXTURE_AREA_REFRESH_TIME = 5.f; // seconds 444 const F32 TEXTURE_AREA_REFRESH_TIME = 5.f; // seconds
409 if (mTextureUpdateTimer.getElapsedTimeF32() > TEXTURE_AREA_REFRESH_TIME) 445 if (mDrawable.notNull() && mTextureUpdateTimer.getElapsedTimeF32() > TEXTURE_AREA_REFRESH_TIME)
410 { 446 {
411 updateTextureVirtualSize(); 447 if (mDrawable->isVisible())
448 {
449 updateTextures();
450 }
412 } 451 }
413} 452}
414 453
415void LLVOVolume::updateTextureVirtualSize() 454void LLVOVolume::updateTextures()
416{ 455{
417 // Update the pixel area of all faces 456 // Update the pixel area of all faces
418 457
419 if(mDrawable.isNull() || !mDrawable->isVisible())
420 {
421 return ;
422 }
423
424 if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SIMPLE)) 458 if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SIMPLE))
425 { 459 {
426 return; 460 return;
427 } 461 }
428 462
429 if (LLViewerImage::sDontLoadVolumeTextures || LLAppViewer::getTextureFetch()->mDebugPause) 463 if (LLViewerImage::sDontLoadVolumeTextures || mDrawable.isNull()) // || !mDrawable->isVisible())
430 { 464 {
431 return; 465 return;
432 } 466 }
@@ -443,15 +477,14 @@ void LLVOVolume::updateTextureVirtualSize()
443 LLFace* face = mDrawable->getFace(i); 477 LLFace* face = mDrawable->getFace(i);
444 const LLTextureEntry *te = face->getTextureEntry(); 478 const LLTextureEntry *te = face->getTextureEntry();
445 LLViewerImage *imagep = face->getTexture(); 479 LLViewerImage *imagep = face->getTexture();
446 if (!imagep || !te || 480 if (!imagep || !te ||
447 face->mExtents[0] == face->mExtents[1]) 481 face->mExtents[0] == face->mExtents[1])
448 { 482 {
449 continue; 483 continue;
450 } 484 }
451 485
452 F32 vsize; 486 F32 vsize;
453 F32 old_size = face->getVirtualSize(); 487
454
455 if (isHUDAttachment()) 488 if (isHUDAttachment())
456 { 489 {
457 F32 area = (F32) LLViewerCamera::getInstance()->getScreenPixelArea(); 490 F32 area = (F32) LLViewerCamera::getInstance()->getScreenPixelArea();
@@ -461,21 +494,24 @@ void LLVOVolume::updateTextureVirtualSize()
461 } 494 }
462 else 495 else
463 { 496 {
464 vsize = face->getTextureVirtualSize(); 497 vsize = getTextureVirtualSize(face);
465 } 498 }
466 499
467 mPixelArea = llmax(mPixelArea, face->getPixelArea()); 500 mPixelArea = llmax(mPixelArea, face->getPixelArea());
501
502 F32 old_size = face->getVirtualSize();
468 503
469 if (face->mTextureMatrix != NULL) 504 if (face->mTextureMatrix != NULL)
470 { 505 {
471 if ((vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE) || 506 if (vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE ||
472 (vsize > MIN_TEX_ANIM_SIZE && old_size < MIN_TEX_ANIM_SIZE)) 507 vsize > MIN_TEX_ANIM_SIZE && old_size < MIN_TEX_ANIM_SIZE)
473 { 508 {
474 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD, FALSE); 509 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD, FALSE);
475 } 510 }
476 } 511 }
477 512
478 face->setVirtualSize(vsize); 513 face->setVirtualSize(vsize);
514 // imagep->addTextureStats(vsize);
479 if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA)) 515 if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA))
480 { 516 {
481 if (vsize < min_vsize) min_vsize = vsize; 517 if (vsize < min_vsize) min_vsize = vsize;
@@ -503,46 +539,46 @@ void LLVOVolume::updateTextureVirtualSize()
503 mSculptTexture = gImageList.getImage(id); 539 mSculptTexture = gImageList.getImage(id);
504 if (mSculptTexture.notNull()) 540 if (mSculptTexture.notNull())
505 { 541 {
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);
506 mSculptTexture->setBoostLevel(llmax((S32)mSculptTexture->getBoostLevel(), 546 mSculptTexture->setBoostLevel(llmax((S32)mSculptTexture->getBoostLevel(),
507 (S32)LLViewerImageBoostLevel::BOOST_SCULPTED)); 547 (S32)LLViewerImageBoostLevel::BOOST_SCULPTED));
508 mSculptTexture->setForSculpt() ; 548 }
509
510 if(!mSculptTexture->isCachedRawImageReady())
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;
528 549
529 if (texture_discard >= 0 && //texture has some data available 550 S32 texture_discard = mSculptTexture->getDiscardLevel(); //try to match the texture
530 (texture_discard < current_discard || //texture has more data than last rebuild 551 S32 current_discard = mSculptLevel;
531 current_discard < 0)) //no previous rebuild
532 {
533 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE);
534 mSculptChanged = TRUE;
535 }
536 552
537 if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SCULPTED)) 553 if (texture_discard >= 0 && //texture has some data available
554 (texture_discard < current_discard || //texture has more data than last rebuild
555 current_discard < 0)) //no previous rebuild
556 {
557 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE);
558 mSculptChanged = TRUE;
559 }
560
561 if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SCULPTED))
538 { 562 {
539 setDebugText(llformat("T%d C%d V%d\n%dx%d", 563 setDebugText(llformat("T%d C%d V%d\n%dx%d",
540 texture_discard, current_discard, getVolume()->getSculptLevel(), 564 texture_discard, current_discard, getVolume()->getSculptLevel(),
541 mSculptTexture->getHeight(), mSculptTexture->getWidth())); 565 mSculptTexture->getHeight(), mSculptTexture->getWidth()));
542 } 566 }
543 }
544 } 567 }
545 568
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 }
546 582
547 if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA)) 583 if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA))
548 { 584 {
@@ -563,6 +599,36 @@ void LLVOVolume::updateTextureVirtualSize()
563 } 599 }
564} 600}
565 601
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
566BOOL LLVOVolume::isActive() const 632BOOL LLVOVolume::isActive() const
567{ 633{
568 return !mStatic || mTextureAnimp || (mVolumeImpl && mVolumeImpl->isActive()); 634 return !mStatic || mTextureAnimp || (mVolumeImpl && mVolumeImpl->isActive());
@@ -699,21 +765,31 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &volume_params, const S32 detail
699 765
700// sculpt replaces generate() for sculpted surfaces 766// sculpt replaces generate() for sculpted surfaces
701void LLVOVolume::sculpt() 767void LLVOVolume::sculpt()
702{ 768{
769 U16 sculpt_height = 0;
770 U16 sculpt_width = 0;
771 S8 sculpt_components = 0;
772 const U8* sculpt_data = NULL;
773
703 if (mSculptTexture.notNull()) 774 if (mSculptTexture.notNull())
704 { 775 {
705 U16 sculpt_height = 0; 776 S32 discard_level;
706 U16 sculpt_width = 0; 777 S32 desired_discard = 0; // lower discard levels have MUCH less resolution
707 S8 sculpt_components = 0; 778
708 const U8* sculpt_data = NULL; 779 discard_level = desired_discard;
709
710 S32 discard_level = mSculptTexture->getCachedRawImageLevel() ;
711 LLImageRaw* raw_image = mSculptTexture->getCachedRawImage() ;
712 780
713 S32 max_discard = mSculptTexture->getMaxDiscardLevel(); 781 S32 max_discard = mSculptTexture->getMaxDiscardLevel();
714 if (discard_level > max_discard) 782 if (discard_level > max_discard)
715 discard_level = max_discard; // clamp to the best we can do 783 discard_level = max_discard; // clamp to the best we can do
716 784
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
717 S32 current_discard = getVolume()->getSculptLevel(); 793 S32 current_discard = getVolume()->getSculptLevel();
718 if(current_discard < -2) 794 if(current_discard < -2)
719 { 795 {
@@ -735,17 +811,28 @@ void LLVOVolume::sculpt()
735 if (current_discard == discard_level) // no work to do here 811 if (current_discard == discard_level) // no work to do here
736 return; 812 return;
737 813
738 if(!raw_image) 814 LLPointer<LLImageRaw> raw_image = new LLImageRaw();
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)
739 { 826 {
740 sculpt_width = 0; 827 sculpt_width = 0;
741 sculpt_height = 0; 828 sculpt_height = 0;
742 sculpt_data = NULL ; 829 sculpt_data = NULL ;
743 } 830 }
744 else 831 else
745 { 832 {
746 sculpt_height = raw_image->getHeight(); 833 if (raw_image->getDataSize() < sculpt_height * sculpt_width * sculpt_components)
747 sculpt_width = raw_image->getWidth(); 834 llwarns << "Sculpt: image data size = " << raw_image->getDataSize()
748 sculpt_components = raw_image->getComponents(); 835 << " < " << sculpt_height << " x " << sculpt_width << " x " <<sculpt_components << llendl;
749 836
750 sculpt_data = raw_image->getData(); 837 sculpt_data = raw_image->getData();
751 } 838 }
@@ -777,7 +864,7 @@ BOOL LLVOVolume::calcLOD()
777 } 864 }
778 865
779 //update face texture sizes on lod calculation 866 //update face texture sizes on lod calculation
780 updateTextureVirtualSize(); 867 // updateTextureVirtualSize();
781 868
782 S32 cur_detail = 0; 869 S32 cur_detail = 0;
783 870
@@ -1231,28 +1318,15 @@ S32 LLVOVolume::setTEColor(const U8 te, const LLColor3& color)
1231 1318
1232S32 LLVOVolume::setTEColor(const U8 te, const LLColor4& color) 1319S32 LLVOVolume::setTEColor(const U8 te, const LLColor4& color)
1233{ 1320{
1234 S32 retval = 0; 1321 S32 res = LLViewerObject::setTEColor(te, color);
1235 const LLTextureEntry *tep = getTE(te); 1322 if (res && mDrawable.notNull())
1236 if (!tep)
1237 { 1323 {
1238 llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl; 1324 //gPipeline.markTextured(mDrawable);
1325 mDrawable->setState(LLDrawable::REBUILD_COLOR);
1326 dirtyMesh();
1327 //mFaceMappingChanged = TRUE;
1239 } 1328 }
1240 else if (color != tep->getColor()) 1329 return res;
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;
1256} 1330}
1257 1331
1258S32 LLVOVolume::setTEBumpmap(const U8 te, const U8 bumpmap) 1332S32 LLVOVolume::setTEBumpmap(const U8 te, const U8 bumpmap)
@@ -1318,7 +1392,7 @@ S32 LLVOVolume::setTEBumpShinyFullbright(const U8 te, const U8 bump)
1318 gPipeline.markTextured(mDrawable); 1392 gPipeline.markTextured(mDrawable);
1319 mFaceMappingChanged = TRUE; 1393 mFaceMappingChanged = TRUE;
1320 } 1394 }
1321 return res; 1395 return res;
1322} 1396}
1323 1397
1324S32 LLVOVolume::setTEMediaFlags(const U8 te, const U8 media_flags) 1398S32 LLVOVolume::setTEMediaFlags(const U8 te, const U8 media_flags)
@@ -1387,6 +1461,40 @@ void LLVOVolume::updateTEData()
1387 1461
1388//---------------------------------------------------------------------------- 1462//----------------------------------------------------------------------------
1389 1463
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
1390void LLVOVolume::setIsLight(BOOL is_light) 1498void LLVOVolume::setIsLight(BOOL is_light)
1391{ 1499{
1392 if (is_light != getIsLight()) 1500 if (is_light != getIsLight())
@@ -1513,6 +1621,77 @@ LLColor3 LLVOVolume::getLightColor() const
1513 } 1621 }
1514} 1622}
1515 1623
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
1516F32 LLVOVolume::getLightIntensity() const 1695F32 LLVOVolume::getLightIntensity() const
1517{ 1696{
1518 const LLLightParams *param_block = (const LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT); 1697 const LLLightParams *param_block = (const LLLightParams *)getParameterEntry(LLNetworkData::PARAMS_LIGHT);
@@ -1604,6 +1783,16 @@ BOOL LLVOVolume::isSculpted() const
1604 return FALSE; 1783 return FALSE;
1605} 1784}
1606 1785
1786BOOL LLVOVolume::hasLightTexture() const
1787{
1788 if (getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE))
1789 {
1790 return TRUE;
1791 }
1792
1793 return FALSE;
1794}
1795
1607BOOL LLVOVolume::isVolumeGlobal() const 1796BOOL LLVOVolume::isVolumeGlobal() const
1608{ 1797{
1609 if (mVolumeImpl) 1798 if (mVolumeImpl)
@@ -1694,7 +1883,7 @@ void LLVOVolume::generateSilhouette(LLSelectNode* nodep, const LLVector3& view_p
1694 trans_mat.translate(getRegion()->getOriginAgent()); 1883 trans_mat.translate(getRegion()->getOriginAgent());
1695 } 1884 }
1696 1885
1697 volume->generateSilhouetteVertices(nodep->mSilhouetteVertices, nodep->mSilhouetteNormals, nodep->mSilhouetteSegments, view_vector, trans_mat, mRelativeXformInvTrans); 1886 volume->generateSilhouetteVertices(nodep->mSilhouetteVertices, nodep->mSilhouetteNormals, nodep->mSilhouetteSegments, view_vector, trans_mat, mRelativeXformInvTrans, nodep->getTESelectMask());
1698 1887
1699 nodep->mSilhouetteExists = TRUE; 1888 nodep->mSilhouetteExists = TRUE;
1700 } 1889 }
@@ -2056,9 +2245,9 @@ U32 LLVOVolume::getPartitionType() const
2056} 2245}
2057 2246
2058LLVolumePartition::LLVolumePartition() 2247LLVolumePartition::LLVolumePartition()
2059: LLSpatialPartition(LLVOVolume::VERTEX_DATA_MASK, FALSE) 2248: LLSpatialPartition(LLVOVolume::VERTEX_DATA_MASK, TRUE, GL_DYNAMIC_DRAW_ARB) // KL
2060{ 2249{
2061 mLODPeriod = 16; 2250 mLODPeriod = 32; // KL 32 in SD
2062 mDepthMask = FALSE; 2251 mDepthMask = FALSE;
2063 mDrawableType = LLPipeline::RENDER_TYPE_VOLUME; 2252 mDrawableType = LLPipeline::RENDER_TYPE_VOLUME;
2064 mPartitionType = LLViewerRegion::PARTITION_VOLUME; 2253 mPartitionType = LLViewerRegion::PARTITION_VOLUME;
@@ -2067,10 +2256,10 @@ LLVolumePartition::LLVolumePartition()
2067} 2256}
2068 2257
2069LLVolumeBridge::LLVolumeBridge(LLDrawable* drawablep) 2258LLVolumeBridge::LLVolumeBridge(LLDrawable* drawablep)
2070: LLSpatialBridge(drawablep, LLVOVolume::VERTEX_DATA_MASK) 2259: LLSpatialBridge(drawablep, TRUE, LLVOVolume::VERTEX_DATA_MASK) // KL SD
2071{ 2260{
2072 mDepthMask = FALSE; 2261 mDepthMask = FALSE;
2073 mLODPeriod = 16; 2262 mLODPeriod = 32; // KL 32 in SD
2074 mDrawableType = LLPipeline::RENDER_TYPE_VOLUME; 2263 mDrawableType = LLPipeline::RENDER_TYPE_VOLUME;
2075 mPartitionType = LLViewerRegion::PARTITION_BRIDGE; 2264 mPartitionType = LLViewerRegion::PARTITION_BRIDGE;
2076 2265
@@ -2125,7 +2314,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
2125 2314
2126 U8 bump = (type == LLRenderPass::PASS_BUMP ? facep->getTextureEntry()->getBumpmap() : 0); 2315 U8 bump = (type == LLRenderPass::PASS_BUMP ? facep->getTextureEntry()->getBumpmap() : 0);
2127 2316
2128 LLViewerImage* tex = facep->getTexture(); 2317 LLImageGL* tex = facep->getGLTexture(); // LLViewerImage* tex = facep->getTexture(); // KL SD
2129 2318
2130 U8 glow = 0; 2319 U8 glow = 0;
2131 2320
@@ -2136,7 +2325,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
2136 2325
2137 if (facep->mVertexBuffer.isNull()) 2326 if (facep->mVertexBuffer.isNull())
2138 { 2327 {
2139 llerrs << "WTF?" << llendl; 2328 llwarns << "WTF?" << llendl;
2140 } 2329 }
2141 2330
2142 if (idx >= 0 && 2331 if (idx >= 0 &&
@@ -2167,6 +2356,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
2167 U32 offset = facep->getIndicesStart(); 2356 U32 offset = facep->getIndicesStart();
2168 U32 count = facep->getIndicesCount(); 2357 U32 count = facep->getIndicesCount();
2169 LLPointer<LLDrawInfo> draw_info = new LLDrawInfo(start,end,count,offset,tex, 2358 LLPointer<LLDrawInfo> draw_info = new LLDrawInfo(start,end,count,offset,tex,
2359 (LLImageGL*)facep->getTexture() == tex ? facep->getTexture() : NULL,
2170 facep->mVertexBuffer, fullbright, bump); 2360 facep->mVertexBuffer, fullbright, bump);
2171 draw_info->mGroup = group; 2361 draw_info->mGroup = group;
2172 draw_info->mVSize = facep->getVirtualSize(); 2362 draw_info->mVSize = facep->getVirtualSize();
@@ -2259,9 +2449,11 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2259 2449
2260 LLVOVolume* vobj = drawablep->getVOVolume(); 2450 LLVOVolume* vobj = drawablep->getVOVolume();
2261 llassert_always(vobj); 2451 llassert_always(vobj);
2262 vobj->updateTextureVirtualSize(); 2452 vobj->updateTextures();
2263 vobj->preRebuild(); 2453 vobj->preRebuild();
2264 2454
2455 drawablep->clearState(LLDrawable::HAS_ALPHA); // KL SD
2456
2265 //for each face 2457 //for each face
2266 for (S32 i = 0; i < drawablep->getNumFaces(); i++) 2458 for (S32 i = 0; i < drawablep->getNumFaces(); i++)
2267 { 2459 {
@@ -2330,6 +2522,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2330 } 2522 }
2331 else 2523 else
2332 { 2524 {
2525 drawablep->setState(LLDrawable::HAS_ALPHA); // KL SD
2333 alpha_faces.push_back(facep); 2526 alpha_faces.push_back(facep);
2334 } 2527 }
2335 } 2528 }
@@ -2353,7 +2546,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2353 } 2546 }
2354 else 2547 else
2355 { //doesn't need normal 2548 { //doesn't need normal
2356 facep->setState(LLFace::FULLBRIGHT); 2549 //facep->setState(LLFace::FULLBRIGHT);
2357 fullbright_faces.push_back(facep); 2550 fullbright_faces.push_back(facep);
2358 } 2551 }
2359 } 2552 }
@@ -2363,14 +2556,14 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2363 { //needs normal + binormal 2556 { //needs normal + binormal
2364 bump_faces.push_back(facep); 2557 bump_faces.push_back(facep);
2365 } 2558 }
2366 else if ((te->getShiny() && LLPipeline::sRenderBump) || 2559 else if (te->getShiny() && LLPipeline::sRenderBump ||
2367 !te->getFullbright()) 2560 !te->getFullbright())
2368 { //needs normal 2561 { //needs normal
2369 simple_faces.push_back(facep); 2562 simple_faces.push_back(facep);
2370 } 2563 }
2371 else 2564 else
2372 { //doesn't need normal 2565 { //doesn't need normal
2373 facep->setState(LLFace::FULLBRIGHT); 2566 // facep->setState(LLFace::FULLBRIGHT);
2374 fullbright_faces.push_back(facep); 2567 fullbright_faces.push_back(facep);
2375 } 2568 }
2376 } 2569 }
@@ -2418,7 +2611,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2418 2611
2419 if (LLPipeline::sDelayVBUpdate) 2612 if (LLPipeline::sDelayVBUpdate)
2420 { 2613 {
2421 group->setState(LLSpatialGroup::MESH_DIRTY); 2614 group->setState(LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO); // KL SD
2422 } 2615 }
2423 2616
2424 mFaceList.clear(); 2617 mFaceList.clear();
@@ -2426,7 +2619,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2426 2619
2427void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) 2620void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
2428{ 2621{
2429 if (group->isState(LLSpatialGroup::MESH_DIRTY)) 2622 if (group->isState(LLSpatialGroup::MESH_DIRTY) && !group->isState(LLSpatialGroup::GEOM_DIRTY)) // KL SD
2430 { 2623 {
2431 S32 num_mapped_veretx_buffer = LLVertexBuffer::sMappedCount ; 2624 S32 num_mapped_veretx_buffer = LLVertexBuffer::sMappedCount ;
2432 2625
@@ -2504,7 +2697,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
2504 } 2697 }
2505 } 2698 }
2506 2699
2507 group->clearState(LLSpatialGroup::MESH_DIRTY); 2700 group->clearState(LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO); // KL SD
2508 } 2701 }
2509} 2702}
2510 2703
@@ -2530,7 +2723,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2530 2723
2531 LLSpatialGroup::buffer_map_t buffer_map; 2724 LLSpatialGroup::buffer_map_t buffer_map;
2532 2725
2533 LLViewerImage* last_tex = NULL; 2726 LLImageGL* last_tex = NULL;// LLViewerImage* last_tex = NULL; // KL SD
2534 S32 buffer_index = 0; 2727 S32 buffer_index = 0;
2535 2728
2536 if (distance_sort) 2729 if (distance_sort)
@@ -2542,7 +2735,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2542 { 2735 {
2543 //pull off next face 2736 //pull off next face
2544 LLFace* facep = *face_iter; 2737 LLFace* facep = *face_iter;
2545 LLViewerImage* tex = facep->getTexture(); 2738 LLImageGL* tex = facep->getGLTexture(); // LLViewerImage* tex = facep->getTexture(); // KL SD
2546 2739
2547 if (distance_sort) 2740 if (distance_sort)
2548 { 2741 {
@@ -2567,7 +2760,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2567 ++i; 2760 ++i;
2568 2761
2569 while (i != faces.end() && 2762 while (i != faces.end() &&
2570 (LLPipeline::sTextureBindTest || (distance_sort || (*i)->getTexture() == tex))) 2763 (LLPipeline::sTextureBindTest || (distance_sort || (*i)->getGLTexture() == tex))) // KL SD getTexture
2571 { 2764 {
2572 facep = *i; 2765 facep = *i;
2573 2766
@@ -2650,6 +2843,11 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2650 2843
2651 BOOL force_simple = facep->mPixelArea < FORCE_SIMPLE_RENDER_AREA; 2844 BOOL force_simple = facep->mPixelArea < FORCE_SIMPLE_RENDER_AREA;
2652 BOOL fullbright = facep->isState(LLFace::FULLBRIGHT); 2845 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
2653 const LLTextureEntry* te = facep->getTextureEntry(); 2851 const LLTextureEntry* te = facep->getTextureEntry();
2654 2852
2655 BOOL is_alpha = facep->getPoolType() == LLDrawPool::POOL_ALPHA ? TRUE : FALSE; 2853 BOOL is_alpha = facep->getPoolType() == LLDrawPool::POOL_ALPHA ? TRUE : FALSE;
@@ -2701,7 +2899,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2701 } 2899 }
2702 else 2900 else
2703 { 2901 {
2704 llassert(mask & LLVertexBuffer::MAP_NORMAL); 2902 // llassert(mask & LLVertexBuffer::MAP_NORMAL);
2705 registerFace(group, facep, LLRenderPass::PASS_SIMPLE); 2903 registerFace(group, facep, LLRenderPass::PASS_SIMPLE);
2706 } 2904 }
2707 } 2905 }
@@ -2732,7 +2930,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2732 } 2930 }
2733 else 2931 else
2734 { 2932 {
2735 llassert(mask & LLVertexBuffer::MAP_NORMAL); 2933 // llassert(mask & LLVertexBuffer::MAP_NORMAL);
2736 registerFace(group, facep, LLRenderPass::PASS_SIMPLE); 2934 registerFace(group, facep, LLRenderPass::PASS_SIMPLE);
2737 } 2935 }
2738 } 2936 }
@@ -2745,8 +2943,8 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2745 2943
2746 if (!is_alpha && !LLPipeline::sRenderDeferred) 2944 if (!is_alpha && !LLPipeline::sRenderDeferred)
2747 { 2945 {
2748 llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright); 2946 // llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright);
2749 facep->setPoolType((fullbright) ? LLDrawPool::POOL_FULLBRIGHT : LLDrawPool::POOL_SIMPLE); 2947 facep->setPoolType(LLDrawPool::POOL_SIMPLE); // facep->setPoolType((fullbright) ? LLDrawPool::POOL_FULLBRIGHT : LLDrawPool::POOL_SIMPLE);
2750 2948
2751 if (!force_simple && te->getBumpmap()) 2949 if (!force_simple && te->getBumpmap())
2752 { 2950 {
@@ -2825,7 +3023,7 @@ LLHUDPartition::LLHUDPartition()
2825 mPartitionType = LLViewerRegion::PARTITION_HUD; 3023 mPartitionType = LLViewerRegion::PARTITION_HUD;
2826 mDrawableType = LLPipeline::RENDER_TYPE_HUD; 3024 mDrawableType = LLPipeline::RENDER_TYPE_HUD;
2827 mSlopRatio = 0.f; 3025 mSlopRatio = 0.f;
2828 mLODPeriod = 1; 3026 mLODPeriod = 32; // KL 32 in SD
2829} 3027}
2830 3028
2831void LLHUDPartition::shift(const LLVector3 &offset) 3029void LLHUDPartition::shift(const LLVector3 &offset)