EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
EBGeometry_MeshRayForms.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Robert Marskar <robert.marskar@sintef.no>
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
17#ifndef EBGEOMETRY_MESHRAYFORMS_HPP
18#define EBGEOMETRY_MESHRAYFORMS_HPP
19
20// Std includes
21#include <cstddef>
22#include <cstdint>
23
24// Our includes
26#include "EBGeometry_Ray.hpp"
27
28namespace EBGeometry {
29
43template <class T, size_t K, size_t W>
44struct RayForm<TriMeshSDF<T, K, W>>
45{
55 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
56 static inline HitT<T>
57 firstHit(const TriMeshSDF<T, K, W>& a_shape,
58 const RayT<T>& a_ray,
59 T a_tMin,
60 T a_tMax,
61 const RayOptions<T>& a_options) noexcept;
62
72 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
73 static inline HitStatus
74 intersects(const TriMeshSDF<T, K, W>& a_shape,
75 const RayT<T>& a_ray,
76 T a_tMin,
77 T a_tMax,
78 const RayOptions<T>& a_options) noexcept;
79
92 static inline void
93 spans(const TriMeshSDF<T, K, W>& a_shape,
94 const RayT<T>& a_ray,
95 T a_tMin,
96 T a_tMax,
97 const RayOptions<T>& a_options,
98 bool a_firstOnly,
99 RaySpansT<T>& a_spans) noexcept;
100};
101
114template <class T, size_t K>
115struct RayForm<MeshSDF<T, K>>
116{
126 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
127 static inline HitT<T>
128 firstHit(
129 const MeshSDF<T, K>& a_shape, const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options) noexcept;
130
140 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
141 static inline HitStatus
143 const MeshSDF<T, K>& a_shape, const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options) noexcept;
144
157 static inline void
158 spans(const MeshSDF<T, K>& a_shape,
159 const RayT<T>& a_ray,
160 T a_tMin,
161 T a_tMax,
162 const RayOptions<T>& a_options,
163 bool a_firstOnly,
164 RaySpansT<T>& a_spans) noexcept;
165};
166
172template <class T>
174{
184 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
185 static inline HitT<T>
186 firstHit(
187 const FlatMeshSDF<T>& a_shape, const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options) noexcept;
188
201 static inline void
202 spans(const FlatMeshSDF<T>& a_shape,
203 const RayT<T>& a_ray,
204 T a_tMin,
205 T a_tMax,
206 const RayOptions<T>& a_options,
207 bool a_firstOnly,
208 RaySpansT<T>& a_spans) noexcept;
209};
210
211namespace RayDetail {
212
219template <class T, size_t K, size_t W>
220struct TracedOnCheaply<TriMeshSDF<T, K, W>> : std::true_type
221{
222};
223
230template <class T, size_t K, size_t W>
231struct HitNamesPart<TriMeshSDF<T, K, W>> : std::true_type
232{
233};
234
240template <class T, size_t K>
241struct TracedOnCheaply<MeshSDF<T, K>> : std::true_type
242{
243};
244
250template <class T, size_t K>
251struct HitNamesPart<MeshSDF<T, K>> : std::true_type
252{
253};
254
260template <class T>
261struct TracedOnCheaply<FlatMeshSDF<T>> : std::true_type
262{
263};
264
269template <class T>
270struct HitNamesPart<FlatMeshSDF<T>> : std::true_type
271{
272};
273
284template <class T>
285[[nodiscard]] EBGEOMETRY_HOST_DEVICE
286inline HitT<T>
287faceHit(const RayT<T>& a_ray, const T a_t, const uint32_t a_face, const Vec3T<T>& a_normal) noexcept
288{
289 HitT<T> hit;
290
291 if (a_face != UINT32_MAX && a_t < Math::Limits<T>::infinity()) {
293 hit.m_t = a_t;
294 hit.m_point = a_ray.at(a_t);
295 hit.m_primitive = a_face;
296 hit.m_normal = a_normal;
297 hit.m_entering = dot(a_ray.m_direction, a_normal) < T(0);
298 hit.m_exact = true;
299 }
300
301 return hit;
302}
303
324template <class T>
325[[nodiscard]] EBGEOMETRY_HOST_DEVICE
326inline T
327tieReach(const RayT<T>& a_ray, const T a_nearestT, const bool a_found, const T a_tMax) noexcept
328{
329 if (!a_found) {
330 return a_tMax;
331 }
332
333 const Vec3T<T>& o = a_ray.m_origin;
334 const T window =
335 T(16) * Math::Limits<T>::epsilon() * (std::abs(a_nearestT) + std::abs(o[0]) + std::abs(o[1]) + std::abs(o[2]));
336
337 return Math::min(a_nearestT + window, a_tMax);
338}
339
357template <class T>
358[[nodiscard]] EBGEOMETRY_HOST_DEVICE
359inline bool
361 const RayT<T>& a_ray, const T a_t, const uint32_t a_face, const T a_nearestT, const uint32_t a_nearestFace) noexcept
362{
363 if (a_nearestFace == UINT32_MAX) {
364 return true;
365 }
366
367 const T reach = tieReach(a_ray, a_nearestT, true, Math::Limits<T>::infinity());
368 const T window = reach - a_nearestT;
369
370 return a_t < a_nearestT - window || (a_t <= reach && a_face < a_nearestFace);
371}
372
381template <class T>
383{
387 static constexpr uint32_t Capacity = 2U * RaySpansT<T>::Capacity + 1U;
388
392 struct Crossing
393 {
398
403 };
404
409
413 uint32_t m_count = 0;
414
419
426 inline void
427 insert(const T a_t, const bool a_entering) noexcept
428 {
429 if (m_count == Capacity) {
430 if (!(a_t < m_crossings[Capacity - 1U].m_t)) {
431 return;
432 }
433
434 m_count--;
435 }
436
437 uint32_t i = m_count;
438
439 while (i > 0 && m_crossings[i - 1U].m_t > a_t) {
440 m_crossings[i] = m_crossings[i - 1U];
441
442 i--;
443 }
444
445 m_crossings[i] = Crossing{a_t, a_entering};
446
447 m_count++;
448 }
449
454 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
455 inline T
456 horizon() const noexcept
457 {
458 return (m_count == Capacity) ? m_crossings[Capacity - 1U].m_t : m_tMax;
459 }
460
468 inline void
469 toSpans(const T a_t0, const bool a_inside, RaySpansT<T>& a_spans) const noexcept
470 {
471 const T horizon = this->horizon();
472
473 a_spans.reset(horizon);
474
475 if (m_count == 0U) {
476 if (a_inside) {
477 a_spans.add(RayDetail::openAt(a_t0), RayDetail::openAt(horizon));
478 }
479
480 return;
481 }
482
483 CrossingPairer<T> pairer;
484
485 for (uint32_t i = 0; i < m_count; i++) {
486 const Crossing& c = m_crossings[i];
487
488 pairer.take(SpanEndT<T>{c.m_t, 0U, SpanEndT<T>::Exact}, c.m_entering, a_t0, a_spans);
489 }
490
491 pairer.finish(horizon, a_spans);
492 }
493};
494
495} // namespace RayDetail
496
497template <class T, size_t K, size_t W>
499inline HitT<T>
501 const RayT<T>& a_ray,
502 const T a_tMin,
503 const T a_tMax,
504 const RayOptions<T>& /*a_options*/) noexcept
505{
506 // The state is the nearest crossing so far; it starts at the far end, so that the walk's bound (the
507 // state's distance) leaves out every box beyond it.
508 struct Nearest
509 {
510 T m_t;
511 uint32_t m_face;
512 Vec3T<T> m_normal;
513 };
514
515 Nearest nearest{a_tMax, UINT32_MAX, Vec3T<T>::zeros()};
516
517 const auto bvh = a_shape.getRoot();
518 const auto groups = bvh.getPrimitives();
519
520 // Lane by lane, so that a tie within a group goes to its lowest face id too (RayDetail::replacesNearest()).
521 const auto leaf = [&groups, &a_ray, a_tMin, a_tMax](Nearest& a_state, size_t a_offset, size_t a_count) noexcept {
522 for (size_t i = a_offset; i < a_offset + a_count; i++) {
523 const auto& group = groups[static_cast<uint32_t>(i)];
524 const T reach = RayDetail::tieReach(a_ray, a_state.m_t, a_state.m_face != UINT32_MAX, a_tMax);
525
526 T crossings[W];
527
528 group.rayCrossings(a_ray.m_origin, a_ray.m_direction, a_tMin, reach, crossings);
529
530 for (uint32_t lane = 0; lane < uint32_t(W); lane++) {
531 const T t = crossings[lane];
532 const uint32_t face = group.getFaceId(lane);
533
534 if (t < Math::Limits<T>::infinity() &&
535 RayDetail::replacesNearest(a_ray, t, face, a_state.m_t, a_state.m_face)) {
536 a_state = Nearest{t, face, group.getNormal(lane)};
537 }
538 }
539 }
540 };
541
542 const auto bound = [&a_ray, a_tMax](const Nearest& a_state) noexcept -> T {
543 return RayDetail::tieReach(a_ray, a_state.m_t, a_state.m_face != UINT32_MAX, a_tMax);
544 };
545
546 bvh.traverse(BVH::RayQuery<T>(a_ray.m_origin, a_ray.m_direction, a_tMin), nearest, leaf, bound);
547
548 HitT<T> hit;
549
550 if (nearest.m_face != UINT32_MAX) {
552 hit.m_t = nearest.m_t;
553 hit.m_point = a_ray.at(nearest.m_t);
554 hit.m_primitive = nearest.m_face;
555 hit.m_normal = nearest.m_normal;
556 hit.m_entering = dot(a_ray.m_direction, nearest.m_normal) < T(0);
557 hit.m_exact = true;
558 }
559
560 return hit;
561}
562
563template <class T, size_t K, size_t W>
565inline HitStatus
567 const RayT<T>& a_ray,
568 const T a_tMin,
569 const T a_tMax,
570 const RayOptions<T>& /*a_options*/) noexcept
571{
572 // The walk ends once a crossing is found: the bound drops to -infinity, which no box is within.
573 bool found = false;
574
575 const auto bvh = a_shape.getRoot();
576 const auto groups = bvh.getPrimitives();
577
578 const auto leaf = [&groups, &a_ray, a_tMin, a_tMax](bool& a_found, size_t a_offset, size_t a_count) noexcept {
579 for (size_t i = a_offset; i < a_offset + a_count && !a_found; i++) {
580 uint32_t face = UINT32_MAX;
582
583 const T t =
584 groups[static_cast<uint32_t>(i)].rayCrossing(a_ray.m_origin, a_ray.m_direction, a_tMin, a_tMax, face, normal);
585
586 a_found = face != UINT32_MAX && t <= a_tMax;
587 }
588 };
589
590 const auto bound = [a_tMax](const bool& a_found) noexcept -> T {
591 return a_found ? -Math::Limits<T>::infinity() : a_tMax;
592 };
593
594 bvh.traverse(BVH::RayQuery<T>(a_ray.m_origin, a_ray.m_direction, a_tMin), found, leaf, bound);
595
596 return found ? HitStatus::Hit : HitStatus::Miss;
597}
598
599template <class T, size_t K>
601inline HitT<T>
603 const RayT<T>& a_ray,
604 const T a_tMin,
605 const T a_tMax,
606 const RayOptions<T>& /*a_options*/) noexcept
607{
608 // The state is the nearest crossing so far and its face; it starts at the far end, so that the walk's
609 // bound leaves out every box beyond it.
610 struct Nearest
611 {
612 T m_t;
613 uint32_t m_face;
614 };
615
616 Nearest nearest{a_tMax, UINT32_MAX};
617
618 const auto bvh = a_shape.getRoot();
619 const auto mesh = a_shape.getMesh();
620 const auto faceIds = bvh.getPrimitives();
621
622 const auto leaf = [&faceIds, &mesh, &a_ray, a_tMin, a_tMax](
623 Nearest& a_state, size_t a_offset, size_t a_count) noexcept {
624 for (size_t i = a_offset; i < a_offset + a_count; i++) {
625 const uint32_t face = faceIds[static_cast<uint32_t>(i)];
626 const T reach = RayDetail::tieReach(a_ray, a_state.m_t, a_state.m_face != UINT32_MAX, a_tMax);
627 const T t = mesh.getFace(face).rayCrossing(a_ray.m_origin, a_ray.m_direction, a_tMin, reach, mesh);
628
629 // A crossing is finite: none is +infinity, however far the interval goes.
630 if (t < Math::Limits<T>::infinity() && RayDetail::replacesNearest(a_ray, t, face, a_state.m_t, a_state.m_face)) {
631 a_state = Nearest{t, face};
632 }
633 }
634 };
635
636 const auto bound = [&a_ray, a_tMax](const Nearest& a_state) noexcept -> T {
637 return RayDetail::tieReach(a_ray, a_state.m_t, a_state.m_face != UINT32_MAX, a_tMax);
638 };
639
640 bvh.traverse(BVH::RayQuery<T>(a_ray.m_origin, a_ray.m_direction, a_tMin), nearest, leaf, bound);
641
642 return nearest.m_face == UINT32_MAX
643 ? HitT<T>()
644 : RayDetail::faceHit(a_ray, nearest.m_t, nearest.m_face, mesh.getFace(nearest.m_face).getNormal());
645}
646
647template <class T, size_t K>
649inline HitStatus
651 const RayT<T>& a_ray,
652 const T a_tMin,
653 const T a_tMax,
654 const RayOptions<T>& /*a_options*/) noexcept
655{
656 // The walk ends once a crossing is found: the bound drops to -infinity, which no box is within.
657 bool found = false;
658
659 const auto bvh = a_shape.getRoot();
660 const auto mesh = a_shape.getMesh();
661 const auto faceIds = bvh.getPrimitives();
662
663 const auto leaf = [&faceIds, &mesh, &a_ray, a_tMin, a_tMax](bool& a_found, size_t a_offset, size_t a_count) noexcept {
664 for (size_t i = a_offset; i < a_offset + a_count && !a_found; i++) {
665 const auto& face = mesh.getFace(faceIds[static_cast<uint32_t>(i)]);
666
667 // None is +infinity, which an unbounded interval would contain.
668 a_found = face.rayCrossing(a_ray.m_origin, a_ray.m_direction, a_tMin, a_tMax, mesh) < Math::Limits<T>::infinity();
669 }
670 };
671
672 const auto bound = [a_tMax](const bool& a_found) noexcept -> T {
673 return a_found ? -Math::Limits<T>::infinity() : a_tMax;
674 };
675
676 bvh.traverse(BVH::RayQuery<T>(a_ray.m_origin, a_ray.m_direction, a_tMin), found, leaf, bound);
677
678 return found ? HitStatus::Hit : HitStatus::Miss;
679}
680
681template <class T>
683inline HitT<T>
685 const RayT<T>& a_ray,
686 const T a_tMin,
687 const T a_tMax,
688 const RayOptions<T>& /*a_options*/) noexcept
689{
690 const auto mesh = a_shape.getMesh();
691
692 T nearest = a_tMax;
693 uint32_t face = UINT32_MAX;
694
695 for (uint32_t i = 0; i < mesh.numFaces(); i++) {
696 const T reach = RayDetail::tieReach(a_ray, nearest, face != UINT32_MAX, a_tMax);
697 const T t = mesh.getFace(i).rayCrossing(a_ray.m_origin, a_ray.m_direction, a_tMin, reach, mesh);
698
699 if (t < Math::Limits<T>::infinity() && RayDetail::replacesNearest(a_ray, t, i, nearest, face)) {
700 nearest = t;
701 face = i;
702 }
703 }
704
705 return face == UINT32_MAX ? HitT<T>() : RayDetail::faceHit(a_ray, nearest, face, mesh.getFace(face).getNormal());
706}
707
708template <class T, size_t K, size_t W>
710inline void
712 const RayT<T>& a_ray,
713 const T a_tMin,
714 const T a_tMax,
715 const RayOptions<T>& a_options,
716 const bool a_firstOnly,
717 RaySpansT<T>& a_spans) noexcept
718{
719 if (a_firstOnly) {
720 RayDetail::firstSpan(a_shape, a_ray, a_tMin, a_tMax, a_options, a_spans);
721
722 return;
723 }
724
726
727 crossings.m_tMax = a_tMax;
728
729 const auto bvh = a_shape.getRoot();
730 const auto groups = bvh.getPrimitives();
731
732 const auto leaf =
733 [&groups, &a_ray, a_tMin](RayDetail::NearestCrossings<T>& a_state, size_t a_offset, size_t a_count) noexcept {
734 for (size_t i = a_offset; i < a_offset + a_count; i++) {
735 const auto& group = groups[static_cast<uint32_t>(i)];
736
737 T t[W];
738
739 group.rayCrossings(a_ray.m_origin, a_ray.m_direction, a_tMin, a_state.horizon(), t);
740
741 for (size_t lane = 0; lane < W; lane++) {
742 if (t[lane] < Math::Limits<T>::infinity()) {
743 a_state.insert(t[lane], dot(a_ray.m_direction, group.getNormal(lane)) < T(0));
744 }
745 }
746 }
747 };
748
749 const auto bound = [](const RayDetail::NearestCrossings<T>& a_state) noexcept -> T { return a_state.horizon(); };
750
751 bvh.traverse(BVH::RayQuery<T>(a_ray.m_origin, a_ray.m_direction, a_tMin), crossings, leaf, bound);
752
753 crossings.toSpans(
754 a_tMin, crossings.m_count == 0U && RayDetail::insideUncrossed(a_shape, a_ray, a_tMin, a_tMax, a_options), a_spans);
755}
756
757template <class T, size_t K>
759inline void
761 const RayT<T>& a_ray,
762 const T a_tMin,
763 const T a_tMax,
764 const RayOptions<T>& a_options,
765 const bool a_firstOnly,
766 RaySpansT<T>& a_spans) noexcept
767{
768 if (a_firstOnly) {
769 RayDetail::firstSpan(a_shape, a_ray, a_tMin, a_tMax, a_options, a_spans);
770
771 return;
772 }
773
775
776 crossings.m_tMax = a_tMax;
777
778 const auto bvh = a_shape.getRoot();
779 const auto mesh = a_shape.getMesh();
780 const auto faceIds = bvh.getPrimitives();
781
782 const auto leaf = [&faceIds, &mesh, &a_ray, a_tMin](
783 RayDetail::NearestCrossings<T>& a_state, size_t a_offset, size_t a_count) noexcept {
784 for (size_t i = a_offset; i < a_offset + a_count; i++) {
785 const uint32_t face = faceIds[static_cast<uint32_t>(i)];
786 const auto& f = mesh.getFace(face);
787 const T t = f.rayCrossing(a_ray.m_origin, a_ray.m_direction, a_tMin, a_state.horizon(), mesh);
788
789 if (t < Math::Limits<T>::infinity()) {
790 a_state.insert(t, dot(a_ray.m_direction, f.getNormal()) < T(0));
791 }
792 }
793 };
794
795 const auto bound = [](const RayDetail::NearestCrossings<T>& a_state) noexcept -> T { return a_state.horizon(); };
796
797 bvh.traverse(BVH::RayQuery<T>(a_ray.m_origin, a_ray.m_direction, a_tMin), crossings, leaf, bound);
798
799 crossings.toSpans(
800 a_tMin, crossings.m_count == 0U && RayDetail::insideUncrossed(a_shape, a_ray, a_tMin, a_tMax, a_options), a_spans);
801}
802
803template <class T>
805inline void
807 const RayT<T>& a_ray,
808 const T a_tMin,
809 const T a_tMax,
810 const RayOptions<T>& a_options,
811 const bool a_firstOnly,
812 RaySpansT<T>& a_spans) noexcept
813{
814 if (a_firstOnly) {
815 RayDetail::firstSpan(a_shape, a_ray, a_tMin, a_tMax, a_options, a_spans);
816
817 return;
818 }
819
821
822 crossings.m_tMax = a_tMax;
823
824 const auto mesh = a_shape.getMesh();
825
826 for (uint32_t i = 0; i < mesh.numFaces(); i++) {
827 const auto& f = mesh.getFace(i);
828 const T t = f.rayCrossing(a_ray.m_origin, a_ray.m_direction, a_tMin, crossings.horizon(), mesh);
829
830 if (t < Math::Limits<T>::infinity()) {
831 crossings.insert(t, dot(a_ray.m_direction, f.getNormal()) < T(0));
832 }
833 }
834
835 crossings.toSpans(
836 a_tMin, crossings.m_count == 0U && RayDetail::insideUncrossed(a_shape, a_ray, a_tMin, a_tMax, a_options), a_spans);
837}
838
839} // namespace EBGeometry
840
841#endif
#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
Declaration of signed distance functions for DCEL meshes.
T tieReach(const RayT< T > &a_ray, const T a_nearestT, const bool a_found, const T a_tMax) noexcept
How far past a mesh's nearest crossing so far its first hit still looks: crossings within a few ulps ...
Definition EBGeometry_MeshRayForms.hpp:327
bool replacesNearest(const RayT< T > &a_ray, const T a_t, const uint32_t a_face, const T a_nearestT, const uint32_t a_nearestFace) noexcept
Whether a face's crossing replaces a mesh's nearest crossing so far in its first hit: there is none s...
Definition EBGeometry_MeshRayForms.hpp:360
HitT< T > faceHit(const RayT< T > &a_ray, const T a_t, const uint32_t a_face, const Vec3T< T > &a_normal) noexcept
A crossing of a mesh face as a HitT.
Definition EBGeometry_MeshRayForms.hpp:287
Ray queries on any shape: where a ray, or the segment between two points, first crosses its surface (...
Signed distance function for a DCEL mesh. Does not use BVHs.
Definition EBGeometry_MeshDistanceFunctions.hpp:99
A FlatMeshSDF must be trivially copyable: that is what lets a rebasedView() be byte-copied into a dev...
Definition EBGeometry_MeshDistanceFunctions.hpp:315
Signed distance function for a pure triangle mesh using SoA-grouped primitives in a compact (lineariz...
Definition EBGeometry_MeshDistanceFunctions.hpp:627
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
static constexpr Vec3T< T > zeros() noexcept
Return a vector with x = y = z = 0.
constexpr T min(const T &a_a, const T &a_b) noexcept
The smaller of two values.
Definition EBGeometry_Math.hpp:44
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
HitStatus intersects(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
Whether a ray crosses a shape's surface in [a_tMin, a_tMax].
T dot(const Vec2T< T > &u, const Vec2T< T > &v) noexcept
Dot product of two 2D vectors.
Vec3T< T > normal(const F &a_function, const Vec3T< T > &a_point, const T &a_delta) noexcept
Outward unit normal of a function's level set, by central finite differences.
HitStatus
The outcome of a ray query.
Definition EBGeometry_Ray.hpp:86
@ Miss
The ray does not cross the surface in the interval.
@ 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.
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.
Definition EBGeometry_Ray.hpp:98
bool m_entering
Whether the ray enters the object there (it was outside just before), rather than leaving it.
Definition EBGeometry_Ray.hpp:131
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:137
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:108
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:126
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:120
HitStatus m_status
Whether the ray crosses the surface.
Definition EBGeometry_Ray.hpp:102
Vec3T< T > m_point
The point at m_t (for a hit or an unresolved query).
Definition EBGeometry_Ray.hpp:113
Numeric limits, with the meanings of the std::numeric_limits members of the same names.
Definition EBGeometry_Math.hpp:91
Pairs crossings, in order, into spans: a span from each crossing the ray enters at to the next it lea...
Definition EBGeometry_RaySpans.hpp:850
void take(const SpanEndT< T > &a_end, const bool a_entering, const T a_t0, RaySpansT< T > &a_spans) noexcept
Take the next crossing.
Definition EBGeometry_RaySpans.hpp:875
void finish(const T a_t, RaySpansT< T > &a_spans) noexcept
Close the open span, if any, at an Open end.
Definition EBGeometry_RaySpans.hpp:902
A crossing.
Definition EBGeometry_MeshRayForms.hpp:393
bool m_entering
Whether the ray enters there: it runs against the face's outward normal.
Definition EBGeometry_MeshRayForms.hpp:402
T m_t
Distance along the ray.
Definition EBGeometry_MeshRayForms.hpp:397
The nearest crossings of a mesh along a ray, in order, as a BVH walk finds them: at most Capacity,...
Definition EBGeometry_MeshRayForms.hpp:383
uint32_t m_count
How many are held.
Definition EBGeometry_MeshRayForms.hpp:413
Crossing m_crossings[Capacity]
The crossings, nearest first.
Definition EBGeometry_MeshRayForms.hpp:408
T horizon() const noexcept
How far the crossings are known: the end of the interval, or the farthest held once full.
Definition EBGeometry_MeshRayForms.hpp:456
void toSpans(const T a_t0, const bool a_inside, RaySpansT< T > &a_spans) const noexcept
The spans: the crossings paired by the side of the face the ray crosses from.
Definition EBGeometry_MeshRayForms.hpp:469
void insert(const T a_t, const bool a_entering) noexcept
Take a crossing.
Definition EBGeometry_MeshRayForms.hpp:427
static constexpr uint32_t Capacity
Most crossings held.
Definition EBGeometry_MeshRayForms.hpp:387
T m_tMax
End of the interval.
Definition EBGeometry_MeshRayForms.hpp:418
How to ray trace a shape directly, instead of marching its signed distance.
Definition EBGeometry_Ray.hpp:401
How a query marches, where a shape has no ray form.
Definition EBGeometry_Ray.hpp:203
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:296
A ray: the points origin + t * direction.
Definition EBGeometry_Ray.hpp:56
One end of a span: where a ray enters or leaves an object.
Definition EBGeometry_Ray.hpp:248