|
EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
|
The arithmetic of each CSG operation, shared by the Tape and the fused operations. More...
Classes | |
| struct | AffineCoefficients |
| An affine map's 12 coefficients: the three rows of its matrix, then its shift. More... | |
| struct | BlurWeights |
| A blur's distance and weights. More... | |
| struct | MollifyGrid |
| A mollification's tap grid: n taps per axis over [-r, r]^3, and the sum of their weights. More... | |
| struct | Pair |
| The two most extreme values seen so far, for an n-ary smooth union or intersection. More... | |
| struct | Repetition |
| A finite repetition: copies of an object on a grid of tiles. More... | |
| struct | RepetitionView |
| A finite repetition read from an array of 15 parameters (period, low and high counts, the object's box corners), as the Tape stores it. More... | |
| struct | Tagged |
| A value with the deciding leaf it comes from: the leaf whose surface the composed value is taken from there, and the point that leaf was evaluated at (in its own frame). More... | |
Functions | |
| template<class T , std::enable_if_t< std::is_floating_point_v< T >, int > = 0> | |
| EBGEOMETRY_HOST_ALWAYS_INLINE T | valueOf (const T a_value) noexcept |
| A plain value's value: itself. | |
| template<class T > | |
| EBGEOMETRY_HOST_ALWAYS_INLINE T | valueOf (const Tagged< T > &a_value) noexcept |
| A tagged value's value. | |
| template<class T , std::enable_if_t< std::is_floating_point_v< T >, int > = 0> | |
| EBGEOMETRY_HOST_ALWAYS_INLINE T | withValue (const T, const T a_value) noexcept |
| A plain value replaced by another: the other. | |
| template<class T > | |
| EBGEOMETRY_HOST_ALWAYS_INLINE Tagged< T > | withValue (const Tagged< T > &a_like, const T a_value) noexcept |
| A tagged value with its value replaced and its tag kept. | |
| template<class V , class T > | |
| EBGEOMETRY_HOST_ALWAYS_INLINE V | leafValue (const T a_value, const uint32_t a_tag, const Vec3T< T > &a_point) noexcept |
| A leaf's value: the value itself, or the value tagged with the leaf and the point. | |
| template<class V > | |
| EBGEOMETRY_HOST_ALWAYS_INLINE V | negated (const V &a_value) noexcept |
| A value negated, its tag kept. | |
| template<class V > | |
| EBGEOMETRY_HOST_ALWAYS_INLINE V | magnitude (const V &a_value) noexcept |
| A value's magnitude, its tag kept. | |
| template<class V , class T > | |
| EBGEOMETRY_HOST_ALWAYS_INLINE V | plus (const V &a_value, const T a_constant) noexcept |
| A value plus a constant, its tag kept. | |
| template<class V , class T > | |
| EBGEOMETRY_HOST_ALWAYS_INLINE V | times (const V &a_value, const T a_constant) noexcept |
| A value times a constant, its tag kept. | |
| template<class T > | |
| EBGEOMETRY_HOST_ALWAYS_INLINE Tagged< T > | select (const bool a_second, const Tagged< T > &a_first, const Tagged< T > &a_other) noexcept |
| One of two tagged values, chosen field by field, so that the compiler selects without a branch: a whole-struct select compiled to a branch, which mispredicts at points where either operand may decide. | |
| template<class V > | |
| EBGEOMETRY_HOST_ALWAYS_INLINE V | noLeaf () noexcept |
| A value that comes from no leaf: zero, tagged with NoTag. | |
| template<class T , std::enable_if_t< std::is_floating_point_v< T >, int > = 0> | |
| EBGEOMETRY_HOST_ALWAYS_INLINE T | smaller (const T a_first, const T a_second) noexcept |
| The smaller of two plain values (Math::min()). | |
| template<class T > | |
| EBGEOMETRY_HOST_ALWAYS_INLINE Tagged< T > | smaller (const Tagged< T > &a_first, const Tagged< T > &a_second) noexcept |
| The tagged value with the smaller value, as Math::min() picks it. | |
| template<class T , std::enable_if_t< std::is_floating_point_v< T >, int > = 0> | |
| EBGEOMETRY_HOST_ALWAYS_INLINE T | larger (const T a_first, const T a_second) noexcept |
| The larger of two plain values (Math::max()). | |
| template<class T > | |
| EBGEOMETRY_HOST_ALWAYS_INLINE Tagged< T > | larger (const Tagged< T > &a_first, const Tagged< T > &a_second) noexcept |
| The tagged value with the larger value, as Math::max() picks it. | |
| template<class T > | |
| AffineCoefficients< T > | affineCoefficients (const Affine3T< T > &a_map) noexcept |
| An affine map's coefficients, laid out as affinePoint() reads them. | |
| template<class T > | |
| Vec3T< T > | affinePoint (const T *a_coefficients, const Vec3T< T > &a_point) noexcept |
| The point an affine map sends a query point to: the point the mapped object's operand sees. | |
| template<class T > | |
| Vec3T< T > | affinePoint (const Affine3T< T > &a_map, const Vec3T< T > &a_point) noexcept |
| The point an affine map sends a query point to, from the map itself. | |
| template<class T > | |
| Vec3T< T > | elongatePoint (const Vec3T< T > &a_halfLengths, const Vec3T< T > &a_point) noexcept |
| The point an elongation evaluates its operand at: p - clamp(p, -h, h). | |
| template<class T > | |
| T | offset (const T a_value, const T a_offset) noexcept |
| An offset's value: v - r, computed as v + (-r). | |
| template<class T > | |
| T | annular (const T a_value, const T a_delta) noexcept |
| An annulus's value: |v| - delta, computed as |v| + (-delta). | |
| template<class V > | |
| Pair< V > | pairInit (const bool a_largest) noexcept |
| The empty pair: both values +inf (for the smallest) or -inf (for the largest). | |
| template<class T , std::enable_if_t< std::is_floating_point_v< T >, int > = 0> | |
| void | pairInsert (Pair< T > &a_pair, const T a_value, const bool a_largest) noexcept |
| Insert a value into a pair of extreme values. | |
| template<class T > | |
| void | pairInsert (Pair< Tagged< T > > &a_pair, const Tagged< T > &a_value, const bool a_largest) noexcept |
| Insert a tagged value into a pair of extreme values. | |
| template<class T , std::enable_if_t< std::is_floating_point_v< T >, int > = 0> | |
| 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. | |
| template<class T > | |
| Tagged< T > | pairBlend (const Pair< Tagged< 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 tagged values, tagged as the more extreme one. | |
| template<class T > | |
| BlurWeights< T > | blurWeights (const T a_distance, const T a_alpha) |
| A blur's distance and weights: the weight of a tap m steps from the center is alpha^(3-m) beta^m with beta = (1 - alpha)/2, and the 27 weights sum to (alpha + 2 beta)^3 = 1. | |
| template<class T , class F > | |
| auto | blur (const T *a_weights, const Vec3T< T > &a_point, const F &a_operand) noexcept |
| A blur's value: the weighted sum of its operand's values at the 27 points p + d (i, j, k), i, j, k in {-1, 0, 1}. | |
| template<class T > | |
| Vec3T< T > | mollifyOffset (const T a_radius, const T a_spacing, const uint32_t a_i, const uint32_t a_j, const uint32_t a_k) noexcept |
| The offset of mollification tap (i, j, k): -r + (i, j, k) dX, dX = 2r / (n - 1). | |
| template<class T > | |
| T | mollifyWeight (const Vec3T< T > &a_offset, const T a_radius) noexcept |
| The unnormalized weight of a mollification tap: the bump kernel max(0, 1 - |o|^2 / (2r)^2)^2. | |
| template<class T > | |
| MollifyGrid< T > | mollifyGrid (const T a_radius, const uint32_t a_samples) |
| Set up a mollification's tap grid. | |
| template<class T , class F > | |
| auto | mollify (const MollifyGrid< T > &a_grid, const Vec3T< T > &a_point, const F &a_operand) noexcept |
| A mollification's value: sum_k w_k f(p - o_k) over the grid's taps, each weight divided by the sum of all of them. | |
| template<class T , class R , class F > | |
| auto | repetition (const R &a_repetition, const Vec3T< T > &a_point, const F &a_object) noexcept |
| A finite repetition's value: the minimum of the object's value over all its copies. | |
Variables | |
| constexpr uint32_t | NoTag = 0xFFFFFFFFU |
| The tag of a value that comes from no leaf. | |
| template<class V > | |
| constexpr bool | isTagged = false |
| Whether V is a tagged value. | |
| template<class T > | |
| constexpr bool | isTagged< Tagged< T > > = true |
| A Tagged<T> is a tagged value. | |
The arithmetic of each CSG operation, shared by the Tape and the fused operations.
Internal helpers; not part of the public API.
|
inlinenoexcept |
An affine map's coefficients, laid out as affinePoint() reads them.
| T | Floating-point precision. |
| [in] | a_map | Map. |
|
inlinenoexcept |
The point an affine map sends a query point to, from the map itself.
| T | Floating-point precision. |
| [in] | a_map | Map. |
| [in] | a_point | Query point. |
|
inlinenoexcept |
The point an affine map sends a query point to: the point the mapped object's operand sees.
| T | Floating-point precision. |
| [in] | a_coefficients | The map's 12 coefficients, as affineCoefficients() lays them out. |
| [in] | a_point | Query point. |
|
inlinenoexcept |
An annulus's value: |v| - delta, computed as |v| + (-delta).
| T | Floating-point precision. |
| [in] | a_value | Operand's value v. |
| [in] | a_delta | Half-thickness delta. |
|
inlinenoexcept |
A blur's value: the weighted sum of its operand's values at the 27 points p + d (i, j, k), i, j, k in {-1, 0, 1}.
| T | Floating-point precision. |
| F | Callable from a point to the operand's value. |
| [in] | a_weights | The distance d and weights, as blurWeights() lays them out. |
| [in] | a_point | Query point p. |
| [in] | a_operand | The operand. |
|
inline |
A blur's distance and weights: the weight of a tap m steps from the center is alpha^(3-m) beta^m with beta = (1 - alpha)/2, and the 27 weights sum to (alpha + 2 beta)^3 = 1.
| T | Floating-point precision. |
| [in] | a_distance | Blur distance d. |
| [in] | a_alpha | Center weight factor alpha. |
|
inlinenoexcept |
The point an elongation evaluates its operand at: p - clamp(p, -h, h).
| T | Floating-point precision. |
| [in] | a_halfLengths | Half-lengths h of the inserted box. |
| [in] | a_point | Query point. |
|
inlinenoexcept |
The larger of two plain values (Math::max()).
| T | Floating-point precision. |
| [in] | a_first | First value. |
| [in] | a_second | Second value. |
|
inlinenoexcept |
The tagged value with the larger value, as Math::max() picks it.
| T | Floating-point precision. |
| [in] | a_first | First value. |
| [in] | a_second | Second value. |
|
inlinenoexcept |
A leaf's value: the value itself, or the value tagged with the leaf and the point.
| V | Value type (T or Tagged<T>). |
| T | Floating-point precision. |
| [in] | a_value | The leaf's value. |
| [in] | a_tag | The leaf, as the structure numbers it. |
| [in] | a_point | The point the leaf was evaluated at. |
|
inlinenoexcept |
A value's magnitude, its tag kept.
| V | Value type (T or Tagged<T>). |
| [in] | a_value | Value. |
|
inlinenoexcept |
A mollification's value: sum_k w_k f(p - o_k) over the grid's taps, each weight divided by the sum of all of them.
| T | Floating-point precision. |
| F | Callable from a point to the operand's value. |
| [in] | a_grid | Tap grid. |
| [in] | a_point | Query point p. |
| [in] | a_operand | The operand. |
|
inline |
Set up a mollification's tap grid.
| T | Floating-point precision. |
| [in] | a_radius | Mollification distance r (> 0). |
| [in] | a_samples | Taps per axis n (>= 2). |
|
inlinenoexcept |
The offset of mollification tap (i, j, k): -r + (i, j, k) dX, dX = 2r / (n - 1).
| T | Floating-point precision. |
| [in] | a_radius | Mollification distance r. |
| [in] | a_spacing | Tap spacing dX. |
| [in] | a_i | Tap index along x. |
| [in] | a_j | Tap index along y. |
| [in] | a_k | Tap index along z. |
|
inlinenoexcept |
The unnormalized weight of a mollification tap: the bump kernel max(0, 1 - |o|^2 / (2r)^2)^2.
The kernel's support has radius 2r, so every tap in [-r, r]^3, the corners included, gets a positive weight.
| T | Floating-point precision. |
| [in] | a_offset | Tap offset o. |
| [in] | a_radius | Mollification distance r. |
|
inlinenoexcept |
A value negated, its tag kept.
| V | Value type (T or Tagged<T>). |
| [in] | a_value | Value. |
|
inlinenoexcept |
A value that comes from no leaf: zero, tagged with NoTag.
| V | Value type (T or Tagged<T>). |
|
inlinenoexcept |
An offset's value: v - r, computed as v + (-r).
| T | Floating-point precision. |
| [in] | a_value | Operand's value v. |
| [in] | a_offset | Offset r. |
|
inlinenoexcept |
The smooth minimum (or maximum) of a pair's two values.
The plain value has an overload of its own, for the reason given in pairInsert().
| T | Floating-point precision. |
| [in] | a_pair | Pair. |
| [in] | a_smooth | Smoothing length. |
| [in] | a_largest | Whether this is a smooth maximum. |
| [in] | a_exponential | Whether to blend exponentially (ExpMinOp/ExpMaxOp) rather than polynomially (SmoothMinOp/SmoothMaxOp). |
|
inlinenoexcept |
The smooth minimum (or maximum) of a pair's two tagged values, tagged as the more extreme one.
| T | Floating-point precision. |
| [in] | a_pair | Pair. |
| [in] | a_smooth | Smoothing length. |
| [in] | a_largest | Whether this is a smooth maximum. |
| [in] | a_exponential | Whether to blend exponentially (ExpMinOp/ExpMaxOp) rather than polynomially (SmoothMinOp/SmoothMaxOp). |
|
inlinenoexcept |
The empty pair: both values +inf (for the smallest) or -inf (for the largest).
| V | Value type (T or Tagged<T>). |
| [in] | a_largest | Whether the pair tracks the largest values. |
|
inlinenoexcept |
Insert a value into a pair of extreme values.
The plain value has an overload of its own, written as it was before values could be tagged: GCC weighs a callee's body when it decides what to inline into the tape's evaluator, and a generic body changed what it inlined there (see the Blur kernel in blur()).
| T | Floating-point precision. |
| [in,out] | a_pair | Pair. |
| [in] | a_value | Value. |
| [in] | a_largest | Whether the pair tracks the largest values. |
|
inlinenoexcept |
A value plus a constant, its tag kept.
| V | Value type (T or Tagged<T>). |
| T | Floating-point precision. |
| [in] | a_value | Value. |
| [in] | a_constant | Constant. |
|
inlinenoexcept |
A finite repetition's value: the minimum of the object's value over all its copies.
The copy in the tile the point folds into is evaluated first. Its value bounds the search for the others: a copy whose box is farther from the point than max(0, best value so far) cannot be closer, so only the tiles whose copy's box comes that near are evaluated. This is the plain minimum over all copies for an object whose value is at least the distance to its box outside it (a distance or a bound), and keeps the sign for any object, since a copy whose box holds the point is always evaluated. An object that fits well inside its tile has few such neighbors.
| T | Floating-point precision. |
| R | The repetition's storage: Repetition<T>, or RepetitionView<T> of a parameter array. |
| F | Callable from a point to the object's value. |
| [in] | a_repetition | Repetition. |
| [in] | a_point | Query point. |
| [in] | a_object | The object. |
|
inlinenoexcept |
One of two tagged values, chosen field by field, so that the compiler selects without a branch: a whole-struct select compiled to a branch, which mispredicts at points where either operand may decide.
| T | Floating-point precision. |
| [in] | a_second | Whether to take the second. |
| [in] | a_first | First value. |
| [in] | a_other | Second value. |
|
inlinenoexcept |
The smaller of two plain values (Math::min()).
| T | Floating-point precision. |
| [in] | a_first | First value. |
| [in] | a_second | Second value. |
|
inlinenoexcept |
The tagged value with the smaller value, as Math::min() picks it.
| T | Floating-point precision. |
| [in] | a_first | First value. |
| [in] | a_second | Second value. |
|
inlinenoexcept |
A value times a constant, its tag kept.
| V | Value type (T or Tagged<T>). |
| T | Floating-point precision. |
| [in] | a_value | Value. |
| [in] | a_constant | Constant. |
|
inlinenoexcept |
A plain value's value: itself.
| T | Floating-point precision. |
| [in] | a_value | Value. |
|
inlinenoexcept |
A tagged value's value.
| T | Floating-point precision. |
| [in] | a_value | Tagged value. |
|
inlinenoexcept |
A plain value replaced by another: the other.
| T | Floating-point precision. |
| [in] | a_value | The new value. |
|
inlinenoexcept |
A tagged value with its value replaced and its tag kept.
| T | Floating-point precision. |
| [in] | a_like | The value whose tag is kept. |
| [in] | a_value | The new value. |
|
inlineconstexpr |
Whether V is a tagged value.
| V | Value type. |
|
inlineconstexpr |
A Tagged<T> is a tagged value.
| T | Floating-point precision. |