Skip to main content

Function: detectPolygonTerrainCollision()

detectPolygonTerrainCollision(polygonBody, terrainBody): CollisionManifold | null

Defined in: physics/collision/detect-polygon-terrain-collision.ts:43

Detects a collision between a convex polygon-shaped body and a terrain-shaped body, by running the same polygon-vs-polygon narrow phase used for detectPolygonPolygonCollision against each of the terrain's segments that overlap the polygon's local x-range, keeping the deepest resulting contact.

Parameters

polygonBody

RigidBody

The body with a PolygonShape. Becomes bodyA of the returned manifold.

terrainBody

RigidBody

The body with a TerrainShape. Becomes bodyB of the returned manifold.

Returns

CollisionManifold | null

A CollisionManifold if the shapes overlap, otherwise null.