Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
momentum::PlaneCollisionQueryT< T > Class Template Reference

Stateful query helper for collision primitives against a fixed world plane. More...

#include <plane_collision_query.h>

Classes

struct  Result
 Collision information for one primitive selected by the current query state. More...

Public Member Functions

 PlaneCollisionQueryT (const CollisionGeometry &cg, const Vector3< T > &planeNormal, T planeOffset)
 Construct a query over explicit collision geometry.
 PlaneCollisionQueryT (const Character &character, const Vector3< T > &planeNormal, T planeOffset)
 Construct a query over a character's collision geometry and initialize it at the zero pose.
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().
size_t primitiveCount () const
 Number of character-attached collision primitives owned by this query.
size_t candidatePrimitiveCount () const
 Number of primitives retained by the most recent broad-phase update.
void update (const SkeletonStateT< T > &state, T contactMargin)
 Update candidate primitive state for a skeleton state and signed plane-distance margin.
void update (std::span< const JointStateT< T > > states, T contactMargin)
 Update candidate primitive state for explicit joint states and signed plane-distance margin.
void updateActiveParentCollisions ()
 Select the deepest active collision under each parent joint from current candidates.
const std::vector< Result > & activeParentCollisions () const
 Return the current deepest active collisions, one per parent joint.
std::vector< size_t > getCollidingPrimitives () const
 Return collision primitive indices that penetrate the plane in the current query state.
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 explicit joint states.
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.

Detailed Description

template<typename T>
class momentum::PlaneCollisionQueryT< T >

Stateful query helper for collision primitives against a fixed world 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 54 of file plane_collision_query.h.

Constructor & Destructor Documentation

◆ PlaneCollisionQueryT() [1/2]

template<typename T>
momentum::PlaneCollisionQueryT< T >::PlaneCollisionQueryT ( const CollisionGeometry & cg,
const Vector3< T > & planeNormal,
T planeOffset )
explicit

Construct a query over explicit collision geometry.

The primitive list is initialized immediately, but candidate and active collision state remain empty until update() is called for a skeleton state. Contact-point helpers that take explicit joint states update that state internally for the duration of the query.

Definition at line 36 of file plane_collision_query.cpp.

References setPlane().

Referenced by PlaneCollisionQueryT().

◆ PlaneCollisionQueryT() [2/2]

template<typename T>
momentum::PlaneCollisionQueryT< T >::PlaneCollisionQueryT ( const Character & character,
const Vector3< T > & planeNormal,
T planeOffset )
explicit

Construct a query over a character's collision geometry and initialize it at the zero pose.

Definition at line 46 of file plane_collision_query.cpp.

References momentum::cast(), momentum::Character::parameterTransform, PlaneCollisionQueryT(), momentum::Character::skeleton, update(), and momentum::ParameterTransformT< T >::zero().

Member Function Documentation

◆ activeParentCollisions()

template<typename T>
const std::vector< Result > & momentum::PlaneCollisionQueryT< T >::activeParentCollisions ( ) const
inlinenodiscard

Return the current deepest active collisions, one per parent joint.

Definition at line 124 of file plane_collision_query.h.

◆ candidatePrimitiveCount()

template<typename T>
size_t momentum::PlaneCollisionQueryT< T >::candidatePrimitiveCount ( ) const
inlinenodiscard

Number of primitives retained by the most recent broad-phase update.

Definition at line 110 of file plane_collision_query.h.

◆ getCollidingPrimitives()

template<typename T>
std::vector< size_t > momentum::PlaneCollisionQueryT< T >::getCollidingPrimitives ( ) const
nodiscard

Return collision primitive indices that penetrate the plane in the current query state.

Definition at line 260 of file plane_collision_query.cpp.

◆ getCollisionDebugInfo()

◆ getContactPoints()

template<typename T>
std::vector< Vector3< T > > momentum::PlaneCollisionQueryT< T >::getContactPoints ( std::span< const JointStateT< T > > states,
T contactMargin )
nodiscard

