Namespace Sylves
Classes
AStarPathfinding
Implementation class for the A* Pathfinding algorithm. This algorith takes an admissible heuristic, and uses it to find the shortest path
BaseModifier
Abstract class for creating wrapper grids. Wrappers defer most methods to an underlying grid.
BaseSubstitutionTilingGrid
Base class for SubstitutionTilingGrid This contains common utilities and calculations that do no rely on caching.
BaseSubstitutionTilingGrid.Aabb
BaseSubstitutionTilingGrid.InternalPrototile
BijectModifier
Remaps the cells of the grid by changing their co-ordinates, without touching the position, shape or topology.
BiMap<U, V>
Represents a 1:1 mapping between two types
BorderRelaxation
CachePolicy
CairoGrid
Periodic 2d grid of pentagons. https://en.wikipedia.org/wiki/Cairo_pentagonal_tiling This is an specialization of PeriodicPlanarMeshGrid.
Cell
Represents a single cell in the grid. Cell is just a set of co-ordinates, the grid itself must be called to get any details about the cell. For more details see the basic concepts in the docs.
CellCorner
Represents a particular corner of a generic cell. The enum is empty - to work with corners, you need to either:
- Use the methods on ICellType.
- Cast to the enum specific to a given cell type, e.g. CellCorner.
CellDir
Represents a particular edge (2d) or face (3d) of a generic cell. The enum is empty - to work with directions, you need to either:
CellPath
CellRotation
Represents a particular rotation of a generic cell. Despite the name, this usually includes reflections too. The enum is empty - to work with directions, you need to either:
- Use the methods on ICellType.
- Cast to the enum specific to a given cell type, e.g. CubeRotation.
CellSwizzle
Identifies a permutation of the 3 axes Identical to Unity's CellSwizzle.
CellSwizzleExtensions
ChairGrid
ChisledPathfinding
Connection
Represents how the edges (2d) or faces (3d) of cells can connect to each other. In 2d, rotation/sides are unused, as two edges can only connect together normally or reflected. In 3d, this represents both a rotation and reflection, similar to NGonCellType rotations. As there, Mirror inverts the y-axis, and is applied before rotation, which is counter clockwise.
ConwayOperators
CubeBound
A bounding box on a regular 2d grid of squares.
CubeCellType
Handles cell information about cubes. This is a 3d cell type, and it supports all 48 rotations / reflections of a cube.
The canonical shape (for use with deformations) is a unit cube centered at the origin.
CubeCorner
Enum of the 8 corners on a cube.
CubeDir
Enum of the 6 faces on a cube.
CubeDirExtensions
CubeGrid
CubeRotation
CubiusGrid
A torus with a quarter turn. Demonstrates how Sylves handles non-orientability on 3d surfaces.
DataDrivenCellData
DataDrivenData
DataDrivenGrid
Deformation
A deformation is a continuous, differentable mapping from one space to another. It is used to warp meshes in arbitrary ways, by mapping the vertices, normals and tangents of the mesh.
Deformation.GetJacobiFunc
DeformationUtils
Delaunator
DelaunayTriangle
DijkstraPathfinding
Computes Dijkstra's Algorithm.
This class to find paths starting at source, and terminating at a single point, or a range of points.
DominoGrid
DualMappingExtensions
DualMeshBuilder
FSTriangleCorner
Values for CellCorner when working with FlatSides triangles Identical to FTHexCorner
FSTriangleDir
Values for CellDir when working with FlatSides triangles. Identical to PTHexDir
FSTrianglePrismDir
FTHexCorner
Values for CellCorner when working with FlatTopped hexes
FTHexDir
Values for CellDir when working with FlatTopped hexes
FTHexPrismDir
FTTriangleCorner
Values for CellCorner when working with FlatTopped triangles. Identical to PTHexCorner
FTTriangleDir
Values for CellDir when working with FlatTopped triangles Identical to FTHexDir
FTTrianglePrismDir
Grid2dException
This exception is thrown when you call a grid method that is only appropriate for grids with 3d cells.
Grid3dException
This exception is thrown when you call a grid method that is only appropriate for grids with 2d cells.
GridExtensions
GridInfiniteException
This exception is thrown when you call a grid method that is only appropriate for grids with a finite amount of cells.
GridSymmetry
Defines a mapping that maps the cells of a grid onto themselves, potentially rotated. This is used to describe reflections and rotations of a grid (as apposed to CellRotation, which just talks about what you can do to a single cell alone).
Use IGrid.TryApplySymmetry to evaluate the map.
The mapping is consistent with the topology of the grid, i.e.
- Let s by any grid symmetry,
- Let a, and b be any cells, with b is a neighbour of a, in direction d.
- Then if ma, ra is the cell and rotation from applying s to a, and likewise mb, rb for apply s to b.
- Then mb is a neighbour of ma, in direciton ra * d.
The consistency property means that the mapping are fully specified over an entire connected grid once you know how it applies to a single cell. All the other cells can be computed via Sylves.DefaultGridImpl.ParallelTransport(Sylves.IGrid,Sylves.Cell,Sylves.Cell,Sylves.IGrid,Sylves.Cell,Sylves.CellRotation,Sylves.Cell@,Sylves.CellRotation@).
In practice, symmetries on regular grids can be easily computed using vector maths operations.
HashUtils
Supplies simple deterministic hashes.
HexBound
Bounding boxes for cube coordinate hexes. This can represent rhombuses and hex shapes drawn on the hex grid.
HexCellType
Cell type for a regular hexagon with 6 sides. Supports both flat and pointy topped orientations. CellDirs are PTHexDir/FTHexDir, integers 0 to 5. CellCorners are PTHexCorner/FTHexCorner, integers 0 to 5. The CellRotations are the numbers 0 to 5 for a CCW rotation of that many sides, plus numbers ~0 to ~5 for the reflections, where rotation ~0 has dir 0 as a fix point.
The canonical shape (for use with deformations) is a regular hexagon with incircle diamater 1.0 in the XY centered at the origin, with normal pointing Z-forward.
HexDirExtensions
HexGrid
A regular 2d grid of hexagons. The co-ordinate system used is "Cube-cordinates described here: https://www.redblobgames.com/grids/hexagons/ However, it'll usually be fairly forgiving if you just use x,y and don't fill the z value. See HexOrientation for more details. Covers both the infinite grid, and bounded versions. Related classes:
HexOrientation
HexPrismBound
HexPrismCellDirExtensions
HexPrismCellType
HexPrismGrid
HexRotation
Represents rotations / reflections of a hex
IntUtils
JitteredSquareGrid
MaskModifier
Filters the cells in the the grid to a customizable subset.
Filtered cells will not be returned by GetCells, TryMove, etc. Passing them as inputs is undefined.
Mathf
Matrix4x4
MeshCellData
MeshData
A replacement for UnityEngine.Mesh that stores all the data in memory, for fast access from C#.
MeshDataOperations
MeshEmitter
MeshGrid
Represents a 2d grid, where each cell corresponds to a face in a given mesh.
MeshGridOptions
MeshPrimitives
Contains some constant meshes
MeshPrismGrid
Represents a 3d grid, where each cell is an extrusion of a face along the normals, offset to a given height.
MeshPrismGridOptions
MeshRaycast
MeshTopology
MeshUtils
Utility for working with meshes.
MeshUtils.Face
References a slice of indices for a face.
MetaHexagonGrid
MobiusSquareGrid
A square grid on a Möbius strip. Demonstrates how Sylves handles non-orientability on 2d surfaces.
NestedModifier
Replaces every cell in one grid (the chunk grid) with a collection of cells from lazily computed child grids.
NGonCellType
Cell type for a regular polygon with n sides. The CellDirs are simply the numbers 0 to n-1 with dir 0 being to the right. The CellRotations are the numbers 0 to n-1 for a CCW rotation of that many sides, plus numbers ~0 to ~(n-1) for the reflections, where rotation ~0 has dir 0 as a fix point.
The canonical shape (for use with deformations) is a regular polygon with incircle diamater 1.0 in the XY centered at the origin, with normal pointing Z-forward.
NGonPrismCellType
Cell type for a regular polygon with n sides extended in the z-axis to a prism.
The canonical shape (for use with deformations) is the shape for the corresponding NGonCellType, extended to +-0.5 along the z-axis.
Pathfinding
PenroseRhombGrid
PeriodicPlanarMeshGrid
A grid made of a repeating pattern of a given mesh, that must be planar in the XY plane. The repeats are given by translation in two independent axes, strideX and strideY .
PlanarLazyGrid
An infinite planar grid. It is evaluated lazily by splitting the plane into overlapping period rectangles which then each has a grid associated.
This class requires you to compute inter-chunk neighbours yourself, which is often tricky. You are recommended to use PlanarLazyMeshGrid instead, which handles this automatically.
This class is simply a specialization of NestedModifier, applied to a grid of overlapping rectangles.
PlanarLazyMeshGrid
An infinite planar grid. It is evaluated lazily by splitting the plane into overlapping period rectangles which then each has a mesh associated. The meshes are converted to cells like a MeshGrid, then stitched together.
PlanarPrismBound
PlanarPrismModifier
Takes a 2d planar grid, and extends it into multiple layers along the third the dimension.
PlanarPrismOptions
PrismInfo
Provides information about promoting a 2d cell type to a 3d cell type via extrusion.
Usually this results in NGonPrismCellType, but squares go to CubeCellType, which has additional symmetry.
Prototile
PTHexCorner
Values for CellCorner when working with PointyTopped hexes
PTHexDir
Values for CellDir when working with PointyTopped hexes
PTHexPrismDir
QuadInterpolation
Supplies various bilinear and trilinear interpolation methods. The conventions are based on a XY plane using either a unit square or unit cube.
Quaternion
A pure .NET implemenation of Unity's Quaternion. See Unity's docs for more details.
RavelModifier
Relabels all the cell co-ordinates to be 1d, i.e. cell.y and cell.z are always zero.
RawSubstitutionTilingGrid
RaycastInfo
RelaxModifier
Applies relaxation to an infinite 2d plane, similar to MeshDataOperations.Relax.
RhombilleGrid
Periodic 2d grid of diamond shapes. https://en.wikipedia.org/wiki/Rhombille_tiling This is an specialization of PeriodicPlanarMeshGrid.
SquareBound
A bounding box on a regular 2d grid of squares.
SquareCellType
Handles cell information about squares. This is a a customized version of NGonCellType and behaves virtually identically.
The canonical shape (for use with deformations) is a unit square in the XY centered at the origin, with normal pointing Z-forward.
SquareCorner
SquareDir
SquareDirExtensions
SquareGrid
A regular square 2d grid. Covers both the infinite grid, and bounded versions. Cell (0, 0) has center at (0.5, 0.5). Related classes:
- FTHexDir/PTHexDir
- NGonCellType (with n = 6)
- HexBound
SquareRotation
Represents rotations / reflections of a square
SquareSnubGrid
Periodic 2d grid of squares and triangles.. https://en.wikipedia.org/wiki/Snub_square_tiling This is an specialization of PeriodicPlanarMeshGrid.
Step
StepLengths
SubstitutionTilingBound
SubstitutionTilingGrid
Creates a tiling of the 2d plane from a set of substitution rules. It is quite flexible:
- imperfect substitution rules where the replacement outline doesn't follow the original outline
- tiles can freely transformed
- tile equivalence under translation, euclidian motion, isometry, similarity all supported
- "statistically round" substitutions like the pinwheel substitution supported
SvgBuilder
SvgExport
TetrakisSquareGrid
Periodic 2d grid of triangles. https://en.wikipedia.org/wiki/Tetrakis_square_tiling This is an specialization of PeriodicPlanarMeshGrid.
TownscaperGrid
A grid closely modelled after the grid used in Townscaper. See the corresponding tutorial.
TransformModifier
Changes the world space positioning of the grid by a linear transform, leaving everything else unchanged.
TriangleBound
TriangleCellType
Cell type for a regular hexagon with 6 sides. Supports both flat topped and flat sides orientations. Up/down triangles are given separate dirs and corners, so you can distinguish them without needing separate cell types. Thus this cell type is quite similar to HexCellType.
CellDirs are FSTriangleDir/FTTriangleDir, integers 0 to 5. CellCorners are FSTriangleCorner/FTDirableCorner, integers 0 to 5. The CellRotations are the numbers 0 to 5 for a CCW rotation of that many sides, plus numbers ~0 to ~5 for the reflections, where rotation ~0 has dir 0 as a fix point.
The canonical shape (for use with deformations) is a regular triangle with incircle diamater 1.0 in the XY centered at the origin, with normal pointing Z-forward.
TriangleGrid
A uniform tiling of triangles. TriangleOrientation.FlatSides gives columns of triangles that alternate pointing left/right. TriangleOrientation.FlatTopped gives rows of triangles that alternate pointing up/down.
In both cases, the cell type used is actually TriangleCellType. For each triangle, three of the directions point towards neighbors, and the other three will point to nothing. This is a similar setup to DoubleOddFaces, and is usually simpler to work with as it doesn't force you to consider some cells as rotated by 180 degrees.
TriangleInterpolation
Supplies various linear interpolation methods from a triangle. The conventions are based on a XY plane, with an equilateral triangle of side 1, vertices: (0.5f, -0.5f / Sqrt3) (0, 1 / Sqrt3) (-0.5f, -0.5f / Sqrt3)
TriangleOrientation
TrianglePrismBound
TrianglePrismCellDirExtensions
TrianglePrismCellType
TrianglePrismGrid
TriHexGrid
Periodic 2d grid of triangles and hexagons. https://en.wikipedia.org/wiki/Trihexagonal_tiling This is an specialization of PeriodicPlanarMeshGrid.
Triple<T>
TRS
Represents a position / rotation and scale. Much like a Unity Transform, but without the association with a Unity object.
Vector2
A pure .NET implemenation of Unity's Vector2. See Unity's docs for more details.
Vector2Int
A pure .NET implemenation of Unity's Vector2Int. See Unity's docs for more details.
Vector3
A pure .NET implemenation of Unity's Vector3. See Unity's docs for more details.
Vector3Int
A pure .NET implemenation of Unity's Vector3Int. See Unity's docs for more details.
Vector4
A pure .NET implemenation of Unity's Vector4. See Unity's docs for more details.
VectorUtils
Voronator
Computes a voronoi diagram in a 2d plane, optionally clipped to a rectangle.
Voronator.PolygonStatus
VoronoiGrid
VoronoiGridOptions
Walker
WrapModifier
Turns any bounded grid into a grid which connects back on itself when you leave the grounds. This is done via a canonicalize method that is responsible for replacing cells that are outside of the bounds.
WrappingSquareGrid
WrapModifier applied to SquareGrid. This is a very common grid in games.
XZCellTypeModifier
Converts a ICellType based in the XY plane to one in the XZ plane. It does this by rotating Y+ to Z- (and Z+ to Y+)
XZHexPrismGrid
Variant of HexPrismGrid that places hexes in the XZ Plane
XZModifier
Converts a IGrid based in the XY plane to one in the XZ plane. It does this by rotating Y+ to Z- (and Z+ to Y+). This is different from a transform in that it doesn't rotate the cells, it applies XZCellModifier to them.
XZTrianglePrismGrid
Variant of TrianglePrismGrid that places triangles in the XZ Plane
Interfaces
IBound
ICachePolicy
Describes how long data should be cached.
ICellType
An ICellType gives summarized info about a single cell in isolation of the grid it comes from. ICellType allows you to enumerate the edges/faces/corners of a cell, and work with cell symmetries (called CellRotation).
ICellType's are always singletons, e.g. SquareCellType.Instance is used for all square cells.
Note that cells can share an cell type, even if they are different shapes. Thus any methods that refer to positions, such as GetMatrix, don't refer to the specific cell in the grid, but the "canonical" cell. You must use IGrid methods like GetPolygon or GetDeformation to get the shape of a specific cell.
The canonical cell is usually a regular polygon or polyhedron of unit size centered on the origin. See the docs for more details
IDualMapping
IGrid
Contains all the methods for querying a grid. A grid is a collection of cells, with each cell having various data associated with it such as neighbours, position in space. For more details see the basic concepts in the docs.