Voronoi Generator¶
The voronoi generator produces compact, feature-rich closed centerlines by snapping a
cycle of angular anchor targets onto a randomly placed field of cell sites, rounding the
resulting polyline, and arc-resampling it into the standard pipeline buffer. It is the
production distillation of the Voronoi / random-geometric prototype: the useful “right number
of cells” control is retained through the fixed site field, while exact Delaunay / Voronoi
ridge traversal and dynamic cycle extraction — which are incompatible with the fixed-shape
CUDA-graph contract — are replaced by a static angular-snap cycle that is allocation-free and
deterministic in (seed, config). Of the five registered generators, voronoi yields the
highest typical compactness (~0.73) and effectively eliminates pre-relax self-intersections
without a generation retry loop.
Sample tracks produced by the voronoi generator across several seeds.¶
How It Works¶
Draw the site field.
_sample_sites_kdrawsS = voronoi_num_sitespoints per environment using one of fourvoronoi_site_layoutmodes:ring— uniform box fill. Each site is drawn independently and uniformly within the full bounding box[-L/2, L/2]²(L = box_size = 2.0). Despite its name, this mode does not produce an annular band; it is the flat, unstructured baseline. Source:_sample_sites_k, lines 103–106 — the_LAYOUT_RINGbranch leavesuse_annulus = 0and falls through to the uniformx, ydraw.void_ring(default) — area-uniform annular band with a center void. Every site is placed in the annulus[0.14·L, 0.52·L]using the area-preserving radius formular = sqrt(r_min² + rand·(r_max² - r_min²)), leaving the center of the box empty. Source:_sample_sites_k, lines 75–76 (use_annulus = 1) and 97–102 (annulus draw).clustered— Gaussian-style clusters around six evenly spaced angular positions. Each point is assigned to a random cluster whose center lies at approximately0.24–0.34·Lfrom the origin; points are scattered with noise radius~0.025–0.105·L. Roughly 22 % of clustered points are redirected to the annulus draw instead (source:_sample_sites_k, line 90,wp.randf(state) < 0.22).mixed— blends the two placement modes per site: each site independently uses the annulus draw with probability 0.65 and the uniform box fill with probability 0.35 (source:_sample_sites_k, line 78,wp.randf(state) < 0.65).
Select anchor sites.
_select_anchor_sites_kdrawsK = voronoi_control_pointsangular sector targets. A global random rotationρis applied; sectoriis centered at angleρ + (2π/K)·iand jittered byεᵢ ∈ [-j, +j]wherej = voronoi_angular_jitter. Each target also has a radial component: a multi-harmonic profileφ(θ)(see Math section) modulates the target radius, scaled byvoronoi_radial_variation. The anchor is then chosen as the site that minimises a combined angle + radius cost, with a large penalty (1 000) for already-used sites — an O(S) scan that keeps the selected cycle free of duplicate anchors.Chaikin subdivision.
_chaikin_once_kapplies one round of Chaikin corner-cutting to theKselected anchors, converting each edge(pᵢ, pᵢ₊₁)into two new vertices at the 1/4 and 3/4 points. This doubles the polygon toAP = 2Kaugmented points and softens the raw anchor-snap polygon before spline evaluation.Closed Catmull-Rom spline.
_catmull_rom_dense_kevaluates a closed uniform Catmull-Rom spline over theAPaugmented vertices, producing a denseM = AP × num_points_per_segment-point loop per environment.Arc-resample and normalize.
_arc_resample_inplacearc-resamples the dense loop tonum_pointsuniformly spaced points._normalize_centerline_kthen centers the environment’s bounding box and isotropically rescales the longest dimension toscale × 1.44, matching the shared target extent of the other generators.Fallback for self-crossing smooth loops.
self_intersections_inplacecounts proper crossings on thenum_points-point loop. For environments where the smooth loop self-intersects,_assemble_polygon_selected_kemits the straight Chaikin-augmented (AP-vertex) polygon by linear interpolation, and_arc_resample_selected_inplaceoverwrites those rows with an arc-resampled version of that polygon. A second_normalize_centerline_kpass re-applies the bbox rescale. Non-crossing rows are left untouched.
Math¶
Angular anchor targets.
Anchor i has target angle
where ρ is a per-environment random offset drawn once and K = voronoi_control_points.
Radial variation profile.
The target radius for anchor i is
where L = box_size = 2.0,
and the phase offsets φ₀, φ₁, φ₂, φ₃ are independent per-environment random angles.
The amplitude is clamped:
with layout boost b = 1.10 for void_ring, 1.16 for clustered, 1.06 for
mixed, and 1.00 for ring.
Anchor snap cost. The nearest-unused-site snap minimises
over all S sites, where Δθₛ is the signed angular difference between site s and
the target angle (wrapped to (-π, π]).
Chaikin corner-cutting.
Each edge (pᵢ, pᵢ₊₁) of the K-anchor polygon is replaced by two vertices:
producing the AP = 2K augmented vertices.
Closed uniform Catmull-Rom. The dense loop is evaluated as
where indices wrap modulo AP.
Parameters¶
The following TrackGenConfig fields are owned by the voronoi generator. All other
fields (num_points, num_points_per_segment, scale, half_width, etc.) are
shared pipeline parameters described in the configuration reference.
voronoi_num_sites(S, default 256)Number of cell sites drawn per environment. Higher values make the anchor-snap richer and improve coverage of the site field, but scale the per-anchor O(S) cost scan linearly.
voronoi_site_layout(default"void_ring")Spatial distribution of sites. One of
"ring"(uniform box fill),"void_ring"(annular band with a center void),"clustered"(six Gaussian-style clusters), or"mixed"(65 % annulus / 35 % uniform, per site). The layout also adjusts the amplitude boost applied tovoronoi_radial_variation.voronoi_control_points(K, default 18)Number of angular anchors selected from the site field. More anchors add local features and tighter curvature, but also increase the smoothing and relaxation burden.
voronoi_radial_variation(default 0.62)Amplitude of the per-anchor radius modulation. At 0 all anchor targets sit at the same base radius (0.34·L); at larger values the multi-harmonic profile drives anchors to vary between 0.16·L and 0.52·L, producing more irregular, non-circular layouts.
voronoi_angular_jitter(default 0.08)Maximum angular perturbation (in radians) applied to each sector target. Small values keep anchors close to their ideal evenly-spaced sectors; larger values break the rotational regularity.
What Makes It Distinct¶
voronoi is the only generator built around a pre-placed site field. The angular-snap
construction produces tracks anchored to a concrete spatial texture rather than drawn from
pure random Cartesian or polar coordinates, which gives the family a characteristic
“cell-like” compactness absent from the other four generators.
Key contrasts:
Highest compactness (~0.73). The
void_ringdefault biases sites into an annular band and selects anchors around the full perimeter, consistently producing compact, looping layouts with high area-to-perimeter ratios.Zero pre-relax self-intersections in practice. The site field and the annular bias of the default layout keep anchors at meaningful separations. The Chaikin + Catmull-Rom smoothing pass almost never produces a self-crossing loop, so the polygon fallback path is rarely triggered.
Multi-scale control.
voronoi_num_sitescontrols global cell density;voronoi_control_pointscontrols route complexity;voronoi_radial_variationandvoronoi_angular_jittercontrol irregularity within the route. No other generator exposes a site-density knob independent of its curve-complexity knob.No style-sampling. Unlike
bezier, the Voronoi generator does not support per-environment parameter sampling from a range; its randomness comes entirely from the seed-driven site draw and anchor selection.
Fallback and Validity¶
If the Chaikin-smoothed Catmull-Rom loop for an environment self-intersects after
arc-resampling, the generator falls back to the corresponding Chaikin-augmented
AP-vertex straight polygon, arc-resampled via _arc_resample_selected_inplace. Only
the crossing rows are overwritten; non-crossing rows are untouched. Both the smooth-loop
and polygon-fallback paths write out_valid_wp = 1 for every environment.
Final geometric validity — turning number close to 2π, minimum track thickness, absence of
NaNs, and width floor — is decided after the shared resample → XPBD relax → inflate
pipeline, not by the generator itself. The XPBD relaxation pass will re-round the
flat-polygon fallback into a smoother loop, just as it does for the bezier and hull
fallback paths.