Skip to content

generated_world: roads shape the ground, two Humvee lanes, smooth strips with a centre stripe - #1032

Merged
transfix merged 3 commits into
masterfrom
feat/road-grading
Nov 7, 2026
Merged

transfix merged 3 commits into
masterfrom
feat/road-grading

Conversation

@transfix

@transfix transfix commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

The generated world's roads hugged the ground: they rose and fell with every bump, tilted with every side slope, and some dipped into the water. On physics, vehicles bounced and rolled on them. Joe asked for roads that shape the terrain instead: level across, with a gradual grade along. He also asked for two Humvees' width, a cleaner surface and a centre stripe.

Roads shape the ground: cvc::world::road_grade (new)

  • grade_road_profile gives each road node a height:
    • It starts from the ground under the node, never lower than 0.8 m above the water.
    • It's relaxed along the network so the grade changes gradually.
    • It's held to a 12% climb, or 5% on a segment meeting a junction, so crossings are level.
    • A road that passes close to another without meeting it is held to agree with it, within the side slope over the gap between them. Roads near each other along the network are left to the grade limit, which already ties them.
  • graded_terrain presses that surface into the ground. Within a road and a mesh cell past each edge, the ground is the road's surface: level across, linear along. Past that it blends back to the original ground over a cut or bank (side slope 0.5, 2 to 30 m).
  • Where several roads reach a point, the ground blends toward all their surfaces, strongest first, so it never steps between them. Each road (a run of segments between junctions) counts once.

