diff options
Diffstat (limited to 'indra/newview/llface.cpp')
-rw-r--r-- | indra/newview/llface.cpp | 65 |
1 files changed, 53 insertions, 12 deletions
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index d12fd48ffb..80acc71a41 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -182,6 +182,7 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp) mAtlasInfop = NULL ; mUsingAtlas = FALSE ; + mHasMedia = FALSE ; } @@ -1327,17 +1328,33 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, return TRUE; } +//check if the face has a media +BOOL LLFace::hasMedia() const +{ + if(mHasMedia) + { + return TRUE ; + } + if(mTexture.notNull()) + { + return mTexture->hasParcelMedia() ; //if has a parcel media + } + + return FALSE ; //no media. +} + const F32 LEAST_IMPORTANCE = 0.05f ; const F32 LEAST_IMPORTANCE_FOR_LARGE_IMAGE = 0.3f ; F32 LLFace::getTextureVirtualSize() { F32 radius; - F32 cos_angle_to_view_dir; - mPixelArea = calcPixelArea(cos_angle_to_view_dir, radius); + F32 cos_angle_to_view_dir; + BOOL in_frustum = calcPixelArea(cos_angle_to_view_dir, radius); - if (mPixelArea <= 0) + if (mPixelArea < 0.0001f || !in_frustum) { + setVirtualSize(0.f) ; return 0.f; } @@ -1374,23 +1391,48 @@ F32 LLFace::getTextureVirtualSize() } } + setVirtualSize(face_area) ; + return face_area; } -F32 LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) +BOOL LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) { //get area of circle around face LLVector3 center = getPositionAgent(); - LLVector3 size = (mExtents[1] - mExtents[0]) * 0.5f; - + LLVector3 size = (mExtents[1] - mExtents[0]) * 0.5f; LLViewerCamera* camera = LLViewerCamera::getInstance(); + + F32 size_squared = size.lengthSquared() ; LLVector3 lookAt = center - camera->getOrigin(); - F32 dist = lookAt.normVec() ; + F32 dist = lookAt.normVec() ; //get area of circle around node - F32 app_angle = atanf(size.length()/dist); + F32 app_angle = atanf(fsqrtf(size_squared) / dist); radius = app_angle*LLDrawable::sCurPixelAngle; - F32 face_area = radius*radius * 3.14159f; + mPixelArea = radius*radius * 3.14159f; + cos_angle_to_view_dir = lookAt * camera->getXAxis() ; + + //if has media, check if the face is out of the view frustum. + if(hasMedia()) + { + if(!camera->AABBInFrustum(center, size)) + { + mImportanceToCamera = 0.f ; + return false ; + } + if(cos_angle_to_view_dir > camera->getCosHalfFov()) //the center is within the view frustum + { + cos_angle_to_view_dir = 1.0f ; + } + else + { + if(dist * dist * (lookAt - camera->getXAxis()).lengthSquared() < size_squared) + { + cos_angle_to_view_dir = 1.0f ; + } + } + } if(dist < mBoundingSphereRadius) //camera is very close { @@ -1398,12 +1440,11 @@ F32 LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) mImportanceToCamera = 1.0f ; } else - { - cos_angle_to_view_dir = lookAt * camera->getXAxis() ; + { mImportanceToCamera = LLFace::calcImportanceToCamera(cos_angle_to_view_dir, dist) ; } - return face_area ; + return true ; } //the projection of the face partially overlaps with the screen |