|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
Penalizes collision between character collision primitives and a fixed plane. More...
#include <plane_collision_error_function.h>
Public Member Functions | |
| PlaneCollisionErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt, const CollisionGeometry &cg, const Vector3< T > &planeNormal, T planeOffset) | |
| PlaneCollisionErrorFunctionT (const Character &character, const Vector3< T > &planeNormal, T planeOffset) | |
| 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 > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Ref< MatrixX< T > > jacobian, Ref< VectorX< T > > residual, int &usedRows) override |
| size_t | getJacobianSize () const final |
| void | setPlane (const Vector3< T > &planeNormal, T planeOffset) |
Set the collision plane after normalizing planeNormal and the matching offset. | |
| const Vector3< T > & | getPlaneNormal () const |
| Return the normalized plane normal used by collision and contact queries. | |
| T | getPlaneOffset () const |
| Return the plane offset after normalization by setPlane(). | |
| PlaneCollisionQueryT< T > & | getCollisionQuery () |
| Return the reusable query helper used by this error function. | |
| const PlaneCollisionQueryT< T > & | getCollisionQuery () const |
| Return the reusable query helper used by this error function. | |
| std::vector< size_t > | getCollidingPrimitives () const |
| std::vector< PlaneCollisionDebugEntryT< T > > | getCollisionDebugInfo () const |
| Query detailed collision state for all currently-colliding primitives. | |
| std::vector< Vector3< T > > | getContactPoints (std::span< const JointStateT< T > > states, T contactMargin) |
| Return world-space primitive surface points at or near the plane for an explicit state. | |
| std::vector< Vector3< T > > | getContactPointsByParent (std::span< const JointStateT< T > > states, T contactMargin) |
| Return one world-space primitive surface point per parent joint at or near the plane. | |
| std::vector< PlaneCollisionContactPointT< T > > | getContactPointsByParentWithDetails (std::span< const JointStateT< T > > states, T contactMargin) |
| Return one detailed world-space primitive surface point per parent joint at or near the plane. | |
| 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 | accumulateGradientAlongChain (const SkeletonStateT< T > &state, const Vector3< T > &position, const Vector3< T > &direction, T weight, size_t startJoint, Ref< VectorX< T > > gradient, T scaleCorrection=T(0)) const |
| Accumulate gradient contributions along a joint chain up to the root. | |
| void | accumulateJacobianAlongChain (const SkeletonStateT< T > &state, const Vector3< T > &position, const Vector3< T > &direction, T factor, size_t startJoint, Ref< MatrixX< T > > jacobian, int row, T scaleCorrection=T(0)) const |
| Accumulate Jacobian contributions along a joint chain up to the root. | |
Protected Attributes | |
| PlaneCollisionQueryT< T > | collisionQuery_ |
| 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-3f |
Penalizes collision between character collision primitives and a fixed plane.
The plane is represented by planeNormal.dot(x) - planeOffset = 0; the non-penetrating side is planeNormal.dot(x) >= planeOffset. Capsules, ellipsoids, and boxes use the same collision geometry state and support-radius convention as CollisionErrorFunctionT.
Definition at line 25 of file plane_collision_error_function.h.
|
explicit |
Definition at line 25 of file plane_collision_error_function.cpp.
References momentum::cast(), collisionQuery_, momentum::SkeletonErrorFunctionT< T >::parameterTransform_, and momentum::SkeletonErrorFunctionT< T >::SkeletonErrorFunctionT().
Referenced by PlaneCollisionErrorFunctionT().
|
explicit |
Definition at line 38 of file plane_collision_error_function.cpp.
References PlaneCollisionErrorFunctionT().
|
protected |
Accumulate gradient contributions along a joint chain up to the root.
scaleCorrection accounts for the primitive support radius changing with uniform scale.
Definition at line 56 of file plane_collision_error_function.cpp.
References momentum::accumulateChainDerivatives(), momentum::SkeletonErrorFunctionT< T >::activeJointParams_, momentum::gradient_jointParams_to_modelParams(), momentum::kInvalidIndex, momentum::SkeletonErrorFunctionT< T >::parameterTransform_, and momentum::SkeletonErrorFunctionT< T >::skeleton_.
Referenced by getGradient().
|
protected |
Accumulate Jacobian contributions along a joint chain up to the root.
scaleCorrection accounts for the primitive support radius changing with uniform scale.
Definition at line 81 of file plane_collision_error_function.cpp.
References momentum::accumulateChainDerivatives(), momentum::SkeletonErrorFunctionT< T >::activeJointParams_, momentum::jacobian_jointParams_to_modelParams(), momentum::kInvalidIndex, momentum::SkeletonErrorFunctionT< T >::parameterTransform_, and momentum::SkeletonErrorFunctionT< T >::skeleton_.
Referenced by getJacobian().
|
nodiscard |
Definition at line 107 of file plane_collision_error_function.cpp.
References collisionQuery_.
|
nodiscard |
Query detailed collision state for all currently-colliding primitives.
Uses the collision state from the most recent solver iteration (computed during getJacobian/getError/getGradient), or the rest pose state immediately after construction.
Definition at line 112 of file plane_collision_error_function.cpp.
References collisionQuery_.
|
inlinenodiscard |
Return the reusable query helper used by this error function.
Definition at line 76 of file plane_collision_error_function.h.
|
inlinenodiscard |
Return the reusable query helper used by this error function.
Definition at line 81 of file plane_collision_error_function.h.
|
nodiscard |
Return world-space primitive surface points at or near the plane for an explicit state.
A primitive contributes when its signed surface distance to the plane is <= contactMargin. The returned point is on the primitive surface, deepest toward the plane.
Definition at line 118 of file plane_collision_error_function.cpp.
References collisionQuery_.
|
nodiscard |
Return one world-space primitive surface point per parent joint at or near the plane.
A primitive contributes when its signed surface distance to the plane is <= contactMargin. When multiple primitives under the same parent joint contribute, the returned point is the deepest one toward the plane.
Definition at line 125 of file plane_collision_error_function.cpp.
References collisionQuery_.
|
nodiscard |
Return one detailed world-space primitive surface point per parent joint at or near the plane.
A primitive contributes when its signed surface distance to the plane is <= contactMargin. When multiple primitives under the same parent joint contribute, the returned point is the deepest one toward the plane.
Definition at line 133 of file plane_collision_error_function.cpp.
References collisionQuery_.
|
nodiscardfinalvirtual |
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 140 of file plane_collision_error_function.cpp.
References collisionQuery_, momentum::SkeletonStateT< T >::jointParameters, momentum::SkeletonStateT< T >::jointState, kCollisionWeight, momentum::kParametersPerJoint, MT_CHECK, MT_LOGD, momentum::sqr(), and momentum::SkeletonErrorFunctionT< T >::weight_.
|
override |
Definition at line 172 of file plane_collision_error_function.cpp.
References accumulateGradientAlongChain(), collisionQuery_, momentum::SkeletonStateT< T >::jointParameters, momentum::SkeletonStateT< T >::jointState, kCollisionWeight, momentum::kParametersPerJoint, MT_CHECK, momentum::sqr(), and momentum::SkeletonErrorFunctionT< T >::weight_.
|
override |
Definition at line 207 of file plane_collision_error_function.cpp.
References accumulateJacobianAlongChain(), collisionQuery_, getJacobianSize(), momentum::SkeletonStateT< T >::jointParameters, momentum::SkeletonStateT< T >::jointState, kCollisionWeight, momentum::kParametersPerJoint, MT_CHECK, MT_PROFILE_FUNCTION, momentum::sqr(), and momentum::SkeletonErrorFunctionT< T >::weight_.
|
nodiscardfinalvirtual |
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 263 of file plane_collision_error_function.cpp.
References collisionQuery_.
Referenced by getJacobian().
|
inlinenodiscard |
Return the normalized plane normal used by collision and contact queries.
Definition at line 66 of file plane_collision_error_function.h.
|
inlinenodiscard |
Return the plane offset after normalization by setPlane().
Definition at line 71 of file plane_collision_error_function.h.
|
inline |
Set the collision plane after normalizing planeNormal and the matching offset.
Definition at line 61 of file plane_collision_error_function.h.
|
protected |
Definition at line 145 of file plane_collision_error_function.h.
Referenced by getCollidingPrimitives(), getCollisionDebugInfo(), getContactPoints(), getContactPointsByParent(), getContactPointsByParentWithDetails(), getError(), getGradient(), getJacobian(), getJacobianSize(), and PlaneCollisionErrorFunctionT().
|
staticconstexprprotected |
Definition at line 147 of file plane_collision_error_function.h.
Referenced by getError(), getGradient(), and getJacobian().