In the world (world_builder's new grade stage, after the streets)

  • The graded ground replaces the terrain for everything after: the buildings, the road mesh, the trees and rocks, the water and the raster. Trees and rocks now read their height from the ground as built. Raster cells a bank lifted out of the water become gravel.
  • The terrain mesh, which physics and nav drive on, is re-sampled near the roads a few rows per step. Natively this runs in parallel; on wasm it's sliced like the other stages.
  • world_model::with_terrain gives the same world on new ground.
  • I tried two other changes and dropped both:
    • A gentler generation grade (20%) cut the 1.2 km world's network from 8.2 km to 1.3 km.
    • A water test along road edges cut it to 4.8 km.
    • The grading handles both problems, so generation is unchanged.

Measured on the terrain mesh, along every segment at 2 m spacing (roadcheck harness):

world tilt across p95 / max grade p95 / max grade change per 2 m p95 / max road samples under water
1.2 km before 0.744 / 1.333 0.612 / 1.087 0.784 / 1.456 68 of 4,568
1.2 km after 0.036 / 0.157 0.127 / 0.243 0.042 / 0.164 0
5.3 km before 0.191 / 0.377 0.217 / 0.532 0.160 / 0.338 0
5.3 km after 0.009 / 0.081 0.060 / 0.141 0.007 / 0.088 0
  • Cuts and fills stay within about 6 to 7 m (1.2 km) and 12 m (5.3 km). The road network, buildings and trees are unchanged.
  • The rest of the roughness on the 1.2 km world is the terrain mesh's resolution: 5 m cells under a 6 m street.

Two Humvees per street: world_lane_m is the Humvee's 2.18 m (vehicle_desc::humvee) plus 0.4 m either side. Every street is at least two lanes: local streets 6.0 m (were 5.0), collectors 7.0 m (6.5), arterials 9.0 m.

A cleaner road surface (extrude_roads)

  • Strips: each run of segments between junctions, dead ends and width changes is one strip. Its bends are rounded by corner cutting and mitred, so there are no gaps or overlaps at a bend.
  • Pads: strips end on the rim of the junction's round pad, so no corner pokes out. Pads sit 2 cm above the strips and cap the dead ends too.
  • Centre stripe: a dark yellow stripe, 0.15 m wide and 3 cm up, runs down every road at least 4.5 m wide and stops short of the junctions.
  • Colour: the world draws every road in one asphalt colour, so pads match. Arterials used to be a shade darker, which is why some roads looked lighter than others.

The ground texture was upside down. paint_surface writes rows south to north (row 0 = min y, the terrain's v = 0), as its header says. But a cvc::image is top-left origin, and setTexture flips an image's rows to VTK's bottom-left convention. So the texture lay mirrored north to south on the ground:

  • water and its sandy shores were painted under dry land and buildings;
  • ground was painted over the real lakes;
  • the asphalt was painted beside the roads.

A good part of "roads go into the water" was this. The node and the C++ terrain lab now reverse the painted rows before handing the image over, and top-down renders show texture water exactly where the water is.

Tests

  • world_roads_test:
    • A road over bumpy ground with a 30% side slope is held to its grade, changes grade far more gently than the ground, and is level across to 2 cm (exact mid-segment).
    • Far from the road the ground is unchanged, and it eases back without a step.
    • A road over a hollow under water stays above the water.
    • Two close roads agree, and a junction's leg climbs at most 5%.
  • world_road_mesh_test:
    • A bend is one mitred strip.
    • The centre stripe's size, colour, height and trim.
    • Strips end on the pad rim.
    • The existing tests are updated for caps and stripes.
  • world_generated_test:
    • RoadsAreDriveable: every street fits two Humvees, tilt p95 under 0.08 and 4× under the ungraded ground's, grade p95 under 0.16, nothing under water.
    • The generator test checks only ungraded ground.
  • Native arigl snapshots of terrain_lab close up: smooth bands with centre stripes and clean junctions.

Not in this PR: rendering the water itself better. The water volume is near-transparent over the shallows, so ponds beside a road look like ground. That's the next piece.

…ips with a centre stripe

The roads lay on the ground as it was, rising and falling with every bump and tilting with every
side slope (on the 1.2 km lab world the 95th-percentile tilt across a road was 0.74), and some
dipped into the water. cvc::world::road_grade gives each road node a height (the ground, above the
water, relaxed along the network, held to a 12% climb and 5% into a junction, close roads held to
agree) and graded_terrain presses that surface into the ground: level across, cut or banked back
to the ground beside, blended where roads meet. world_builder's grade stage swaps it in for
everything after the streets, the terrain mesh physics drives on included. Tilt p95 is now 0.036
(1.2 km) and 0.009 (5.3 km); nothing is under water.

Every street is two lanes of world_lane_m (the Humvee's 2.18 m plus 0.4 m either side): local
streets 6.0 m, collectors 7.0 m. The road mesh draws each run between junctions as one rounded,
mitred strip ending on its pad's rim, in one asphalt colour, with a dark yellow centre stripe.
paint_surface's rows run south to north (row 0 = min y, the terrain's v = 0) but a cvc::image's
run top down, and setTexture flips an image's rows to VTK's bottom-left origin, so the texture lay
mirrored north to south on the ground: water and its sandy shores painted under dry land and
buildings, ground painted over the lakes, asphalt beside the roads. The generated_world node and
the C++ terrain lab now reverse the painted rows before they hand the image over.
…e whole occupied count

With the roads graded, a bank lifts some deep water (occupied) to dry gravel (not occupied), so a
world with a city can have fewer occupied cells than one without (macOS: 3,734 vs 3,771). The test
now checks what it means: the city's wall cells are all occupied, and a world without a city has
none.
@transfix
transfix merged commit 08f0c67 into master Nov 7, 2026
21 of 27 checks passed
@transfix
transfix deleted the feat/road-grading branch November 7, 2026 01:07
transfix added a commit that referenced this pull request Nov 7, 2026
Bumps the project version and every recipe's upstream_version from 3.7.11 to 3.7.12. The v3.7.12 tag on this commit is the first release with the multi-car controller template (pycvc_gl.cars, #1031 #1035 #1040), the hidden-subtree fix in cvcGL (#1037), the discrete-gradient dyn_bike step (#978), semi-implicit Euler by default in the nav rollout (#981), the implicit contact damper (#1004, #1038), and generated_world's roads and water (#1032, #1034).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant