Class 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 .
Inheritance
System.Object
PeriodicPlanarMeshGrid
Assembly: Sylves.dll
Syntax
public class PeriodicPlanarMeshGrid : Object, IGrid
Constructors
PeriodicPlanarMeshGrid(MeshData, Vector2, Vector2)
Declaration
public PeriodicPlanarMeshGrid(MeshData meshData, Vector2 strideX, Vector2 strideY)
Parameters
Properties
CoordinateDimension
Declaration
public int CoordinateDimension { get; }
Property Value
Type |
Description |
System.Int32 |
|
IndexCount
Finds a number one larger than the maximum index for an in bounds cell.
Declaration
public int IndexCount { get; }
Property Value
Type |
Description |
System.Int32 |
|
Is2d
True if this grid uses 2d cell types
Declaration
public bool Is2d { get; }
Property Value
Type |
Description |
System.Boolean |
|
Is3d
True if this grid uses 3d cell types
Declaration
public bool Is3d { get; }
Property Value
Type |
Description |
System.Boolean |
|
IsFinite
True if there is a finite amout of cells in the grid.
Declaration
public bool IsFinite { get; }
Property Value
Type |
Description |
System.Boolean |
|
IsOrientable
True if tile connections never set Mirror to true.
Declaration
public bool IsOrientable { get; }
Property Value
Type |
Description |
System.Boolean |
|
IsPlanar
True if this grid uses 2d cell types, and all cells fit in the XY plane.
Declaration
public bool IsPlanar { get; }
Property Value
Type |
Description |
System.Boolean |
|
IsRepeating
True for grids that are some fixed pattern repeated over and over.
Declaration
public bool IsRepeating { get; }
Property Value
Type |
Description |
System.Boolean |
|
IsSingleCellType
True if GetCellTypes always returns a single value.
Declaration
public bool IsSingleCellType { get; }
Property Value
Type |
Description |
System.Boolean |
|
Unbounded
Returns the grid with any bounds removed.
Declaration
public IGrid Unbounded { get; }
Property Value
Unwrapped
Returns the grid with most grid modifiers removed.
Declaration
public IGrid Unwrapped { get; }
Property Value
Methods
BoundBy(IBound)
Returns a new grid restricted to just the given bound.
If the grid already has a bound, the new grid will have the intersection of both.
Declaration
public IGrid BoundBy(IBound bound)
Parameters
Type |
Name |
Description |
IBound |
bound |
|
Returns
FindBasicPath(Cell, Cell)
Declaration
public IEnumerable<(Cell, CellDir)> FindBasicPath(Cell startCell, Cell destCell)
Parameters
Type |
Name |
Description |
Cell |
startCell |
|
Cell |
destCell |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.ValueTuple<Cell, CellDir>> |
|
FindCell(Matrix4x4, out Cell, out CellRotation)
Returns the cell and rotation corresponding to a given transform matrix.
Declaration
public bool FindCell(Matrix4x4 matrix, out Cell cell, out CellRotation rotation)
Parameters
Returns
Type |
Description |
System.Boolean |
|
FindCell(Vector3, out Cell)
Finds the cell containg the give position
Declaration
public bool FindCell(Vector3 position, out Cell cell)
Parameters
Returns
Type |
Description |
System.Boolean |
|
FindGridSymmetry(ISet<Cell>, ISet<Cell>, Cell, CellRotation)
Finds a GridSymmetry that:
- Maps from the cells of src into dest (in any order / rotation), and
- Maps srcCell using cellRotation (to any cell in dest)
For simple, regular grids, srcCell is irrelevant, as every cell uses the same cellRotation.
Returns null if one cannot be found. Returns an arbitrary pick if there are multiple possibilities.
Declaration
public GridSymmetry FindGridSymmetry(ISet<Cell> src, ISet<Cell> dest, Cell srcCell, CellRotation cellRotation)
Parameters
Type |
Name |
Description |
System.Collections.Generic.ISet<Cell> |
src |
|
System.Collections.Generic.ISet<Cell> |
dest |
|
Cell |
srcCell |
|
CellRotation |
cellRotation |
|
Returns
GetBound()
Returns the bound currently applied to the grid.
Declaration
Returns
GetBound(IEnumerable<Cell>)
Returns a bound that contains all the listed cells.
Declaration
public IBound GetBound(IEnumerable<Cell> cells)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<Cell> |
cells |
|
Returns
GetCellByIndex(Int32)
Finds the cell associated with a given index.
Declaration
public Cell GetCellByIndex(int index)
Parameters
Type |
Name |
Description |
System.Int32 |
index |
|
Returns
GetCellCenter(Cell)
Returns the center of the cell in local space
Declaration
public Vector3 GetCellCenter(Cell cell)
Parameters
Type |
Name |
Description |
Cell |
cell |
|
Returns
GetCellCorner(Cell, CellCorner)
Declaration
public Vector3 GetCellCorner(Cell cell, CellCorner cellCorner)
Parameters
Returns
GetCellCorners(Cell)
Declaration
public IEnumerable<CellCorner> GetCellCorners(Cell cell)
Parameters
Type |
Name |
Description |
Cell |
cell |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<CellCorner> |
|
GetCellDirs(Cell)
Declaration
public IEnumerable<CellDir> GetCellDirs(Cell cell)
Parameters
Type |
Name |
Description |
Cell |
cell |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<CellDir> |
|
GetCells()
Gets a full list of cells in bounds.
Declaration
public IEnumerable<Cell> GetCells()
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<Cell> |
|
GetCellsInBounds(IBound)
Returns the cells inside a given bound.
Declaration
public IEnumerable<Cell> GetCellsInBounds(IBound bound)
Parameters
Type |
Name |
Description |
IBound |
bound |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<Cell> |
|
GetCellsIntersectsApprox(Vector3, Vector3)
Gets the set of cells that potentially overlap bounds.
Declaration
public IEnumerable<Cell> GetCellsIntersectsApprox(Vector3 min, Vector3 max)
Parameters
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<Cell> |
|
GetCellType(Cell)
Returns the cell type associated with a given cell
Declaration
public ICellType GetCellType(Cell cell)
Parameters
Type |
Name |
Description |
Cell |
cell |
|
Returns
GetCellTypes()
Declaration
public IEnumerable<ICellType> GetCellTypes()
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<ICellType> |
|
Returns a deformation mapping from the cell's co-ordinates
to something that fits in the grids co-ordinates.
Declaration
public Deformation GetDeformation(Cell cell)
Parameters
Type |
Name |
Description |
Cell |
cell |
|
Returns
GetDual()
Declaration
public virtual IDualMapping GetDual()
Returns
GetIndex(Cell)
Finds the index associated with a given cell.
Declaration
public int GetIndex(Cell cell)
Parameters
Type |
Name |
Description |
Cell |
cell |
|
Returns
Type |
Description |
System.Int32 |
|
GetMeshData(Cell, out MeshData, out Matrix4x4)
For 3d cells, returns the mesh of a given cell.
Declaration
public void GetMeshData(Cell cell, out MeshData meshData, out Matrix4x4 transform)
Parameters
GetPolygon(Cell, out Vector3[], out Matrix4x4)
For 2d cells, returns the polygon of the boundary of the cell.
For performance reasons, cells can share a vertices array, so you need to apply
a specific transform to get the polygon specific to a particular cell.
Declaration
public void GetPolygon(Cell cell, out Vector3[] vertices, out Matrix4x4 transform)
Parameters
Type |
Name |
Description |
Cell |
cell |
|
Vector3[] |
vertices |
The vertices of the polygon. This should not be mutated.
|
Matrix4x4 |
transform |
A transformation that needs to be applied to each vertex.
|
GetTriangleMesh(Cell)
For 3d cells, returns triangles on the boundary of a given cell, and which direction they correspond to.
Declaration
public IEnumerable<(Vector3, Vector3, Vector3, CellDir)> GetTriangleMesh(Cell cell)
Parameters
Type |
Name |
Description |
Cell |
cell |
|
Returns
GetTRS(Cell)
Returns the appropriate transform for the cell.
The translation will always be to GetCellCenter,
rotation reflects the particular orientation of this cell
and the scale will reflect cell sizing.
GetTRS is often "best effort", there might not be an obvious
linear transformation from the canonical cell to the grid cell.
Declaration
public TRS GetTRS(Cell cell)
Parameters
Type |
Name |
Description |
Cell |
cell |
|
Returns
IntersectBounds(IBound, IBound)
Returns a bound that contains cells included in both arguments.
Declaration
public IBound IntersectBounds(IBound bound, IBound other)
Parameters
Returns
IsCellInBound(Cell, IBound)
Tests if a given cell is in bound.
i.e. returns true if the cell is listed in GetCellsInBounds.
Declaration
public bool IsCellInBound(Cell cell, IBound bound)
Parameters
Returns
Type |
Description |
System.Boolean |
|
IsCellInGrid(Cell)
Returns true if the cell is in the grid (and within bounds).
This is one of the few methods that accepts any Cell object, most
other methods only work with the cells in the grid.
Declaration
public bool IsCellInGrid(Cell cell)
Parameters
Type |
Name |
Description |
Cell |
cell |
|
Returns
Type |
Description |
System.Boolean |
|
ParallelTransport(IGrid, Cell, Cell, Cell, CellRotation, out Cell, out CellRotation)
Declaration
public bool ParallelTransport(IGrid aGrid, Cell aSrcCell, Cell aDestCell, Cell srcCell, CellRotation startRotation, out Cell destCell, out CellRotation destRotation)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Raycast(Vector3, Vector3, Single)
Returns the cells intersecting a ray starting at origin, of length direction.magnitude * maxDistance, in order.
Declaration
public IEnumerable<RaycastInfo> Raycast(Vector3 origin, Vector3 direction, float maxDistance = InfinityF)
Parameters
Type |
Name |
Description |
Vector3 |
origin |
|
Vector3 |
direction |
|
System.Single |
maxDistance |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<RaycastInfo> |
|
TryApplySymmetry(GridSymmetry, Cell, out Cell, out CellRotation)
Applies the mapping of s to cell, and also returns the rotation
For more details, see GridSymmetry.
For simple, regular grids, the output rotation is copied directly from Rotation.
Declaration
public bool TryApplySymmetry(GridSymmetry s, Cell src, out Cell dest, out CellRotation r)
Parameters
Returns
Type |
Description |
System.Boolean |
|
TryApplySymmetry(GridSymmetry, IBound, out IBound)
Finds a bound that would contain all the cells of srcBound after applying the grid symmetry to them.
Declaration
public bool TryApplySymmetry(GridSymmetry s, IBound srcBound, out IBound destBound)
Parameters
Returns
Type |
Description |
System.Boolean |
|
TryMove(Cell, CellDir, out Cell, out CellDir, out Connection)
Declaration
public bool TryMove(Cell cell, CellDir dir, out Cell dest, out CellDir inverseDir, out Connection connection)
Parameters
Returns
Type |
Description |
System.Boolean |
|
TryMoveByOffset(Cell, Vector3Int, Vector3Int, CellRotation, out Cell, out CellRotation)
Declaration
public bool TryMoveByOffset(Cell startCell, Vector3Int startOffset, Vector3Int destOffset, CellRotation startRotation, out Cell destCell, out CellRotation destRotation)
Parameters
Returns
Type |
Description |
System.Boolean |
|
UnionBounds(IBound, IBound)
Returns a bound that contains cells included in either argument.
Declaration
public IBound UnionBounds(IBound bound, IBound other)
Parameters
Returns
Implements