Class MeshGrid
Represents a 2d grid, where each cell corresponds to a face in a given mesh.
Assembly: Sylves.dll
Syntax
public class MeshGrid : DataDrivenGrid, IGrid
Constructors
MeshGrid(MeshData, MeshGridOptions)
Declaration
public MeshGrid(MeshData meshData, MeshGridOptions meshGridOptions = null)
Parameters
MeshGrid(MeshGrid, CubeBound)
Declaration
protected MeshGrid(MeshGrid meshGrid, CubeBound bound)
Parameters
Fields
bound
Declaration
protected readonly CubeBound bound
Field Value
is2d
Declaration
protected readonly bool is2d
Field Value
max
Declaration
Field Value
meshData
Declaration
protected readonly MeshData meshData
Field Value
min
Declaration
Field Value
Properties
CoordinateDimension
Returns the number of co-ordinates needed to identify a cell.
i.e.
dim 1 means cell.y === 0 and cell.z === 0
dim 2 means cell.z === 0
dim 3 means all three co-ordinates are relevant.
Declaration
public override int CoordinateDimension { get; }
Property Value
Overrides
Is2d
True if this grid uses 2d cell types
Declaration
public override bool Is2d { get; }
Property Value
Overrides
Is3d
True if this grid uses 3d cell types
Declaration
public override bool Is3d { get; }
Property Value
Overrides
IsPlanar
True if this grid uses 2d cell types, and all cells fit in the XY plane.
Declaration
public override bool IsPlanar { get; }
Property Value
Overrides
Unbounded
Returns the grid with any bounds removed.
Declaration
public override IGrid Unbounded { get; }
Property Value
Overrides
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 override IGrid BoundBy(IBound bound)
Parameters
| Type |
Name |
Description |
| IBound |
bound |
|
Returns
Overrides
ComputeBounds(Cell)
Declaration
protected virtual (Vector3, Vector3) ComputeBounds(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
FindCell(Matrix4x4, out Cell, out CellRotation)
Returns the cell and rotation corresponding to a given transform matrix.
Declaration
public override bool FindCell(Matrix4x4 matrix, out Cell cell, out CellRotation rotation)
Parameters
Returns
Overrides
FindCell(Vector3, out Cell)
Finds the cell containg the give position
Declaration
public override bool FindCell(Vector3 position, out Cell cell)
Parameters
Returns
Overrides
GetAabb(Cell)
Gets a bounding box for a single cell.
Declaration
public override Aabb GetAabb(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
Overrides
GetAabb(IEnumerable<Cell>)
Gets a bounding box for a collection of cells.
Throws if cells is empty.
Declaration
public override Aabb GetAabb(IEnumerable<Cell> cells)
Parameters
Returns
Overrides
GetBound()
Returns the bound currently applied to the grid.
Declaration
public override IBound GetBound()
Returns
Overrides
GetBound(IEnumerable<Cell>)
Returns a bound that contains all the listed cells.
Declaration
public override IBound GetBound(IEnumerable<Cell> cells)
Parameters
Returns
Overrides
GetBoundAabb(IBound)
Returns a bounding box that fully covers all the cells in bounds.
Returns null
Declaration
public override Aabb? GetBoundAabb(IBound bound)
Parameters
| Type |
Name |
Description |
| IBound |
bound |
|
Returns
Overrides
GetCellCorner(Cell, CellCorner)
Returns the position of a corner.
Declaration
public override Vector3 GetCellCorner(Cell cell, CellCorner corner)
Parameters
Returns
Overrides
GetCellsInBounds(IBound)
Returns the cells inside a given bound.
Declaration
public override IEnumerable<Cell> GetCellsInBounds(IBound bound)
Parameters
| Type |
Name |
Description |
| IBound |
bound |
|
Returns
Overrides
GetCellsIntersectsApprox(Vector3, Vector3)
Gets the set of cells that potentially overlap bounds.
Declaration
public override IEnumerable<Cell> GetCellsIntersectsApprox(Vector3 min, Vector3 max)
Parameters
Returns
Overrides
GetCompactGrid()
For a grid that has CoordinateDimension == 3,
returns a grid that is the same as the current, but uses at most 2 dimensions.
Otherwise, returns the current grid.
(see RavelModifier if you want to reduce to 1 dimension).
Declaration
public override IGrid GetCompactGrid()
Returns
Overrides
GetDiagonalGrid()
Returns a new grid with the same cells as this grid, but more
directions allowing movement between diagonally adjacent cells.
Declaration
public override IGrid GetDiagonalGrid()
Returns
Overrides
GetDual()
Returns a second grid which has one cell for every vertex of this grid,
and also methods for mapping corners of one grid to the other.
Declaration
public override IDualMapping GetDual()
Returns
Overrides
GetFaceIndices(Cell)
Declaration
public IReadOnlyList<int> GetFaceIndices(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
GetMeshData(Cell, out MeshData, out Matrix4x4)
For 3d cells, returns the mesh of a given cell.
Declaration
public override void GetMeshData(Cell cell, out MeshData meshData, out Matrix4x4 transform)
Parameters
Overrides
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 override 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.
|
Overrides
GetTriangleMesh(Cell)
For 3d cells, returns triangles on the boundary of a given cell, and which direction they correspond to.
Declaration
public override IEnumerable<(Vector3, Vector3, Vector3, CellDir)> GetTriangleMesh(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
Overrides
IntersectBounds(IBound, IBound)
Returns a bound that contains cells included in both arguments.
Declaration
public override IBound IntersectBounds(IBound bound, IBound other)
Parameters
Returns
Overrides
IsCellInBound(Cell, IBound)
Tests if a given cell is in bound.
i.e. returns true if the cell is listed in GetCellsInBounds.
Declaration
public override bool IsCellInBound(Cell cell, IBound bound)
Parameters
Returns
Overrides
IsCellInGrid(Cell)
Declaration
public virtual bool IsCellInGrid(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
IsPointInCell(Vector3, Cell)
Declaration
protected virtual bool IsPointInCell(Vector3 position, Cell cell)
Parameters
Returns
Raycast(Vector3, Vector3, float)
Returns the cells intersecting a ray starting at origin, of length direction.magnitude * maxDistance, in order.
Declaration
public override IEnumerable<RaycastInfo> Raycast(Vector3 origin, Vector3 direction, float maxDistance = Infinity)
Parameters
Returns
Overrides
RaycastCell(Cell, Vector3, Vector3)
Declaration
protected virtual RaycastInfo? RaycastCell(Cell cell, Vector3 rayOrigin, Vector3 direction)
Parameters
Returns
TryMove(Cell, CellDir, out Cell, out CellDir, out Connection)
Attempts to move from a cell in a given direction, and returns information about the move if successful.
Declaration
public override bool TryMove(Cell cell, CellDir dir, out Cell dest, out CellDir inverseDir, out Connection connection)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
The cell to move from
|
| CellDir |
dir |
The direction to move in
|
| Cell |
dest |
The cell moved to
|
| CellDir |
inverseDir |
The direction leading back from dest to cell.
|
| Connection |
connection |
A descriptor of how cell-local space relates between cell and dest.
|
Returns
Overrides
UnionBounds(IBound, IBound)
Returns a bound that contains cells included in either argument.
Declaration
public override IBound UnionBounds(IBound bound, IBound other)
Parameters
Returns
Overrides
Implements
Extension Methods