Bounding Volumes
ImplicitBVH.BoundingVolume — Type
struct BoundingVolume{V, I, M}Bounding volume wrapper, containing a bounding volume of type V, an index of type I, and a computed Morton code of type M.
The index will be the one reported in case of contact during traversal; it can be anything (user-defined) to identify the bounding volume later in e.g. a simulation.
Fields
volume::V: the bounding volume, e.g.BSphereorBBox.index::I: the user-defined index associated with this bounding volume.morton::M: the Morton code for this bounding volume computed during BVH construction.
ImplicitBVH.BBox — Type
struct BBox{T}Axis-aligned bounding box, optimised for computing bounding volumes for triangles and merging into larger bounding volumes.
Can also be constructed from two spheres to e.g. allow merging BSphere leaves into BBox nodes.
Methods
# Convenience constructors
BBox(lo::NTuple{3, T}, up::NTuple{3, T}) where T
BBox{T}(lo::AbstractVector, up::AbstractVector) where T
BBox(lo::AbstractVector, up::AbstractVector)
# Construct from triangle vertices
BBox{T}(p1, p2, p3) where T
BBox(p1, p2, p3)
BBox{T}(vertices::AbstractMatrix) where T
BBox(vertices::AbstractMatrix)
BBox{T}(triangle) where T
BBox(triangle)
# Merging bounding boxes
BBox{T}(a::BBox, b::BBox) where T
BBox(a::BBox{T}, b::BBox{T}) where T
Base.:+(a::BBox, b::BBox)
# Merging bounding spheres
BBox{T}(a::BSphere{T}) where T
BBox(a::BSphere{T}) where T
BBox{T}(a::BSphere{T}, b::BSphere{T}) where T
BBox(a::BSphere{T}, b::BSphere{T}) where TImplicitBVH.BSphere — Type
struct BSphere{T}Bounding sphere, optimised for computing bounding volumes for triangles and merging into larger bounding volumes.
Methods
# Convenience constructors
BSphere(x::NTuple{3, T}, r)
BSphere{T}(x::AbstractVector, r) where T
BSphere(x::AbstractVector, r)
# Construct from triangle vertices
BSphere{T}(p1, p2, p3) where T
BSphere(p1, p2, p3)
BSphere{T}(vertices::AbstractMatrix) where T
BSphere(vertices::AbstractMatrix)
BSphere{T}(triangle) where T
BSphere(triangle)
# Merging bounding volumes
BSphere{T}(a::BSphere, b::BSphere) where T
BSphere(a::BSphere{T}, b::BSphere{T}) where T
Base.:+(a::BSphere, b::BSphere)Query Functions
ImplicitBVH.iscontact — Function
iscontact(a::BSphere, b::BSphere)
iscontact(a::BBox, b::BBox)
iscontact(a::BSphere, b::BBox)
iscontact(a::BBox, b::BSphere)Check if two bounding volumes are touching or inter-penetrating.
ImplicitBVH.isintersection — Function
isintersection(
b::BBox{T},
p::Union{AbstractVector{T}, NTuple{3, T}},
d::Union{AbstractVector{T}, NTuple{3, T}},
) where T
isintersection(
s::BSphere{T},
p::Union{AbstractVector{T}, NTuple{3, T}},
d::Union{AbstractVector{T}, NTuple{3, T}},
) where TCheck if a forward ray, defined by a point p and a direction d intersects a bounding volume; p and d can be any iterables with 3 numbers (e.g. Vector{Float64}).
ImplicitBVH.center — Function
center(b::BSphere)
center(b::BBox{T}) where TGet the coordinates of a bounding volume's centre, as a NTuple{3, T}.