14#ifndef EBGEOMETRY_SPHERECLOUDRAYFORM_HPP
15#define EBGEOMETRY_SPHERECLOUDRAYFORM_HPP
40template <
class T,
size_t K,
size_t W>
116template <
class T,
size_t K,
size_t W>
126 [&a_shape, &a_ray, &a_options](
const T a_t0,
const T a_t1,
const bool a_all,
RaySpansT<T>& a_spans)
noexcept {
127 spans(a_shape, a_ray, a_t0, a_t1, a_options, !a_all, a_spans);
130 const auto resolve = [&a_shape, &a_ray, &a_options](
const T a_t,
const uint32_t a_sphere)
noexcept {
131 return leafHit(a_shape, a_ray, a_t, a_sphere, a_options);
134 return RayDetail::traceSpans(trace, resolve, a_ray, a_tMin, a_tMax);
137template <
class T,
size_t K,
size_t W>
147 [&a_shape, &a_ray, &a_options](
const T a_t0,
const T a_t1,
const bool a_all,
RaySpansT<T>& a_spans)
noexcept {
148 spans(a_shape, a_ray, a_t0, a_t1, a_options, !a_all, a_spans);
151 return RayDetail::traceCrossing(trace, a_ray, a_tMin, a_tMax);
154template <
class T,
size_t K,
size_t W>
162 const bool a_firstOnly,
165 a_spans.reset(a_tMax);
167 if (a_shape.numSpheres() == 0U) {
171 const auto bvh = a_shape.getBVH();
172 const auto groups = bvh.getPrimitives();
178 const auto leaf = [&groups, &a_ray, a_tMin, a_firstOnly, &operand](
179 RaySpansT<T>& a_union,
const size_t a_offset,
const size_t a_count)
noexcept {
180 for (
size_t g = a_offset; g < a_offset + a_count; g++) {
181 const auto& group = groups[
static_cast<uint32_t
>(g)];
186 group.rayIntervals(a_ray.m_origin, a_ray.m_direction, entry, exit);
188 for (uint32_t lane = 0; lane < W; lane++) {
189 if (entry[lane] <= exit[lane] && exit[lane] >= a_tMin && entry[lane] <= a_union.m_horizon) {
190 operand.
reset(a_union.m_horizon);
191 operand.
addClipped(entry[lane], exit[lane], a_tMin, a_union.m_horizon);
193 RayDetail::nameLeaf(group.getSphereId(lane), operand);
194 RayDetail::uniteInto(a_union, operand);
197 RayDetail::keepFirst(a_union);
205 const auto bound = [](
const RaySpansT<T>& a_union)
noexcept -> T {
return a_union.m_horizon; };
207 bvh.traverse(
BVH::RayQuery<T>(a_ray.m_origin, a_ray.m_direction, a_tMin), a_spans, leaf, bound);
210template <
class T,
size_t K,
size_t W>
216 const uint32_t a_sphere,
#define EBGEOMETRY_HOST_DEVICE
Mark a function as callable from both host and device code (no-op on host compilers).
Definition EBGeometry_GPU.hpp:80
Ray queries on any shape: where a ray, or the segment between two points, first crosses its surface (...
A BVH over spheres of differing radii, built where its pool is: the signed distance to their union an...
A BVH over spheres of differing radii (polydisperse particles), with the signed distance to their uni...
Definition EBGeometry_SphereCloudBVH.hpp:235
static constexpr Vec3T< T > zeros() noexcept
Return a vector with x = y = z = 0.
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
T dot(const Vec2T< T > &u, const Vec2T< T > &v) noexcept
Dot product of two 2D vectors.
CrossingT< T > firstCrossing(const S &a_shape, const RayT< T > &a_ray, typename RayT< T >::Scalar a_tMin, typename RayT< T >::Scalar a_tMax, const RayOptions< T > &a_options=RayOptions< T >()) noexcept
The first crossing of a shape's surface along a ray, as firstHit() finds it, without the normal or th...
@ Hit
The ray crosses the surface; HitT says where.
HitT< T > firstHit(const S &a_shape, const RayT< T > &a_ray, typename RayT< T >::Scalar a_tMin, typename RayT< T >::Scalar a_tMax, const RayOptions< T > &a_options=RayOptions< T >()) noexcept
The first crossing of a shape's surface along a ray, entering or leaving.
Fixed-size array with host- and device-callable members.
Definition EBGeometry_Array.hpp:33
A ray tracked through a BVH: the key of a box is the distance along the ray at which it enters the bo...
Definition EBGeometry_BVHQuery.hpp:286
Where a ray first crosses a surface, without the normal or the primitive there: what firstCrossing() ...
Definition EBGeometry_Ray.hpp:156
Where a ray first crosses a surface.
Definition EBGeometry_Ray.hpp:97
bool m_entering
Whether the ray enters the object there (it was outside just before), rather than leaving it.
Definition EBGeometry_Ray.hpp:130
bool m_exact
Whether the crossing is exact (found by a ray form), rather than found to within RayOptions::m_tolera...
Definition EBGeometry_Ray.hpp:136
T m_t
Distance along the ray: of the crossing for a hit, of the last point reached for an unresolved query,...
Definition EBGeometry_Ray.hpp:107
Vec3T< T > m_normal
The outward unit normal at the crossing: from the shape's ray form, or the normalized gradient of its...
Definition EBGeometry_Ray.hpp:125
uint32_t m_primitive
The finest element the shape can name at the crossing: the face of a mesh SDF, the deciding leaf of a...
Definition EBGeometry_Ray.hpp:119
HitStatus m_status
Whether the ray crosses the surface.
Definition EBGeometry_Ray.hpp:101
Vec3T< T > m_point
The point at m_t (for a hit or an unresolved query).
Definition EBGeometry_Ray.hpp:112
How a query marches, where a shape has no ray form.
Definition EBGeometry_Ray.hpp:202
Where a ray is inside an object over an interval [t0, t1]: its spans, in order, each from where it en...
Definition EBGeometry_Ray.hpp:295
void addClipped(T a_in, T a_out, T a_t0, T a_t1) noexcept
Append the span [a_in, a_out] cut to [a_t0, a_t1]: an end outside it (or infinite) becomes an Open en...
void reset(T a_horizon) noexcept
Empty the list, complete up to a horizon.
A ray: the points origin + t * direction.
Definition EBGeometry_Ray.hpp:55
A sphere of a sphere cloud: a center and a radius.
Definition EBGeometry_SphereCloud.hpp:48
Vec3T< T > m_center
The center.
Definition EBGeometry_SphereCloud.hpp:49
T m_radius
The radius, at least 0.
Definition EBGeometry_SphereCloud.hpp:50