Class ScyllaLooseQuadtree.Builder
Fluent builder for incrementally configuring and constructing ScyllaLooseQuadtree instances. Obtain an instance via CreateBuilder().
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaLooseQuadtree.Builder
Remarks
Default values: maxDepth = 8, maxItemsPerNode = 8, looseness = 1.2, itemCapacity = 64. The root bounds and allocator have no defaults and must be set before calling Build() or BuildConcrete().
Methods
Build()
Builds and returns the configured ScyllaLooseQuadtree instance.
Declaration
public ScyllaLooseQuadtree Build()
Returns
| Type | Description |
|---|---|
| ScyllaLooseQuadtree | The configured ScyllaLooseQuadtree instance |
Remarks
Validates that WithRootBounds(ScyllaAABB2) and WithAllocator(Allocator) have been called before constructing the quadtree. Since ScyllaLooseQuadtree doesn't have a synchronized wrapper, this method returns the concrete type directly.
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when rootBounds or allocator has not been set |
BuildConcrete()
Builds and returns the concrete ScyllaLooseQuadtree instance. This method is functionally identical to Build() since ScyllaLooseQuadtree doesn't have a synchronized wrapper.
Declaration
public ScyllaLooseQuadtree BuildConcrete()
Returns
| Type | Description |
|---|---|
| ScyllaLooseQuadtree | The configured ScyllaLooseQuadtree instance |
Remarks
Validates that WithRootBounds(ScyllaAABB2) and WithAllocator(Allocator) have been called before constructing the quadtree. This method exists for API consistency with other collection builders, but returns the same type as Build().
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when rootBounds or allocator has not been set |
WithAllocator(Allocator)
Sets the memory allocator for native containers. This method must be called before Build() or BuildConcrete().
Declaration
public ScyllaLooseQuadtree.Builder WithAllocator(Allocator allocator)
Parameters
| Type | Name | Description |
|---|---|---|
| Allocator | allocator | Memory allocator for native containers (must not be Allocator.None) |
Returns
| Type | Description |
|---|---|
| ScyllaLooseQuadtree.Builder | This builder instance for method chaining |
Remarks
Allocator Selection:
- Allocator.Persistent: Long-lived quadtree (recommended for most game scenarios)
- Allocator.TempJob: Quadtree used within a single frame across jobs
- Allocator.Temp: Short-lived quadtree used within a single frame (avoid for quadtree due to size)
Validation:
Allocator.None is not allowed and will throw an ArgumentException.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when allocator is Allocator.None |
WithItemCapacity(int)
Sets the initial capacity for item storage.
Declaration
public ScyllaLooseQuadtree.Builder WithItemCapacity(int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | capacity | The initial item capacity. Must be at least 0. If negative, will be clamped to 1 during construction. |
Returns
| Type | Description |
|---|---|
| ScyllaLooseQuadtree.Builder | This builder instance for method chaining |
Remarks
This is a hint to reduce early allocations. The quadtree will grow automatically if needed. Set this to the number of items you expect to store.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when capacity is negative |
WithLooseness(float)
Sets the looseness factor.
Declaration
public ScyllaLooseQuadtree.Builder WithLooseness(float looseness)
Parameters
| Type | Name | Description |
|---|---|---|
| float | looseness | Looseness factor (must be >= 1.0 and finite) |
Returns
| Type | Description |
|---|---|
| ScyllaLooseQuadtree.Builder | This builder instance for method chaining |
Remarks
Looseness expands each node's query bounds relative to tight cell bounds. Larger values reduce reinsertion churn for moving items but increase node overlap. Typical range: 1.0 to 2.0.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when looseness is less than 1.0, NaN, or Infinity |
WithMaxDepth(int)
Sets the maximum subdivision depth.
Declaration
public ScyllaLooseQuadtree.Builder WithMaxDepth(int maxDepth)
Parameters
| Type | Name | Description |
|---|---|---|
| int | maxDepth | Maximum subdivision depth (must be >= 0) |
Returns
| Type | Description |
|---|---|
| ScyllaLooseQuadtree.Builder | This builder instance for method chaining |
Remarks
A value of 0 disables subdivision. Higher values allow finer spatial partitioning but increase memory usage.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when maxDepth is negative |
WithMaxItemsPerNode(int)
Sets the maximum items per node before subdivision.
Declaration
public ScyllaLooseQuadtree.Builder WithMaxItemsPerNode(int maxItemsPerNode)
Parameters
| Type | Name | Description |
|---|---|---|
| int | maxItemsPerNode | Maximum items per node (must be >= 1) |
Returns
| Type | Description |
|---|---|
| ScyllaLooseQuadtree.Builder | This builder instance for method chaining |
Remarks
When a node exceeds this count, it will be subdivided into 4 child nodes.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when maxItemsPerNode is less than 1 |
WithRootBounds(ScyllaAABB2)
Sets the tight root bounds of the quadtree. This method must be called before Build() or BuildConcrete().
Declaration
public ScyllaLooseQuadtree.Builder WithRootBounds(ScyllaAABB2 rootBounds)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaAABB2 | rootBounds | Tight root bounds (must be valid) |
Returns
| Type | Description |
|---|---|
| ScyllaLooseQuadtree.Builder | This builder instance for method chaining |
Remarks
All inserted items must be fully contained by the root loose bounds (tight bounds expanded by looseness).
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when root bounds are invalid |