Allocator2D

Description

sealed class Tinman.Engine.Rendering.Util.Allocator2D

Derived from

AllocatorBase<Vec2I, Vec2I, Box2I> abstract

Helper class for allocating slot ranges in a two-dimensional square domain:

    slots (X,Y)
+---+---+---+---+  \
|0,0|1,0|2,0|3,0|  |
+---+---+---+---+  |
|0,1|1,1|2,1|3,1|  |
+---+---+---+---+  | capacity
|0,2|1,2|2,2|3,2|  | (here 4)
+---+---+---+---+  |
|0,3|1,3|2,3|3,3|  |
+---+---+---+---+  /

\_______________/
 capacity (here 4)

For optimal results, the aspect ratio of the dimensions passed to IAllocator.Allocate should be close to one of the following values:

  • 1 / 4 = 0.25; 4 / 1 = 4.00

  • 1 / 3 = 0.33; 3 / 1 = 3.00

  • 2 / 5 = 0.40; 5 / 2 = 2.50

  • 1 / 2 = 0.50; 2 / 1 = 2.00

  • 2 / 3 = 0.67; 3 / 2 = 1.50

  • 3 / 4 = 0.75; 4 / 3 = 1.33

  • 1 / 1 = 1.00

The slot ranges returned by IAllocator.Range may have dimensions that are greater then the dimensions that have been passed to IAllocator.Allocate. Also, the returned range may have transposed dimensions.

Public / Constructors

Allocator2​D


public constructor Allocator2D → (2)

size in : int32

The capacity, in allocation slots along each domain axis. Will be clamped to [1..32768] and round up to the next power of two.

chunks opt : int32 = 1

The number of allocation chunks. Will be clamped to [1..N], where N is the maximum chunk count that still produces positive 32-bit signed integer slot indices.

Creates a new instance of Allocator2D.