22#ifndef EBGEOMETRY_SMOOTHRAYFORMS_HPP
23#define EBGEOMETRY_SMOOTHRAYFORMS_HPP
55blendDepth(
const T a_smooth,
const bool a_exponential)
noexcept
57 return a_exponential ? a_smooth * T(0.6931471805599453) : T(0.25) * a_smooth;
93 return m_shape.signedDistance(a_point);
104 return m_shape.computeBoundingVolume();
113struct IsComposition<
MarchedView<S>> : std::bool_constant<CalledOutOfLine<S>>
129template <
class T,
class... Cs>
161 return this->value(a_point, std::index_sequence_for<Cs...>{});
182 template <
size_t... Is>
185 value(
const Vec3T<T>& a_point, std::index_sequence<Is...>)
const noexcept
195 return Math::max(blended, pair.
m_second - (smooth + RayDetail::blendDepth(smooth,
false)));
204template <
class T,
class... Cs>
222template <
class T,
class Op,
class... Cs,
size_t... Is>
229 std::index_sequence<Is...>)
noexcept
234 for (
size_t i = 0; i <
sizeof...(Is); i++) {
235 for (
size_t j = i + 1; j <
sizeof...(Is); j++) {
236 const Vec3T<T> lo =
max(boxes[i].getLowCorner(), boxes[j].getLowCorner()) - grow;
237 const Vec3T<T> hi =
min(boxes[i].getHighCorner(), boxes[j].getHighCorner()) + grow;
239 if (lo[0] <= hi[0] && lo[1] <= hi[1] && lo[2] <= hi[2]) {
264template <
class T,
bool IsUnion,
class... Cs>
265struct RayForm<Fused::
Node<Fused::SmoothCombineOp<T, IsUnion>, Cs...>>
286 [&a_shape, &a_ray, &a_options](
const T a_t0,
const T a_t1,
const bool a_all,
RaySpansT<T>& a_spans)
noexcept {
287 spans(a_shape, a_ray, a_t0, a_t1, a_options, !a_all, a_spans);
291 const auto resolve = [&a_shape, &a_ray, &a_options](
const T a_t,
const uint32_t)
noexcept {
292 const auto box = a_shape.computeBoundingVolume();
293 const T h = a_options.m_tolerance * RayDetail::scaleOf(box.getLowCorner(), box.getHighCorner(), a_options);
302 HitT<T> hit = RayDetail::traceSpans(trace, resolve, a_ray, a_tMin, a_tMax);
324 [&a_shape, &a_ray, &a_options](
const T a_t0,
const T a_t1,
const bool a_all,
RaySpansT<T>& a_spans)
noexcept {
325 spans(a_shape, a_ray, a_t0, a_t1, a_options, !a_all, a_spans);
328 return RayDetail::traceCrossing(trace, a_ray, a_tMin, a_tMax);
355 if constexpr (IsUnion) {
360 RayDetail::shapeSpans(
366 RayDetail::fusedOperandSpans<0>(a_shape, a_ray, a_tMin, a_tMax, a_options, a_firstOnly, a_spans);
369 RayDetail::keepFirst(a_spans);
372 RayDetail::fusedUnite<1>(a_shape, a_ray, a_tMin, a_options, a_firstOnly, a_spans, operand);
382 RayDetail::pairOverlaps(a_shape, level, zone, any, std::index_sequence_for<Cs...>{});
393 RayDetail::uniteInto(a_spans, operand);
396 RayDetail::keepFirst(a_spans);
409 RayDetail::fusedOperandSpans<first>(a_shape, a_ray, a_tMin, a_tMax, a_options,
false, bracket);
410 RayDetail::fusedIntersect<0, false, first>(a_shape, a_ray, a_tMin, a_options,
false, bracket, operand, scratch);
411 RayDetail::fusedIntersect<0, true, first>(a_shape, a_ray, a_tMin, a_options,
false, bracket, operand, scratch);
412 RayDetail::spansWithin(
416 RayDetail::nameLeaf(0U, a_spans);
Fused CSG: the operations of the expression builder (EBGeometry_Expr.hpp) as types,...
#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
Scalar helpers and numeric limits that compile for both host and device.
The span arithmetic that traces a composition along a ray: each operand's spans (where the ray is ins...
Ray queries on any shape: where a ray, or the segment between two points, first crosses its surface (...
Axis-aligned bounding box (AABB) enclosing a set of 3D points.
Definition EBGeometry_BoundingVolumes.hpp:37
const Layout & layout() const noexcept
The node's layout.
Definition EBGeometry_Fused.hpp:383
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
static constexpr Vec3T< T > ones() noexcept
Return a vector with x = y = z = 1.
T pairBlend(const Pair< T > &a_pair, const T a_smooth, const bool a_largest, const bool a_exponential) noexcept
The smooth minimum (or maximum) of a pair's two values.
Definition EBGeometry_CSGOps.hpp:603
void pairInsert(Pair< T > &a_pair, const T a_value, const bool a_largest) noexcept
Insert a value into a pair of extreme values.
Definition EBGeometry_CSGOps.hpp:547
constexpr T max(const T &a_a, const T &a_b) noexcept
The larger of two values.
Definition EBGeometry_Math.hpp:61
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
Vec2T< T > min(const Vec2T< T > &u, const Vec2T< T > &v) noexcept
Component-wise minimum of two vectors.
typename ExprDetail::ShapeInfo< S >::precision ShapePrecision
The precision of a shape type: T for a shape whose box type is AABBT<T>.
Definition EBGeometry_Expr.hpp:167
DistanceQuality
How far the value of a signed distance function can be trusted, from strongest to weakest.
Definition EBGeometry_DistanceQuality.hpp:25
Vec2T< T > max(const Vec2T< T > &u, const Vec2T< T > &v) noexcept
Component-wise maximum of two vectors.
The two most extreme values seen so far, for an n-ary smooth union or intersection.
Definition EBGeometry_CSGOps.hpp:496
V m_second
The next.
Definition EBGeometry_CSGOps.hpp:505
Where a ray first crosses a surface, without the normal or the primitive there: what firstCrossing() ...
Definition EBGeometry_Ray.hpp:156
Smooth union or intersection: a smooth minimum (maximum) of the two smallest (largest) values.
Definition EBGeometry_Fused.hpp:570
bool m_exponential
Whether the blend is exponential (BlendKind::Exponential) rather than polynomial.
Definition EBGeometry_Fused.hpp:579
T m_smooth
Smoothing length.
Definition EBGeometry_Fused.hpp:574
Where a ray first crosses a surface.
Definition EBGeometry_Ray.hpp:97
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
A fused smooth union restricted to where it can differ from the plain union of its operands: the valu...
Definition EBGeometry_SmoothRayForms.hpp:131
BoundingVolumes::AABBT< T > m_box
Where two operands' boxes, grown by w, overlap: the blend zone lies within it.
Definition EBGeometry_SmoothRayForms.hpp:150
Node m_node
The smooth union.
Definition EBGeometry_SmoothRayForms.hpp:145
T signedDistance(const Vec3T< T > &a_point) const noexcept
The value.
Definition EBGeometry_SmoothRayForms.hpp:159
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The blend zone's box.
Definition EBGeometry_SmoothRayForms.hpp:170
static constexpr DistanceQuality distanceQuality
The quality of its value: a bound at best.
Definition EBGeometry_SmoothRayForms.hpp:140
The first of a fused node's operands an intersection does not march, which it traces first: 0 if it m...
Definition EBGeometry_CSGRayForms.hpp:225
A shape seen only through its value, with no ray form: what a smooth operation is marched as where it...
Definition EBGeometry_SmoothRayForms.hpp:68
T signedDistance(const Vec3T< T > &a_point) const noexcept
The shape's value.
Definition EBGeometry_SmoothRayForms.hpp:91
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's box.
Definition EBGeometry_SmoothRayForms.hpp:102
static constexpr DistanceQuality distanceQuality
The quality of its value: the shape's.
Definition EBGeometry_SmoothRayForms.hpp:77
S m_shape
The shape.
Definition EBGeometry_SmoothRayForms.hpp:82
ShapePrecision< S > T
Floating-point precision.
Definition EBGeometry_SmoothRayForms.hpp:72
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
A ray: the points origin + t * direction.
Definition EBGeometry_Ray.hpp:55