|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
Functions | |
| size_t | findCommonAncestorForVertex (const SkinWeights &skinWeights, const Skeleton &skeleton, size_t vertexIndex, size_t sdfParent) |
| Shared, stateless helpers for SDF-collision error functions. | |
| template<typename T, typename SdfColliderType> | |
| TransformT< T > | computeWorldToColliderTransform (const SdfColliderType &collider, const SkeletonStateT< T > &state) |
| Returns the world-to-collider transform for a collider given a skeleton state. | |
| template<typename T, typename SdfColliderType> | |
| axel::BoundingBox< T > | computeColliderWorldBoundingBox (const SdfColliderType &collider, const SkeletonStateT< T > &state) |
| Returns the world-space axis-aligned bounding box of a collider given a skeleton state. | |
| template<typename T> | |
| axel::BoundingBox< T > | computeBoneBoundingBox (std::span< const size_t > vertexIndices, const MeshT< T > &posedMesh) |
| Returns the world-space axis-aligned bounding box enclosing the given posed-mesh vertices. | |
| template<typename T> | |
| void | accumulateJointGradient (const JointStateT< T > &jointState, size_t paramIndex, const Eigen::Vector3< T > &posd, const Eigen::Vector3< T > &direction, const VectorX< bool > &activeJointParams, const ParameterTransform ¶meterTransform, Eigen::Ref< Eigen::VectorX< T > > gradient) |
| Accumulates the gradient contribution of a single joint onto the model-parameter gradient. | |
| template<typename T> | |
| void | accumulateJointJacobian (const JointStateT< T > &jointState, size_t paramIndex, const Eigen::Vector3< T > &posd, const Eigen::Vector3< T > &direction, const VectorX< bool > &activeJointParams, const ParameterTransform ¶meterTransform, Eigen::Ref< Eigen::MatrixX< T > > jacobianRow) |
| Accumulates the Jacobian contribution of a single joint onto one residual row. | |
| template<typename T> | |
| void | accumulateColliderHierarchyGradient (const SkeletonStateT< T > &state, size_t colliderParent, size_t commonAncestor, const Eigen::Vector3< T > &sdfSurfacePoint, const Eigen::Vector3< T > &direction, const Skeleton &skeleton, const VectorX< bool > &activeJointParams, const ParameterTransform ¶meterTransform, Eigen::Ref< Eigen::VectorX< T > > gradient) |
| Accumulates the gradient contribution of a collider's joint hierarchy onto the gradient. | |
| template<typename T> | |
| void | accumulateColliderHierarchyJacobian (const SkeletonStateT< T > &state, size_t colliderParent, size_t commonAncestor, const Eigen::Vector3< T > &sdfSurfacePoint, const Eigen::Vector3< T > &direction, const Skeleton &skeleton, const VectorX< bool > &activeJointParams, const ParameterTransform ¶meterTransform, Eigen::Ref< Eigen::MatrixX< T > > jacobianRow) |
| Accumulates the Jacobian contribution of a collider's joint hierarchy onto one residual row. | |
| void momentum::detail_sdf_collision::accumulateColliderHierarchyGradient | ( | const SkeletonStateT< T > & | state, |
| size_t | colliderParent, | ||
| size_t | commonAncestor, | ||
| const Eigen::Vector3< T > & | sdfSurfacePoint, | ||
| const Eigen::Vector3< T > & | direction, | ||
| const Skeleton & | skeleton, | ||
| const VectorX< bool > & | activeJointParams, | ||
| const ParameterTransform & | parameterTransform, | ||
| Eigen::Ref< Eigen::VectorX< T > > | gradient ) |
Accumulates the gradient contribution of a collider's joint hierarchy onto the gradient.
Walks from the collider's parent joint up to (but not including) commonAncestor, accumulating each joint's contribution for the collider-side of the constraint at sdfSurfacePoint.
Definition at line 230 of file sdf_collision_utility.h.
References accumulateJointGradient(), momentum::SkeletonT< T >::joints, momentum::SkeletonStateT< T >::jointState, momentum::kInvalidIndex, and momentum::kParametersPerJoint.
Referenced by momentum::SDFCollisionSequenceErrorFunctionT< T, SdfColliderType >::getGradient().
| void momentum::detail_sdf_collision::accumulateColliderHierarchyJacobian | ( | const SkeletonStateT< T > & | state, |
| size_t | colliderParent, | ||
| size_t | commonAncestor, | ||
| const Eigen::Vector3< T > & | sdfSurfacePoint, | ||
| const Eigen::Vector3< T > & | direction, | ||
| const Skeleton & | skeleton, | ||
| const VectorX< bool > & | activeJointParams, | ||
| const ParameterTransform & | parameterTransform, | ||
| Eigen::Ref< Eigen::MatrixX< T > > | jacobianRow ) |
Accumulates the Jacobian contribution of a collider's joint hierarchy onto one residual row.
Like accumulateColliderHierarchyGradient but writes a single-row Jacobian block.
Definition at line 255 of file sdf_collision_utility.h.
References accumulateJointJacobian(), momentum::SkeletonT< T >::joints, momentum::SkeletonStateT< T >::jointState, momentum::kInvalidIndex, and momentum::kParametersPerJoint.
Referenced by momentum::SDFCollisionSequenceErrorFunctionT< T, SdfColliderType >::getJacobian().
| void momentum::detail_sdf_collision::accumulateJointGradient | ( | const JointStateT< T > & | jointState, |
| size_t | paramIndex, | ||
| const Eigen::Vector3< T > & | posd, | ||
| const Eigen::Vector3< T > & | direction, | ||
| const VectorX< bool > & | activeJointParams, | ||
| const ParameterTransform & | parameterTransform, | ||
| Eigen::Ref< Eigen::VectorX< T > > | gradient ) |
Accumulates the gradient contribution of a single joint onto the model-parameter gradient.
Projects the constraint direction onto the joint's translation/rotation/scale derivatives and maps the result from joint-parameter to model-parameter space. posd is the constrained point relative to the joint origin.
Definition at line 154 of file sdf_collision_utility.h.
References momentum::JointStateT< T >::getRotationDerivative(), momentum::JointStateT< T >::getScaleDerivative(), momentum::JointStateT< T >::getTranslationDerivative(), and momentum::gradient_jointParams_to_modelParams().
Referenced by accumulateColliderHierarchyGradient(), and momentum::SDFCollisionSequenceErrorFunctionT< T, SdfColliderType >::getGradient().
| void momentum::detail_sdf_collision::accumulateJointJacobian | ( | const JointStateT< T > & | jointState, |
| size_t | paramIndex, | ||
| const Eigen::Vector3< T > & | posd, | ||
| const Eigen::Vector3< T > & | direction, | ||
| const VectorX< bool > & | activeJointParams, | ||
| const ParameterTransform & | parameterTransform, | ||
| Eigen::Ref< Eigen::MatrixX< T > > | jacobianRow ) |
Accumulates the Jacobian contribution of a single joint onto one residual row.
Like accumulateJointGradient but writes a single-row Jacobian block (jacobianRow) in model-parameter space rather than a gradient vector.
Definition at line 192 of file sdf_collision_utility.h.
References momentum::JointStateT< T >::getRotationDerivative(), momentum::JointStateT< T >::getScaleDerivative(), momentum::JointStateT< T >::getTranslationDerivative(), and momentum::jacobian_jointParams_to_modelParams().
Referenced by accumulateColliderHierarchyJacobian(), and momentum::SDFCollisionSequenceErrorFunctionT< T, SdfColliderType >::getJacobian().
| axel::BoundingBox< T > momentum::detail_sdf_collision::computeBoneBoundingBox | ( | std::span< const size_t > | vertexIndices, |
| const MeshT< T > & | posedMesh ) |
Returns the world-space axis-aligned bounding box enclosing the given posed-mesh vertices.
Returns an empty box when vertexIndices is empty.
Definition at line 135 of file sdf_collision_utility.h.
References momentum::MeshT< T >::vertices.
| axel::BoundingBox< T > momentum::detail_sdf_collision::computeColliderWorldBoundingBox | ( | const SdfColliderType & | collider, |
| const SkeletonStateT< T > & | state ) |
Returns the world-space axis-aligned bounding box of a collider given a skeleton state.
Transforms the collider's eight local-bound corners into world space. Returns an empty box for invalid colliders.
Definition at line 92 of file sdf_collision_utility.h.
References momentum::cast(), momentum::SkeletonStateT< T >::jointState, momentum::kInvalidIndex, and MT_CHECK.
| TransformT< T > momentum::detail_sdf_collision::computeWorldToColliderTransform | ( | const SdfColliderType & | collider, |
| const SkeletonStateT< T > & | state ) |
Returns the world-to-collider transform for a collider given a skeleton state.
World-fixed colliders (parentJoint() == kInvalidIndex) use only their local-to-parent transform; joint-attached colliders are first composed with their parent joint transform.
Definition at line 73 of file sdf_collision_utility.h.
References momentum::cast(), momentum::SkeletonStateT< T >::jointState, momentum::kInvalidIndex, and MT_CHECK.
Referenced by momentum::SDFCollisionSequenceErrorFunctionT< T, SdfColliderType >::getError(), momentum::SDFCollisionSequenceErrorFunctionT< T, SdfColliderType >::getGradient(), and momentum::SDFCollisionSequenceErrorFunctionT< T, SdfColliderType >::getJacobian().
|
inline |
Shared, stateless helpers for SDF-collision error functions.
These free functions hold the geometry queries (collider transforms, bounding boxes) and the joint chain-rule accumulation that are common to both the single-frame SDFCollisionErrorFunctionT and the cross-frame (sequence) collision error functions. Keeping them as free functions lets both error functions share the same derivation without depending on each other's class.
The SdfColliderType is duck-typed; see SDFCollisionErrorFunctionT for the required interface. Returns the common ancestor joint of a vertex's skinning chain and an SDF collider's parent joint, or kInvalidIndex when the collider has no parent joint.
This is the joint at which the vertex and collider hierarchies meet; derivatives above it cancel because both the vertex and the collider move together, so it bounds the chains that need to be walked.
Definition at line 44 of file sdf_collision_utility.h.
References momentum::SkeletonT< T >::commonAncestor(), momentum::SkinWeights::index, momentum::kInvalidIndex, momentum::kMaxSkinJoints, and momentum::SkinWeights::weight.
Referenced by momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >::getGradient(), momentum::SDFCollisionSequenceErrorFunctionT< T, SdfColliderType >::getGradient(), momentum::SDFCollisionErrorFunctionT< T, SdfColliderType >::getJacobian(), and momentum::SDFCollisionSequenceErrorFunctionT< T, SdfColliderType >::getJacobian().