Struct VoronoiRegionSettings
Immutable settings for the Voronoi Regions map generation algorithm.
Inherited Members
Namespace: Scylla.Core.Util.ProceduralMapGen
Assembly: ScyllaCore.dll
Syntax
public readonly struct VoronoiRegionSettings
Remarks
The Voronoi Regions algorithm places seed points across the grid using Poisson disk sampling (ensuring a minimum spacing of MinSpacing world units between seeds) and then assigns every grid cell to the nearest seed point by distance, forming irregular, organic-looking regions. A fraction of each region's area - determined by FloorRatio - is carved to floor, while the outer cells remain as walls.
When ConnectRegions is true, the algorithm runs a connectivity
pass after carving, carving corridors between isolated region components so that
every floor area is reachable from every other floor area.
This algorithm supports square, hex, and triangle grids. Pass the completed settings struct to the appropriate ProceduralMapGenerator overload.
Constructors
VoronoiRegionSettings(int, float, float, bool)
Initializes a new VoronoiRegionSettings with the specified parameters.
Declaration
public VoronoiRegionSettings(int regionCount = 12, float minSpacing = 5, float floorRatio = 0.65, bool connectRegions = true)
Parameters
| Type | Name | Description |
|---|---|---|
| int | regionCount | Target number of Voronoi region seed points. The sampler may place fewer seeds
if |
| float | minSpacing | Minimum distance in world units between any two Poisson disk seed points.
Smaller values allow denser seed placement. Defaults to |
| float | floorRatio | Fraction of each region's radius carved to floor. Useful range is approximately
|
| bool | connectRegions | When |
Fields
Clustered
Clustered preset: 20 small regions with 3-unit minimum spacing and 55 % floor ratio. Produces many tight, closely packed regions with narrow passages between them.
Declaration
public static readonly VoronoiRegionSettings Clustered
Field Value
| Type | Description |
|---|---|
| VoronoiRegionSettings |
Remarks
Best used on larger grids. On small grids the Poisson sampler may be unable to fit all 20 seeds at 3-unit spacing, resulting in fewer actual regions.
ConnectRegions
Whether to carve corridors to connect all regions into a single connected component.
Declaration
public readonly bool ConnectRegions
Field Value
| Type | Description |
|---|---|
| bool |
Remarks
When true, a post-processing connectivity pass is performed after region
carving. Isolated floor components are linked by carving straight corridor paths
between them, ensuring every floor cell is reachable from every other floor cell.
When false, regions are independent and may be entirely isolated.
Set to false only when isolation is intentional (e.g. island-style maps
where disconnected regions are a design goal).
Default
Default preset: 12 regions with 5-unit minimum spacing, 65 % floor ratio, and connectivity enabled. Produces a balanced, cave-like layout.
Declaration
public static readonly VoronoiRegionSettings Default
Field Value
| Type | Description |
|---|---|
| VoronoiRegionSettings |
FloorRatio
Fraction of each region's radius that is carved to floor. Range is approximately [0.1, 1.0].
Declaration
public readonly float FloorRatio
Field Value
| Type | Description |
|---|---|
| float |
Remarks
A value of 1.0 carves the entire interior of every region to floor, resulting
in wall-free region interiors. A value of 0.5 carves only the inner half of
each region, leaving a wide border of wall cells along the region boundaries.
Values below 0.1 may produce degenerate layouts with very few floor cells.
MinSpacing
Minimum distance in world units that must separate any two seed points placed by the Poisson disk sampler.
Declaration
public readonly float MinSpacing
Field Value
| Type | Description |
|---|---|
| float |
Remarks
Smaller values allow seeds to be placed close together, producing tightly clustered small regions. Larger values force seeds apart, producing fewer, larger regions that better fill the available space. If this value is too large for the grid, fewer seeds than RegionCount will be placed.
RegionCount
Target number of Voronoi region seed points to place.
Declaration
public readonly int RegionCount
Field Value
| Type | Description |
|---|---|
| int |
Remarks
The Poisson disk sampler distributes exactly this many seed points across the grid (subject to the MinSpacing constraint). If MinSpacing is too large relative to the grid size, fewer seeds may be placed than requested. More seeds produce smaller, more numerous regions; fewer seeds produce larger, more open regions.
Sparse
Sparse preset: 6 large regions with 8-unit minimum spacing and 75 % floor ratio. Produces a wide-open layout with few, spacious rooms.
Declaration
public static readonly VoronoiRegionSettings Sparse
Field Value
| Type | Description |
|---|---|
| VoronoiRegionSettings |
Methods
Lerp(VoronoiRegionSettings, VoronoiRegionSettings, float)
Linearly interpolates between two VoronoiRegionSettings instances and returns a new blended settings struct.
Declaration
public static VoronoiRegionSettings Lerp(VoronoiRegionSettings a, VoronoiRegionSettings b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| VoronoiRegionSettings | a | Start settings returned when |
| VoronoiRegionSettings | b | End settings returned when |
| float | t | Interpolation factor. Values outside [0, 1] are clamped before use. |
Returns
| Type | Description |
|---|---|
| VoronoiRegionSettings | A new VoronoiRegionSettings whose numeric fields are linearly
blended between |
Remarks
RegionCount is interpolated as a float and rounded to the nearest integer. MinSpacing and FloorRatio are interpolated as floats without rounding.
The ConnectRegions boolean cannot be meaningfully interpolated; it
takes the value from a when t < 0.5 and from
b when t >= 0.5.