Skip to content

Physics: add collision layers/masks for selective collision filtering #560

Description

@stormmuller

Problem

There is no concept of collision categories/layers in src/physics — every collider is checked against every other collider in broad/narrow phase. Games commonly need to exclude certain pairs from colliding entirely (e.g. player bullets shouldn't hit the player that fired them, enemy-only trigger zones shouldn't affect the player, etc).

Impact

Without filtering, this has to be worked around at the gameplay layer (e.g. manually ignoring contacts after the fact), which is wasted broad/narrow-phase work and awkward to express compared to a first-class filtering API.

Suggested fix

Add a category/mask pair to collider components (Box2D-style: each collider declares what category it belongs to and what categories it collides with), checked cheaply in the broad phase before doing any shape-overlap work, so filtered-out pairs are skipped early rather than resolved and then ignored.

Acceptance criteria

  • Collider components support a category + collision mask
  • Broad phase skips pairs that are filtered out by category/mask before narrow-phase work
  • Covered by physics unit tests
  • 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