Potential collision between two objects in a Simulation, including a stateful collision algorithm for generating the actual contact points between them.
More...
#include <GREM/physics/collision.hpp>
|
| | Contact (ShapeView< N > shapeA, ShapeView< N > shapeB) |
| | Construct a contact with a collision algorithm that can be used to generate contact points for a given ordered pair of shapes.
|
| size_t | insertCollision (ManifoldMask &mergedManifolds, const CollisionAlgorithmResult< N > &collision, const Transformation< N > &transformationA, const Transformation< N > &transformationB, LinearVelocity< N > linearVelocityA, LinearVelocity< N > linearVelocityB, AngularVelocity< N > angularVelocityA, AngularVelocity< N > angularVelocityB, Distance maxCollisionTouchingDistance, Scale1D minContactManifoldDotProduct) |
| | Merge in a new collision manifold with the existing manifolds, and calculate its new tangent and relative tangent-space velocity.
|
| void | removeManifolds (ManifoldMask removeMask) |
| | Remove a specific set of manifolds.
|
|
| static constexpr size_t | MAX_MANIFOLD_COUNT = (N == 3) ? 4 : 2 |
| | Maximum number of contact manifolds in a single contact.
|
template<size_t N>
struct grem::physics::Contact< N >
Potential collision between two objects in a Simulation, including a stateful collision algorithm for generating the actual contact points between them.
- Template Parameters
-
| N | number of dimensions of the world space (must be 2 or 3). |
◆ ManifoldMask
Bitset of manifold indices in a contact.
◆ Contact()
Construct a contact with a collision algorithm that can be used to generate contact points for a given ordered pair of shapes.
- Parameters
-
| shapeA | the first shape in the pair of shapes to choose a collision algorithm for. |
| shapeB | the second shape to the pair of shapes to choose a collision algorithm for. |
- Exceptions
-
| std::bad_alloc | on allocation failure. |
◆ getTangentSpaceBasis()
Calculate a suitable orthonormal tangent-space basis for a contact point pair given its normal and current relative velocity.
- Parameters
-
| normal | world-space contact normal. |
| relativeVelocity | relative world-space velocity of the contact point (A - B). |
- Returns
- the tangent-space basis in world space as a TBN matrix (tangent, bitangent, normal) in 3D or a TN matrix (tangent, normal) in 2D.
◆ insertCollision()
Merge in a new collision manifold with the existing manifolds, and calculate its new tangent and relative tangent-space velocity.
The merging logic works as follows:
- If there exists a manifold with equal featureTypes, featureIndices and filterTestResult that has a similar enough normal (within minContactManifoldDotProduct), and it has not already been merged, its normal is replaced with the new manifold's normal and its points are merged with the new manifold's points.
- Before merging, existing points that are no longer within touching range are removed.
- When merging, existing points that are within maxCollisionTouchingDistance of a new point get their offsets and localOffsets replaced, but keep the values of other fields (transformed to the new tangent-space basis).
- Other points are transformed to the new tangent-space basis, but otherwise remain unchanged. If no nearby point was found, the new point is added to the list, unless the list is full, in which case it replaces the point with the smallest penetration depth.
- Otherwise, if no manifold suitable for merging was found, the new manifold is added to the list, unless the list is full, in which case it replaces the manifold whose deepest point has the smallest penetration depth.
- Parameters
-
| mergedManifolds | mask of manifolds that have already been merged, which will be excluded from being merged again (unless the list is full). The mask will be updated to also contain the new index chosen by this procedure. |
| collision | collision containing the new manifold to merge in. |
| transformationA | world-space transformation of the first object. |
| transformationB | world-space transformation of the second object. |
| linearVelocityA | world-space linear velocity of the first object. |
| linearVelocityB | world-space linear velocity of the second object. |
| angularVelocityA | world-space angular velocity of the first object. |
| angularVelocityB | world-space angular velocity of the second object. |
| maxCollisionTouchingDistance | maximum separation distance of a contact point before it is considered to no longer be touching. Must be non-negative. |
| minContactManifoldDotProduct | minimum dot product (cosine of the angle) between two manifold normals before they are no longer considered similar enough to be merged. |
- Returns
- the index of the merged manifold.
◆ removeManifolds()
Remove a specific set of manifolds.
- Parameters
-
| removeMask | bitmask of manifolds to remove, where each set bit refers to the corresponding index to remove from the list of manifolds. |
◆ MAX_MANIFOLD_COUNT
Maximum number of contact manifolds in a single contact.
◆ manifolds
List of contact manifolds between the potentially colliding objects.
◆ collisionAlgorithm
Collision algorithm for generating contact points between the potentially colliding objects.
◆ wasTouchingOnLastSubStep
Whether the contact had at least one manifold during the last sub-step or not.
The documentation for this struct was generated from the following file: