|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
#include <collision_error_function.h>
Classes | |
| struct | CollisionPairInfo |
| Pre-computed valid collision pair with common ancestor. More... | |
Public Member Functions | |
| CollisionErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt, const CollisionGeometry &cg, bool filterRestPoseOverlaps=true) | |
| CollisionErrorFunctionT (const Character &character, bool filterRestPoseOverlaps=true) | |
| 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 |
| std::vector< CollisionDebugEntryT< T > > | getCollisionDebugInfo () const |
| Query detailed collision state for all currently-colliding pairs. | |
| 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 (bool filterRestPoseOverlaps=true) |
| 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 from startJoint up to (but not including) stopJoint. | |
| 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 from startJoint up to (but not including) stopJoint. | |
Protected Attributes | |
| const CollisionGeometry | collisionGeometry_ |
| std::vector< CollisionPairInfo > | validPairs_ |
| Pre-filtered list of valid collision pairs (excludes rest-pose overlaps and adjacent joints). | |
| 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 |
Definition at line 36 of file collision_error_function.h.
|
explicit |
| filterRestPoseOverlaps | When true (default), capsule pairs that overlap in the rest pose are excluded from collision checking. Set to false for characters where limbs are close to the body in bind pose (e.g., beefy characters) and you still want collision avoidance between those pairs. |
Definition at line 23 of file collision_error_function.cpp.
References collisionGeometry_, momentum::SkeletonErrorFunctionT< T >::SkeletonErrorFunctionT(), and updateCollisionPairs().
Referenced by CollisionErrorFunctionT().
|
explicit |
Definition at line 33 of file collision_error_function.cpp.
References CollisionErrorFunctionT().
|
protected |
Accumulate gradient contributions along a joint chain from startJoint up to (but not including) stopJoint.
The sign of weight controls the push direction. scaleCorrection is an additive term for the scale derivative (for capsule radius correction).
Definition at line 104 of file collision_error_function.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 from startJoint up to (but not including) stopJoint.
The sign of factor controls the push direction. scaleCorrection is an additive term for the scale derivative (for capsule radius correction).
Definition at line 130 of file collision_error_function.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 92 of file collision_error_function.cpp.
References aabbs_, collisionGeometry_, and momentum::overlaps().
Referenced by getCollisionDebugInfo(), getCollisionPairs(), getError(), getGradient(), and getJacobian().
|
protected |
Update collisionState_ and aabbs_ given the new skeleton state.
Definition at line 80 of file collision_error_function.cpp.
References aabbs_, collisionGeometry_, collisionState_, MT_PROFILE_EVENT, and momentum::updateAabb().
Referenced by getError(), getGradient(), and getJacobian().
|
nodiscard |
Query detailed collision state for all currently-colliding pairs.
Returns overlap, distance, capsule indices, and parent joint indices for each colliding pair. Uses the collision state from the most recent solver iteration (computed during getJacobian/getError/getGradient).
Definition at line 364 of file collision_error_function.cpp.
References checkCollision(), collisionGeometry_, collisionState_, momentum::CollisionOverlapResultT< T >::distance, momentum::CollisionOverlapResultT< T >::overlap, and validPairs_.
|
nodiscard |
Definition at line 157 of file collision_error_function.cpp.
References checkCollision(), collisionState_, and validPairs_.
|
nodiscardfinalvirtual |
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 169 of file collision_error_function.cpp.
References checkCollision(), collisionState_, computeBroadPhase(), momentum::SkeletonStateT< T >::jointParameters, momentum::SkeletonStateT< T >::jointState, kCollisionWeight, momentum::kParametersPerJoint, MT_CHECK, MT_LOGD, momentum::CollisionOverlapResultT< T >::overlap, momentum::sqr(), validPairs_, and momentum::SkeletonErrorFunctionT< T >::weight_.
|
override |
Definition at line 205 of file collision_error_function.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 275 of file collision_error_function.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 382 of file collision_error_function.cpp.
References validPairs_.
Referenced by getJacobian().
|
protected |
Definition at line 48 of file collision_error_function.cpp.
References aabbs_, momentum::cast(), collisionGeometry_, collisionState_, momentum::isValidCollisionPair(), momentum::SkeletonErrorFunctionT< T >::parameterTransform_, momentum::SkeletonErrorFunctionT< T >::skeleton_, momentum::updateAabb(), and validPairs_.
Referenced by CollisionErrorFunctionT().
|
protected |
Per-capsule AABBs, updated each frame for broadphase culling.
Definition at line 134 of file collision_error_function.h.
Referenced by checkCollision(), computeBroadPhase(), and updateCollisionPairs().
|
protected |
Definition at line 128 of file collision_error_function.h.
Referenced by checkCollision(), CollisionErrorFunctionT(), computeBroadPhase(), getCollisionDebugInfo(), getGradient(), getJacobian(), and updateCollisionPairs().
|
protected |
Definition at line 136 of file collision_error_function.h.
Referenced by computeBroadPhase(), getCollisionDebugInfo(), getCollisionPairs(), getError(), getGradient(), getJacobian(), and updateCollisionPairs().
|
staticconstexprprotected |
Definition at line 139 of file collision_error_function.h.
Referenced by getError(), getGradient(), and getJacobian().
|
protected |
Pre-filtered list of valid collision pairs (excludes rest-pose overlaps and adjacent joints).
Definition at line 131 of file collision_error_function.h.
Referenced by getCollisionDebugInfo(), getCollisionPairs(), getError(), getGradient(), getJacobian(), getJacobianSize(), and updateCollisionPairs().