Struct BSPSettings
Settings for the Binary Space Partitioning (BSP) map generation algorithm, invoked via ProceduralMapGenerator. Controls how the grid is recursively subdivided into partitions, how rooms are sized and padded within each partition, the width and style of the corridors that connect sibling rooms, and the random split ratio used when dividing partitions. Operates on square grids only.
Inherited Members
Namespace: Scylla.Core.Util.ProceduralMapGen
Assembly: ScyllaCore.dll
Syntax
public readonly struct BSPSettings
Remarks
The BSP algorithm works in three phases:
- Partition - the grid is recursively split either horizontally or vertically at a position chosen uniformly in the range [SplitRatioMin, SplitRatioMax]. Recursion stops when a partition's shorter dimension falls below MinPartitionSize or MaxDepth is reached.
-
Room placement - each leaf partition receives one room whose width is
chosen in [MinRoomWidth, MaxRoomWidth] and
height in [MinRoomHeight, MaxRoomHeight], both
clamped to the partition minus RoomPadding on each side.
Setting MaxRoomWidth or MaxRoomHeight to
0removes the cap so the room fills the padded partition. - Corridor carving - pairs of sibling rooms are connected by corridors of width CorridorWidth using the style selected by CorridorStyle. When Winding is chosen, WindingSettings controls the jog behaviour.
Use the static presets (Default, SmallRooms,
LargeRooms) as starting points. All fields are readonly;
use Lerp(BSPSettings, BSPSettings, float) to smoothly transition between configurations.
Constructors
BSPSettings(int, int, int, int, int, int, int, int, float, float, CorridorStyle, WindingCorridorSettings)
Initializes a new BSPSettings with explicit control over all partitioning, room sizing, corridor, and split ratio parameters.
Declaration
public BSPSettings(int minRoomWidth = 4, int minRoomHeight = 4, int maxRoomWidth = 15, int maxRoomHeight = 15, int minPartitionSize = 8, int maxDepth = 6, int roomPadding = 1, int corridorWidth = 1, float splitRatioMin = 0.35, float splitRatioMax = 0.65, CorridorStyle corridorStyle = CorridorStyle.LShaped, WindingCorridorSettings windingSettings = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | minRoomWidth | Minimum room width in cells. Must be at least |
| int | minRoomHeight | Minimum room height in cells. Must be at least |
| int | maxRoomWidth | Maximum room width in cells, or |
| int | maxRoomHeight | Maximum room height in cells, or |
| int | minPartitionSize | Minimum partition dimension (width or height) before a partition becomes a leaf.
Should exceed the minimum room size plus |
| int | maxDepth | Maximum BSP recursion depth. Defaults to |
| int | roomPadding | Cells to preserve between a room edge and the containing partition boundary.
Defaults to |
| int | corridorWidth | Width in cells of carved corridors between sibling rooms. Defaults to |
| float | splitRatioMin | Minimum relative split position along the chosen axis. Must be in |
| float | splitRatioMax | Maximum relative split position along the chosen axis. Must be in |
| CorridorStyle | corridorStyle | Carving style for inter-room corridors. Defaults to LShaped. |
| WindingCorridorSettings | windingSettings | Winding corridor parameters. Only consulted when |
Fields
CorridorStyle
The corridor carving style used when connecting sibling rooms in the BSP tree. LShaped produces a simple L-shaped corridor with a single bend; Winding adds random waypoints (jogs) for a more organic appearance.
Declaration
public readonly CorridorStyle CorridorStyle
Field Value
| Type | Description |
|---|---|
| CorridorStyle |
See Also
CorridorWidth
Width in cells of the corridors carved between sibling rooms. A value of
1 produces single-cell-wide passages; higher values produce wider corridors
that are more navigable but consume more floor space.
Declaration
public readonly int CorridorWidth
Field Value
| Type | Description |
|---|---|
| int |
Default
A balanced preset suitable as a general-purpose BSP dungeon configuration. Produces moderately-sized rooms (4-15 cells wide and tall), up to six levels of recursion, single-cell-wide L-shaped corridors, and a symmetric split range of 35%-65%.
Declaration
public static readonly BSPSettings Default
Field Value
| Type | Description |
|---|---|
| BSPSettings |
Remarks
Specific values: MinRoomWidth=4, MinRoomHeight=4, MaxRoomWidth=15,
MaxRoomHeight=15, MinPartitionSize=8, MaxDepth=6, RoomPadding=1,
CorridorWidth=1, SplitRatioMin=0.35, SplitRatioMax=0.65,
CorridorStyle=LShaped.
LargeRooms
A preset that generates few, spacious rooms by using a high room minimum size, no
room size cap (MaxRoomWidth=0, MaxRoomHeight=0), and shallow recursion
depth. Wide corridors (two cells) and generous padding keep the layout readable
at large room sizes.
Declaration
public static readonly BSPSettings LargeRooms
Field Value
| Type | Description |
|---|---|
| BSPSettings |
Remarks
Specific values: MinRoomWidth=6, MinRoomHeight=6, MaxRoomWidth=0,
MaxRoomHeight=0, MinPartitionSize=14, MaxDepth=4, RoomPadding=2,
CorridorWidth=2, SplitRatioMin=0.35, SplitRatioMax=0.65,
CorridorStyle=LShaped.
MaxDepth
Maximum recursion depth for BSP splitting. The tree stops subdividing once this depth is reached regardless of partition size. Higher values produce more, smaller partitions and rooms; lower values produce fewer, larger partitions and rooms.
Declaration
public readonly int MaxDepth
Field Value
| Type | Description |
|---|---|
| int |
MaxRoomHeight
Maximum height in cells that a room placed inside a leaf partition may have.
A value of 0 removes the cap and allows the room to fill the partition height
minus RoomPadding on each side. Must be greater than or equal to
MinRoomHeight when non-zero.
Declaration
public readonly int MaxRoomHeight
Field Value
| Type | Description |
|---|---|
| int |
MaxRoomWidth
Maximum width in cells that a room placed inside a leaf partition may have.
A value of 0 removes the cap and allows the room to fill the partition width
minus RoomPadding on each side. Must be greater than or equal to
MinRoomWidth when non-zero.
Declaration
public readonly int MaxRoomWidth
Field Value
| Type | Description |
|---|---|
| int |
MinPartitionSize
The minimum side length (in cells) a partition must have in both dimensions before
it is treated as a leaf and receives a room instead of being split further.
Must be large enough to accommodate the minimum room size plus
2 * RoomPadding in each dimension, otherwise some leaf
partitions may be unable to place any room.
Declaration
public readonly int MinPartitionSize
Field Value
| Type | Description |
|---|---|
| int |
MinRoomHeight
Minimum height in cells that a room placed inside a leaf partition may have.
Must be at least 1. The actual room height is chosen randomly in the range
[MinRoomHeight, MaxRoomHeight] and then clamped to
the available padded partition height.
Declaration
public readonly int MinRoomHeight
Field Value
| Type | Description |
|---|---|
| int |
MinRoomWidth
Minimum width in cells that a room placed inside a leaf partition may have.
Must be at least 1. The actual room width is chosen randomly in the range
[MinRoomWidth, MaxRoomWidth] and then clamped to
the available padded partition width.
Declaration
public readonly int MinRoomWidth
Field Value
| Type | Description |
|---|---|
| int |
RoomPadding
Number of wall cells to preserve between a room edge and the edge of its containing partition. Higher values ensure rooms never touch partition boundaries, creating more space for corridor carving and preventing rooms from touching the grid border.
Declaration
public readonly int RoomPadding
Field Value
| Type | Description |
|---|---|
| int |
SmallRooms
A preset that generates many small, densely-packed rooms by using a low room size cap and a high recursion depth. Suitable for tight dungeon interiors with many interconnected small chambers.
Declaration
public static readonly BSPSettings SmallRooms
Field Value
| Type | Description |
|---|---|
| BSPSettings |
Remarks
Specific values: MinRoomWidth=3, MinRoomHeight=3, MaxRoomWidth=8,
MaxRoomHeight=8, MinPartitionSize=7, MaxDepth=8, RoomPadding=1,
CorridorWidth=1, SplitRatioMin=0.4, SplitRatioMax=0.6,
CorridorStyle=LShaped.
SplitRatioMax
The upper bound of the random range used to choose where to split a partition.
See SplitRatioMin for full details. A symmetric range centred at
0.5 produces balanced splits; an asymmetric range biases toward one side.
Must be in (0, 1) and greater than SplitRatioMin.
Declaration
public readonly float SplitRatioMax
Field Value
| Type | Description |
|---|---|
| float |
SplitRatioMin
The lower bound of the random range used to choose where to split a partition.
The split position along the chosen axis is selected uniformly in
[SplitRatioMin, SplitRatioMax]. A value of
0.35 means the split occurs no closer than 35% from the near edge, keeping
sub-partitions from becoming very narrow. Must be in (0, 1) and less than
SplitRatioMax.
Declaration
public readonly float SplitRatioMin
Field Value
| Type | Description |
|---|---|
| float |
WindingSettings
Winding corridor parameters controlling the number of jogs and the perpendicular offset range applied at each waypoint. This field is only used when CorridorStyle is set to Winding; it is ignored for LShaped.
Declaration
public readonly WindingCorridorSettings WindingSettings
Field Value
| Type | Description |
|---|---|
| WindingCorridorSettings |
Remarks
When constructing a BSPSettings with winding corridors, pass
Default or a custom
WindingCorridorSettings instance rather than using the C#
default keyword, which zero-initialises all fields and may produce
degenerate corridor behaviour.
See Also
Methods
Lerp(BSPSettings, BSPSettings, float)
Linearly interpolates between two BSPSettings instances and returns the blended result.
Declaration
public static BSPSettings Lerp(BSPSettings a, BSPSettings b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| BSPSettings | a | The start settings returned when |
| BSPSettings | b | The end settings returned when |
| float | t | Interpolation factor in the range |
Returns
| Type | Description |
|---|---|
| BSPSettings | A new BSPSettings whose fields are blended between
|
Remarks
Integer fields are interpolated with Math.Round; float fields are
interpolated continuously. The CorridorStyle enum field
switches from a to b at
t = 0.5. WindingSettings is
delegated to Lerp(WindingCorridorSettings, WindingCorridorSettings, float).
t is clamped to [0, 1] before any calculation.