aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvovolume.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llvovolume.cpp')
-rw-r--r--linden/indra/newview/llvovolume.cpp422
1 files changed, 310 insertions, 112 deletions
diff --git a/linden/indra/newview/llvovolume.cpp b/linden/indra/newview/llvovolume.cpp
index 385dbe0..d4c4020 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)
@@ -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();
@@ -2254,9 +2444,11 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2254 2444
2255 LLVOVolume* vobj = drawablep->getVOVolume(); 2445 LLVOVolume* vobj = drawablep->getVOVolume();
2256 llassert_always(vobj); 2446 llassert_always(vobj);
2257 vobj->updateTextureVirtualSize(); 2447 vobj->updateTextures();
2258 vobj->preRebuild(); 2448 vobj->preRebuild();
2259 2449
2450 drawablep->clearState(LLDrawable::HAS_ALPHA); // KL SD
2451
2260 //for each face 2452 //for each face
2261 for (S32 i = 0; i < drawablep->getNumFaces(); i++) 2453 for (S32 i = 0; i < drawablep->getNumFaces(); i++)
2262 { 2454 {
@@ -2325,6 +2517,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2325 } 2517 }
2326 else 2518 else
2327 { 2519 {
2520 drawablep->setState(LLDrawable::HAS_ALPHA); // KL SD
2328 alpha_faces.push_back(facep); 2521 alpha_faces.push_back(facep);
2329 } 2522 }
2330 } 2523 }
@@ -2348,7 +2541,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2348 } 2541 }
2349 else 2542 else
2350 { //doesn't need normal 2543 { //doesn't need normal
2351 facep->setState(LLFace::FULLBRIGHT); 2544 //facep->setState(LLFace::FULLBRIGHT);
2352 fullbright_faces.push_back(facep); 2545 fullbright_faces.push_back(facep);
2353 } 2546 }
2354 } 2547 }
@@ -2358,14 +2551,14 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2358 { //needs normal + binormal 2551 { //needs normal + binormal
2359 bump_faces.push_back(facep); 2552 bump_faces.push_back(facep);
2360 } 2553 }
2361 else if ((te->getShiny() && LLPipeline::sRenderBump) || 2554 else if (te->getShiny() && LLPipeline::sRenderBump ||
2362 !te->getFullbright()) 2555 !te->getFullbright())
2363 { //needs normal 2556 { //needs normal
2364 simple_faces.push_back(facep); 2557 simple_faces.push_back(facep);
2365 } 2558 }
2366 else 2559 else
2367 { //doesn't need normal 2560 { //doesn't need normal
2368 facep->setState(LLFace::FULLBRIGHT); 2561 // facep->setState(LLFace::FULLBRIGHT);
2369 fullbright_faces.push_back(facep); 2562 fullbright_faces.push_back(facep);
2370 } 2563 }
2371 } 2564 }
@@ -2413,7 +2606,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2413 2606
2414 if (LLPipeline::sDelayVBUpdate) 2607 if (LLPipeline::sDelayVBUpdate)
2415 { 2608 {
2416 group->setState(LLSpatialGroup::MESH_DIRTY); 2609 group->setState(LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO); // KL SD
2417 } 2610 }
2418 2611
2419 mFaceList.clear(); 2612 mFaceList.clear();
@@ -2421,7 +2614,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
2421 2614
2422void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) 2615void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
2423{ 2616{
2424 if (group->isState(LLSpatialGroup::MESH_DIRTY)) 2617 if (group->isState(LLSpatialGroup::MESH_DIRTY) && !group->isState(LLSpatialGroup::GEOM_DIRTY)) // KL SD
2425 { 2618 {
2426 S32 num_mapped_veretx_buffer = LLVertexBuffer::sMappedCount ; 2619 S32 num_mapped_veretx_buffer = LLVertexBuffer::sMappedCount ;
2427 2620
@@ -2499,7 +2692,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
2499 } 2692 }
2500 } 2693 }
2501 2694
2502 group->clearState(LLSpatialGroup::MESH_DIRTY); 2695 group->clearState(LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO); // KL SD
2503 } 2696 }
2504} 2697}
2505 2698
@@ -2524,7 +2717,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2524 2717
2525 LLSpatialGroup::buffer_map_t buffer_map; 2718 LLSpatialGroup::buffer_map_t buffer_map;
2526 2719
2527 LLViewerImage* last_tex = NULL; 2720 LLImageGL* last_tex = NULL;// LLViewerImage* last_tex = NULL; // KL SD
2528 S32 buffer_index = 0; 2721 S32 buffer_index = 0;
2529 2722
2530 if (distance_sort) 2723 if (distance_sort)
@@ -2536,7 +2729,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2536 { 2729 {
2537 //pull off next face 2730 //pull off next face
2538 LLFace* facep = *face_iter; 2731 LLFace* facep = *face_iter;
2539 LLViewerImage* tex = facep->getTexture(); 2732 LLImageGL* tex = facep->getGLTexture(); // LLViewerImage* tex = facep->getTexture(); // KL SD
2540 2733
2541 if (distance_sort) 2734 if (distance_sort)
2542 { 2735 {
@@ -2561,7 +2754,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2561 ++i; 2754 ++i;
2562 2755
2563 while (i != faces.end() && 2756 while (i != faces.end() &&
2564 (LLPipeline::sTextureBindTest || (distance_sort || (*i)->getTexture() == tex))) 2757 (LLPipeline::sTextureBindTest || (distance_sort || (*i)->getGLTexture() == tex))) // KL SD getTexture
2565 { 2758 {
2566 facep = *i; 2759 facep = *i;
2567 2760
@@ -2644,6 +2837,11 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2644 2837
2645 BOOL force_simple = facep->mPixelArea < FORCE_SIMPLE_RENDER_AREA; 2838 BOOL force_simple = facep->mPixelArea < FORCE_SIMPLE_RENDER_AREA;
2646 BOOL fullbright = facep->isState(LLFace::FULLBRIGHT); 2839 BOOL fullbright = facep->isState(LLFace::FULLBRIGHT);
2840 if ((mask & LLVertexBuffer::MAP_NORMAL) == 0) // KL SD
2841 { //paranoia check to make sure GL doesn't try to read non-existant normals
2842 fullbright = TRUE;
2843 }
2844
2647 const LLTextureEntry* te = facep->getTextureEntry(); 2845 const LLTextureEntry* te = facep->getTextureEntry();
2648 2846
2649 BOOL is_alpha = facep->getPoolType() == LLDrawPool::POOL_ALPHA ? TRUE : FALSE; 2847 BOOL is_alpha = facep->getPoolType() == LLDrawPool::POOL_ALPHA ? TRUE : FALSE;
@@ -2695,7 +2893,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2695 } 2893 }
2696 else 2894 else
2697 { 2895 {
2698 llassert(mask & LLVertexBuffer::MAP_NORMAL); 2896 // llassert(mask & LLVertexBuffer::MAP_NORMAL);
2699 registerFace(group, facep, LLRenderPass::PASS_SIMPLE); 2897 registerFace(group, facep, LLRenderPass::PASS_SIMPLE);
2700 } 2898 }
2701 } 2899 }
@@ -2726,7 +2924,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2726 } 2924 }
2727 else 2925 else
2728 { 2926 {
2729 llassert(mask & LLVertexBuffer::MAP_NORMAL); 2927 // llassert(mask & LLVertexBuffer::MAP_NORMAL);
2730 registerFace(group, facep, LLRenderPass::PASS_SIMPLE); 2928 registerFace(group, facep, LLRenderPass::PASS_SIMPLE);
2731 } 2929 }
2732 } 2930 }
@@ -2739,8 +2937,8 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
2739 2937
2740 if (!is_alpha && !LLPipeline::sRenderDeferred) 2938 if (!is_alpha && !LLPipeline::sRenderDeferred)
2741 { 2939 {
2742 llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright); 2940 // llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright);
2743 facep->setPoolType((fullbright) ? LLDrawPool::POOL_FULLBRIGHT : LLDrawPool::POOL_SIMPLE); 2941 facep->setPoolType(LLDrawPool::POOL_SIMPLE); // facep->setPoolType((fullbright) ? LLDrawPool::POOL_FULLBRIGHT : LLDrawPool::POOL_SIMPLE);
2744 2942
2745 if (!force_simple && te->getBumpmap()) 2943 if (!force_simple && te->getBumpmap())
2746 { 2944 {
@@ -2819,7 +3017,7 @@ LLHUDPartition::LLHUDPartition()
2819 mPartitionType = LLViewerRegion::PARTITION_HUD; 3017 mPartitionType = LLViewerRegion::PARTITION_HUD;
2820 mDrawableType = LLPipeline::RENDER_TYPE_HUD; 3018 mDrawableType = LLPipeline::RENDER_TYPE_HUD;
2821 mSlopRatio = 0.f; 3019 mSlopRatio = 0.f;
2822 mLODPeriod = 1; 3020 mLODPeriod = 32; // KL 32 in SD
2823} 3021}
2824 3022
2825void LLHUDPartition::shift(const LLVector3 &offset) 3023void LLHUDPartition::shift(const LLVector3 &offset)