Show / Hide Table of Contents

Class MeshGrid

Represents a 2d grid, where each cell corresponds to a face in a given mesh.

Inheritance
object
DataDrivenGrid
MeshGrid
MeshPrismGrid
MobiusSquareGrid
PlanarMeshGrid
VoronoiGrid
VoronoiSphereGrid
Implements
IGrid
Inherited Members
DataDrivenGrid.GetCellTypes()
DataDrivenGrid.Recenter(Cell)
DataDrivenGrid.GetCells()
DataDrivenGrid.GetCellType(Cell)
DataDrivenGrid.TryMoveByOffset(Cell, Vector3Int, Vector3Int, CellRotation, out Cell, out CellRotation)
DataDrivenGrid.ParallelTransport(IGrid, Cell, Cell, Cell, CellRotation, out Cell, out CellRotation)
DataDrivenGrid.GetCellDirs(Cell)
DataDrivenGrid.GetCellCorners(Cell)
DataDrivenGrid.FindBasicPath(Cell, Cell)
DataDrivenGrid.GetIndex(Cell)
DataDrivenGrid.GetCellByIndex(int)
DataDrivenGrid.GetCellCenter(Cell)
DataDrivenGrid.GetTRS(Cell)
DataDrivenGrid.GetDeformation(Cell)
DataDrivenGrid.FindGridSymmetry(ISet<Cell>, ISet<Cell>, Cell, CellRotation)
DataDrivenGrid.TryApplySymmetry(GridSymmetry, IBound, out IBound)
DataDrivenGrid.TryApplySymmetry(GridSymmetry, Cell, out Cell, out CellRotation)
DataDrivenGrid.Moves
DataDrivenGrid.CellData
DataDrivenGrid.IsRepeating
DataDrivenGrid.IsOrientable
DataDrivenGrid.IsFinite
DataDrivenGrid.IsSingleCellType
DataDrivenGrid.Unwrapped
DataDrivenGrid.IndexCount
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: Sylves
Assembly: Sylves.dll
Syntax
public class MeshGrid : DataDrivenGrid, IGrid

Constructors

MeshGrid(MeshData, MeshGridOptions)

Declaration
public MeshGrid(MeshData meshData, MeshGridOptions meshGridOptions = null)
Parameters
Type Name Description
MeshData meshData
MeshGridOptions meshGridOptions

MeshGrid(MeshGrid, CubeBound)

Declaration
protected MeshGrid(MeshGrid meshGrid, CubeBound bound)
Parameters
Type Name Description
MeshGrid meshGrid
CubeBound bound

Fields

bound

Declaration
protected readonly CubeBound bound
Field Value
Type Description
CubeBound

is2d

Declaration
protected readonly bool is2d
Field Value
Type Description
bool

max

Declaration
protected Vector3 max
Field Value
Type Description
Vector3

meshData

Declaration
protected readonly MeshData meshData
Field Value
Type Description
MeshData

min

Declaration
protected Vector3 min
Field Value
Type Description
Vector3

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
Type Description
int
Overrides
DataDrivenGrid.CoordinateDimension

Is2d

True if this grid uses 2d cell types

Declaration
public override bool Is2d { get; }
Property Value
Type Description
bool
Overrides
DataDrivenGrid.Is2d

Is3d

True if this grid uses 3d cell types

Declaration
public override bool Is3d { get; }
Property Value
Type Description
bool
Overrides
DataDrivenGrid.Is3d

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
Type Description
bool
Overrides
DataDrivenGrid.IsPlanar

Unbounded

Returns the grid with any bounds removed.

Declaration
public override IGrid Unbounded { get; }
Property Value
Type Description
IGrid
Overrides
DataDrivenGrid.Unbounded

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
Type Description
IGrid
Overrides
DataDrivenGrid.BoundBy(IBound)

ComputeBounds(Cell)

Declaration
protected virtual (Vector3, Vector3) ComputeBounds(Cell cell)
Parameters
Type Name Description
Cell cell
Returns
Type Description
(Vector3, Vector3)

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
Type Name Description
Matrix4x4 matrix
Cell cell
CellRotation rotation
Returns
Type Description
bool
Overrides
DataDrivenGrid.FindCell(Matrix4x4, out Cell, out CellRotation)

FindCell(Vector3, out Cell)

Finds the cell containg the give position

Declaration
public override bool FindCell(Vector3 position, out Cell cell)
Parameters
Type Name Description
Vector3 position
Cell cell
Returns
Type Description
bool
Overrides
DataDrivenGrid.FindCell(Vector3, out Cell)

GetAabb(Cell)

Gets a bounding box for a single cell.

Declaration
public override Aabb GetAabb(Cell cell)
Parameters
Type Name Description
Cell cell
Returns
Type Description
Aabb
Overrides
DataDrivenGrid.GetAabb(Cell)

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
Type Name Description
IEnumerable<Cell> cells
Returns
Type Description
Aabb
Overrides
DataDrivenGrid.GetAabb(IEnumerable<Cell>)

GetBound()

Returns the bound currently applied to the grid.

Declaration
public override IBound GetBound()
Returns
Type Description
IBound
Overrides
DataDrivenGrid.GetBound()

GetBound(IEnumerable<Cell>)

