1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//! Tensor-field-driven procedural urban layout generator.
//!
//! This crate generates realistic road networks and building lots on terrain
//! defined by a [`symbios_ground::HeightMap`]. Roads follow the natural
//! topography: **major** roads trace elevation contours while **minor** roads
//! run along the gradient, producing organic street grids that adapt to hills
//! and valleys. On flat terrain the field falls back to an axis-aligned
//! Manhattan grid.
//!
//! # Pipeline
//!
//! 1. **Road generation** — [`generate_roads`] seeds streamlines on a jittered
//! grid and traces them through a [`TensorField`] using RK2 integration,
//! snapping and splitting edges to form a planar [`RoadGraph`].
//! 2. **Graph rationalization** — [`rationalize_graph`] rewrites the raw tracer
//! output into clean geometry: RDP decimation removes unnecessary points,
//! quadratic Bézier fillets smooth sharp bends, and elevation profiles are
//! Laplacian-smoothed and grade-clamped. Arteries are traced through
//! intersections for global straightening; severed side-streets are
//! reconnected.
//! 3. **Block extraction** — [`extract_blocks`] walks the planar graph with a
//! minimum-angle (left-most turn) algorithm, producing closed [`CityBlock`]
//! polygons for every bounded interior face.
//! 4. **Lot subdivision** — [`extract_lots`] recursively splits each block
//! perpendicular to its longest edge (through the centroid) until pieces
//! are below a configurable area threshold, then computes a street-aligned
//! [`BuildingLot`] rectangle with front/side/rear setbacks.
//! 5. **Terrain carving** — [`carve_roads`] and [`carve_lots`] flatten the
//! heightmap under roads and building foundations with smooth embankment
//! blending at the edges. Both accept a configurable `blend_radius` that
//! controls how far the embankment zone extends — larger values produce
//! wider, gentler slopes on steep terrain. `carve_roads` returns a boolean
//! road-surface mask so that `carve_lots` can avoid overwriting
//! already-flattened pavement. Road elevations use the rationalized
//! (smoothed) node heights.
//! 6. **Road pruning** — [`prune_unused_roads`] optionally removes roads that
//! do not serve any building lot, keeping only the minimal connected
//! sub-network via Dijkstra-based Steiner tree construction.
//! 7. **3D mesh generation** — [`generate_road_meshes`] produces engine-agnostic
//! [`ProceduralMesh`] vertex buffers for intersection hubs (flat N-gon
//! polygons with embankment skirts) and street ribbons (extruded strips
//! with flanking skirt meshes).
//!
//! # Quick start
//!
//! ```ignore
//! use symbios_ground::HeightMap;
//! use symbios_tensor::*;
//!
//! let heightmap = HeightMap::new(128, 128, 4.0);
//! let config = TensorConfig::default();
//!
//! // 1. Generate road network
//! let mut graph = generate_roads(&heightmap, &config).expect("invalid config");
//!
//! // 2. Rationalize: straighten, fillet, and smooth elevations
//! rationalize_graph(&mut graph, &heightmap, &RationalizeConfig::default());
//!
//! // 3. Extract city blocks
//! extract_blocks(&mut graph);
//!
//! // 4. Subdivide blocks into building lots
//! let mut hm = heightmap;
//! let lots = extract_lots(&graph, &mut hm, &LotConfig::default());
//!
//! // 5. Carve roads and lots into terrain
//! let road_mask = carve_roads(&graph, &mut hm, &RoadMeshConfig::default(), 4.0);
//! carve_lots(&lots, &mut hm, 2.0, Some(&road_mask));
//!
//! // 6. (Optional) Prune roads that don't serve any lot
//! prune_unused_roads(&mut graph, &lots);
//!
//! // 7. Generate 3D road meshes
//! let meshes = generate_road_meshes(&graph, &hm, &RoadMeshConfig::default());
//! // meshes.hubs — intersection polygons
//! // meshes.ribbons — street ribbon strips
//! // meshes.skirts — embankment skirt meshes
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use prune_unused_roads;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;