Collision Manager
Efficient collision management system built on the collide crate.
Features
- Stable Indices: Safe object references even with frequent add/remove
- Bidirectional Collisions: Track collisions from the perspectives of both objects
- Multiple Query Modes: Find first/all collisions with simple API
- Zero Allocation: Reuses memory buffers for frequent updates
Basic Usage
use CollisionManager;
use Collider;
let mut manager = new;
// Add colliders with associated IDs
let player_id = manager.insert_collider;
let enemy_id = manager.insert_collider;
// Check collisions
if manager.check_collision
Advanced Usage
// Compute all internal collisions
let collisions = manager.compute_inner_collisions;
// Process collision results
for in collisions.indexed
Performance
- O(1) insert/remove by index
- O(n²) broad-phase collision checks (suitable for <1000 objects)
- Zero heap allocations after initial setup