|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
NOTE: This is a resurrected version of the CollisionErrorFunction (previously updated by D50818775). More...
#include <collision_error_function_stateless.h>
Classes | |
| struct | CollisionPairInfo |
| Pre-computed valid collision pair with common ancestor. More... | |
Public Member Functions | |
| CollisionErrorFunctionStatelessT (const Skeleton &skel, const ParameterTransform &pt, const CollisionGeometry &cg) | |
| CollisionErrorFunctionStatelessT (const Character &character) | |
| double | getError (const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState) final |
| double | getGradient (const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Ref< VectorX< T > > gradient) override |
| double | getJacobian (const ModelParametersT< T > &, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Ref< MatrixX< T > > jacobian, Ref< VectorX< T > > residual, int &usedRows) override |
| size_t | getJacobianSize () const final |
| std::vector< Vector2i > | getCollisionPairs () 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 |
| 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 double | getGradient (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::VectorX< T > >) |
| virtual double | getJacobian (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::MatrixX< T > >, Eigen::Ref< Eigen::VectorX< T > >, int &usedRows) |
| 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) |
| virtual bool | needsMesh () const |
Protected Member Functions | |
| void | updateCollisionPairs () |
| void | computeBroadPhase (const SkeletonStateT< T > &state) |
| Update collisionState and aabbs_ given the new skeleton state. | |
| bool | checkCollision (const CollisionGeometryStateT< T > &colState, size_t indexA, size_t indexB, CollisionOverlapResultT< T > &result) const |
| AABB broadphase pre-check followed by narrow-phase collision overlap test. | |
| void | accumulateGradientAlongChain (const SkeletonStateT< T > &state, const Vector3< T > &position, const Vector3< T > &direction, T weight, size_t startJoint, size_t stopJoint, Ref< VectorX< T > > gradient, T scaleCorrection=T(0)) const |
| Accumulate gradient contributions along a joint chain. | |
| void | accumulateJacobianAlongChain (const SkeletonStateT< T > &state, const Vector3< T > &position, const Vector3< T > &direction, T factor, size_t startJoint, size_t stopJoint, Ref< MatrixX< T > > jacobian, int row, T scaleCorrection=T(0)) const |
| Accumulate Jacobian contributions along a joint chain. | |
Protected Attributes | |
| const CollisionGeometry | collisionGeometry |
| std::vector< CollisionPairInfo > | validPairs_ |
| Pre-filtered list of valid collision pairs. | |
| std::vector< axel::BoundingBox< T > > | aabbs_ |
| Per-capsule AABBs, updated each frame for broadphase culling. | |
| CollisionGeometryStateT< T > | collisionState |
| Protected Attributes inherited from momentum::SkeletonErrorFunctionT< T > | |
| const Skeleton & | skeleton_ |
| const ParameterTransform & | parameterTransform_ |
| T | weight_ |
| VectorX< bool > | activeJointParams_ |
| ParameterSet | enabledParameters_ |
| bool | useHessian_ {false} |
Static Protected Attributes | |
| static constexpr T | kCollisionWeight = 5e-3 |
NOTE: This is a resurrected version of the CollisionErrorFunction (previously updated by D50818775).
Its stateless nature makes it ideal for testing in multi-threaded settings.
Represents an error function that penalizes self-intersections between collision geometries of the character.
The function pre-filters collision geometries to ignore those attached to the same joint, those intersecting in the rest pose, or those very close in the rest pose.
Definition at line 30 of file collision_error_function_stateless.h.
|
explicit |
Definition at line 22 of file collision_error_function_stateless.cpp.
References collisionGeometry, momentum::SkeletonErrorFunctionT< T >::SkeletonErrorFunctionT(), and updateCollisionPairs().
Referenced by CollisionErrorFunctionStatelessT().
|
explicit |
Definition at line 31 of file collision_error_function_stateless.cpp.
References CollisionErrorFunctionStatelessT().
|
protected |
Accumulate gradient contributions along a joint chain.
scaleCorrection is an additive term for the scale derivative (for capsule radius correction).
Definition at line 98 of file collision_error_function_stateless.cpp.
References momentum::accumulateChainDerivatives(), momentum::SkeletonErrorFunctionT< T >::activeJointParams_, momentum::gradient_jointParams_to_modelParams(), momentum::SkeletonErrorFunctionT< T >::parameterTransform_, and momentum::SkeletonErrorFunctionT< T >::skeleton_.
Referenced by getGradient().
|
protected |
Accumulate Jacobian contributions along a joint chain.
scaleCorrection is an additive term for the scale derivative (for capsule radius correction).
Definition at line 124 of file collision_error_function_stateless.cpp.
References momentum::accumulateChainDerivatives(), momentum::SkeletonErrorFunctionT< T >::activeJointParams_, momentum::jacobian_jointParams_to_modelParams(), momentum::SkeletonErrorFunctionT< T >::parameterTransform_, and momentum::SkeletonErrorFunctionT< T >::skeleton_.
Referenced by getJacobian().
|
nodiscardprotected |
AABB broadphase pre-check followed by narrow-phase collision overlap test.
Returns true when the pair collides, filling result with contact details.
Definition at line 86 of file collision_error_function_stateless.cpp.
References aabbs_, collisionGeometry, and momentum::overlaps().
Referenced by getCollisionPairs(), getError(), getGradient(), and getJacobian().
|
protected |
Update collisionState and aabbs_ given the new skeleton state.
Definition at line 74 of file collision_error_function_stateless.cpp.
References aabbs_, collisionGeometry, collisionState, MT_PROFILE_EVENT, and momentum::updateAabb().
Referenced by getError(), getGradient(), and getJacobian().
|
nodiscard |
Definition at line 151 of file collision_error_function_stateless.cpp.
References checkCollision(), collisionState, and validPairs_.
|
nodiscardfinalvirtual |
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 163 of file collision_error_function_stateless.cpp.
References checkCollision(), collisionState, computeBroadPhase(), momentum::SkeletonStateT< T >::jointParameters, momentum::SkeletonStateT< T >::jointState, kCollisionWeight, momentum::kParametersPerJoint, MT_CHECK, momentum::CollisionOverlapResultT< T >::overlap, momentum::sqr(), validPairs_, and momentum::SkeletonErrorFunctionT< T >::weight_.
|
override |
Definition at line 190 of file collision_error_function_stateless.cpp.
References accumulateGradientAlongChain(), momentum::SkeletonErrorFunctionT< T >::activeJointParams_, checkCollision(), collisionGeometry, collisionState, computeBroadPhase(), momentum::CollisionOverlapResultT< T >::distance, momentum::gradient_jointParams_to_modelParams(), momentum::SkeletonStateT< T >::jointParameters, momentum::SkeletonStateT< T >::jointState, kCollisionWeight, momentum::kInvalidIndex, momentum::kParametersPerJoint, momentum::ln2(), MT_CHECK, momentum::CollisionOverlapResultT< T >::overlap, momentum::SkeletonErrorFunctionT< T >::parameterTransform_, momentum::CollisionOverlapResultT< T >::positionA, momentum::CollisionOverlapResultT< T >::positionB, momentum::CollisionOverlapResultT< T >::radiusA, momentum::CollisionOverlapResultT< T >::radiusB, momentum::SkeletonErrorFunctionT< T >::skeleton_, momentum::sqr(), validPairs_, and momentum::SkeletonErrorFunctionT< T >::weight_.
|
override |
Definition at line 257 of file collision_error_function_stateless.cpp.
References accumulateJacobianAlongChain(), momentum::SkeletonErrorFunctionT< T >::activeJointParams_, checkCollision(), collisionGeometry, collisionState, computeBroadPhase(), momentum::CollisionOverlapResultT< T >::distance, getJacobianSize(), momentum::jacobian_jointParams_to_modelParams(), momentum::SkeletonStateT< T >::jointParameters, momentum::SkeletonStateT< T >::jointState, kCollisionWeight, momentum::kInvalidIndex, momentum::kParametersPerJoint, momentum::ln2(), MT_CHECK, MT_PROFILE_FUNCTION, momentum::CollisionOverlapResultT< T >::overlap, momentum::SkeletonErrorFunctionT< T >::parameterTransform_, momentum::CollisionOverlapResultT< T >::positionA, momentum::CollisionOverlapResultT< T >::positionB, momentum::CollisionOverlapResultT< T >::radiusA, momentum::CollisionOverlapResultT< T >::radiusB, momentum::SkeletonErrorFunctionT< T >::skeleton_, momentum::sqr(), validPairs_, and momentum::SkeletonErrorFunctionT< T >::weight_.
|
nodiscardfinalvirtual |
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 346 of file collision_error_function_stateless.cpp.
References validPairs_.
Referenced by getJacobian().
|
protected |
Definition at line 43 of file collision_error_function_stateless.cpp.
References aabbs_, momentum::cast(), collisionGeometry, collisionState, momentum::isValidCollisionPair(), momentum::SkeletonErrorFunctionT< T >::parameterTransform_, momentum::SkeletonErrorFunctionT< T >::skeleton_, momentum::updateAabb(), and validPairs_.
Referenced by CollisionErrorFunctionStatelessT().
|
protected |
Per-capsule AABBs, updated each frame for broadphase culling.
Definition at line 114 of file collision_error_function_stateless.h.
Referenced by checkCollision(), computeBroadPhase(), and updateCollisionPairs().
|
protected |
Definition at line 108 of file collision_error_function_stateless.h.
Referenced by checkCollision(), CollisionErrorFunctionStatelessT(), computeBroadPhase(), getGradient(), getJacobian(), and updateCollisionPairs().
|
protected |
Definition at line 116 of file collision_error_function_stateless.h.
Referenced by computeBroadPhase(), getCollisionPairs(), getError(), getGradient(), getJacobian(), and updateCollisionPairs().
|
staticconstexprprotected |
Definition at line 119 of file collision_error_function_stateless.h.
Referenced by getError(), getGradient(), and getJacobian().
|
protected |
Pre-filtered list of valid collision pairs.
Definition at line 111 of file collision_error_function_stateless.h.
Referenced by getCollisionPairs(), getError(), getGradient(), getJacobian(), getJacobianSize(), and updateCollisionPairs().