ISampleBufferBase

Description

interface Tinman.Terrain.Buffers.ISampleBufferBase

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

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.

Public / Methods

Offset​At

2 overloads


[Pure]
public method OffsetAt1 → (1)

in : int32

[0..ISampleBufferBase.Height-1]
Y-coordinate of the row.

returns → int32

Buffer index of the heightmap sample.

Computes the buffer index for the given heightmap sample.

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


[Pure]
public method OffsetAt2 → (2)

in : int32

[0..ISampleBufferBase.Width-1]
X-coordinate of sample.

in : int32

[0..ISampleBufferBase.Height-1]
Y-coordinate of sample.

returns → int32

Buffer index of the heightmap sample.

Computes the buffer index for the given heightmap sample.

Restore


public method Restore → ()

This sample buffer has been taken out of a pool.

Shift


public method Shift → (3)

in : int32

Horizontal shift amount.

in : int32

Vertical shift amount.

callback opt : ICollector<Box2I> = null

Collector for sample buffer regions that have been invalidated by the shift.

Shifts the samples in this buffer by the given amount.

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

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

Specifying a positive value for in will create space for new samples at the top buffer border, a negative value for in 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.

Public / Attributes

Height


public attribute Height → (get)

value : int32

[>0]
The height of the buffer, in samples.

The height of the buffer, in samples.

Is​Packed


public attribute IsPacked → (get)

value : bool

true if this buffer is densely packed, false if not.

Returns if this sample buffer is densely packed.

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.

Is​Pooled


public attribute IsPooled → (get)

value : bool

true if this buffer is currently in a pool, false if not.

Is this sample buffer being held in a pool?

Using a sample buffer that is being held in a pool is an error and indicates incorrect use of IDeletable.Delete.

After calling IDeletable.Delete, a sample buffer is considered to be in a pool and IsPooled will return true.

After taking a sample buffer out of the pool, Restore must be called.

Offset


public attribute Offset → (get)

value : int32

[>=0]
The buffer offset.

Index of top-left sample in the buffer.

Stride


public attribute Stride → (get)

value : int32

[>0]
The buffer stride, in samples.

Distance between two consecutive rows in the buffer.

Width


public attribute Width → (get)

value : int32

[>0]
The width of the buffer, in samples.

The width of the buffer, in samples.

Extensions

Assert​Not​Pooled


public static method AssertNotPooled → (1)

source in : string

The error source tag.

Asserts that ISampleBufferBase.IsPooled returns true.

Assert​Pooled


public static method AssertPooled → (1)

source in : string

The error source tag.

Asserts that ISampleBufferBase.IsPooled returns false.