UNPKG

@rpgjs/physic

Version:

A deterministic 2D top-down physics library for RPG, sandbox and MMO games

26 lines 1.03 kB
import { Vector2 } from '../core/math/Vector2'; import { Collider } from './Collider'; import { Entity } from '../physics/Entity'; export interface SweepResult { time: number; normal: Vector2; point: Vector2; } /** * Computes time-of-impact for a pair of entities using simple analytical sweeps. * Supports Circle-Circle, Circle-AABB, AABB-AABB. Polygon falls back to AABB sweep. * * @param a - First entity * @param b - Second entity * @param delta - World displacement of entity A over the step (A's motion, B assumed static). For relative motion, pass (vA - vB) * dt. * @returns SweepResult or null if no hit in [0,1] * * @example * ```typescript * const rel = entityA.velocity.sub(entityB.velocity).mul(dt); * const hit = sweepEntities(entityA, entityB, rel); * ``` */ export declare function sweepEntities(a: Entity, b: Entity, delta: Vector2): SweepResult | null; export declare function sweepColliders(a: Collider, b: Collider, delta: Vector2): SweepResult | null; //# sourceMappingURL=sweep.d.ts.map