summaryrefslogtreecommitdiff
path: root/indra/newview/llvotree.cpp
diff options
context:
space:
mode:
authorXiaohong Bao <bao@lindenlab.com>2010-08-18 11:33:01 -0600
committerXiaohong Bao <bao@lindenlab.com>2010-08-18 11:33:01 -0600
commit3ac134ec228d81a222d4df58be9577faa6757539 (patch)
tree263b1bc328fa1f8fb2c9164146d8b69946b2f592 /indra/newview/llvotree.cpp
parent0742f89208c016e5b9e73e471e669445bffde744 (diff)
EXT-8673: FIXED: UDP texture loading is slower in 2.x viewers than 1.23.5
Improved the following: 1, make sure the texture callback queue is properly handled and cleaned in time; 2, estimate the LLVOTree pixel area more accurately; 3, eliminate the possibility of back and forth stopping/restarting a texture fetching
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