17#include <axel/BoundingBox.h>
18#include <axel/SignedDistanceField.h>
30 using SDFType = axel::SignedDistanceField<S>;
42 std::shared_ptr<const SDFType>
sdf;
49 std::shared_ptr<const SDFType> sdfPtr)
77 return sdf !=
nullptr;
89 [[nodiscard]] T
evaluate(
const Eigen::Vector3<T>& localPos)
const {
90 return static_cast<T
>(
sdf->sample(localPos));
96 const Eigen::Vector3<T>& localPos)
const {
97 const auto [d, g] =
sdf->sampleWithGradient(localPos);
98 return {
static_cast<T
>(d), g.template
cast<T>()};
102 [[nodiscard]] axel::BoundingBox<S>
bounds()
const {
103 return sdf->bounds();
117 template <
typename T>
#define MOMENTUM_DEFINE_POINTERS(x)
Define the standard set of smart-pointer type aliases for type x.
constexpr T Eps(T FloatEps=T(1e-7), T DoubleEps=T(1e-16))
Returns a type-appropriate tolerance/epsilon value.
SDFCollisionGeometryT< double > SDFCollisionGeometryd
constexpr size_t kInvalidIndex
Sentinel value indicating an invalid or unset size_t index.
SDFCollisionGeometryT< float > SDFCollisionGeometry
decltype(auto) cast(const ContainerType< ObjectType > &originalContainer)
Casts the scalar type of objects in a container that support the cast<>() method.
std::vector< SDFColliderT< S > > SDFCollisionGeometryT
Collection of SDF colliders representing a character's collision geometry.
TransformT< float > transformation
bool isApprox(const SDFColliderT &other, const S &tol=Eps< S >(1e-4f, 1e-10)) const
Checks if the current SDF collider is approximately equal to another.
size_t parentJoint() const
std::pair< T, Eigen::Vector3< T > > evaluateWithGradient(const Eigen::Vector3< T > &localPos) const
Evaluate the SDF distance and gradient at a local-frame position.
axel::SignedDistanceField< float > SDFType
axel::BoundingBox< S > bounds() const
Bounding box of the SDF in local frame.
TransformT< S > localToParentTransform() const
Transform from SDF local frame to parent joint frame.
void update(const Eigen::VectorX< T > &)
Per-iteration update (no-op for voxel SDFs).
bool isValid() const
Returns true when the collider holds a non-null SDF and is therefore usable for collision queries.
std::shared_ptr< const SDFType > sdf
SDFColliderT(const TransformT< S > &transform, size_t parentJoint, std::shared_ptr< const SDFType > sdfPtr)
T evaluate(const Eigen::Vector3< T > &localPos) const
Evaluate the SDF distance at a local-frame position.