UNPKG

@rpgjs/physic

Version:

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

36 lines 1.22 kB
import { AABB } from '../core/math/AABB'; import { Entity } from '../physics/Entity'; import { SpatialPartition } from '../world/SpatialPartition'; import { Ray, RaycastHit } from './Ray'; /** * Quadtree spatial partition implementation * * Design: simple PR quadtree with capacity threshold; reinserts on update. * This implementation favors predictable performance and minimal allocations. * * @example * ```typescript * const qt = new Quadtree(new AABB(-1000,-1000,1000,1000), 8, 6, 8); * qt.insert(entity); * const near = qt.query(entity); * ``` */ export declare class Quadtree implements SpatialPartition { private root; private capacity; private maxDepth; private entityMap; constructor(worldBounds: AABB, capacity?: number, maxDepth?: number); clear(): void; insert(entity: Entity): void; remove(entity: Entity): void; update(entity: Entity): void; query(entity: Entity): Set<Entity>; queryAABB(bounds: AABB): Set<Entity>; raycast(ray: Ray, mask?: number, filter?: (entity: Entity) => boolean): RaycastHit | null; private insertItem; private queryBounds; private subdivide; private findChild; } //# sourceMappingURL=quadtree.d.ts.map