Repository navigation
Description
Rewritten to option C (GP7-C) after the owner's direction of 2026-11-05 (#3096, comments 6668537331 and 6670626340). The previous body (CPU heights, refinement, floors, pieces per node) is in this issue's edit history.
Status: approved
Part of #3096. One pull request into ground-plan: #3160.
Depends on: GP3 and GP3R (faces and the near records of a cell), GP6 (height_at on the GPU, merged in #3140).
TL;DR
Goal: Each cell gives the GPU the 2D topology of the ground that the terrain grid cannot draw: the sharp faces, one ring of ground about them, and a strip that meets the terrain grid. The GPU gives each corner its height, look fields and normal from the one height function, once per cell. The CPU builds no height.
Problem: GP7 as first built (CDT, Ruppert at 20°, CPU heights and normals over the whole owned region) took 5–6 s per town cell and about 22 s per jump.
Decision: R = the level-17 cells of the sharp faces, grown by two rings; the outer ring is the strip. One bulk-loaded CDT of D = R ∖ S with the faces' edges and the level-18 grid, no refinement. Corners are (point, label). One step slot per face-edge piece between two labels, always drawn. The terrain sinks its vertices strictly inside R, so no floors are necessary. One mesh range (level-18 grid); the far look B (GP8) draws past it.
Rejected:
- Ruppert refinement and a least angle: thin triangles of correct geometry are valid (owner); the rosettes at cm-short edges go.
- CPU heights and normals: seconds per town cell; the GPU computes them once per cell (GP9).
- Floors (CPU or GPU pass): the sunk vertices and the strip of the terrain's own triangles keep the terrain under the mesh by construction.
- A second mesh range at level 17: B draws past the near range.
- Grid points only outside paved faces: the interpolation error inside a road is about 2× higher (spike, p99 20–28 mm against 8–13 mm).
Design (the code is the reference: host/obc-ground-plan/src/mesh/)
- Sharp face: a face whose height rule is not slope or terrain.
- R: the level-17 cells whose open square meets the inside of a sharp face, grown by
FACE_RING= 2 rings (Chebyshev). R is a union of 5 × 5 squares. S (the strip): the cells of R with an 8-neighbour outside R; one cell wide. D = (R ∖ S) ∩ cell. - Rim: each cell gives its neighbours its sharp marks (one bit per level-17 cell) and its plan vertices on its four lines. R about a cell reads the rims of the cell and its 8 neighbours, so two cells agree on R.
- Points and constraints of D: every face edge with a sharp face on a side, split into equal pieces of at most
l_max(4 m paved, 3 m shoulder and verge, 2 m blend, 2.4 m ground); D's border, locked: each side of a D cell toward a non-D cell, with its middle point (a level-18 grid point); a span on the cell line also holds the plan vertices of both cells on it, and its middle only where it lies more than 0.4 m from them; the level-18 grid points inside D, 0.4 m or more from every face edge, in every face. Edges between two ground faces are no constraints: the ground is one continuous field. - Triangulation: one
try_bulk_load_cdtof all points and constraints. A crossing of two constraints returnsMeshError::InvalidPlan. A flood fill from the face edges, then from D's border, gives each triangle its face. - Strip: each strip cell is the terrain's own 8 triangles over its 3 × 3 level-18 points. A point on ∂R is a terrain vertex: the GPU draws it with the terrain's vertex code (it slides, morphs and takes the page's height). Every other point is a fixed ground corner. A unit test shows that no strip triangle turns over, for all 255 neighbour patterns and every morph.
- Corners: a sharp face's triangles take the face's label (
face_labels, the records' label). A ground triangle takes at each point the point's one ground corner, labelled by the ground face that holds the point: the ground side of a face edge at the point, else the face raster at a grid point, elserecords::find(points on the cell lines). - Step slots: one per face-edge piece p → q between two labels: the corners of the left face at p and q, then those of the right face. Always drawn as two triangles that meet at the zero point of the step. No threshold, no counter, no indirect draw.
- Sunk points: the level-18 grid points of the cell strictly inside R. The terrain draws such a vertex far below the mesh. Every terrain triangle inside R then has a sunk corner, or all three corners on ∂R and is the strip's own triangle.
- Bytes:
CellMesh::to_bytes(module doc ofmesh/mod.rs): a head, corners (2 words: x, y in 19 bits each, a 25-bit label, the terrain-vertex flag), triangles (3 × u32), step slots (4 × u32), sunk bits (257 × 257). One piece per cell. - Bridge and worker: the cell build makes the faces and the near records in one pass.
CellPlan.rim(),CellPlan.mesh_input(),MeshInput.mesh(rims),MeshInput.records(). The plan worker keeps the rims and meshes a cell when the rims of its 8 neighbours are there (at most 12 cells wait; the oldest then meshes with the rims that are there).Built.meshescarries each mesh with its near records.
Checks
obc test -p obc-ground-plan --lib mesh: region marks, the strip's morph test.obc test -p obc-ground-plan --test mesh: all 256 fixture cells: every triangle turns asgridIndices, every edge has two triangles or lies on a cell line or ∂R; ground corners carry the records' label; two neighbour cells have the same corners and height bits (CPU twin ofheight_at) on their shared line. About 35 s.- Dropped by the owner: the angle gate, the CPU floor twin, the native = WASM hash.
Measurements
All 256 fixture cells, timosPC, one thread, release, load 14–17 (other agents and the terrain run). Median / p95 / max per cell, ms. Evidence: /media/timo/OSM1/tmp/ground-plan/gp7c/ (native/, wasm/, INDEX.md).
| Per cell | Native | WASM (Node 24, the bridge) | Reference |
|---|---|---|---|
| Mesh stage | 6.1 / 47 / 90 | 8.1 / 72 / 200 | GP7 first build: 6,000 (v12 town cell); spike C: 12.5 / 133 / 270 |
| of it: region, points, triangulation, corners | 0.3 / 0.9 / 3.5 / 1.4 (p95 0.4 / 4.4 / 37 / 6.0) | – | |
| Faces and near records | 7.9 / 104 / 254 | – | |
| Whole cell (decode, graph, faces and records, rim, mesh) | 17 / 155 / 359 | 32 / 260 / 447 | develop's road job: 72–84 median |
| Jump: all cells within 600 m of a view (52 views whose cells all have their tiles) | Native | WASM, one worker |
|---|---|---|
| Whole build, median / p95 / max (s) | 1.17 / 2.56 / 2.63 | 1.95 / 3.27 / 3.27 |
| Of it the mesh (s) | 0.33 / 0.69 / 0.71 | 0.57 / 1.01 / 1.03 |
With two workers the WASM jump is about 1.0 / 1.6 s (half; not measured). GP3's faces and records are about 70 % of it.
| Per view (cells within 600 m, median / max) | GP7-C | Develop |
|---|---|---|
| Triangles drawn: D + strip + 2 per step slot | 587k / 1,060k (D 360k / 667k, strip 120k / 173k, slots 106k / 223k) | 156k / 409k road triangles |
| Corners | 311k / 555k | – |
| Bytes to the GPU (corners 8 B, triangles 12 B, slots 16 B, sunk bits 8 kB per cell) | 9.2 / 16.4 MB | – |
Per cell: corners 4,705 / 36,262 / 67,537; triangles 7,252 / 56,163 / 98,663 (strip 2,136 / 12,832 / 17,456); slots 593 / 6,750 / 15,536. R covers 5 % / 37 % / 60 % of a cell. The 600 m disc is an upper bound: the mesh draws only over level-18 nodes. A slot of no step covers no pixel, but its vertices run.
WASM size: 1,676,975 B raw, 643,415 B gzipped (the faces alone: 1,410,161 / 537,529); the budget is now the head build rounded up to 16 KiB.
Checks over the fixture (tests/mesh.rs): 0 validity faults; on 480 shared cell lines no difference in corners or height bits over 1 mm, 2 points with a sub-mm step (0.18 and 0.35 mm) between two labels that one cell holds and the other does not; 0 ground corners with a label other than the records'; 69 sharp triangles in GP3R's known patch class (a crossing over a rail bed) carry the face plan's label; 631 ground corners on an edge between two ground faces carry the other ground label (equal heights).
Out of scope
- GP9: the GPU passes (corners: heights, look fields, normals; the step slots' vertex shader), the sinking of terrain vertices, the draw, the range, the crack count.
- GP11: the looks. GP12: decks. GP14: water surfaces.
Deviations from the option C proposal and its review
- No floors: sunk vertices. The terrain draws each level-18 vertex strictly inside R far below the mesh (the sunk bits). The strip is the terrain's own triangles, so every terrain triangle inside R has a sunk corner or is the strip's own triangle. This replaces the floors pass of the proposal (step 10) and review change 3 (floors from the page heights): there is no floor value, no atomic and no recompute after a stamp. It was the owner's idea to try first; it holds in the 2D tests (morph test, validity), not yet on the GPU.
- The strip: the terrain's own 8 triangles per strip cell, with fixed ground corners where the terrain has no ∂R vertex. GP7's first body filled holes by a search over triangulations and kept level-18 points off the inner border. Here the inner border holds the level-18 middle point of each side as a fixed vertex (it never slides), so no search, no pattern table and no strip growth are necessary. 8 triangles per strip cell.
- Neighbour data: a cell reads its neighbours' rims (sharp marks and plan vertices on the shared lines), not their whole plans. The border spans hold their ends, both cells' plan vertices on them and the middle point; no feet, no halving (they served the angle bound).
- Ground labels come from the face plan: the ground side of a face edge at the point, else a scan-line raster of the faces at the grid points, else
records::findon the cell lines. Againstfindover the fixture: 0 wrong ground corners. 69 sharp triangles (one level crossing over a rail bed, cell 34296/23098) take the face plan's rail-bed label where the records give the crossing: GP3R's known "patch" class. - One piece per cell, u32 indices. No pieces per level-18 node and no 16-bit parts: GP9 draws per cell today. A town cell has about 60k corners, so 16-bit indices would need pieces.
- The step's material is not in the slot: the GPU takes the look from the two labels and the step's height (review finding 10).
- Border steps: a face edge on the cell line has no slot (a plan holds its own cell's faces). Over the fixture's 480 shared lines, 2 points have a sub-mm step (0.18 and 0.35 mm) between two labels that one cell holds and the other does not; no other difference in corners or height bits.
- The cell build makes the faces and the near records in one pass in the bridge (the mesh's labels index that block).
Generated by Claude Code
Activity
timohueser commentedon Nov 3, 2026
Deviation from GP1 (PR #3117), for this sub-issue:
Terrain::new(key, pages)takes the cell key and keeps only the pages thatTerrain::wanted(key)lists, so heights depend on the cell alone.Terrain::heightis defined only inside the cell grown by its margin and answersNonepast level 13; handleNone, do not query outside that square.timohueser commentedon Nov 3, 2026
Note from GP0's review (PR #3118): the road worker's build times in the baseline are approximate:
roads/road-worker.tshandles messages async and awaits tile and ground decodes, so a later job can answer first. GP7 times its cell build inside the worker (the build itself, decode apart).timohueser commentedon Nov 3, 2026
Deviations from GP5 phase A (draft PR #3124), for this sub-issue: a build request holds a tile list, because a cell reads 1–4 zoom-13 tiles (
feature_tiles); the bridge hasadd_tile(column, row, bytes)andfeature_tiles(x, y), and a cell is empty only when none of its tiles exists.cell::build_cell(bytes, rules, now)takes the request bytes, runsSTAGESand times each stage (the clock changes no output); later stages add themselves toSTAGES. The plan digest (FNV-1a over the canonical bytes) is computed only for the debug draw, so build timings exclude it. Stats JSON is written by hand (no serde): add new stats toFlat::of. The timing page isbuilder/web/plan-timing.html(native vs WASM in Chrome; the iPhone steps are inbuilder/ground-plan-wasm/README.md).timohueser commentedon Nov 3, 2026
More from GP5's review round (draft PR #3124): the timing page reports
first(only row 1 runs on a cold instance) andmean(elapsed time of all later runs ÷ their count; Safari clampsperformance.now()to about 1 ms, so per-run times of a few ms are coarse there).PlanStats.build.prepareholds the worker's gunzip and WebP decode time per cell (median 2.1 ms in Chrome; the first cell about 107 ms for the decoder's first use). Therequestsindex lists each cell's fixture input files assources. The bridge'sdigest()throws on a NaN in the plan. The viewer'sreadyof 4.7–6.7 s on top views is mostly the wait for the pages to go idle, not build time: the 2 s jump gate needs its own measurement.timohueser commentedon Nov 5, 2026
DRAFT for review: a new body of GP7 for the one road model. This comment does not change the issue body. An independent reviewer reads it before the owner does.
Sources: the round's proposal (#3096 (comment)), its review (#3096 (comment)), the owner's decisions of 2026-11-05 (#3096 (comment)), the GP6 draft on #3113, and on timosPC
/media/timo/OSM1/tmp/ground-plan/one-model/(PROPOSAL-heights.md,heights/cost/,q4w/,shapes/far/).How to read it. GP7's mesh stays as approved. What changes is where its heights, normals, look frames and owned region come from. A section marked unchanged keeps the approved text word for word; the body edit copies it. Every other section is new text.
TrailView ground plan GP7: the mesh of GP3's faces on
height_at, its strip, pieces and floors, and the cell build timesStatus: draft (one road model)
Part of #3096. One pull request into ground-plan.
Depends on: #3100 (GP5), #3113 (GP6:
height_at,height_at_sides), GP3R ("the records of a cell", being filed: the near records), #3134 (GP3 follow-ups).TL;DR
Goal: Each cell's faces become a valid triangle mesh in two ranges (near and far), with locked cell borders, vertical faces only on face edges and only by a named rule, a strip that meets the terrain at every morph, pieces per level-18 node and floors that keep the terrain under the mesh. Every vertex takes its height from GP6's
height_atwith its face's label, so the mesh draws the same function as the far pages. The build time, the triangles, the bytes and the WASM size of every fixture cell are known, native, in Chrome and on the iPhone.Problem: The approved body meshes GP6's heights per face (
Heights::z,z_grad,frame) and takes the owned region from GP6's bit grid. In the one road model GP6 gives one point function over the records, with no gradient, no frame and no owned region. The far range draws the same function on its pages (GP8), so near and far agree only if the mesh reads it at its vertices.Decision: The triangulation, the locked lines, the strip, the floors, the vertex and the pieces stay as approved. Changes: (1) every vertex calls
height_atwith its face's label; an edge vertex callsheight_at_sideswith the labels of both sides (0.52× the time of two calls); (2) a vertical face stands only where the two sides differ by more than 1 mm andHeight.stepnames a rule; (3) the normal comes from central differences ofheight_atwith the vertex's label; (4) the look's across, along and half come from the label's host line by the same rule as the far look's fields; (5) the owned region comes from GP3's faces (every non-terrain face, slope bands included) and the footprints of the stamp's kept water and structure terms; (6) the WASM budget rises at GP7 (owner, 2026-11-05).Rejected:
height_atnow: about as much code again in Rust and WGSL. Central differences cost four calls per vertex; the bench decides (Measurements). If the cost is too high, GP6 adds the gradient.wedge.rsfor the look: the far look takes its fields from the label's host lines, so the mesh does the same.refine, a two-row strip, pieces cut at node lines, 32-bit indices, floors as f32, a height-error refinement in slope faces): unchanged.Systems: trailview
Contracts: none
Size: L (a mesh module of about 2,000 lines, a new dependency, the bridge and the timing page, the debug tool's layers, fixture-wide checks)
Facts
Unchanged (approved Facts 1 to 13 on the terrain grid,
vertex_place, the corridor vertex, pieces, spade,Cargo.lock, the fixture), with these lines replaced:height_at(block, q, label, t) -> Height { h, kind, owner, step }andheight_at_sides(block, q, [label_a, label_b], t) -> [Height; 2]. q is in frame units (about 1.6 mm) from the cell origin; t is the plain terrain at q. A face's label is the label of the records at every point of the face (GP3R's invariant: one set of candidates, onedecide).shapes/far/).builder/wasm/wasm_size_guard.pyonground-plan). Owner, 2026-11-05: raise the budget at GP7.q4w/mesh/,heights/round6/mesh/) clipped GP3's faces to a 0.5 m grid, tookheight_atwith each face's label, and filled the steps on face edges with walls. It shows a smooth road where the pages show a texel stair. It is not GP7's triangulation.Design
1. What GP7 takes and gives
Takes:
CellKey, the frame,Terrain::height, the debug tool.Facewith its label index,Edge, overlay priority), every face edge split at the cell lines. GP7 meshes faces of level 0.findfor a point's label where GP7 needs it.height_at,height_at_sides,Height.step.Gives: unchanged (
mesh_cell,MeshOptions { near },CellMesh,triangulate,morph::place), withmesh_cell(cell, plan, block, terrain, options)in place ofmesh_cell(cell, plan, heights, terrain, owned, options).2. Regions
height_atreturns T (the slope field fades into T withinband_fade_mof the band's edge, GP6 section 4), and the far pages hold the same function (GP8). So at the strip the page's height is the plain terrain.waterways.json'sreach; a lake's or the sea's shore ramp,SHORE_REACH_M(15 m) past the shore; a deck's trough, a bore's cover and a gallery's fill, the reaches ofstamp-core.wgsl(about 16 m past the way's edge). They come from GP1's feature lines. The footprints keep the strip on terrain that no kept stamp changes, so the strip's outer vertices take the plain terrain (the approved reason). Inside a footprint the mesh drawsheight_at, which knows no kept stamp, while the hidden page holds it (GP8 bounds the pages' heights by the kept water and structure terms). So until GP12 and GP14 the mesh draws plain ground over today's river banks, deck troughs and bore covers inside the owned region, as in the approved design.REGION_RING: unchanged.3. Locked lines
Unchanged. The split rule reads
height_at_sidesalong the line in place of GP6'szfor "every point where a step along the line changes sign".4. Triangulation
Unchanged, with "a face whose height rule is slope or terrain" read from the face's label.
5. Vertices, heights and vertical faces
height_at(block, p, label, T(p))with that face's label. A point on a face edge takesheight_at_sideswith the labels of the two faces. A point where more than two faces meet takesheight_at_sidesfor each pair of neighbours in cyclic order; each face's height is computed once.JOIN_M(1 mm). The rule reads heights, not edge kinds, so the mesh is closed whatever GP6 gives.KerbgivesMAT.KERB;NoRoom,CutWins,RailRoad,UnrelatedandStructureEndgiveMAT.WALL(GP11 givesRailRoadits retaining-wall look). A vertical face where neither side names a step counts inunnamed_steps(target 0; a GP6 fault, reported with its place).cut_max), by surface (steep_inside). Reported; the target is 0 on paved faces.height_atwith the vertex's own label at ±NORMAL_STEP_Malong east and south (four calls; they do not need a label at the offset points, because the label is fixed). A vertex on a step edge takes the normal of its own side. Stored octahedral, as approved.6. The strip
Unchanged.
7. Floors
Unchanged.
8. The vertex
Unchanged (20 bytes, five words). Word 4 holds the normal of section 5.
9. Pieces
Unchanged, with the contract with GP9.
10. Look attributes
One function,
look::vertex_look(block, face, p) -> VertexLook { word, across, along }. GP11 owns what the fields mean and replaces the body; GP7 writes the first version:lookOf,drawnCodeandmarked, as approved. Sidewalk, kerb top and ground faces as approved.model_atuses for its fields in the far look (GP3R). So the near mesh and the far look read one frame, and the lines run on through junctions by the same rule. Where the label has no host line, across, along and half are 0.11. Constants
Unchanged (
mesh/params.rs), with two rows added and one changed:NORMAL_STEP_Mℓ_max(2 m near, 4 m far), so the normal is the function's at the vertex; under the 0.41 m texel of a level-18 pageSTEEP_INSIDEcut_max: an interior edge steeper than it is a jump of the functionJOIN_Mheights.step_m(read from the table, not a copy)12. Edge cases
Unchanged, with these lines changed:
height_at_sides(approved section 4, step 1).height_atis unknown where T is unknown; only those triangles and their vertical faces go (unchanged).13. Fallbacks
Unchanged, plus
unnamed_stepsandsteep_insideas counts.14. Checks in the crate
M1 to M6: unchanged. M3 compares height bits; it holds only with GP6's border invariant. Added:
unnamed_steps0).height_atwith the triangle's label (the approved deviation gate, now against the function): paved labels (owner, blend, kerb offset) p99 ≤ 1 cm and max ≤ 3 cm near, p99 ≤ 3 cm far; slope and terrain reported.Plan
Unchanged (steps 1 to 20), with these steps changed:
mesh/region.rs): R from the faces' labels and the kept footprints (section 2).mesh/vertices.rs): heights byheight_atandheight_at_sides, groups, normals by central differences, vertical faces with the step's material,unnamed_steps,steep_inside.mesh/look.rs):vertex_lookfrom the label's host line.ground-planbudget = the head build with faces, records, heights and mesh, rounded up to 16 KiB; the PR states raw and gzip with and without each stage (faces, records, heights, mesh) as the reason.Files
Unchanged, plus
host/obc-ground-plan/src/mesh/readsfaces::heights(noHeightstype).Verification
mesh_fixturewith M1 to M8, the look vectors, clippy,check-bytes.sh, the size guard with the raised budget, fmt,obc suites check).height_at_sides, normals) and ns per call.near: false); the owner posts the table and sets the gates.heights.legs=rampand =wall(the owner's question 4 needs both; withwallonly once GP3 splits legs). The owner looks for: walls on face edges only, a flat road, no torn or slanted triangles inside a face.Done when
WORKERSis set from the jump times.MeshStatsfallback count is 0;unnamed_stepsis 0.ground-plan.Out of scope
Unchanged, with: heights and step names: GP6; the records: GP3R; the far look: GP8.
Questions for the owner
height_atper vertex, or an analytic gradient in GP6. Recommendation: central differences; GP6 adds the gradient only if the jump gate fails on its cost.What changed from the approved body, and why
height_atandheight_at_sideswith the face's label, not fromHeights::z. Reason: one function near and far (owner: one road model).Height.step);unnamed_stepsandsteep_insidecount the faults. Reason: the owner rule that a step stands only where a rule asks for it.Generated by Claude Code
timohueser commentedon Nov 5, 2026
Deviation from GP5 (PR #3136), for this sub-issue: the size budget of
ground-planinbuilder/wasm/wasm_size_guard.pyalready holds the bridge with the faces stage: 1,376 KiB raw and 528 KiB gzip (measured 1,400,602 B and 535,120 B, rounded up to the next 16 KiB). The old budget (672 / 272 KiB) failed CI. GP7 sets the budget again when it addsspade, with the reason in its pull request.Generated by Claude Code
timohueser commentedon Nov 5, 2026
Update to the deviation from GP5 (PR #3136): after the merge of GP3R's records, the bridge is 1,410,161 B raw and 537,529 B gzip. The budget of
ground-planis now this size plus 5 %, rounded up to the next 16 KiB: 1,456 KiB raw and 560 KiB gzip. The 5 % is headroom for the stages that land before GP7, which sets the budget.Generated by Claude Code
timohueser commentedon Nov 5, 2026
Interface note from GP6 (draft PR #3140), for this sub-issue:
height_at_sides(block, q, [label_a, label_b], t) -> [Height; 2]gives both sides the sameHeight.step: the rule of the step between them (NoRoom, CutWins, RailRoad, Unrelated, StructureEnd), orStep::Noneunderheights.step_mor with no rule. A name holds where the step lies within its rule's size andstep_m(not equal to it).height_atalone always givesStep::None.heights.wall_m(andwall_face_m,wall_min_m) are not in the block: GP6 has no reader. GP7 addswall_mwith its reader.height_at_sidesis 0.59 times two calls.Generated by Claude Code
timohueser commentedon Nov 5, 2026
Status of GP7 after plan step 7 (first part): the jump gate fails. Work stops before step 8 for an owner decision. Draft PR #3159 (branch
claude/gp7-mesh, head 683e0e0, stacked onclaude/gp6-heights).Done
spade = "=2.15.1",mesh/params.rs,morph.rs,region.rs,lines.rs,cdt.rs,vertices.rs. 8 unit tests pass, clippy clean, fmt clean. Not done: groups' vertices as output, vertical faces, steps 8 to 20.mesh(one thread, release): stage times, counts, the jump estimate, and wireframes per range.Measurements (release, one thread, timosPC under load 3.5 to 4.5; ms per cell)
Pictures
/media/timo/OSM1/tmp/ground-plan/gp7/step7/withINDEX.md. Best:angle20/v17-sharp-corners-near.png(20°: every triangle in its face, the grid in slopes, no red, rosettes at tiny edges) andangle0/v17-sharp-corners-near.png(no bound: slivers along the shoulders, fans at the island tip).Options for the owner (each measured or estimated)
FACE_RING2 → 1. Estimate: a third fewer near triangles in towns.l_maxwide, else for example 10°): 10° everywhere gives near 126,109 to 147,652 triangles on the v17 cells (20°: 175,767 to 221,538). M2 changes. Slivers are valid geometry, and the normals come from the function, so the shading does not show them.Recommendation: do 1 and 2 now (no design change), measure again, then the owner chooses from 3, 4 and 5 with that table. 1 and 2 alone do not pass the gate in towns.
Next step
The owner's decision on the gate. Then plan step 7's rest (per-face vertices, vertical faces,
unnamed_steps), then step 8 (the strip;Region::newtakes the strip'ssolvablealready).Tools
obc exec env CARGO_TARGET_DIR=/media/timo/OSM1/cache/cargo-target-gp7 cargo run --release -p obc-ground-plan --example debug -- mesh --places v17,v12 --size-m 48 [--min-angle DEG] [--far-only] --out DIR(undersystemd-run --user --scope -p MemoryMax=3G -p MemorySwapMax=0 timeout 900);--cells alltimes every fixture cell without pictures (about 1 h at 20°: not run).MESH_PLAN_STATS=1prints the plan's edge lengths.Generated by Claude Code
timohueser commentedon Nov 5, 2026
Deviations of GP7-C (draft PR #3160) from the option C proposal and its review. The body of this issue now holds the GP7-C design; the first GP7 design is in its edit history.
records::findon the cell lines. Againstfindover the fixture: 0 wrong ground corners. 69 sharp triangles (one level crossing over a rail bed, cell 34296/23098) take the face plan's rail-bed label where the records give the crossing: GP3R's known "patch" class.Generated by Claude Code
timohueser commentedon Nov 6, 2026
GP7-C landed in
ground-planwith PR #3160. The CPU builds the 2D near mesh only (sharp faces, one ring, the strip). Heights, look fields and normals come from the GPU in GP9. The first review, the delta review and their fixes are on the PR. The old CPU mesh draft #3159 is superseded.Generated by Claude Code
timohueser commentedon Nov 6, 2026
This is the GP7-C design as merged with PR #3160 (the agent could not edit the body; posted as a comment). Numbers are from the first round; the delta fixes are on the PR.
Rewritten to option C (GP7-C) after the owner's direction of 2026-11-05 (#3096, comments 6668537331 and 6670626340). The previous body (CPU heights, refinement, floors, pieces per node) is in this issue's edit history.
Status: approved
Part of #3096. One pull request into ground-plan: #3160.
Depends on: GP3 and GP3R (faces and the near records of a cell), GP6 (
height_aton the GPU, merged in #3140).TL;DR
Goal: Each cell gives the GPU the 2D topology of the ground that the terrain grid cannot draw: the sharp faces, one ring of ground about them, and a strip that meets the terrain grid. The GPU gives each corner its height, look fields and normal from the one height function, once per cell. The CPU builds no height.
Problem: GP7 as first built (CDT, Ruppert at 20°, CPU heights and normals over the whole owned region) took 5–6 s per town cell and about 22 s per jump.
Decision: R = the level-17 cells of the sharp faces, grown by two rings; the outer ring is the strip. One bulk-loaded CDT of D = R ∖ S with the faces' edges and the level-18 grid, no refinement. Corners are (point, label). One step slot per face-edge piece between two labels, always drawn. The terrain sinks its vertices strictly inside R, so no floors are necessary. One mesh range (level-18 grid); the far look B (GP8) draws past it.
Rejected:
Design (the code is the reference:
host/obc-ground-plan/src/mesh/)FACE_RING= 2 rings (Chebyshev). R is a union of 5 × 5 squares. S (the strip): the cells of R with an 8-neighbour outside R; one cell wide. D = (R ∖ S) ∩ cell.l_max(4 m paved, 3 m shoulder and verge, 2 m blend, 2.4 m ground); D's border, locked: each side of a D cell toward a non-D cell, with its middle point (a level-18 grid point); a span on the cell line also holds the plan vertices of both cells on it, and its middle only where it lies more than 0.4 m from them; the level-18 grid points inside D, 0.4 m or more from every face edge, in every face. Edges between two ground faces are no constraints: the ground is one continuous field.try_bulk_load_cdtof all points and constraints. A crossing of two constraints returnsMeshError::InvalidPlan. A flood fill from the face edges, then from D's border, gives each triangle its face.face_labels, the records' label). A ground triangle takes at each point the point's one ground corner, labelled by the ground face that holds the point: the ground side of a face edge at the point, else the face raster at a grid point, elserecords::find(points on the cell lines).params::MESH_LEVEL= 18) and without the snap of terrain vertices to road edges; the mesh draws only there.CellMesh::to_bytes(module doc ofmesh/mod.rs): a head, corners sorted by point (2 words: x, y in 19 bits each, a 25-bit label, the terrain-vertex flag), triangle runs (count, base corner), triangles (3 × u16 less the run's base), step runs, step slots (4 × u16 less the run's base), R on the cell and one ring (130 × 130 bits). GP9 draws a run withbaseVertex.CellPlan.rim(),CellPlan.mesh_input(),MeshInput.mesh(rims)(nothing when the mesh reads the same of the rims as the last call),MeshInput.records(). The plan sends the worker the wanted, coming and kept cells. The worker meshes a cell when each of its 8 neighbours has a rim or does not come (a failed build or mesh leaves an empty rim), and again when what it reads of a changed rim changes; so the meshes do not depend on the build order. Ameshesmessage carries each mesh with its near records, orgonefor an unwanted cell whose mesh no longer fits (the plan drops its record).Checks
obc test -p obc-ground-plan --lib mesh: region marks, the strip's morph test.obc test -p obc-ground-plan --test mesh: all 256 fixture cells: every triangle turns asgridIndices, every edge has two triangles or lies on a cell line or ∂R; ground corners carry the records' label; two neighbour cells have the same corners and height bits (CPU twin ofheight_at) on their shared line. About 35 s.Measurements
All 256 fixture cells, timosPC, one thread, release, load 14–17 (other agents and the terrain run). Median / p95 / max per cell, ms. Evidence:
/media/timo/OSM1/tmp/ground-plan/gp7c/(native/,wasm/,INDEX.md).With two workers the WASM jump is about 1.0 / 1.6 s (half; not measured). GP3's faces and records are about 70 % of it.
Per cell: corners 4,705 / 36,262 / 67,537; triangles 7,252 / 56,163 / 98,663 (strip 2,136 / 12,832 / 17,456); slots 593 / 6,750 / 15,536. R covers 5 % / 37 % / 60 % of a cell. The 600 m disc is an upper bound: the mesh draws only over level-18 nodes. A slot of no step covers no pixel, but its vertices run.
WASM size: 1,676,975 B raw, 643,415 B gzipped (the faces alone: 1,410,161 / 537,529); the budget is now the head build rounded up to 16 KiB.
Checks over the fixture (
tests/mesh.rs): 0 validity faults; on 480 shared cell lines no difference in corners or height bits over 1 mm, 2 points with a sub-mm step (0.18 and 0.35 mm) between two labels that one cell holds and the other does not; 0 ground corners with a label other than the records'; 69 sharp triangles in GP3R's known patch class (a crossing over a rail bed) carry the face plan's label; 631 ground corners on an edge between two ground faces carry the other ground label (equal heights).Out of scope
Deviations from the option C proposal and its review
records::findon the cell lines. Againstfindover the fixture: 0 wrong ground corners. 69 sharp triangles (one level crossing over a rail bed, cell 34296/23098) take the face plan's rail-bed label where the records give the crossing: GP3R's known "patch" class.Generated by Claude Code