LodPartition

Description

static class Tinman.Terrain.Codec.LodPartition

The LodPartition implements a level-of-detail aware partitioning scheme which is used to rearrange samples of a gridded dataset so that loading at runtime can be performed efficiently.

The virtual gridded dataset which is partitioned covers the entire coordinate space of 32-bit positive integers (i.e. coordinates in the range [0..2147483647]). This space is split into interweaved chunks of equal size (i.e. both width and height are 256).

The following figures explain the partitioning scheme by using a virtual gridded dataset of size 8x8 and a chunk size of 2x2.

LOD Level 0:          LOD Levels 0-3:       LOD Levels 0-6:
+-----------------+   +-----------------+   +-----------------+
| 0 . . . 0 . . . |   | 0 . 1 . 0 . 1 . |   | 0 4 1 4 0 4 1 4 |
| . . . . . . . . |   | . . . . . . . . |   | 5 6 5 6 5 6 5 6 |
| . . . . . . . . |   | 2 . 3 . 2 . 3 . |   | 2 4 3 4 2 4 3 4 |
| . . . . . . . . |   | . . . . . . . . |   | 5 6 5 6 5 6 5 6 |
| 0 . . . 0 . . . |   | 0 . 1 . 0 . 1 . |   | 0 4 1 4 0 4 1 4 |
| . . . . . . . . |   | . . . . . . . . |   | 5 6 5 6 5 6 5 6 |
| . . . . . . . . |   | 2 . 3 . 2 . 3 . |   | 2 4 3 4 2 4 3 4 |
| . . . . . . . . |   | . . . . . . . . |   | 5 6 5 6 5 6 5 6 |
+-----------------+   +-----------------+   +-----------------+

LOD Level 1:          LOD Level 2:          LOD Level 3:
+-----------------+   +-----------------+   +-----------------+
| . . 1 . . . 1 . |   | . . . . . . . . |   | . . . . . . . . |
| . . . . . . . . |   | . . . . . . . . |   | . . . . . . . . |
| . . . . . . . . |   | 2 . . . 2 . . . |   | . . 3 . . . 3 . |
| . . . . . . . . |   | . . . . . . . . |   | . . . . . . . . |
| . . 1 . . . 1 . |   | . . . . . . . . |   | . . . . . . . . |
| . . . . . . . . |   | . . . . . . . . |   | . . . . . . . . |
| . . . . . . . . |   | 2 . . . 2 . . . |   | . . 3 . . . 3 . |
| . . . . . . . . |   | . . . . . . . . |   | . . . . . . . . |
+-----------------+   +-----------------+   +-----------------+

LOD Level 4:          LOD Level 5:          LOD Level 6:
+-----------------+   +-----------------+   +-----------------+
| . 4 . 4 . 4 . 4 |   | . . . . . . . . |   | . . . . . . . . |
| . . . . . . . . |   | 5 . 5 . 5 . 5 . |   | . 6 . 6 . 6 . 6 |
| . 4 . 4 . 4 . 4 |   | . . . . . . . . |   | . . . . . . . . |
| . . . . . . . . |   | 5 . 5 . 5 . 5 . |   | . 6 . 6 . 6 . 6 |
| . 4 . 4 . 4 . 4 |   | . . . . . . . . |   | . . . . . . . . |
| . . . . . . . . |   | 5 . 5 . 5 . 5 . |   | . 6 . 6 . 6 . 6 |
| . 4 . 4 . 4 . 4 |   | . . . . . . . . |   | . . . . . . . . |
| . . . . . . . . |   | 5 . 5 . 5 . 5 . |   | . 6 . 6 . 6 . 6 |
+-----------------+   +-----------------+   +-----------------+

LOD levels 0 to 3 contain one chunk; levels 4 to 6 contain four chunks. Levels 7 to 9 will contain sixteen chunks, and so on. Each chunk in a LOD level greater than 0 has four direct children (see ChildBlockIndex). Each chunk in a LOD level greater than 3 has one direct parent. In essence there are three distinct quad-trees, rooting at LOD levels 1, 2 and 3, respectively.

Public / Constants

Block​Samples


public constant BlockSamples → (65536:int32)

Number of samples in a LOD block.

Block​Size


public constant BlockSize → (256:int32)

Size of a LOD block (width and height).

Block​Stride


public constant BlockStride → (4194304:int32)

Stride distance between LOD blocks.

Max​Block​Idx


public constant MaxBlockIdx → (1231453023109119:int64)

Maximum LOD block index value.

Max​Block​Step


