Show / Hide Table of Contents

Class 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.

Inheritance
object
BaseModifier
WrapModifier
WrappingHexGrid
WrappingSquareGrid
Implements
IGrid
Inherited Members
BaseModifier.GetCellTypes()
BaseModifier.GetDiagonalGrid()
BaseModifier.GetCompactGrid()
BaseModifier.Recenter(Cell)
BaseModifier.GetCells()
BaseModifier.GetCellType(Cell)
BaseModifier.IsCellInGrid(Cell)
BaseModifier.GetCellDirs(Cell)
BaseModifier.GetCellCorners(Cell)
BaseModifier.FindBasicPath(Cell, Cell)
BaseModifier.GetIndex(Cell)
BaseModifier.GetCellByIndex(int)
BaseModifier.GetBound()
BaseModifier.GetBound(IEnumerable<Cell>)
BaseModifier.BoundBy(IBound)
BaseModifier.IntersectBounds(IBound, IBound)
BaseModifier.UnionBounds(IBound, IBound)
BaseModifier.GetCellsInBounds(IBound)
BaseModifier.IsCellInBound(Cell, IBound)
BaseModifier.GetBoundAabb(IBound)
BaseModifier.GetCellCenter(Cell)
BaseModifier.GetCellCorner(Cell, CellCorner)
BaseModifier.GetTRS(Cell)
BaseModifier.GetDeformation(Cell)
BaseModifier.GetPolygon(Cell, out Vector3[], out Matrix4x4)
BaseModifier.GetTriangleMesh(Cell)
BaseModifier.GetMeshData(Cell, out MeshData, out Matrix4x4)
BaseModifier.GetAabb(Cell)
BaseModifier.GetAabb(IEnumerable<Cell>)
BaseModifier.FindCell(Vector3, out Cell)
BaseModifier.FindCell(Matrix4x4, out Cell, out CellRotation)
BaseModifier.GetCellsIntersectsApprox(Vector3, Vector3)
BaseModifier.TryApplySymmetry(GridSymmetry, IBound, out IBound)
BaseModifier.Is2d
BaseModifier.Is3d
BaseModifier.IsPlanar
BaseModifier.IsRepeating
BaseModifier.IsOrientable
BaseModifier.IsFinite
BaseModifier.IsSingleCellType
BaseModifier.CoordinateDimension
BaseModifier.Unwrapped
BaseModifier.Underlying
BaseModifier.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 WrapModifier : BaseModifier, IGrid

Constructors

WrapModifier(IGrid, Func<Cell, Cell?>)

Declaration
public WrapModifier(IGrid underlying, Func<Cell, Cell?> canonicalize)
Parameters
Type Name Description
IGrid underlying
Func<Cell, Cell?> canonicalize

Properties

Unbounded

Returns the grid with any bounds removed.

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

Methods

Canonicalize(Cell)

Declaration
public Cell? Canonicalize(Cell cell)
Parameters
Type Name Description
Cell cell
Returns
Type Description
Cell?

FindGridSymmetry(ISet<Cell>, ISet<Cell>, Cell, CellRotation)

Finds a GridSymmetry that:

  1. Maps from the cells of src into dest (in any order / rotation), and
  2. 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 override GridSymmetry FindGridSymmetry(ISet<Cell> src, ISet<Cell> dest, Cell srcCell, CellRotation cellRotation)
Parameters
Type Name Description
ISet<Cell> src
ISet<Cell> dest
Cell srcCell
CellRotation cellRotation
Returns
Type Description
GridSymmetry
Overrides
BaseModifier.FindGridSymmetry(ISet<Cell>, ISet<Cell>, Cell, CellRotation)

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
BaseModifier.GetDual()

ParallelTransport(IGrid, Cell, Cell, Cell, CellRotation, out Cell, out CellRotation)

Given a path in aGrid from aSrcCell to aDestCell follows the same path in the current grid, starting at srcCell, and with the whole path rotated by startRotation. Reports the final spot that the path ends at, and it's rotation. Returns false if this cannot be done (typically because an equivalent pathc annot be found in the grid).

This method is useful for translating co-ordinates between different grids that are similarish, at least having the same celltypes. For example, suppose aGrid = new SquareGrid(1); aSrcCell = new Cell(0, 0) aDestCell = new Cell(5, 0) srcCell = new Cell(100, 100) startRotation = identity

Then the path in aGrid is a straight line moving 5 units to the right, and this method would attempt to move 5 units in the straight line that leads right out of (100, 100).

Declaration
public override bool ParallelTransport(IGrid aGrid, Cell aSrcCell, Cell aDestCell, Cell srcCell, CellRotation startRotation, out Cell destCell, out CellRotation destRotation)
Parameters
Type Name Description
IGrid aGrid
Cell aSrcCell
Cell aDestCell
Cell srcCell
CellRotation startRotation
Cell destCell
CellRotation destRotation
Returns
Type Description
bool
Overrides
BaseModifier.ParallelTransport(IGrid, Cell, Cell, Cell, CellRotation, out Cell, out CellRotation)

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
BaseModifier.Raycast(Vector3, Vector3, float)

Rebind(IGrid)

Creates a new grid applying the current wrapper to a new underlying.

Declaration
protected override IGrid Rebind(IGrid underlying)
Parameters
Type Name Description
IGrid underlying
Returns
Type Description
IGrid
Overrides
BaseModifier.Rebind(IGrid)

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 override bool TryApplySymmetry(GridSymmetry s, Cell src, out Cell dest, out CellRotation r)
Parameters
Type Name Description
GridSymmetry s
Cell src
Cell dest
CellRotation r
Returns
Type Description
bool
Overrides
BaseModifier.TryApplySymmetry(GridSymmetry, Cell, out Cell, out CellRotation)

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
BaseModifier.TryMove(Cell, CellDir, out Cell, out CellDir, out Connection)

TryMoveByOffset(Cell, Vector3Int, Vector3Int, CellRotation, out Cell, out CellRotation)

Maps between cell offsets and cells in the grid. This is normally done via FindBasicPath(Cell, Cell), but regular grids often have a more efficient implementation.

Declaration
public override bool TryMoveByOffset(Cell startCell, Vector3Int startOffset, Vector3Int destOffset, CellRotation startRotation, out Cell destCell, out CellRotation destRotation)
Parameters
Type Name Description
Cell startCell
Vector3Int startOffset
Vector3Int destOffset
CellRotation startRotation
Cell destCell
CellRotation destRotation
Returns
Type Description
bool
Overrides
BaseModifier.TryMoveByOffset(Cell, Vector3Int, Vector3Int, CellRotation, out Cell, out CellRotation)

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