miaoda-game-contact2d-core
v0.1.0
Published
Engine-neutral continuous 2D contact queries for moving circles, segments, and capsules with earliest time of impact and deterministic ordering.
Downloads
123
Maintainers
Readme
miaoda-game-contact2d-core
Use this engine-neutral package when fast 2D circles can cross a target between fixed ticks. It returns the earliest time of impact, contact point, and normal without moving either object or applying collision response.
pnpm add miaoda-game-contact2d-coreimport { sweepCircleCapsule } from 'miaoda-game-contact2d-core';
const hit = sweepCircleCapsule(
{ from: shuttle.previous, to: shuttle.position, radius: 3 },
{ start: racket.handle, end: racket.head, radius: 6 },
);
if (hit) game.handleRacketContact(hit);Scope
sweepCircleshandles two linearly moving circles.sweepCircleSegmenthandles thin walls, nets, goals, and beams.sweepCircleCapsulehandles thick segments such as rackets, bats, swords, rails, and rounded obstacles.sortContactsorders multiple results by impact fraction and stable ID.
targeting2d-core answers which targets overlap a range at one instant.
kinematic2d-core owns swept-AABB actor movement and collision response.
This package only calculates stateless continuous contacts and deliberately
does not own a world, broadphase, position integration, bounce, damage, or
scoring.
A capsule is static during one query. For a rapidly rotating rigid racket or bat, use the physics engine's CCD, substep the motion, or model its striking head as a moving circle; this package does not approximate angular sweep.
With Box2D, Planck, Matter, or another physics engine, prefer the engine's CCD for physics bodies. Use this package for engine-free simulations, prediction, headless tests, or explicit gameplay contacts, but never let both systems resolve the same body movement.