public constant MaxBlockStep → (8388608:int32)

The maximum LOD block step value (see LodBlock.BlockStep).

Min​Block​Step


public constant MinBlockStep → (2:int32)

The minimum LOD block step value (see LodBlock.BlockStep).

Public / Constructors

For​Block​Index


[Pure]
public static method ForBlockIndex → (3)

blockIdx in : int64

[0..LodPartition.MaxBlockIdx]
The LOD block index.

mx opt : int32 = HeightmapsUtil.MaxCoord

[0..HeightmapsUtil.MaxCoord]
Maximum X-coordinate of map.

my opt : int32 = HeightmapsUtil.MaxCoord

[0..HeightmapsUtil.MaxCoord]
Maximum Y-coordinate of map.

returns → LodBlock

The LOD block.

Returns information about a LOD block.

For​Coords


[Pure]
public static method ForCoords → (2)

in : int32

[>=0]
X-component of input coordinates.

in : int32

[>=0]
Y-component of input coordinates.

returns → LodCoords

The LOD block coordinates.

Returns the LOD block index and block offsets for the given set of coordinates.

For​Region


public static method ForRegion → (3)

region in : CubemapFaceRect

The cubemap face rectangle.

step in : int32

[pow2]
The step value.

regions opt : LodRegions = null

Optional LodRegions to use for output.

returns → LodRegions

The intersecting LOD regions.

Enumerates all LOD blocks that intersect the given step aligned cubemap face rectangle.

Public / Methods

Child​Block​Index


[Pure]
public static method ChildBlockIndex → (2)

blockIdx in : int64

[0..LodPartition.MaxBlockIdx]
Index of parent LOD block.

child in : int32

[0..3]
Number of child block.

returns → int64

Index of child LOD block or -1 if the given LOD block is a leaf.

Computes the LOD block index of a child of the given LOD block.

Child​Lod​Id


[Pure]
public static method ChildLodId → (2)

lodId in : int64

LOD ID of parent block.

child in : int32

Index of child block.

returns → int64

LOD ID of child block.

Returns the LOD ID of a child of the given LOD block.

Child​Number


[Pure]
public static method ChildNumber → (1)

blockIdx in : int64

[0..LodPartition.MaxBlockIdx]
The LOD block index.

returns → int32

The child index number.

Returns the child index number of the given LOD block in its parent.

Get​Block​Index


[Pure]
public static method GetBlockIndex → (1)

lodId in : int64

The LOD ID.

returns → int64

The LOD block index.

Extracts the LOD block index from the given LOD ID.

Get​Bounds


public static method GetBounds → (3)

lodId in : int64

The LOD block ID.

root in : int32

The LOD root of the block.

shift in : int32

Shift amount for heightmap coordinates to HeightmapsUtil.MaxCoord.

returns → CubemapFaceRect

The cubemap face rectangle.

Computes the cubemap face rectangle for the given LOD block.

Get​Face


[Pure]
public static method GetFace → (1)

lodId in : int64

The LOD ID.

returns → CubemapFace

The cubemap face.

Returns the cubemap face of the given LOD ID.

Get​Lod​Id


[Pure]
public static method GetLodId → (2)

lodBlockIdx in : int64

The LOD block index.

face opt : CubemapFace = CubemapFace.NegZ

The cubemap face.

returns → int64

The LOD ID value.

Constructs a new LOD ID value.

Get​Step


[Pure]
public static method GetStep → (1)

blockIdx in : int64

[0..LodPartition.MaxBlockIdx]
The LOD block index.

returns → int32

The LOD block step.

Returns the step of a LOD block.

Parent​Block​Index


[Pure]
public static method ParentBlockIndex → (1)

blockIdx in : int64

[0..LodPartition.MaxBlockIdx]
Index of child LOD block.

returns → int64

Index of parent LOD block or -1 if the given LOD block is a root.

Computes the LOD block index of the parent of the given LOD block.

Parent​Lod​Id


[Pure]
public static method ParentLodId → (1)

lodId in : int64

LOD ID of child block.

returns → int64

LOD ID of parent block.

Returns the LOD ID of the parent of the given LOD block.

Root​Block​Index


[Pure]
public static method RootBlockIndex → (1)

root in : int32

[1..3]
The quadtree root.

returns → int64

The LOD block index.

Returns the LOD block index of a quadtree root.

Root​Number


[Pure]
public static method RootNumber → (1)

blockIdx in : int64

The LOD block index.

returns → int32

The quadtree root or 0.

Returns the quadtree root which contains the given LOD block.