summaryrefslogtreecommitdiff
path: root/indra/newview/llmeshrepository.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llmeshrepository.cpp')
-rwxr-xr-xindra/newview/llmeshrepository.cpp39
1 files changed, 29 insertions, 10 deletions
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index b6e3626cba..e259ee9846 100755
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -3100,9 +3100,7 @@ F32 LLMeshRepository::getStreamingCost(const LLSD& header, F32 radius)
F32 dlowest = llmin(radius/0.06f, 256.f);
F32 dlow = llmin(radius/0.24f, 256.f);
F32 dmid = llmin(radius/1.0f, 256.f);
- F32 dhigh = 0.f;
-
-
+
F32 bytes_lowest = header["lowest_lod"]["size"].asReal()/1024.f;
F32 bytes_low = header["low_lod"]["size"].asReal()/1024.f;
F32 bytes_mid = header["medium_lod"]["size"].asReal()/1024.f;
@@ -3128,14 +3126,35 @@ F32 LLMeshRepository::getStreamingCost(const LLSD& header, F32 radius)
bytes_lowest = bytes_low;
}
- F32 cost = 0.f;
- cost += llmax(256.f-dlowest, 1.f)/32.f*bytes_lowest;
- cost += llmax(dlowest-dlow, 1.f)/32.f*bytes_low;
- cost += llmax(dlow-dmid, 1.f)/32.f*bytes_mid;
- cost += llmax(dmid-dhigh, 1.f)/32.f*bytes_high;
+ F32 max_area = 65536.f;
+ F32 min_area = 1.f;
+
+ F32 high_area = llmin(F_PI*dmid*dmid, max_area);
+ F32 mid_area = llmin(F_PI*dlow*dlow, max_area);
+ F32 low_area = llmin(F_PI*dlowest*dlowest, max_area);
+ F32 lowest_area = max_area;
+
+ lowest_area -= low_area;
+ low_area -= mid_area;
+ mid_area -= high_area;
+
+ high_area = llclamp(high_area, min_area, max_area);
+ mid_area = llclamp(mid_area, min_area, max_area);
+ low_area = llclamp(low_area, min_area, max_area);
+ lowest_area = llclamp(lowest_area, min_area, max_area);
+
+ F32 total_area = high_area + mid_area + low_area + lowest_area;
+ high_area /= total_area;
+ mid_area /= total_area;
+ low_area /= total_area;
+ lowest_area /= total_area;
+
+ F32 weighted_avg = bytes_high*high_area +
+ bytes_mid*mid_area +
+ bytes_low*low_area +
+ bytes_lowest*lowest_area;
- cost *= gSavedSettings.getF32("MeshStreamingCostScaler");
- return cost;
+ return weighted_avg * gSavedSettings.getF32("MeshStreamingCostScaler");
}