PhysicsBasedAnimationToolkit 0.0.10
Cross-platform C++20 library of algorithms and data structures commonly used in computer graphics research on physically-based simulation.
Loading...
Searching...
No Matches
pbat::geometry::sdf::Composite< TScalar > Struct Template Reference

Composite signed distance function represented as a forest of SDFs. More...

#include <Composite.h>

Public Types

using ScalarType = TScalar
 Scalar type.
 

Public Member Functions

PBAT_HOST_DEVICE Composite (std::span< Node< ScalarType > const > nodes, std::span< Transform< ScalarType > const > transforms, std::span< std::pair< int, int > const > children, std::span< int const > roots)
 Construct a composite SDF from nodes, transforms, children, ancestors and roots.
 
PBAT_HOST_DEVICE ScalarType Eval (Vec3< ScalarType > const &p) const
 Evaluate the signed distance function at a given point.
 
PBAT_HOST_DEVICE ScalarType Eval (int n, Vec3< ScalarType > const &p) const
 Evaluate the signed distance function rooted in node n at a given point p.
 
PBAT_HOST_DEVICE Vec3< ScalarTypeGrad (Vec3< ScalarType > const &p, ScalarType h) const
 Evaluate the (numerical) gradient of the signed distance function at a given point using a central difference scheme.
 
PBAT_HOST_DEVICE ECompositeStatus Status () const
 Get the status of the composite SDF.
 

Public Attributes

std::span< Node< ScalarType > const > mNodes
 |# nodes| nodes in the composite SDF
 
std::span< Transform< ScalarType > const > mTransforms
 |# nodes| transforms associated to each node
 
std::span< std::pair< int, int > const > mChildren
 
std::span< int const > mRoots
 |# roots| root indices of the composite SDF
 
ECompositeStatus mStatus
 Status of the composite SDF.
 

Detailed Description

template<common::CArithmetic TScalar>
struct pbat::geometry::sdf::Composite< TScalar >

Composite signed distance function represented as a forest of SDFs.

Constructor & Destructor Documentation

◆ Composite()

template<common::CArithmetic TScalar>
pbat::geometry::sdf::Composite< TScalar >::Composite ( std::span< Node< ScalarType > const > nodes,
std::span< Transform< ScalarType > const > transforms,
std::span< std::pair< int, int > const > children,
std::span< int const > roots )
inline

Construct a composite SDF from nodes, transforms, children, ancestors and roots.

Parameters
nodesSpan of nodes in the composite SDF
transformsSpan of transforms associated to each node
childrenSpan of pairs of children indices for each node, such that c* < 0 if no child
rootsSpan of root indices of the composite SDF

Member Function Documentation

◆ Eval() [1/2]

template<common::CArithmetic TScalar>
TScalar pbat::geometry::sdf::Composite< TScalar >::Eval ( int n,
Vec3< ScalarType > const & p ) const
inline

Evaluate the signed distance function rooted in node n at a given point p.

Parameters
nIndex of the root node
pPoint at which to evaluate the SDF
Returns
Signed distance to the composite shape rooted in node n

◆ Eval() [2/2]

template<common::CArithmetic TScalar>
TScalar pbat::geometry::sdf::Composite< TScalar >::Eval ( Vec3< ScalarType > const & p) const
inline

Evaluate the signed distance function at a given point.

Parameters
pPoint at which to evaluate the SDF
Returns
Signed distance to the composite shape

◆ Grad()

template<common::CArithmetic TScalar>
Vec3< TScalar > pbat::geometry::sdf::Composite< TScalar >::Grad ( Vec3< ScalarType > const & p,
ScalarType h ) const
inline

Evaluate the (numerical) gradient of the signed distance function at a given point using a central difference scheme.

We use the tetrahedron technique described in https://iquilezles.org/articles/normalsSDF/

Parameters
pPoint at which to evaluate the gradient
hFinite difference step size
Returns
Numerical gradient of the signed distance function at point p

◆ Status()

template<common::CArithmetic TScalar>
PBAT_HOST_DEVICE ECompositeStatus pbat::geometry::sdf::Composite< TScalar >::Status ( ) const
inline

Get the status of the composite SDF.

Returns
Status of the composite SDF

Member Data Documentation

◆ mChildren

template<common::CArithmetic TScalar>
std::span<std::pair<int, int> const> pbat::geometry::sdf::Composite< TScalar >::mChildren

|# nodes| children pairs (ci, cj) of each node, such that c* < 0 if no child. A binary node n has 2 children stored in (ci, cj), a unary node n has 1 child stored in ci, and a primitive has no children.


The documentation for this struct was generated from the following file: