Morton Encoding

ImplicitBVH.morton_encode!Function
morton_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.

Warning

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.

source
ImplicitBVH.morton_encode_singleFunction
morton_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.

source
ImplicitBVH.morton_scalingFunction
morton_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.

source
ImplicitBVH.morton_split3Function
morton_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.

source
ImplicitBVH.relative_precisionFunction
relative_precision(::Type{Float16}) = 1e-2
relative_precision(::Type{Float32}) = 1e-5
relative_precision(::Type{Float64}) = 1e-14

Relative precision value for floating-point types.

source