Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
momentum::SDFCollisionErrorFunctionT< T, SdfColliderType > Class Template Reference

SDF-based collision error function that penalizes vertex penetration into SDF colliders. More...

#include <sdf_collision_error_function.h>

Inheritance diagram for momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >:

Public Member Functions

 SDFCollisionErrorFunctionT (const Character &character, const std::vector< SdfColliderType > &sdfColliders, const std::vector< int > &participatingVertices={}, const std::vector< T > &vertexWeights={}, bool filterRestPoseIntersections=true, uint8_t maxCollisionsPerVertex=1)
 Constructor with vertex index list and uniform weights.
 SDFCollisionErrorFunctionT (const SDFCollisionErrorFunctionT &)=default
SDFCollisionErrorFunctionT & operator= (const SDFCollisionErrorFunctionT &)=delete
 SDFCollisionErrorFunctionT (SDFCollisionErrorFunctionT &&) noexcept=default
SDFCollisionErrorFunctionT & operator= (SDFCollisionErrorFunctionT &&) noexcept=delete
 ~SDFCollisionErrorFunctionT () override=default
double getError (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState) override
double getGradient (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::VectorX< T > > gradient) override
double getJacobian (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::MatrixX< T > > jacobian, Eigen::Ref< Eigen::VectorX< T > > residual, int &usedRows) override
size_t getJacobianSize () const override
bool needsMesh () const override
const Character * getCharacter () const override
 Returns the character used to update mesh state for SDF collision evaluation.
size_t getNumActiveVertices () const
size_t getNumCollisionPairs () const
Public Member Functions inherited from momentum::SkeletonErrorFunctionT< T >
 SkeletonErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt)
virtual ~SkeletonErrorFunctionT ()=default
const Skeleton & getSkeleton () const
const ParameterTransform & getParameterTransform () const
void setWeight (T w)
T getWeight () const
void setActiveJoints (const VectorX< bool > &aj)
void setEnabledParameters (const ParameterSet &ps)
virtual void getHessian (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::MatrixX< T > >)
virtual double getSolverDerivatives (const ModelParametersT< T > &parameters, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, const size_t actualParameters, Eigen::MatrixX< T > &hess, Eigen::VectorX< T > &grad)

Static Public Attributes

static constexpr T kSDFCollisionWeight = T(5e-3)

Additional Inherited Members

Protected Attributes inherited from momentum::SkeletonErrorFunctionT< T >
const Skeleton & skeleton_
const ParameterTransform & parameterTransform_
T weight_
VectorX< bool > activeJointParams_
ParameterSet enabledParameters_
bool useHessian_ {false}

Detailed Description

template<typename T, typename SdfColliderType = SDFColliderT<float>>
class momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >

SDF-based collision error function that penalizes vertex penetration into SDF colliders.

This error function tests source vertices against SDF collision objects and applies penalties for interpenetration. It uses an efficient contiguous memory layout where vertices are grouped by their primary bone index to improve cache locality and reduce memory usage.

The SdfColliderType must provide the following duck-typed interface:

  • T evaluate(const Vector3<T>& localPos) const — signed distance
  • pair<T, Vector3<T>> evaluateWithGradient(const Vector3<T>& localPos) const
  • BoundingBox<S> bounds() const — local-frame AABB
  • size_t parentJoint() const — parent joint index
  • TransformT<S> localToParentTransform() const — local-to-parent transform
  • void update(const VectorX<T>& modelParams) — per-iteration update
  • bool isValid() const — whether the collider is usable

Definition at line 76 of file sdf_collision_error_function.h.

Constructor & Destructor Documentation

◆ SDFCollisionErrorFunctionT() [1/3]

template<typename T, typename SdfColliderType>
momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >::SDFCollisionErrorFunctionT ( const Character & character,
const std::vector< SdfColliderType > & sdfColliders,
const std::vector< int > & participatingVertices = {},
const std::vector< T > & vertexWeights = {},
bool filterRestPoseIntersections = true,
uint8_t maxCollisionsPerVertex = 1 )
explicit

Constructor with vertex index list and uniform weights.

Parameters
characterThe character containing skeleton, mesh, and skin weights
sdfCollidersThe SDF collision geometry to test against
participatingVerticesVertex indices to include (empty means all vertices)
vertexWeightsPer-vertex collision weights (empty means uniform weight of 1.0)

Definition at line 228 of file sdf_collision_error_function.h.

References MT_CHECK, MT_CHECK_NOTNULL, and momentum::SkeletonErrorFunctionT< T >::SkeletonErrorFunctionT().

◆ SDFCollisionErrorFunctionT() [2/3]

template<typename T, typename SdfColliderType = SDFColliderT<float>>
momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >::SDFCollisionErrorFunctionT ( const SDFCollisionErrorFunctionT< T, SdfColliderType > & )
default

◆ SDFCollisionErrorFunctionT() [3/3]

template<typename T, typename SdfColliderType = SDFColliderT<float>>
momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >::SDFCollisionErrorFunctionT ( SDFCollisionErrorFunctionT< T, SdfColliderType > && )
defaultnoexcept

◆ ~SDFCollisionErrorFunctionT()

template<typename T, typename SdfColliderType = SDFColliderT<float>>
momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >::~SDFCollisionErrorFunctionT ( )
overridedefault

Member Function Documentation

◆ getCharacter()

template<typename T, typename SdfColliderType = SDFColliderT<float>>
const Character * momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >::getCharacter ( ) const
inlinenodiscardoverridevirtual

Returns the character used to update mesh state for SDF collision evaluation.

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 124 of file sdf_collision_error_function.h.

◆ getError()

template<typename T, typename SdfColliderType>
double momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >::getError ( const ModelParametersT< T > & params,
const SkeletonStateT< T > & state,
const MeshStateT< T > & meshState )
nodiscardoverridevirtual

◆ getGradient()

◆ getJacobian()

◆ getJacobianSize()

template<typename T, typename SdfColliderType>
size_t momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >::getJacobianSize ( ) const
nodiscardoverridevirtual

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 737 of file sdf_collision_error_function.h.

◆ getNumActiveVertices()

template<typename T, typename SdfColliderType = SDFColliderT<float>>
size_t momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >::getNumActiveVertices ( ) const
inlinenodiscard

Definition at line 128 of file sdf_collision_error_function.h.

◆ getNumCollisionPairs()

template<typename T, typename SdfColliderType = SDFColliderT<float>>
size_t momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >::getNumCollisionPairs ( ) const
inlinenodiscard

Definition at line 132 of file sdf_collision_error_function.h.

◆ needsMesh()

template<typename T, typename SdfColliderType = SDFColliderT<float>>
bool momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >::needsMesh ( ) const
inlinenodiscardoverridevirtual

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 119 of file sdf_collision_error_function.h.

◆ operator=() [1/2]

template<typename T, typename SdfColliderType = SDFColliderT<float>>
SDFCollisionErrorFunctionT & momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >::operator= ( const SDFCollisionErrorFunctionT< T, SdfColliderType > & )
delete

◆ operator=() [2/2]

template<typename T, typename SdfColliderType = SDFColliderT<float>>
SDFCollisionErrorFunctionT & momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >::operator= ( SDFCollisionErrorFunctionT< T, SdfColliderType > && )
deletenoexcept

Member Data Documentation

◆ kSDFCollisionWeight

template<typename T, typename SdfColliderType = SDFColliderT<float>>
T momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >::kSDFCollisionWeight = T(5e-3)
staticconstexpr

Definition at line 136 of file sdf_collision_error_function.h.

Referenced by getError(), getGradient(), and getJacobian().


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