Returns a bound that contains all the listed cells.

Declaration
public override IBound GetBound(IEnumerable<Cell> cells)
Parameters
Type Name Description
IEnumerable<Cell> cells
Returns
Type Description
IBound
Overrides
DataDrivenGrid.GetBound(IEnumerable<Cell>)

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
Type Description
Aabb?
Overrides
DataDrivenGrid.GetBoundAabb(IBound)

GetCellCorner(Cell, CellCorner)

Returns the position of a corner.

Declaration
public override Vector3 GetCellCorner(Cell cell, CellCorner corner)
Parameters
Type Name Description
Cell cell
CellCorner corner
Returns
Type Description
Vector3
Overrides
DataDrivenGrid.GetCellCorner(Cell, CellCorner)

GetCellsInBounds(IBound)

Returns the cells inside a given bound.

Declaration
public override IEnumerable<Cell> GetCellsInBounds(IBound bound)
Parameters
Type Name Description
IBound bound
Returns
Type Description
IEnumerable<Cell>
Overrides
DataDrivenGrid.GetCellsInBounds(IBound)

GetCellsIntersectsApprox(Vector3, Vector3)

Gets the set of cells that potentially overlap bounds.

Declaration
public override IEnumerable<Cell> GetCellsIntersectsApprox(Vector3 min, Vector3 max)
Parameters
Type Name Description
Vector3 min
Vector3 max
Returns
Type Description
IEnumerable<Cell>
Overrides
DataDrivenGrid.GetCellsIntersectsApprox(Vector3, Vector3)

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
Type Description
IGrid
Overrides
DataDrivenGrid.GetCompactGrid()

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
Type Description
IGrid
Overrides
DataDrivenGrid.GetDiagonalGrid()

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
Type Description
IDualMapping
Overrides
DataDrivenGrid.GetDual()

GetFaceIndices(Cell)

Declaration
public IReadOnlyList<int> GetFaceIndices(Cell cell)
Parameters
Type Name Description
Cell cell
Returns
Type Description
IReadOnlyList<int>

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
Type Name Description
Cell cell
MeshData meshData
Matrix4x4 transform
Overrides
DataDrivenGrid.GetMeshData(Cell, out MeshData, out Matrix4x4)

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
DataDrivenGrid.GetPolygon(Cell, out Vector3[], out Matrix4x4)

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
Type Description
IEnumerable<(Vector3, Vector3, Vector3, CellDir)>
Overrides
DataDrivenGrid.GetTriangleMesh(Cell)

IntersectBounds(IBound, IBound)

Returns a bound that contains cells included in both arguments.

Declaration
public override IBound IntersectBounds(IBound bound, IBound other)
Parameters
Type Name Description
IBound bound
IBound other
Returns
Type Description
IBound
Overrides
DataDrivenGrid.IntersectBounds(IBound, IBound)

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
Type Name Description
Cell cell
IBound bound
Returns
Type Description
bool
Overrides
DataDrivenGrid.IsCellInBound(Cell, IBound)

IsCellInGrid(Cell)

Declaration
public virtual bool IsCellInGrid(Cell cell)
Parameters
Type Name Description
Cell cell
Returns
Type Description
bool

IsPointInCell(Vector3, Cell)

Declaration
protected virtual bool IsPointInCell(Vector3 position, Cell cell)
Parameters
Type Name Description
Vector3 position
Cell cell
Returns
Type Description
bool

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
Type Name Description
Vector3 origin
Vector3 direction
float maxDistance
Returns
Type Description
IEnumerable<RaycastInfo>
Overrides
DataDrivenGrid.Raycast(Vector3, Vector3, float)

RaycastCell(Cell, Vector3, Vector3)

Declaration
protected virtual RaycastInfo? RaycastCell(Cell cell, Vector3 rayOrigin, Vector3 direction)
Parameters
Type Name Description
Cell cell
Vector3 rayOrigin
Vector3 direction
Returns
Type Description
RaycastInfo?

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
Type Description
bool
Overrides
DataDrivenGrid.TryMove(Cell, CellDir, out Cell, out CellDir, out Connection)

UnionBounds(IBound, IBound)

Returns a bound that contains cells included in either argument.

Declaration
public override IBound UnionBounds(IBound bound, IBound other)
Parameters
Type Name Description
IBound bound
IBound other
Returns
Type Description
IBound
Overrides
DataDrivenGrid.UnionBounds(IBound, IBound)

Implements

IGrid

Extension Methods

GridExtensions.FindCell(IGrid, Vector3)
GridExtensions.GetCellsIntersectsApprox(IGrid, Aabb)
GridExtensions.GetMeshData(IGrid, Cell)
GridExtensions.GetNeighbours(IGrid, Cell)
GridExtensions.GetPolygon(IGrid, Cell)
GridExtensions.Masked(IGrid, ISet<Cell>)
GridExtensions.Masked(IGrid, Func<Cell, bool>, IEnumerable<Cell>)
GridExtensions.Move(IGrid, Cell, CellDir)
GridExtensions.ToMeshData(IGrid)
GridExtensions.ToMeshData(IGrid, IEnumerable<Cell>)
GridExtensions.Transformed(IGrid, Matrix4x4)
In this article
Back to top Generated by DocFX