diff options
Diffstat (limited to 'linden/indra/newview/llvovolume.cpp')
-rw-r--r-- | linden/indra/newview/llvovolume.cpp | 142 |
1 files changed, 104 insertions, 38 deletions
diff --git a/linden/indra/newview/llvovolume.cpp b/linden/indra/newview/llvovolume.cpp index 9d8369f..ad44356 100644 --- a/linden/indra/newview/llvovolume.cpp +++ b/linden/indra/newview/llvovolume.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -68,8 +68,7 @@ | |||
68 | const S32 MIN_QUIET_FRAMES_COALESCE = 30; | 68 | const S32 MIN_QUIET_FRAMES_COALESCE = 30; |
69 | const F32 FORCE_SIMPLE_RENDER_AREA = 512.f; | 69 | const F32 FORCE_SIMPLE_RENDER_AREA = 512.f; |
70 | const F32 FORCE_CULL_AREA = 8.f; | 70 | const 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 | 71 | const S32 MAX_SCULPT_REZ = 128; |
72 | const S32 SCULPT_REZ = 128; | ||
73 | 72 | ||
74 | BOOL gAnimateTextures = TRUE; | 73 | BOOL gAnimateTextures = TRUE; |
75 | extern BOOL gHideSelectedObjects; | 74 | extern BOOL gHideSelectedObjects; |
@@ -90,7 +89,7 @@ LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *re | |||
90 | mLOD = MIN_LOD; | 89 | mLOD = MIN_LOD; |
91 | mSculptLevel = -2; | 90 | mSculptLevel = -2; |
92 | mTextureAnimp = NULL; | 91 | mTextureAnimp = NULL; |
93 | mVObjRadius = LLVector3(1,1,0.5f).magVec(); | 92 | mVObjRadius = LLVector3(1,1,0.5f).length(); |
94 | mNumFaces = 0; | 93 | mNumFaces = 0; |
95 | mLODChanged = FALSE; | 94 | mLODChanged = FALSE; |
96 | mSculptChanged = FALSE; | 95 | mSculptChanged = FALSE; |
@@ -498,6 +497,7 @@ void LLVOVolume::updateTextures() | |||
498 | else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) | 497 | else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) |
499 | { | 498 | { |
500 | F32 pri = imagep->getDecodePriority(); | 499 | F32 pri = imagep->getDecodePriority(); |
500 | pri = llmax(pri, 0.0f); | ||
501 | if (pri < min_vsize) min_vsize = pri; | 501 | if (pri < min_vsize) min_vsize = pri; |
502 | if (pri > max_vsize) max_vsize = pri; | 502 | if (pri > max_vsize) max_vsize = pri; |
503 | } | 503 | } |
@@ -516,7 +516,10 @@ void LLVOVolume::updateTextures() | |||
516 | mSculptTexture = gImageList.getImage(id); | 516 | mSculptTexture = gImageList.getImage(id); |
517 | if (mSculptTexture.notNull()) | 517 | if (mSculptTexture.notNull()) |
518 | { | 518 | { |
519 | mSculptTexture->addTextureStats(SCULPT_REZ * SCULPT_REZ); | 519 | S32 lod = llmin(mLOD, 3); |
520 | F32 lodf = ((F32)(lod + 1.0f)/4.f); | ||
521 | F32 tex_size = lodf * MAX_SCULPT_REZ; | ||
522 | mSculptTexture->addTextureStats(2.f * tex_size * tex_size); | ||
520 | mSculptTexture->setBoostLevel(llmax((S32)mSculptTexture->getBoostLevel(), | 523 | mSculptTexture->setBoostLevel(llmax((S32)mSculptTexture->getBoostLevel(), |
521 | (S32)LLViewerImage::BOOST_SCULPTED)); | 524 | (S32)LLViewerImage::BOOST_SCULPTED)); |
522 | } | 525 | } |
@@ -577,7 +580,7 @@ F32 LLVOVolume::getTextureVirtualSize(LLFace* face) | |||
577 | 580 | ||
578 | //get area of circle in texture space | 581 | //get area of circle in texture space |
579 | LLVector2 tdim = face->mTexExtents[1] - face->mTexExtents[0]; | 582 | LLVector2 tdim = face->mTexExtents[1] - face->mTexExtents[0]; |
580 | F32 texel_area = (tdim * 0.5f).magVecSquared()*3.14159f; | 583 | F32 texel_area = (tdim * 0.5f).lengthSquared()*3.14159f; |
581 | if (texel_area <= 0) | 584 | if (texel_area <= 0) |
582 | { | 585 | { |
583 | // Probably animated, use default | 586 | // Probably animated, use default |
@@ -605,7 +608,7 @@ BOOL LLVOVolume::setMaterial(const U8 material) | |||
605 | void LLVOVolume::setTexture(const S32 face) | 608 | void LLVOVolume::setTexture(const S32 face) |
606 | { | 609 | { |
607 | llassert(face < getNumTEs()); | 610 | llassert(face < getNumTEs()); |
608 | LLViewerImage::bindTexture(getTEImage(face)); | 611 | gGL.getTexUnit(0)->bind(getTEImage(face)); |
609 | } | 612 | } |
610 | 613 | ||
611 | void LLVOVolume::setScale(const LLVector3 &scale, BOOL damped) | 614 | void LLVOVolume::setScale(const LLVector3 &scale, BOOL damped) |
@@ -759,10 +762,10 @@ void LLVOVolume::sculpt() | |||
759 | // corrupted volume... don't update the sculpty | 762 | // corrupted volume... don't update the sculpty |
760 | return; | 763 | return; |
761 | } | 764 | } |
762 | else if (current_discard > max_discard) | 765 | else if (current_discard > MAX_DISCARD_LEVEL) |
763 | { | 766 | { |
764 | llwarns << "WARNING!!: Current discard of sculpty at " << current_discard | 767 | llwarns << "WARNING!!: Current discard of sculpty at " << current_discard |
765 | << " is more than than allowed max of " << max_discard << llendl; | 768 | << " is more than than allowed max of " << MAX_DISCARD_LEVEL << llendl; |
766 | 769 | ||
767 | // corrupted volume... don't update the sculpty | 770 | // corrupted volume... don't update the sculpty |
768 | return; | 771 | return; |
@@ -828,7 +831,7 @@ BOOL LLVOVolume::calcLOD() | |||
828 | 831 | ||
829 | S32 cur_detail = 0; | 832 | S32 cur_detail = 0; |
830 | 833 | ||
831 | F32 radius = getVolume()->mLODScaleBias.scaledVec(getScale()).magVec(); | 834 | F32 radius = getVolume()->mLODScaleBias.scaledVec(getScale()).length(); |
832 | F32 distance = mDrawable->mDistanceWRTCamera; | 835 | F32 distance = mDrawable->mDistanceWRTCamera; |
833 | distance *= sDistanceFactor; | 836 | distance *= sDistanceFactor; |
834 | 837 | ||
@@ -1687,7 +1690,7 @@ void LLVOVolume::generateSilhouette(LLSelectNode* nodep, const LLVector3& view_p | |||
1687 | 1690 | ||
1688 | //transform view vector into volume space | 1691 | //transform view vector into volume space |
1689 | view_vector -= getRenderPosition(); | 1692 | view_vector -= getRenderPosition(); |
1690 | mDrawable->mDistanceWRTCamera = view_vector.magVec(); | 1693 | mDrawable->mDistanceWRTCamera = view_vector.length(); |
1691 | LLQuaternion worldRot = getRenderRotation(); | 1694 | LLQuaternion worldRot = getRenderRotation(); |
1692 | view_vector = view_vector * ~worldRot; | 1695 | view_vector = view_vector * ~worldRot; |
1693 | if (!isVolumeGlobal()) | 1696 | if (!isVolumeGlobal()) |
@@ -1728,7 +1731,7 @@ void LLVOVolume::updateRadius() | |||
1728 | return; | 1731 | return; |
1729 | } | 1732 | } |
1730 | 1733 | ||
1731 | mVObjRadius = getScale().magVec(); | 1734 | mVObjRadius = getScale().length(); |
1732 | mDrawable->setRadius(mVObjRadius); | 1735 | mDrawable->setRadius(mVObjRadius); |
1733 | } | 1736 | } |
1734 | 1737 | ||
@@ -1841,7 +1844,7 @@ F32 LLVOVolume::getBinRadius() | |||
1841 | } | 1844 | } |
1842 | else if (shrink_wrap) | 1845 | else if (shrink_wrap) |
1843 | { | 1846 | { |
1844 | radius = (ext[1]-ext[0]).magVec()*0.5f; | 1847 | radius = (ext[1]-ext[0]).length()*0.5f; |
1845 | } | 1848 | } |
1846 | else if (mDrawable->isStatic()) | 1849 | else if (mDrawable->isStatic()) |
1847 | { | 1850 | { |
@@ -1934,10 +1937,20 @@ LLVector3 LLVOVolume::volumeDirectionToAgent(const LLVector3& dir) const | |||
1934 | } | 1937 | } |
1935 | 1938 | ||
1936 | 1939 | ||
1937 | BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, S32 *face_hitp, | 1940 | BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, BOOL pick_transparent, S32 *face_hitp, |
1938 | LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal) | 1941 | LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal) |
1939 | 1942 | ||
1940 | { | 1943 | { |
1944 | if (!mbCanSelect || | ||
1945 | (gHideSelectedObjects && isSelected()) || | ||
1946 | mDrawable->isDead() || | ||
1947 | !gPipeline.hasRenderType(mDrawable->getRenderType())) | ||
1948 | { | ||
1949 | return FALSE; | ||
1950 | } | ||
1951 | |||
1952 | BOOL ret = FALSE; | ||
1953 | |||
1941 | LLVolume* volume = getVolume(); | 1954 | LLVolume* volume = getVolume(); |
1942 | if (volume) | 1955 | if (volume) |
1943 | { | 1956 | { |
@@ -1946,38 +1959,91 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& e | |||
1946 | v_start = agentPositionToVolume(start); | 1959 | v_start = agentPositionToVolume(start); |
1947 | v_end = agentPositionToVolume(end); | 1960 | v_end = agentPositionToVolume(end); |
1948 | 1961 | ||
1949 | S32 face_hit = volume->lineSegmentIntersect(v_start, v_end, face, | 1962 | LLVector3 p; |
1950 | intersection, tex_coord, normal, bi_normal); | 1963 | LLVector3 n; |
1951 | if (face_hit >= 0) | 1964 | LLVector2 tc; |
1965 | LLVector3 bn; | ||
1966 | |||
1967 | if (intersection != NULL) | ||
1952 | { | 1968 | { |
1953 | if (face_hitp != NULL) | 1969 | p = *intersection; |
1954 | { | 1970 | } |
1955 | *face_hitp = face_hit; | 1971 | |
1956 | } | 1972 | if (tex_coord != NULL) |
1973 | { | ||
1974 | tc = *tex_coord; | ||
1975 | } | ||
1976 | |||
1977 | if (normal != NULL) | ||
1978 | { | ||
1979 | n = *normal; | ||
1980 | } | ||
1981 | |||
1982 | if (bi_normal != NULL) | ||
1983 | { | ||
1984 | bn = *bi_normal; | ||
1985 | } | ||
1986 | |||
1987 | S32 face_hit = -1; | ||
1988 | |||
1989 | S32 start_face, end_face; | ||
1990 | if (face == -1) | ||
1991 | { | ||
1992 | start_face = 0; | ||
1993 | end_face = volume->getNumFaces(); | ||
1994 | } | ||
1995 | else | ||
1996 | { | ||
1997 | start_face = face; | ||
1998 | end_face = face+1; | ||
1999 | } | ||
2000 | |||
2001 | for (S32 i = start_face; i < end_face; ++i) | ||
2002 | { | ||
2003 | face_hit = volume->lineSegmentIntersect(v_start, v_end, i, | ||
2004 | &p, &tc, &n, &bn); | ||
1957 | 2005 | ||
1958 | if (intersection != NULL) | 2006 | if (face_hit >= 0 && mDrawable->getNumFaces() > face_hit) |
1959 | { | 2007 | { |
1960 | *intersection = volumePositionToAgent(*intersection); // must map back to agent space | 2008 | LLFace* face = mDrawable->getFace(face_hit); |
1961 | } | 2009 | |
2010 | if (pick_transparent || !face->getTexture() || face->getTexture()->getMask(face->surfaceToTexture(tc, p, n))) | ||
2011 | { | ||
2012 | v_end = p; | ||
2013 | if (face_hitp != NULL) | ||
2014 | { | ||
2015 | *face_hitp = face_hit; | ||
2016 | } | ||
2017 | |||
2018 | if (intersection != NULL) | ||
2019 | { | ||
2020 | *intersection = volumePositionToAgent(p); // must map back to agent space | ||
2021 | } | ||
1962 | 2022 | ||
1963 | if (normal != NULL) | 2023 | if (normal != NULL) |
1964 | { | 2024 | { |
1965 | *normal = volumeDirectionToAgent(*normal); | 2025 | *normal = volumeDirectionToAgent(n); |
1966 | (*normal).normVec(); | 2026 | (*normal).normVec(); |
1967 | } | 2027 | } |
1968 | 2028 | ||
1969 | if (bi_normal != NULL) | 2029 | if (bi_normal != NULL) |
1970 | { | 2030 | { |
1971 | *bi_normal = volumeDirectionToAgent(*bi_normal); | 2031 | *bi_normal = volumeDirectionToAgent(bn); |
1972 | (*bi_normal).normVec(); | 2032 | (*bi_normal).normVec(); |
1973 | } | 2033 | } |
1974 | 2034 | ||
1975 | 2035 | if (tex_coord != NULL) | |
1976 | return TRUE; | 2036 | { |
2037 | *tex_coord = tc; | ||
2038 | } | ||
2039 | |||
2040 | ret = TRUE; | ||
2041 | } | ||
2042 | } | ||
1977 | } | 2043 | } |
1978 | } | 2044 | } |
1979 | 2045 | ||
1980 | return FALSE; | 2046 | return ret; |
1981 | } | 2047 | } |
1982 | 2048 | ||
1983 | U32 LLVOVolume::getPartitionType() const | 2049 | U32 LLVOVolume::getPartitionType() const |