From 223b8ecf70f9a1e1c1f30715baf36c2c8eadea28 Mon Sep 17 00:00:00 2001 From: gaozheng Date: Wed, 17 Jun 2026 17:58:43 +0800 Subject: [PATCH] =?UTF-8?q?perf(vtk):=20=E7=93=A6=E7=89=87=E5=B0=B1?= =?UTF-8?q?=E8=BF=91=E4=BC=98=E5=85=88=E5=8A=A0=E8=BD=BD(=E7=A6=BB?= =?UTF-8?q?=E7=9B=B8=E6=9C=BA=E8=BF=91=E7=9A=84=E5=85=88=E6=8B=89,?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=AD=A3=E7=9C=8B=E5=8C=BA=E5=9F=9F=E6=9C=80?= =?UTF-8?q?=E5=85=88=E5=87=BA)+=E5=B9=B6=E5=8F=918->12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/TileBasemap.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/app/TileBasemap.cpp b/src/app/TileBasemap.cpp index 4cde51d..e403a52 100644 --- a/src/app/TileBasemap.cpp +++ b/src/app/TileBasemap.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -47,7 +48,7 @@ constexpr int kMaxLeaves = 200; // 一次覆盖的叶瓦片上限(安全 constexpr double kRangeFactor = 10.0; constexpr double kRangeFloor = 2000.0; // 至少 2km(小剖面也有足够地理背景) constexpr double kRangeCeil = 30000.0; // 最多 30km(防远裁剪面失控) -constexpr int kMaxConcurrent = 8; // 瓦片请求最大并发(防暴发饱和单域名连接) +constexpr int kMaxConcurrent = 12; // 瓦片请求最大并发(天地图 8 子域+Mapbox,适度提高吞吐) constexpr int kMinZoom = 3; constexpr int kMaxZoom = 18; constexpr double kGroundZ = 0.0; // 底图置于 z=0 地面参考(剖面深度向下为负,落其下) @@ -287,12 +288,23 @@ void TileBasemap::refresh() { for (int dx = -1; dx <= 1; ++dx) refineTile(kRootZoom, root.x + dx, root.y + dy, desired_, count); - // 拉取缺失瓦片(旧层暂不删,落地后由 purgeStale 清理)。 + // 拉取缺失瓦片:按离相机距离排序,最近的先拉 → 用户正看的区域最先出现(而非粗/远块先出)。 + std::vector> todo; for (long long key : desired_) { if (placed_.count(key) || inFlight_.count(key)) continue; int z, x, y; unpackKey(key, z, x, y); - fetchTile(z, x, y, key); + const geopro::render::LonLatBox b = geopro::render::tileBounds(z, x, y); + const auto sw = frame_->toLocal(b.south, b.west); + const auto ne = frame_->toLocal(b.north, b.east); + const double cx = (sw.x + ne.x) * 0.5 - camX_, cy = (sw.y + ne.y) * 0.5 - camY_; + todo.push_back({cx * cx + cy * cy, key}); + } + std::sort(todo.begin(), todo.end()); + for (const auto& t : todo) { + int z, x, y; + unpackKey(t.second, z, x, y); + fetchTile(z, x, y, t.second); } purgeStale();