sealed class Tinman.Terrain.Kernel.TriangulationBuffer

Derived from


The TriangulationBuffer consume the output of a mesh triangulation process.

The triangulation process always outputs triangles, which may be encoded in different ways. Obvious ones are triangle lists and triangle strips, more sophisticated ones are terminal triangle lists and sector lists (see TriangleMode). The latter ones require compute features on the GPU, when being used for rendering.

See also


Public / Constructors


public constructor TriangulationBuffer → (1)

capacity opt : int32 = 1048576

The fixed buffer capacity, in indices.

Creates a new instance of TriangulationBuffer.

Public / Methods


public static method IndicesPerTriangle → (1)

mode in : TriangleMode

The triangle mode.

returns → int32

The number of indices per triangles, multiplied with 100.

Returns the estimated average number of 32-bit integer indices that need to be generated to describe a single triangle.


public method Reset → (2)

capacity in : int32

The buffer capacity, in indices.

grow opt : bool = false

true to only grow the buffer if capacity in is greater than ICapacity.Capacity,
false to re-allocate the buffer so that capacity in will be equal to ICapacity.Capacity.

Resets the buffer to a new capacity.

Calling this method will invalidate the current triangulation result (if any).


public method Set → (2)

indexCount in : int32

The number of indices that have been generated.

overflow in : bool

If this triangulation buffer has overflown during the last triangulation process.

Sets the index count of this buffer.


2 overloads

public method TriangleWindingFor1 → (1)

geometry in : IGeometry

The geometry.

Sets the TriangleWinding property according to the handedness of the given geometry.

public method TriangleWindingFor2 → (1)

handedness in : CartesianHandedness

The coordinate system handedness.

Sets the TriangleWinding property according to the given handedness.


public method Update → (3)

buffer in : IIndexBuffer

The index buffer to update.

bufferIndex opt : int32 = 0

Offset of first index in buffer in to write.

flag opt : GpuUpdateFlag = GpuUpdateFlag.Discard

The update flag to apply.

returns → bool

true if buffer in has been updated, false if the given index buffer has not enough capacity.

Updates the given index buffer.

Public / Attributes


public attribute HasOverflow → (get)

value : bool

true if an overflow has occurred, false if not.

Returns if this triangulation buffer has overflown during the last triangulation process.


public attribute IndexCount → (get)

value : int32

The number of generated indices.

Returns the number of indices that have been generated.


public attribute Indices → (get)

value : int32 [ ]

The vertex indices array.

Returns the array that holds the generated vertex indices.


public attribute Mode → (get,set)

value : TriangleMode

The triangulation mode.

The triangulation mode that has been used to fill this triangulation buffer.


public attribute PrimitiveRestart → (get,set)

value : bool

true to restart primitives with special index value ~0,
false to use degenerated triangles.

Use special index value ~0 for restarting primitives, instead of inserting degenerated triangles?

Primitives only need to be restarted when in TriangleMode.TriangleStrip mode. Degenerated triangles resp. special index values will only appear in this mode.

Defaults to false.


public attribute TriangleWinding → (get,set)

value : bool

The desired winding value (see remarks).

The winding of the triangles in the triangulation buffer.

The winding is defined according to the cubemap face coordinates of the triangle vertices:

winding = sign(cross(B - A, C - A)) > 0

where A, B and C are the two-dimensional cubemap face coordinates of the triangle vertices (in the same order as they are referenced in the triangulation buffer).

Defaults to false.