summaryrefslogtreecommitdiff
path: root/indra/newview/llvotree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llvotree.cpp')
-rw-r--r--indra/newview/llvotree.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp
index 0efe6682be..9c08c0eec1 100644
--- a/indra/newview/llvotree.cpp
+++ b/indra/newview/llvotree.cpp
@@ -448,22 +448,35 @@ void LLVOTree::render(LLAgent &agent)
void LLVOTree::setPixelAreaAndAngle(LLAgent &agent)
{
- // First calculate values as for any other object (for mAppAngle)
- LLViewerObject::setPixelAreaAndAngle(agent);
-
- // Re-calculate mPixelArea accurately
+ LLVector3 center = getPositionAgent();//center of tree.
+ LLVector3 viewer_pos_agent = gAgentCamera.getCameraPositionAgent();
+ LLVector3 lookAt = center - viewer_pos_agent;
+ F32 dist = lookAt.normVec() ;
+ F32 cos_angle_to_view_dir = lookAt * LLViewerCamera::getInstance()->getXAxis() ;
- // This should be the camera's center, as soon as we move to all region-local.
- LLVector3 relative_position = getPositionAgent() - gAgentCamera.getCameraPositionAgent();
- F32 range_squared = relative_position.lengthSquared() ;
+ F32 range = dist - getMinScale()/2;
+ if (range < F_ALMOST_ZERO || isHUDAttachment()) // range == zero
+ {
+ mAppAngle = 180.f;
+ }
+ else
+ {
+ mAppAngle = (F32) atan2( getMaxScale(), range) * RAD_TO_DEG;
+ }
F32 max_scale = mBillboardScale * getMaxScale();
F32 area = max_scale * (max_scale*mBillboardRatio);
-
// Compute pixels per meter at the given range
- F32 pixels_per_meter = LLViewerCamera::getInstance()->getViewHeightInPixels() / tan(LLViewerCamera::getInstance()->getView());
+ F32 pixels_per_meter = LLViewerCamera::getInstance()->getViewHeightInPixels() / (tan(LLViewerCamera::getInstance()->getView()) * dist);
+ mPixelArea = pixels_per_meter * pixels_per_meter * area ;
+
+ F32 importance = LLFace::calcImportanceToCamera(cos_angle_to_view_dir, dist) ;
+ mPixelArea = LLFace::adjustPixelArea(importance, mPixelArea) ;
+ if (mPixelArea > LLViewerCamera::getInstance()->getScreenPixelArea())
+ {
+ mAppAngle = 180.f;
+ }
- mPixelArea = (pixels_per_meter) * (pixels_per_meter) * area / range_squared;
#if 0
// mAppAngle is a bit of voodoo;
// use the one calculated LLViewerObject::setPixelAreaAndAngle above