diff options
Diffstat (limited to 'linden/indra/newview/llvovolume.cpp')
-rw-r--r-- | linden/indra/newview/llvovolume.cpp | 121 |
1 files changed, 90 insertions, 31 deletions
diff --git a/linden/indra/newview/llvovolume.cpp b/linden/indra/newview/llvovolume.cpp index 9d8369f..47289ff 100644 --- a/linden/indra/newview/llvovolume.cpp +++ b/linden/indra/newview/llvovolume.cpp | |||
@@ -90,7 +90,7 @@ LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *re | |||
90 | mLOD = MIN_LOD; | 90 | mLOD = MIN_LOD; |
91 | mSculptLevel = -2; | 91 | mSculptLevel = -2; |
92 | mTextureAnimp = NULL; | 92 | mTextureAnimp = NULL; |
93 | mVObjRadius = LLVector3(1,1,0.5f).magVec(); | 93 | mVObjRadius = LLVector3(1,1,0.5f).length(); |
94 | mNumFaces = 0; | 94 | mNumFaces = 0; |
95 | mLODChanged = FALSE; | 95 | mLODChanged = FALSE; |
96 | mSculptChanged = FALSE; | 96 | mSculptChanged = FALSE; |
@@ -577,7 +577,7 @@ F32 LLVOVolume::getTextureVirtualSize(LLFace* face) | |||
577 | 577 | ||
578 | //get area of circle in texture space | 578 | //get area of circle in texture space |
579 | LLVector2 tdim = face->mTexExtents[1] - face->mTexExtents[0]; | 579 | LLVector2 tdim = face->mTexExtents[1] - face->mTexExtents[0]; |
580 | F32 texel_area = (tdim * 0.5f).magVecSquared()*3.14159f; | 580 | F32 texel_area = (tdim * 0.5f).lengthSquared()*3.14159f; |
581 | if (texel_area <= 0) | 581 | if (texel_area <= 0) |
582 | { | 582 | { |
583 | // Probably animated, use default | 583 | // Probably animated, use default |
@@ -605,7 +605,7 @@ BOOL LLVOVolume::setMaterial(const U8 material) | |||
605 | void LLVOVolume::setTexture(const S32 face) | 605 | void LLVOVolume::setTexture(const S32 face) |
606 | { | 606 | { |
607 | llassert(face < getNumTEs()); | 607 | llassert(face < getNumTEs()); |
608 | LLViewerImage::bindTexture(getTEImage(face)); | 608 | gGL.getTexUnit(0)->bind(getTEImage(face)); |
609 | } | 609 | } |
610 | 610 | ||
611 | void LLVOVolume::setScale(const LLVector3 &scale, BOOL damped) | 611 | void LLVOVolume::setScale(const LLVector3 &scale, BOOL damped) |
@@ -828,7 +828,7 @@ BOOL LLVOVolume::calcLOD() | |||
828 | 828 | ||
829 | S32 cur_detail = 0; | 829 | S32 cur_detail = 0; |
830 | 830 | ||
831 | F32 radius = getVolume()->mLODScaleBias.scaledVec(getScale()).magVec(); | 831 | F32 radius = getVolume()->mLODScaleBias.scaledVec(getScale()).length(); |
832 | F32 distance = mDrawable->mDistanceWRTCamera; | 832 | F32 distance = mDrawable->mDistanceWRTCamera; |
833 | distance *= sDistanceFactor; | 833 | distance *= sDistanceFactor; |
834 | 834 | ||
@@ -1687,7 +1687,7 @@ void LLVOVolume::generateSilhouette(LLSelectNode* nodep, const LLVector3& view_p | |||
1687 | 1687 | ||
1688 | //transform view vector into volume space | 1688 | //transform view vector into volume space |
1689 | view_vector -= getRenderPosition(); | 1689 | view_vector -= getRenderPosition(); |
1690 | mDrawable->mDistanceWRTCamera = view_vector.magVec(); | 1690 | mDrawable->mDistanceWRTCamera = view_vector.length(); |
1691 | LLQuaternion worldRot = getRenderRotation(); | 1691 | LLQuaternion worldRot = getRenderRotation(); |
1692 | view_vector = view_vector * ~worldRot; | 1692 | view_vector = view_vector * ~worldRot; |
1693 | if (!isVolumeGlobal()) | 1693 | if (!isVolumeGlobal()) |
@@ -1728,7 +1728,7 @@ void LLVOVolume::updateRadius() | |||
1728 | return; | 1728 | return; |
1729 | } | 1729 | } |
1730 | 1730 | ||
1731 | mVObjRadius = getScale().magVec(); | 1731 | mVObjRadius = getScale().length(); |
1732 | mDrawable->setRadius(mVObjRadius); | 1732 | mDrawable->setRadius(mVObjRadius); |
1733 | } | 1733 | } |
1734 | 1734 | ||
@@ -1841,7 +1841,7 @@ F32 LLVOVolume::getBinRadius() | |||
1841 | } | 1841 | } |
1842 | else if (shrink_wrap) | 1842 | else if (shrink_wrap) |
1843 | { | 1843 | { |
1844 | radius = (ext[1]-ext[0]).magVec()*0.5f; | 1844 | radius = (ext[1]-ext[0]).length()*0.5f; |
1845 | } | 1845 | } |
1846 | else if (mDrawable->isStatic()) | 1846 | else if (mDrawable->isStatic()) |
1847 | { | 1847 | { |
@@ -1934,10 +1934,18 @@ LLVector3 LLVOVolume::volumeDirectionToAgent(const LLVector3& dir) const | |||
1934 | } | 1934 | } |
1935 | 1935 | ||
1936 | 1936 | ||
1937 | BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, S32 *face_hitp, | 1937 | 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) | 1938 | LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal) |
1939 | 1939 | ||
1940 | { | 1940 | { |
1941 | if (!mbCanSelect || | ||
1942 | (gHideSelectedObjects && isSelected()) || | ||
1943 | mDrawable->isDead() || | ||
1944 | !gPipeline.hasRenderType(mDrawable->getRenderType())) | ||
1945 | { | ||
1946 | return FALSE; | ||
1947 | } | ||
1948 | |||
1941 | LLVolume* volume = getVolume(); | 1949 | LLVolume* volume = getVolume(); |
1942 | if (volume) | 1950 | if (volume) |
1943 | { | 1951 | { |
@@ -1946,37 +1954,88 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& e | |||
1946 | v_start = agentPositionToVolume(start); | 1954 | v_start = agentPositionToVolume(start); |
1947 | v_end = agentPositionToVolume(end); | 1955 | v_end = agentPositionToVolume(end); |
1948 | 1956 | ||
1949 | S32 face_hit = volume->lineSegmentIntersect(v_start, v_end, face, | 1957 | LLVector3 p; |
1950 | intersection, tex_coord, normal, bi_normal); | 1958 | LLVector3 n; |
1951 | if (face_hit >= 0) | 1959 | LLVector2 tc; |
1960 | LLVector3 bn; | ||
1961 | |||
1962 | if (intersection != NULL) | ||
1952 | { | 1963 | { |
1953 | if (face_hitp != NULL) | 1964 | p = *intersection; |
1954 | { | 1965 | } |
1955 | *face_hitp = face_hit; | 1966 | |
1956 | } | 1967 | if (tex_coord != NULL) |
1968 | { | ||
1969 | tc = *tex_coord; | ||
1970 | } | ||
1971 | |||
1972 | if (normal != NULL) | ||
1973 | { | ||
1974 | n = *normal; | ||
1975 | } | ||
1976 | |||
1977 | if (bi_normal != NULL) | ||
1978 | { | ||
1979 | bn = *bi_normal; | ||
1980 | } | ||
1981 | |||
1982 | S32 face_hit = -1; | ||
1983 | |||
1984 | S32 start_face, end_face; | ||
1985 | if (face == -1) | ||
1986 | { | ||
1987 | start_face = 0; | ||
1988 | end_face = volume->getNumFaces(); | ||
1989 | } | ||
1990 | else | ||
1991 | { | ||
1992 | start_face = face; | ||
1993 | end_face = face+1; | ||
1994 | } | ||
1995 | |||
1996 | for (S32 i = start_face; i < end_face; ++i) | ||
1997 | { | ||
1998 | face_hit = volume->lineSegmentIntersect(v_start, v_end, i, | ||
1999 | &p, &tc, &n, &bn); | ||
1957 | 2000 | ||
1958 | if (intersection != NULL) | 2001 | if (face_hit >= 0) |
1959 | { | 2002 | { |
1960 | *intersection = volumePositionToAgent(*intersection); // must map back to agent space | 2003 | LLFace* face = mDrawable->getFace(face_hit); |
1961 | } | 2004 | if (pick_transparent || !face->getTexture() || face->getTexture()->getMask(face->surfaceToTexture(tc, p, n))) |
2005 | { | ||
2006 | if (face_hitp != NULL) | ||
2007 | { | ||
2008 | *face_hitp = face_hit; | ||
2009 | } | ||
2010 | |||
2011 | if (intersection != NULL) | ||
2012 | { | ||
2013 | *intersection = volumePositionToAgent(p); // must map back to agent space | ||
2014 | } | ||
1962 | 2015 | ||
1963 | if (normal != NULL) | 2016 | if (normal != NULL) |
1964 | { | 2017 | { |
1965 | *normal = volumeDirectionToAgent(*normal); | 2018 | *normal = volumeDirectionToAgent(n); |
1966 | (*normal).normVec(); | 2019 | (*normal).normVec(); |
1967 | } | 2020 | } |
1968 | 2021 | ||
1969 | if (bi_normal != NULL) | 2022 | if (bi_normal != NULL) |
1970 | { | 2023 | { |
1971 | *bi_normal = volumeDirectionToAgent(*bi_normal); | 2024 | *bi_normal = volumeDirectionToAgent(bn); |
1972 | (*bi_normal).normVec(); | 2025 | (*bi_normal).normVec(); |
1973 | } | 2026 | } |
1974 | 2027 | ||
1975 | 2028 | if (tex_coord != NULL) | |
1976 | return TRUE; | 2029 | { |
2030 | *tex_coord = tc; | ||
2031 | } | ||
2032 | |||
2033 | return TRUE; | ||
2034 | } | ||
2035 | } | ||
1977 | } | 2036 | } |
1978 | } | 2037 | } |
1979 | 2038 | ||
1980 | return FALSE; | 2039 | return FALSE; |
1981 | } | 2040 | } |
1982 | 2041 | ||