Table of Contents

Struct BoundVolume

Namespace
SwiftCollections.Query
Assembly
SwiftCollections.dll

Represents an axis-aligned bounding box (AABB) in 3D space.

public struct BoundVolume : IBoundVolume<BoundVolume>, IEquatable<BoundVolume>
Implements
Inherited Members

Constructors

BoundVolume(Vector3, Vector3)

Initializes a new instance of the BoundVolume struct with the specified minimum and maximum points.

public BoundVolume(Vector3 min, Vector3 max)

Parameters

min Vector3

The minimum point of the bounding volume.

max Vector3

The maximum point of the bounding volume.

Properties

Center

The center of the bounding volume as the midpoint of the minimum and maximum points.

public Vector3 Center { get; }

Property Value

Vector3

Max

The maximum point of the bounding volume.

public readonly Vector3 Max { get; }

Property Value

Vector3

Min

The minimum point of the bounding volume.

public readonly Vector3 Min { get; }

Property Value

Vector3

Size

The size of the bounding volume as the difference between the maximum and minimum points.

public Vector3 Size { get; }

Property Value

Vector3

Volume

The volume of the bounding box, calculated as the product of its dimensions.

public double Volume { get; }

Property Value

double

Methods

BoundsEquals(BoundVolume)

Determines whether the bounds represent the same spatial region.

public readonly bool BoundsEquals(BoundVolume other)

Parameters

other BoundVolume

The other bounding volume to compare against.

Returns

bool

True when both bounds share the same minimum and maximum extents; otherwise, false.

Equals(BoundVolume)

public readonly bool Equals(BoundVolume other)

Parameters

other BoundVolume

Returns

bool

Equals(object?)

public override readonly bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetCost(BoundVolume)

Calculates the cost of combining the current bounding volume with another. Used as the SAH insertion metric; returned as long to avoid overflow in worlds with large coordinate ranges.

public readonly long GetCost(BoundVolume other)

Parameters

other BoundVolume

The other bounding volume to consider.

Returns

long

The cost metric of the union operation.

GetHashCode()

public override readonly int GetHashCode()

Returns

int

Intersects(BoundVolume)

Determines whether the current bounding volume intersects with another.

public readonly bool Intersects(BoundVolume other)

Parameters

other BoundVolume

The other bounding volume to test for intersection.

Returns

bool

True if the volumes intersect; otherwise, false.

ToString()

Returns a string that represents the current object, including the minimum and maximum values.

public override readonly string ToString()

Returns

string

A string in the format "Min: {Min}, Max: {Max}" that displays the minimum and maximum values of the object.

Union(BoundVolume)

Combines the current bounding volume with another, creating a new volume that encloses both.

public readonly BoundVolume Union(BoundVolume other)

Parameters

other BoundVolume

The other bounding volume to combine with.

Returns

BoundVolume

A new bounding volume that contains both the current and other volumes.

Operators

operator ==(BoundVolume, BoundVolume)

Determines whether two BoundVolume instances are equal.

public static bool operator ==(BoundVolume left, BoundVolume right)

Parameters

left BoundVolume
right BoundVolume

Returns

bool

operator !=(BoundVolume, BoundVolume)

Determines whether two BoundVolume instances are not equal.

public static bool operator !=(BoundVolume left, BoundVolume right)

Parameters

left BoundVolume
right BoundVolume

Returns

bool