Morton Encoding
ImplicitBVH.MortonUnsigned
— TypeAcceptable unsigned integer types for Morton encoding: Union{UInt16, UInt32, UInt64}.
ImplicitBVH.morton_encode
— Functionmorton_encode(
bounding_volumes,
::Type{U}=UInt,
options=BVHOptions(),
) where {U <: MortonUnsigned}
Encode the centers of some bounding_volumes
as Morton codes of type U <:
MortonUnsigned
. See morton_encode!
for full details.
ImplicitBVH.morton_encode!
— Functionmorton_encode!(
mortons::AbstractVector{U},
bounding_volumes,
options=BVHOptions(),
) where {U <: MortonUnsigned}
morton_encode!(
mortons::AbstractVector{U},
bounding_volumes::AbstractVector,
mins,
maxs,
options=BVHOptions(),
) where {U <: MortonUnsigned}
Encode each bounding volume into vector of corresponding Morton codes such that they uniformly cover the maximum Morton range given an unsigned integer type U <:
MortonUnsigned
.
The dimension-wise exclusive mins
and maxs
must be correct; if any bounding volume center is equal to, or beyond mins
/ maxs
, the results will be silently incorrect.
ImplicitBVH.morton_encode_single
— Functionmorton_encode_single(centre, mins, maxs, U::MortonUnsignedType=UInt32)
Return Morton code for a single 3D position centre
scaled uniformly between mins
and maxs
. Works transparently for SVector, Vector, etc. with eltype UInt16, UInt32 or UInt64.
ImplicitBVH.morton_scaling
— Functionmorton_scaling(::Type{UInt16}) = 2^5
morton_scaling(::Type{UInt32}) = 2^10
morton_scaling(::Type{UInt64}) = 2^21
Exclusive maximum number possible to use for 3D Morton encoding for each type.
ImplicitBVH.morton_split3
— Functionmorton_split3(v::UInt16)
morton_split3(v::UInt32)
morton_split3(v::UInt64)
Shift a number's individual bits such that they have two zeros between them.
ImplicitBVH.bounding_volumes_extrema
— Functionbounding_volumes_extrema(bounding_volumes)
Compute exclusive lower and upper bounds in iterable of bounding volumes, e.g. Vector{BBox}.
ImplicitBVH.relative_precision
— Functionrelative_precision(::Type{Float16}) = 1e-2
relative_precision(::Type{Float32}) = 1e-5
relative_precision(::Type{Float64}) = 1e-14
Relative precision value for floating-point types.