SAPCollisionConstraint

A class that implements collision resolution between two bodies in a simulation using a Sweep and Prune (SAP) algorithm. This constraint resolves collisions by identifying and responding to intersections between the boundary nodes or edges of the two bodies.

The algorithm ensures that the two objects maintain realistic physical interactions during collisions by applying positional corrections based on the configuration of their boundary elements (nodes and edges). These corrections are computed for both the static and dynamic components of the bodies based on their properties such as position, mass, and boundary geometry.

Key Operations:

  • Detects the closest points or edges between the two bodies using a nearest-neighbor search approach.

  • Computes signed distances between points and edges for collision detection.

  • Checks for object intersections using boundary information, including points and circle approximations.

  • Applies contact resolution, moving the positions of points and edges based on inverse mass contributions and penetration depth to prevent objects from overlapping.

This class is designed to handle both static and dynamic bodies in the simulation, allowing for versatile interactions between different types of objects. The skin width parameter is used to define a tolerance for collision detection, ensuring stability in the resolution process.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
open suspend override fun solve(body: Body, other: Body, dt: Double)