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.cpp85
1 files changed, 66 insertions, 19 deletions
diff --git a/linden/indra/newview/llvovolume.cpp b/linden/indra/newview/llvovolume.cpp
index e352f14..b70dd23 100644
--- a/linden/indra/newview/llvovolume.cpp
+++ b/linden/indra/newview/llvovolume.cpp
@@ -68,6 +68,7 @@
68const S32 MIN_QUIET_FRAMES_COALESCE = 30; 68const S32 MIN_QUIET_FRAMES_COALESCE = 30;
69const F32 FORCE_SIMPLE_RENDER_AREA = 512.f; 69const F32 FORCE_SIMPLE_RENDER_AREA = 512.f;
70const F32 FORCE_CULL_AREA = 8.f; 70const F32 FORCE_CULL_AREA = 8.f;
71// sadly - we can't lower sculptie rez below b/c residents have a LOT of content that depends on the 128
71const S32 SCULPT_REZ = 128; 72const S32 SCULPT_REZ = 128;
72 73
73BOOL gAnimateTextures = TRUE; 74BOOL gAnimateTextures = TRUE;
@@ -87,6 +88,7 @@ LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *re
87 mRelativeXformInvTrans.setIdentity(); 88 mRelativeXformInvTrans.setIdentity();
88 89
89 mLOD = MIN_LOD; 90 mLOD = MIN_LOD;
91 mSculptLevel = -2;
90 mTextureAnimp = NULL; 92 mTextureAnimp = NULL;
91 mVObjRadius = LLVector3(1,1,0.5f).magVec(); 93 mVObjRadius = LLVector3(1,1,0.5f).magVec();
92 mNumFaces = 0; 94 mNumFaces = 0;
@@ -212,9 +214,9 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys,
212 // Well, crap, there's something bogus in the data that we're unpacking. 214 // Well, crap, there's something bogus in the data that we're unpacking.
213 dp->dumpBufferToLog(); 215 dp->dumpBufferToLog();
214 llwarns << "Flushing cache files" << llendl; 216 llwarns << "Flushing cache files" << llendl;
215 char mask[LL_MAX_PATH]; /* Flawfinder: ignore */ 217 std::string mask;
216 snprintf(mask, LL_MAX_PATH, "%s*.slc", gDirUtilp->getDirDelimiter().c_str()); /* Flawfinder: ignore */ 218 mask = gDirUtilp->getDirDelimiter() + "*.slc";
217 gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,"").c_str(),mask); 219 gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""), mask);
218// llerrs << "Bogus TE data in " << getID() << ", crashing!" << llendl; 220// llerrs << "Bogus TE data in " << getID() << ", crashing!" << llendl;
219 llwarns << "Bogus TE data in " << getID() << llendl; 221 llwarns << "Bogus TE data in " << getID() << llendl;
220 } 222 }
@@ -515,12 +517,13 @@ void LLVOVolume::updateTextures()
515 if (mSculptTexture.notNull()) 517 if (mSculptTexture.notNull())
516 { 518 {
517 mSculptTexture->addTextureStats(SCULPT_REZ * SCULPT_REZ); 519 mSculptTexture->addTextureStats(SCULPT_REZ * SCULPT_REZ);
518 mSculptTexture->setBoostLevel(LLViewerImage::BOOST_SCULPTED); 520 mSculptTexture->setBoostLevel(llmax((S32)mSculptTexture->getBoostLevel(),
521 (S32)LLViewerImage::BOOST_SCULPTED));
519 } 522 }
520 523
521 S32 texture_discard = mSculptTexture->getDiscardLevel(); //try to match the texture 524 S32 texture_discard = mSculptTexture->getDiscardLevel(); //try to match the texture
522 S32 current_discard = getVolume()->getSculptLevel(); 525 S32 current_discard = mSculptLevel;
523 526
524 if (texture_discard >= 0 && //texture has some data available 527 if (texture_discard >= 0 && //texture has some data available
525 (texture_discard < current_discard || //texture has more data than last rebuild 528 (texture_discard < current_discard || //texture has more data than last rebuild
526 current_discard < 0)) //no previous rebuild 529 current_discard < 0)) //no previous rebuild
@@ -528,7 +531,13 @@ void LLVOVolume::updateTextures()
528 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE); 531 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE);
529 mSculptChanged = TRUE; 532 mSculptChanged = TRUE;
530 } 533 }
531 534
535 if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SCULPTED))
536 {
537 setDebugText(llformat("T%d C%d V%d\n%dx%d",
538 texture_discard, current_discard, getVolume()->getSculptLevel(),
539 mSculptTexture->getHeight(), mSculptTexture->getWidth()));
540 }
532 } 541 }
533 542
534 543
@@ -701,6 +710,7 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &volume_params, const S32 detail
701 if (mSculptTexture.notNull()) 710 if (mSculptTexture.notNull())
702 { 711 {
703 sculpt(); 712 sculpt();
713 mSculptLevel = getVolume()->getSculptLevel();
704 } 714 }
705 } 715 }
706 else 716 else
@@ -1893,26 +1903,42 @@ LLVector3 LLVOVolume::agentPositionToVolume(const LLVector3& pos) const
1893 1903
1894LLVector3 LLVOVolume::agentDirectionToVolume(const LLVector3& dir) const 1904LLVector3 LLVOVolume::agentDirectionToVolume(const LLVector3& dir) const
1895{ 1905{
1896 return dir * ~getRenderRotation(); 1906 LLVector3 ret = dir * ~getRenderRotation();
1907
1908 LLVector3 objScale = isVolumeGlobal() ? LLVector3(1,1,1) : getScale();
1909 ret.scaleVec(objScale);
1910
1911 return ret;
1897} 1912}
1898 1913
1899LLVector3 LLVOVolume::volumePositionToAgent(const LLVector3& dir) const 1914LLVector3 LLVOVolume::volumePositionToAgent(const LLVector3& dir) const
1900{ 1915{
1901 LLVector3 ret = dir; 1916 LLVector3 ret = dir;
1902 ret.scaleVec(getScale()); 1917 LLVector3 objScale = isVolumeGlobal() ? LLVector3(1,1,1) : getScale();
1918 ret.scaleVec(objScale);
1903 ret = ret * getRenderRotation(); 1919 ret = ret * getRenderRotation();
1904 ret += getRenderPosition(); 1920 ret += getRenderPosition();
1905 1921
1906 return ret; 1922 return ret;
1907} 1923}
1908 1924
1909BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, LLVector3& end) const 1925LLVector3 LLVOVolume::volumeDirectionToAgent(const LLVector3& dir) const
1910{ 1926{
1911 return FALSE; 1927 LLVector3 ret = dir;
1928 LLVector3 objScale = isVolumeGlobal() ? LLVector3(1,1,1) : getScale();
1929 LLVector3 invObjScale(1.f / objScale.mV[VX], 1.f / objScale.mV[VY], 1.f / objScale.mV[VZ]);
1930 ret.scaleVec(invObjScale);
1931 ret = ret * getRenderRotation();
1932
1933 return ret;
1934}
1935
1936
1937BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, S32 *face_hitp,
1938 LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal)
1912 1939
1913#if 0 // needs to be rewritten to use face extents instead of volume bounds 1940{
1914 LLVolume* volume = getVolume(); 1941 LLVolume* volume = getVolume();
1915 BOOL ret = FALSE;
1916 if (volume) 1942 if (volume)
1917 { 1943 {
1918 LLVector3 v_start, v_end, v_dir; 1944 LLVector3 v_start, v_end, v_dir;
@@ -1920,17 +1946,38 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, LLVector3& end) co
1920 v_start = agentPositionToVolume(start); 1946 v_start = agentPositionToVolume(start);
1921 v_end = agentPositionToVolume(end); 1947 v_end = agentPositionToVolume(end);
1922 1948
1923 if (LLLineSegmentAABB(v_start, v_end, volume->mBounds[0], volume->mBounds[1])) 1949 S32 face_hit = volume->lineSegmentIntersect(v_start, v_end, face,
1950 intersection, tex_coord, normal, bi_normal);
1951 if (face_hit >= 0)
1924 { 1952 {
1925 if (volume->lineSegmentIntersect(v_start, v_end) >= 0) 1953 if (face_hitp != NULL)
1954 {
1955 *face_hitp = face_hit;
1956 }
1957
1958 if (intersection != NULL)
1959 {
1960 *intersection = volumePositionToAgent(*intersection); // must map back to agent space
1961 }
1962
1963 if (normal != NULL)
1926 { 1964 {
1927 end = volumePositionToAgent(v_end); 1965 *normal = volumeDirectionToAgent(*normal);
1928 ret = TRUE; 1966 (*normal).normVec();
1929 } 1967 }
1968
1969 if (bi_normal != NULL)
1970 {
1971 *bi_normal = volumeDirectionToAgent(*bi_normal);
1972 (*bi_normal).normVec();
1973 }
1974
1975
1976 return TRUE;
1930 } 1977 }
1931 } 1978 }
1932 return ret; 1979
1933#endif 1980 return FALSE;
1934} 1981}
1935 1982
1936U32 LLVOVolume::getPartitionType() const 1983U32 LLVOVolume::getPartitionType() const