TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

interface ISampleBufferBase in Tinman.Terrain.Buffers

Base interface for classes that represent buffers for heightmap sample values.

interface ISampleBufferBase extends IMemoryConsumption
  base of HeightmapRegion
  ISampleBuffer

Remarks

Subclasses provide an array that stores the buffer samples. This array can be accessed as follows:

Samples[Offset + y * Stride + x * TupleSize + z] := value
where x and y are the coordinates of the buffer sample and z is the index of the tuple component to access.

Attributes

Height

The height of the buffer, in samples.

property Height { get }
type int32
value [>0] The height of the buffer, in samples.

IsPacked

Returns if this sample buffer is densely packed.

property IsPacked { get }
type bool
value true if this buffer is densely packed, false if not.

Remarks:

A packed sample buffer can be indexed with the following scheme:

Samples[(y * Width + x) * TupleSize + 0] := 1st value of sample at (x,y).
Samples[(y * Width + x) * TupleSize + 1] := 2nd value of sample at (x,y).
...
Samples[(y * Width + x) * TupleSize + TupleSize - 1] := last value of sample.
Thus the samples of a densely packed buffer form a contiguous region in memory.

MemoryConsumption

Returns the estimated memory consumption of this object.

property MemoryConsumption { get }
type int64
value [>=0] The estimated memory consumption, in bytes.
inherited IMemoryConsumption.MemoryConsumption

Offset

Index of top-left sample in the buffer.

property Offset { get }
type int32
value [>=0] The buffer offset.

Stride

Distance between two consecutive rows in the buffer.

property Stride { get }
type int32
value [>0] The buffer stride, in samples.

Width

The width of the buffer, in samples.

property Width { get }
type int32
value [>0] The width of the buffer, in samples.

Methods

OffsetAt

Computes the buffer index for the given heightmap sample.

[Pure]
method OffsetAt (int32 y)
type int32
params y [0..Height-1] Y-coordinate of the row.
returns [>=0] Buffer index of the heightmap sample.

Remarks:

The returned buffer index may only be used to access the heightmap samples in the specified row (see y).


Computes the buffer index for the given heightmap sample.

[Pure]
method OffsetAt (int32 x, int32 y)
type int32
params x [0..Width-1] X-coordinate of sample.
  y [0..Height-1] Y-coordinate of sample.
returns [>=0] Buffer index of the heightmap sample.

Shift

Shifts the samples in this buffer by the given amount.

method Shift (int32 x, int32 y, ICollector<Box2I> callback = null)
params x Horizontal shift amount.
  y Vertical shift amount.
  callback Collector for sample buffer regions that have been invalidated by the shift.

Remarks:

This method allows sample buffers to be used in a toroidal manner (i.e. as a two-dimensional ringbuffer).

Specifying a positive value for x will create space for new samples at the left buffer border, a negative value for x will create space at the right border.

Specifying a positive value for y will create space for new samples at the top buffer border, a negative value for y will create space at the bottom border.

The contents of the samples in the additional space at the buffer border is unspecified and must be set by the application.