summaryrefslogtreecommitdiff
path: root/indra/newview/llface.cpp
diff options
context:
space:
mode:
authorMike Antipov <mantipov@productengine.com>2010-02-11 09:49:57 +0200
committerMike Antipov <mantipov@productengine.com>2010-02-11 09:49:57 +0200
commitb0af6b8acb33c86e5ac8d693131b5c9e7d9407b5 (patch)
treedbe58da2c0ff07a8950548a513db31806f0308d4 /indra/newview/llface.cpp
parentd3bde04a8c3a2cd142bb75dbcad577d083aad0d1 (diff)
parentabae31cb4a26500012663cdc2a06a290ac4e46c9 (diff)
Merge from default branch
--HG-- branch : product-engine
Diffstat (limited to 'indra/newview/llface.cpp')
-rw-r--r--indra/newview/llface.cpp76
1 files changed, 59 insertions, 17 deletions
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 965ac1cad0..c0a3eb1316 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -301,7 +301,8 @@ void LLFace::switchTexture(LLViewerTexture* new_texture)
if(!new_texture)
{
- llerrs << "Can not switch to a null texture." << llendl ;
+ llerrs << "Can not switch to a null texture." << llendl;
+ return;
}
new_texture->addTextureStats(mTexture->getMaxVirtualSize()) ;
@@ -1040,17 +1041,20 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
if (rebuild_color)
{
- GLfloat alpha[4] =
- {
- 0.00f,
- 0.25f,
- 0.5f,
- 0.75f
- };
-
- if (getPoolType() != LLDrawPool::POOL_ALPHA && (LLPipeline::sRenderDeferred || (LLPipeline::sRenderBump && tep->getShiny())))
+ if (tep)
{
- color.mV[3] = U8 (alpha[tep->getShiny()] * 255);
+ GLfloat alpha[4] =
+ {
+ 0.00f,
+ 0.25f,
+ 0.5f,
+ 0.75f
+ };
+
+ if (getPoolType() != LLDrawPool::POOL_ALPHA && (LLPipeline::sRenderDeferred || (LLPipeline::sRenderBump && tep->getShiny())))
+ {
+ color.mV[3] = U8 (alpha[tep->getShiny()] * 255);
+ }
}
}
@@ -1323,6 +1327,21 @@ 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 ;
@@ -1332,7 +1351,7 @@ F32 LLFace::getTextureVirtualSize()
F32 cos_angle_to_view_dir;
mPixelArea = calcPixelArea(cos_angle_to_view_dir, radius);
- if (mPixelArea <= 0)
+ if (mPixelArea < 0.0001f)
{
return 0.f;
}
@@ -1377,14 +1396,38 @@ F32 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();
+
+ //if has media, check if the face is out of the view frustum.
+ BOOL has_media = hasMedia() ;
+ if(has_media && !camera->AABBInFrustum(center, size))
+ {
+ mImportanceToCamera = 0.f ;
+ return 0.f ;
+ }
+
+ F32 size_squared = size.lengthSquared() ;
LLVector3 lookAt = center - camera->getOrigin();
F32 dist = lookAt.normVec() ;
+ cos_angle_to_view_dir = lookAt * camera->getXAxis() ;
+ if(has_media)
+ {
+ 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 ;
+ }
+ }
+ }
//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;
@@ -1394,8 +1437,7 @@ 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) ;
}