Return world-space primitive surface points at or near the plane for explicit joint states.

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 290 of file plane_collision_query.cpp.

References momentum::PlaneCollisionQueryT< T >::Result::position, momentum::PlaneCollisionQueryT< T >::Result::surfaceDistance(), and update().

◆ getContactPointsByParent()

template<typename T>
std::vector< Vector3< T > > momentum::PlaneCollisionQueryT< T >::getContactPointsByParent ( std::span< const JointStateT< T > > states,
T contactMargin )
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 307 of file plane_collision_query.cpp.

References getContactPointsByParentWithDetails().

◆ getContactPointsByParentWithDetails()

template<typename T>
std::vector< PlaneCollisionContactPointT< T > > momentum::PlaneCollisionQueryT< T >::getContactPointsByParentWithDetails ( std::span< const JointStateT< T > > states,
T contactMargin )
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 322 of file plane_collision_query.cpp.

References momentum::kInvalidIndex, momentum::PlaneCollisionQueryT< T >::Result::parentJoint, momentum::PlaneCollisionQueryT< T >::Result::position, momentum::PlaneCollisionQueryT< T >::Result::surfaceDistance(), and update().

Referenced by momentum::computePlaneCollisionSupportContacts(), and getContactPointsByParent().

◆ getPlaneNormal()

template<typename T>
const Vector3< T > & momentum::PlaneCollisionQueryT< T >::getPlaneNormal ( ) const
inlinenodiscard

Return the normalized plane normal used by collision and contact queries.

Definition at line 95 of file plane_collision_query.h.

◆ getPlaneOffset()

template<typename T>
T momentum::PlaneCollisionQueryT< T >::getPlaneOffset ( ) const
inlinenodiscard

Return the plane offset after normalization by setPlane().

Definition at line 100 of file plane_collision_query.h.

◆ primitiveCount()

template<typename T>
size_t momentum::PlaneCollisionQueryT< T >::primitiveCount ( ) const
inlinenodiscard

Number of character-attached collision primitives owned by this query.

Definition at line 105 of file plane_collision_query.h.

◆ setPlane()

template<typename T>
void momentum::PlaneCollisionQueryT< T >::setPlane ( const Vector3< T > & planeNormal,
T planeOffset )

Set the collision plane after normalizing planeNormal and the matching offset.

planeOffset must use the same scale as planeNormal. Equivalent plane equations such as 2 * normal.dot(x) - 2 * offset = 0 are stored in one canonical form, so getPlaneOffset() returns the offset divided by the input normal length.

Definition at line 57 of file plane_collision_query.cpp.

References momentum::Eps(), and MT_CHECK.

Referenced by PlaneCollisionQueryT().

◆ update() [1/2]

template<typename T>
void momentum::PlaneCollisionQueryT< T >::update ( const SkeletonStateT< T > & state,
T contactMargin )

Update candidate primitive state for a skeleton state and signed plane-distance margin.

Definition at line 143 of file plane_collision_query.cpp.

References MT_PROFILE_EVENT.

Referenced by getContactPoints(), getContactPointsByParentWithDetails(), PlaneCollisionQueryT(), and update().

◆ update() [2/2]

template<typename T>
void momentum::PlaneCollisionQueryT< T >::update ( std::span< const JointStateT< T > > states,
T contactMargin )

Update candidate primitive state for explicit joint states and signed plane-distance margin.

Definition at line 162 of file plane_collision_query.cpp.

References momentum::SkeletonStateT< T >::jointState, and update().

◆ updateActiveParentCollisions()

template<typename T>
void momentum::PlaneCollisionQueryT< T >::updateActiveParentCollisions ( )

Select the deepest active collision under each parent joint from current candidates.

Definition at line 235 of file plane_collision_query.cpp.

References momentum::PlaneCollisionQueryT< T >::Result::overlap, and momentum::PlaneCollisionQueryT< T >::Result::parentJoint.


The documentation for this class was generated from the following files: