|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
Error function that penalizes deviation of mesh vertex SDF distance from a target value. More...
#include <vertex_sdf_error_function.h>
Public Member Functions | |
| VertexSDFErrorFunctionT (const Character &character, const SDFColliderT< float > &sdfCollider) | |
| Constructor. | |
| ~VertexSDFErrorFunctionT () override=default | |
| Destructor. | |
| void | addConstraint (const VertexSDFConstraintT< T > &constraint) |
| Add a constraint specifying a target distance for a vertex. | |
| void | clearConstraints () |
| Clear all constraints. | |
| const std::vector< VertexSDFConstraintT< T > > & | getConstraints () const |
| Returns the current constraints. | |
| size_t | getNumConstraints () const |
| Returns the number of constraints. | |
| double | getError (const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState) override |
| Computes the error for the given model parameters and skeleton state. | |
| double | getGradient (const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::VectorX< T > > gradient) override |
| Computes the error and its gradient. | |
| double | getJacobian (const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::MatrixX< T > > jacobian, Eigen::Ref< Eigen::VectorX< T > > residual, int &usedRows) override |
| Computes the Jacobian and residual. | |
| size_t | getJacobianSize () const override |
| Returns the maximum number of Jacobian rows needed. | |
| bool | needsMesh () const override |
| Returns true because this error function requires mesh state. | |
| 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 |
| virtual const Character * | getCharacter () const |
| For mesh-based error functions, get access to the underlying character. | |
| 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 > ¶meters, 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 | kVertexSDFWeight = T(5e-3) |
| Weight constant for vertex SDF penalties. | |
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} |
Error function that penalizes deviation of mesh vertex SDF distance from a target value.
Takes a single SDFCollider (with optional parent joint and offset transform) and allows adding constraints that specify target signed distance values for individual vertices. Error per constraint: weight * kVertexSDFWeight * (distance - targetDistance)^2
Definition at line 33 of file vertex_sdf_error_function.h.
|
explicit |
Constructor.
| character | The character containing skeleton, mesh, and skin weights |
| sdfCollider | The SDF collider to test against (with optional parent joint and offset) |
Definition at line 57 of file vertex_sdf_error_function.cpp.
References MT_CHECK, MT_CHECK_NOTNULL, and momentum::SkeletonErrorFunctionT< T >::SkeletonErrorFunctionT().
|
overridedefault |
Destructor.
| void momentum::VertexSDFErrorFunctionT< T >::addConstraint | ( | const VertexSDFConstraintT< T > & | constraint | ) |
Add a constraint specifying a target distance for a vertex.
Definition at line 70 of file vertex_sdf_error_function.cpp.
References MT_CHECK, and momentum::VertexSDFConstraintT< T >::vertexIndex.
| void momentum::VertexSDFErrorFunctionT< T >::clearConstraints | ( | ) |
Clear all constraints.
Definition at line 81 of file vertex_sdf_error_function.cpp.
|
nodiscard |
Returns the current constraints.
Definition at line 86 of file vertex_sdf_error_function.cpp.
|
nodiscardoverridevirtual |
Computes the error for the given model parameters and skeleton state.
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 240 of file vertex_sdf_error_function.cpp.
References kVertexSDFWeight, MT_CHECK_NOTNULL, MT_PROFILE_FUNCTION, momentum::MeshStateT< T >::posedMesh_, and momentum::SkeletonErrorFunctionT< T >::weight_.
|
overridevirtual |
Computes the error and its gradient.
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 269 of file vertex_sdf_error_function.cpp.
References momentum::SkinningWeightIteratorT< T >::finished(), momentum::SkeletonStateT< T >::jointState, momentum::kInvalidIndex, momentum::kParametersPerJoint, kVertexSDFWeight, MT_CHECK, MT_CHECK_NOTNULL, MT_PROFILE_FUNCTION, momentum::SkinningWeightIteratorT< T >::next(), momentum::MeshStateT< T >::posedMesh_, momentum::MeshStateT< T >::restMesh_, momentum::SkeletonErrorFunctionT< T >::skeleton_, and momentum::SkeletonErrorFunctionT< T >::weight_.
|
overridevirtual |
Computes the Jacobian and residual.
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 343 of file vertex_sdf_error_function.cpp.
References momentum::SkinningWeightIteratorT< T >::finished(), momentum::SkeletonStateT< T >::jointState, momentum::kInvalidIndex, momentum::kParametersPerJoint, kVertexSDFWeight, MT_CHECK, MT_CHECK_NOTNULL, MT_PROFILE_FUNCTION, momentum::SkinningWeightIteratorT< T >::next(), momentum::MeshStateT< T >::posedMesh_, momentum::MeshStateT< T >::restMesh_, momentum::SkeletonErrorFunctionT< T >::skeleton_, and momentum::SkeletonErrorFunctionT< T >::weight_.
|
nodiscardoverridevirtual |
Returns the maximum number of Jacobian rows needed.
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 448 of file vertex_sdf_error_function.cpp.
|
nodiscard |
Returns the number of constraints.
Definition at line 91 of file vertex_sdf_error_function.cpp.
|
inlinenodiscardoverridevirtual |
Returns true because this error function requires mesh state.
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 87 of file vertex_sdf_error_function.h.
|
staticconstexpr |
Weight constant for vertex SDF penalties.
Definition at line 36 of file vertex_sdf_error_function.h.
Referenced by getError(), getGradient(), and getJacobian().