Skip to content

Physics: add continuous collision detection (CCD) for fast-moving bodies #558

Description

@stormmuller

Problem

src/physics only performs discrete collision detection: a body's position is integrated each tick and then checked for overlap. A fast-moving body can fully pass through a thin collider (e.g. a TerrainCollider wall, a thin PolygonCollider) within a single tick without ever registering an overlapping AABB — classic tunneling.

Impact

Any gameplay involving high-speed projectiles, fast-moving characters, or thin walls/floors is at risk of objects passing straight through geometry they should collide with.

Suggested fix

Add continuous collision detection for bodies moving fast relative to their own size and/or nearby collider thickness — options include swept-shape (conservative advancement) checks between the previous and current tick's transform, or sub-stepping the integration for qualifying bodies. Should be opt-in/threshold-based so it doesn't add cost to the common slow-moving-body case (consistent with how Box2D gates CCD on a speed threshold).

Acceptance criteria

  • A fast-moving circle/polygon body reliably collides with thin static geometry instead of tunneling through it
  • CCD only engages for bodies/situations that need it, to avoid broad performance regression
  • Covered by a physics unit test that reproduces tunneling without the fix and passes with it
  • Documented in documentation-site/docs/docs/physics

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions