|
EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
|
The arithmetic of each CSG operation, shared by the Tape's evaluator and the fused operations. More...
#include <cmath>#include <cstdint>#include <type_traits>#include "EBGeometry_Affine.hpp"#include "EBGeometry_Blend.hpp"#include "EBGeometry_BoundingVolumes.hpp"#include "EBGeometry_GPU.hpp"#include "EBGeometry_Macros.hpp"#include "EBGeometry_Math.hpp"#include "EBGeometry_Vec.hpp"

Go to the source code of this file.
Classes | |
| struct | EBGeometry::CSGOps::Tagged< T > |
| 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... | |
| struct | EBGeometry::CSGOps::AffineCoefficients< T > |
| An affine map's 12 coefficients: the three rows of its matrix, then its shift. More... | |
| struct | EBGeometry::CSGOps::Pair< V > |
| The two most extreme values seen so far, for an n-ary smooth union or intersection. More... | |
| struct | EBGeometry::CSGOps::BlurWeights< T > |
| A blur's distance and weights. More... | |
| struct | EBGeometry::CSGOps::MollifyGrid< T > |
| A mollification's tap grid: n taps per axis over [-r, r]^3, and the sum of their weights. More... | |
| struct | EBGeometry::CSGOps::Repetition< T > |
| A finite repetition: copies of an object on a grid of tiles. More... | |
| struct | EBGeometry::CSGOps::RepetitionView< T > |
| 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... | |
Namespaces | |
| namespace | EBGeometry |
| Namespace containing all of EBGeometry's functionality. | |
| namespace | EBGeometry::CSGOps |
| The arithmetic of each CSG operation, shared by the Tape and the fused operations. | |
Functions | |
| template<class T , std::enable_if_t< std::is_floating_point_v< T >, int > = 0> | |
| EBGEOMETRY_HOST_ALWAYS_INLINE T | EBGeometry::CSGOps::valueOf (const T a_value) noexcept |
| A plain value's value: itself. | |
| template<class T > | |
| EBGEOMETRY_HOST_ALWAYS_INLINE T | EBGeometry::CSGOps::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 | EBGeometry::CSGOps::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 > | EBGeometry::CSGOps::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 | EBGeometry::CSGOps::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 | EBGeometry::CSGOps::negated (const V &a_value) noexcept |
| A value negated, its tag kept. | |
| template<class V > | |
| EBGEOMETRY_HOST_ALWAYS_INLINE V | EBGeometry::CSGOps::magnitude (const V &a_value) noexcept |
| A value's magnitude, its tag kept. | |
| template<class V , class T > | |
| EBGEOMETRY_HOST_ALWAYS_INLINE V | EBGeometry::CSGOps::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 | EBGeometry::CSGOps::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 > | EBGeometry::CSGOps::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 | EBGeometry::CSGOps::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 | EBGeometry::CSGOps::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 > | EBGeometry::CSGOps::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 | EBGeometry::CSGOps::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 > | EBGeometry::CSGOps::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 > | EBGeometry::CSGOps::affineCoefficients (const Affine3T< T > &a_map) noexcept |
| An affine map's coefficients, laid out as affinePoint() reads them. | |
| template<class T > | |
| Vec3T< T > | EBGeometry::CSGOps::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 > | EBGeometry::CSGOps::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 > | EBGeometry::CSGOps::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 | EBGeometry::CSGOps::offset (const T a_value, const T a_offset) noexcept |
| An offset's value: v - r, computed as v + (-r). | |
| template<class T > | |
| T | EBGeometry::CSGOps::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 > | EBGeometry::CSGOps::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 | EBGeometry::CSGOps::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 | EBGeometry::CSGOps::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 | EBGeometry::CSGOps::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 > | EBGeometry::CSGOps::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 > | EBGeometry::CSGOps::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 | EBGeometry::CSGOps::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 > | EBGeometry::CSGOps::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 | EBGeometry::CSGOps::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 > | EBGeometry::CSGOps::mollifyGrid (const T a_radius, const uint32_t a_samples) |
| Set up a mollification's tap grid. | |
| template<class T , class F > | |
| auto | EBGeometry::CSGOps::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 | EBGeometry::CSGOps::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 | EBGeometry::CSGOps::NoTag = 0xFFFFFFFFU |
| The tag of a value that comes from no leaf. | |
| template<class V > | |
| constexpr bool | EBGeometry::CSGOps::isTagged = false |
| Whether V is a tagged value. | |
| template<class T > | |
| constexpr bool | EBGeometry::CSGOps::isTagged< Tagged< T > > = true |
| A Tagged<T> is a tagged value. | |
The arithmetic of each CSG operation, shared by the Tape's evaluator and the fused operations.
Internal helpers; not part of the public API. Each function computes one operation's value or point the way both the Tape (EBGeometry_Tape.hpp) and the fused operations (EBGeometry_Fused.hpp) do, in the same order of floating-point operations, so that the two give the same values (to rounding: a compiler may fuse a multiply and an add into one instruction in one and not the other). The functions that evaluate an operand several times (blur, mollification, repetition) take it as a callable from a point to a value. Everything that runs per evaluation is device-callable; the functions that set up an operation's parameters run on the host.