Class ScyllaLooseOctree.Builder
Fluent builder for configuring and constructing ScyllaLooseOctree instances.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaLooseOctree.Builder
Methods
Build()
Builds and returns the configured ScyllaLooseOctree instance.
Declaration
public ScyllaLooseOctree Build()
Returns
| Type | Description |
|---|---|
| ScyllaLooseOctree | The configured ScyllaLooseOctree instance |
Remarks
Validates that WithRootBounds(ScyllaAABB3) and WithAllocator(Allocator) have been called before constructing the octree. Since ScyllaLooseOctree 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 ScyllaLooseOctree instance. This method is functionally identical to Build() since ScyllaLooseOctree doesn't have a synchronized wrapper.
Declaration
public ScyllaLooseOctree BuildConcrete()
Returns
| Type | Description |
|---|---|
| ScyllaLooseOctree | The configured ScyllaLooseOctree instance |
Remarks
Validates that WithRootBounds(ScyllaAABB3) and WithAllocator(Allocator) have been called before constructing the octree. 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 ScyllaLooseOctree.Builder WithAllocator(Allocator allocator)
Parameters
| Type | Name | Description |
|---|---|---|
| Allocator | allocator | Memory allocator for native containers (must not be Allocator.None) |
Returns
| Type | Description |
|---|---|
| ScyllaLooseOctree.Builder | This builder instance for method chaining |
Remarks
Allocator Selection:
- Allocator.Persistent: Long-lived octree (recommended for most game scenarios)
- Allocator.TempJob: Octree used within a single frame across jobs
- Allocator.Temp: Short-lived octree used within a single frame (avoid for octree 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 ScyllaLooseOctree.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 |
|---|---|
| ScyllaLooseOctree.Builder | This builder instance for method chaining |
Remarks
This is a hint to reduce early allocations. The octree 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 ScyllaLooseOctree.Builder WithLooseness(float looseness)
Parameters
| Type | Name | Description |
|---|---|---|
| float | looseness | Looseness factor (must be >= 1.0 and finite) |
Returns
| Type | Description |
|---|---|
| ScyllaLooseOctree.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 ScyllaLooseOctree.Builder WithMaxDepth(int maxDepth)
Parameters
| Type | Name | Description |
|---|---|---|
| int | maxDepth | Maximum subdivision depth (must be >= 0) |
Returns
| Type | Description |
|---|---|
| ScyllaLooseOctree.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 ScyllaLooseOctree.Builder WithMaxItemsPerNode(int maxItemsPerNode)
Parameters
| Type | Name | Description |
|---|---|---|
| int | maxItemsPerNode | Maximum items per node (must be >= 1) |
Returns
| Type | Description |
|---|---|
| ScyllaLooseOctree.Builder | This builder instance for method chaining |
Remarks
When a node exceeds this count, it will be subdivided into 8 child nodes.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when maxItemsPerNode is less than 1 |
WithRootBounds(ScyllaAABB3)
Sets the tight root bounds of the octree. This method must be called before Build() or BuildConcrete().
Declaration
public ScyllaLooseOctree.Builder WithRootBounds(ScyllaAABB3 rootBounds)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaAABB3 | rootBounds | Tight root bounds (must be valid) |
Returns
| Type | Description |
|---|---|
| ScyllaLooseOctree.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 |