maps: render buildings from z13 to match the new planet archive
- Commit
13a8849f39fcaa62574a5c311c5e7dbd3c3fe48e- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-05 03:24 UTC (1 day ago)
- Parents
e4c33ff
The live planet5 archive (build 0xa28884b9a29a7279) now carries building and building_part features at z13, but the app only drew buildings from z14, so a z13 view showed no footprints. The builder-side change that produced that archive lowered the schema floor and the basemap style floor to 13; this is the matching app-side change. Two app-side gates defined the floor, and both are lowered here: - The buildings layer in basemap.flat.json carried minzoom 14. That value drives tessellation (a tile builds the layer when its ANCESTOR_DEPTH window reaches the floor) and the per-frame draws_at gate, so it is now 13. - The extruded 3D pass had its own camera floor, BUILDINGS_DRAW_MIN_ZOOM 14.0 in the renderer, documented as matching the style floor but not moved by the builder change. Buildings tessellate into the extruded mesh rather than a flat fill, so with only the style moved nothing would have drawn at z13. It is now 13.0, and a new unit test pins it to the style layer floor so the two cannot drift apart again. The renderer zoom-gating was checked for z13 artefacts. The ancestor window is generic: ANCESTOR_DEPTH is 4, tessellation gates on z + ANCESTOR_DEPTH reaching the layer floor, and the resident set keeps ancestors by the same depth, with no buildings-specific zoom constants anywhere else. Lowering the floor by one level therefore moves the tessellation boundary from z10 to z9 exactly: a z9 tile now carries buildings as a stand-in for zooms up to z13, a z8 tile still carries none, and extrusion heights already scale from the tile own zoom and latitude, as they did when a z10 tile stood in for z14. A new geometry test pins that boundary. Fetch is not layer-gated (the camera zoom tile is fetched as-is), and the z13 tiles in the new archive are what the z13 camera now asks for. Older archives simply have no building features in their z13 tiles, so this draws nothing extra there; the archive max zoom is unchanged. Doc comments that named the old floor (z14) for the building mesh, pipeline, upload and draw-pass gates are updated to z13. User-visible effect: buildings, flat at pitch 0 and extruded when tilted, render one zoom earlier against the new planet archive. Verified test-first: the updated style zoom-gate tests and the new ancestor-window test failed against the z14 floor (3 failures), then passed after the change. cargo test --release -p map_renderer: 582 passed, 0 failed (1 live-network test ignored). cargo fmt --check clean; the 2 clippy warnings are in untouched files (transit.rs, caching.rs). Gradle with the JDK21 devvm environment: :maps:lint :maps:lintVitalRelease :maps:testDevUnitTest :library:map:lint :library:map:testDebugUnitTest all pass (BUILD SUCCESSFUL), so there were no failures to prove pre-existing.
Diff
library/map/src/main/rust/src/style/tests.rs
diff --git a/library/map/src/main/rust/src/style/tests.rs b/library/map/src/main/rust/src/style/tests.rsindex 951c629d1b..dd5b2a5d41 100644--- a/library/map/src/main/rust/src/style/tests.rs+++ b/library/map/src/main/rust/src/style/tests.rs@@ -101,7 +101,7 @@ fn the_landuse_park_family_is_gated_off_at_world_zoom() { #[test] fn only_a_declared_cost_floor_gates_a_fill_by_zoom() { for l in layers().iter().filter(|l| l.kind == LayerKind::Fill) {- let expected = if l.id == "buildings" { 14 } else { 0 };+ let expected = if l.id == "buildings" { 13 } else { 0 }; assert_eq!( (l.min_zoom, l.max_zoom), (expected, paint::MAX_ZOOM),
library/map/src/main/rust/src/style/tests_part2.rs
diff --git a/library/map/src/main/rust/src/style/tests_part2.rs b/library/map/src/main/rust/src/style/tests_part2.rsindex f1f4997a44..816b3c3f65 100644--- a/library/map/src/main/rust/src/style/tests_part2.rs+++ b/library/map/src/main/rust/src/style/tests_part2.rs@@ -159,8 +159,8 @@ fn the_interned_whitelist_is_the_authored_one() { fn zoom_ranges_gate_the_expensive_layers() { // Buildings are the densest layer in the schema, so they stay off until they are // worth drawing.- assert!(!find("buildings").draws_at(13));- assert!(find("buildings").draws_at(14));+ assert!(!find("buildings").draws_at(12));+ assert!(find("buildings").draws_at(13)); assert!(find("earth").draws_at(0)); assert!(find("earth").draws_at(22)); }
library/map/src/main/rust/src/tile/geometry/mesh.rs
diff --git a/library/map/src/main/rust/src/tile/geometry/mesh.rs b/library/map/src/main/rust/src/tile/geometry/mesh.rsindex ec9620700a..92db5474d5 100644--- a/library/map/src/main/rust/src/tile/geometry/mesh.rs+++ b/library/map/src/main/rust/src/tile/geometry/mesh.rs@@ -63,7 +63,7 @@ pub struct LayerMesh { /// /// Kept apart from [`LayerMesh`] because it is neither a flat 2D layer nor drawn through the fill /// pipeline: its vertices carry a height, a normal and a per-vertex colour, and it draws through-/// the building pipeline WS-A added with depth on. Empty on every tile below z14 and on any tile+/// the building pipeline WS-A added with depth on. Empty on every tile below z13 and on any tile /// with no `buildings` layer. #[derive(Default)] pub struct BuildingMesh {@@ -232,7 +232,7 @@ pub struct TileMesh { pub x: u32, pub y: u32, pub meshes: Vec<LayerMesh>,- /// The tile's extruded 3D buildings, or an empty mesh below z14 / where the tile has none.+ /// The tile's extruded 3D buildings, or an empty mesh below z13 / where the tile has none. /// Drawn depth-tested through the building pipeline, not in the flat layer loop. pub buildings: BuildingMesh, /// The tile's DEM-displaced ground grid (WS-G), or an empty mesh where the tile carries no
library/map/src/main/rust/src/tile/geometry/tests_extra3.rs
diff --git a/library/map/src/main/rust/src/tile/geometry/tests_extra3.rs b/library/map/src/main/rust/src/tile/geometry/tests_extra3.rsindex f136590904..2a4a188cfb 100644--- a/library/map/src/main/rust/src/tile/geometry/tests_extra3.rs+++ b/library/map/src/main/rust/src/tile/geometry/tests_extra3.rs@@ -270,7 +270,7 @@ fn a_building_with_no_side_table_still_extrudes_a_default_box() { #[test] fn buildings_are_not_extruded_far_below_their_zoom() { use tilecodec::mamaps::body::BuildingAttrs;- // A coarse tile outside the z14 ancestor window carries no buildings at all, the same gate+ // A coarse tile outside the z13 ancestor window carries no buildings at all, the same gate // every zoomed-in layer uses. let coarse = build( &building_body(Some(BuildingAttrs { height: 300, ..Default::default() })),@@ -282,3 +282,19 @@ fn buildings_are_not_extruded_far_below_their_zoom() { ); assert!(coarse.buildings.indices.is_empty(), "a z5 tile is far below the buildings zoom"); }++#[test]+fn buildings_enter_the_ancestor_window_exactly_at_the_style_floor() {+ use tilecodec::mamaps::body::BuildingAttrs;+ // deepest = z + ANCESTOR_DEPTH(4): a z9 tile stands in for zooms up to z13, so it must+ // carry buildings for the z13 floor; a z8 tile tops out at z12 and must not.+ let body = building_body(Some(BuildingAttrs { height: 300, ..Default::default() }));+ let layers = style::layers();+ let at_edge = build(&body, layers, 9, 0, 256, false);+ assert!(!at_edge.buildings.indices.is_empty(), "a z9 ancestor of a z13 view carries buildings");+ let below = build(&body, layers, 8, 0, 128, false);+ assert!(+ below.buildings.indices.is_empty(),+ "a z8 tile never stands in at z13, so carries none"+ );+}
library/map/src/main/rust/src/vulkan/pipeline/pipelines_extra.rs
diff --git a/library/map/src/main/rust/src/vulkan/pipeline/pipelines_extra.rs b/library/map/src/main/rust/src/vulkan/pipeline/pipelines_extra.rsindex 3991a7b838..046142970a 100644--- a/library/map/src/main/rust/src/vulkan/pipeline/pipelines_extra.rs+++ b/library/map/src/main/rust/src/vulkan/pipeline/pipelines_extra.rs@@ -33,7 +33,7 @@ pub struct Pipelines { /// The 3D building pipeline (WS-A): the extruded walls and roof caps of the `buildings` layer. /// Its own vertex format — position + height + normal + per-vertex ARGB colour — and its own /// `building.vert`/`building.frag`, depth-tested ([`Depth::TestWrite`]) so buildings occlude- /// one another and the basemap at z14+. Takes the push-only [`layout`](Self::layout): it samples+ /// one another and the basemap at z13+. Takes the push-only [`layout`](Self::layout): it samples /// no atlas, its colour is per-vertex. At pitch 0 its vertex shader collapses to the footprint, /// so the flat map is unchanged. pub building: vk::Pipeline,
library/map/src/main/rust/src/vulkan/renderer/mod.rs
diff --git a/library/map/src/main/rust/src/vulkan/renderer/mod.rs b/library/map/src/main/rust/src/vulkan/renderer/mod.rsindex db6e752dfd..d40003a6ac 100644--- a/library/map/src/main/rust/src/vulkan/renderer/mod.rs+++ b/library/map/src/main/rust/src/vulkan/renderer/mod.rs@@ -116,7 +116,7 @@ pub(crate) struct ResidentTile { /// Pooled-path arena ranges, released to the pool when the tile leaves the retiring queue. arena_ranges: Vec<upload_pool::ArenaRange>, layers: Vec<LayerBuffers>,- /// The tile's extruded 3D buildings, or `None` below z14 / where the tile has none. Drawn in+ /// The tile's extruded 3D buildings, or `None` below z13 / where the tile has none. Drawn in /// its own depth-tested pass ([`Renderer::record_buildings`]), not the flat layer loop. /// One combined mesh per tile, so this keeps its own buffer pair — nothing to pool. buildings: Option<BuildingBuffers>,@@ -200,7 +200,7 @@ struct CarriagewayBuffers { /// /// One combined mesh per tile — every building in the tile, walls and roofs — in the 7-float /// `tess::roof` vertex format, drawn depth-tested through [`Pipelines::building`]. `None` on a tile-/// with no buildings, which is every tile below z14.+/// with no buildings, which is every tile below z13. struct BuildingBuffers { vertices: Buffer, indices: Buffer,@@ -387,7 +387,7 @@ const TRAFFIC_WIDTH_DP: f32 = 4.0; /// `minzoom`. A tile may carry building geometry as a deeper-zoom ancestor stand-in, but the pass /// is gated on the camera's own zoom so buildings appear only once the map is zoomed in far enough /// for the extruded detail to read — below it the map is the flat basemap it always was.-const BUILDINGS_DRAW_MIN_ZOOM: f64 = 14.0;+const BUILDINGS_DRAW_MIN_ZOOM: f64 = 13.0; /// One placed label as the pick path sees it: everything `pickLabels` needs /// to answer without touching tiles, layers, or the camera.@@ -470,3 +470,17 @@ fn argb_to_rgba(argb: u32) -> [f32; 4] { ((argb >> 24) & 0xFF) as f32 / 255.0, ] }++#[cfg(test)]+mod tests {+ use super::BUILDINGS_DRAW_MIN_ZOOM;++ #[test]+ fn the_buildings_draw_floor_matches_the_style_floor() {+ let buildings = crate::style::layers()+ .iter()+ .find(|l| l.id == "buildings")+ .expect("the basemap carries a buildings layer");+ assert_eq!(BUILDINGS_DRAW_MIN_ZOOM, buildings.min_zoom as f64);+ }+}
library/map/src/main/rust/src/vulkan/renderer/record_extra.rs
diff --git a/library/map/src/main/rust/src/vulkan/renderer/record_extra.rs b/library/map/src/main/rust/src/vulkan/renderer/record_extra.rsindex 5de4a3d84e..1b136af208 100644--- a/library/map/src/main/rust/src/vulkan/renderer/record_extra.rs+++ b/library/map/src/main/rust/src/vulkan/renderer/record_extra.rs@@ -183,7 +183,7 @@ impl Renderer { /// shared by every tile. `line.x` carries the tile's world-px span, the scale that turns the /// mesh's tile-normalised heights into the world-px height the WS0 matrix's `z` input expects. /// Distance-fogged per tile toward the earth land colour like the flat layers (buildings keep their- /// per-vertex colours and are deliberately not fogged — no shader change for a z14+-only+ /// per-vertex colours and are deliberately not fogged — no shader change for a z13+-only /// layer whose tiles sit inside the near ramp anyway). /// /// Since v8 the `earth` fill arm reads source `landtype` (matched by style id, because the@@ -302,7 +302,7 @@ impl Renderer { /// Draw the extruded 3D buildings: each resident tile's combined building mesh, depth-tested so /// buildings occlude one another and sit above the flat basemap drawn before them. Only at- /// z14+, where the extruded detail is legible; below that nothing is drawn and the map is the+ /// z13+, where the extruded detail is legible; below that nothing is drawn and the map is the /// flat basemap it always was. At pitch 0 the building vertex shader collapses height to the /// footprint, so from directly overhead the buildings read as their 2D outline. ///
library/map/src/main/rust/src/vulkan/renderer/record_extra4.rs
diff --git a/library/map/src/main/rust/src/vulkan/renderer/record_extra4.rs b/library/map/src/main/rust/src/vulkan/renderer/record_extra4.rsindex fbe8fdd844..6e70ab1549 100644--- a/library/map/src/main/rust/src/vulkan/renderer/record_extra4.rs+++ b/library/map/src/main/rust/src/vulkan/renderer/record_extra4.rs@@ -118,7 +118,7 @@ impl Renderer { ); self.step_times.borrow_mut().record(Step::RecordCarriageways, nanos_since(step_start)); // 3D buildings: after the flat basemap so they paint over it, depth-tested so they occlude- // one another. Gated to z14+; at pitch 0 the building matrix collapses height to the+ // one another. Gated to z13+; at pitch 0 the building matrix collapses height to the // footprint, so the flat overhead map is unchanged. Before the deferred symbols, so POI // icons and labels are not buried behind a tower. let step_start = std::time::Instant::now();
library/map/src/main/rust/src/vulkan/renderer/upload.rs
diff --git a/library/map/src/main/rust/src/vulkan/renderer/upload.rs b/library/map/src/main/rust/src/vulkan/renderer/upload.rsindex 5aabb9ebd3..80a268a51d 100644--- a/library/map/src/main/rust/src/vulkan/renderer/upload.rs+++ b/library/map/src/main/rust/src/vulkan/renderer/upload.rs@@ -190,7 +190,7 @@ impl Renderer { let carriageways = upload_tail::build_carriageways(&mesh, &ribbon_first); // The tile's 3D buildings, if any: one combined mesh, uploaded fresh — 2 allocs // when present, counted below. Buildings and terrain stay on the fresh path- // deliberately: they are single meshes per tile (not packed groups), rare (z14++ // deliberately: they are single meshes per tile (not packed groups), rare (z13+ // with extruded detail only), and pooling them would complicate the arena // bookkeeping for no steady-state gain — the packed groups are the per-frame cost. let buildings = if mesh.buildings.indices.is_empty() {
library/map/src/main/rust/style/basemap.flat.json
diff --git a/library/map/src/main/rust/style/basemap.flat.json b/library/map/src/main/rust/style/basemap.flat.jsonindex 7349ee58cb..3b96d710a2 100644--- a/library/map/src/main/rust/style/basemap.flat.json+++ b/library/map/src/main/rust/style/basemap.flat.json@@ -292,7 +292,7 @@ "light": "#cccccc", "dark": "#3c4048", "opacity": 0.5,- "minzoom": 14+ "minzoom": 13 }, { "id": "roads-minor-casing",