forked from tas/major_tom
Support large maps up to 8192x8192 tiles
Raise hard map size cap from 4096 to 8192 via MAX_MAP_SIZE constant. Replace fixed 16 KB fgets buffer with dynamic line reader that handles arbitrarily long tile rows. Check calloc returns for tile layer allocation. Add entity distance culling: skip updates for entities beyond 2x screen width from camera, skip rendering beyond 64 px margin. Dead entities bypass culling so cleanup callbacks always run. Player, spacecraft, drone, and moving platforms set ENTITY_ALWAYS_UPDATE to opt out. Replace naive 4-neighbor flood fill with scanline algorithm (O(height) stack instead of O(area)) for safe use on large maps. Raise MAX_ENTITY_SPAWNS from 128 to 512 and MAX_EXIT_ZONES from 8 to 16 to support populated large levels.
This commit is contained in:
24
TODO.md
24
TODO.md
@@ -11,15 +11,21 @@ with state machine (FLYING_IN → LANDING → LANDED → TAKEOFF → FLYING_OUT
|
||||
DONE), engine/synth sounds, thruster particles, level intro sequence with
|
||||
deferred player spawn.
|
||||
|
||||
## Large map support (5000x5000)
|
||||
Audit the engine for anything that breaks or becomes slow at very large map
|
||||
sizes. Key areas to check:
|
||||
- Tile layer allocation (`uint16_t *` for 25M tiles)
|
||||
- Tilemap rendering culling (already viewport-clipped, verify correctness)
|
||||
- Physics / collision queries (should only check nearby tiles)
|
||||
- Entity updates (currently iterates full pool regardless of distance)
|
||||
- Camera bounds and coordinate overflow (float precision at large coords)
|
||||
- Level file parsing (row lines could exceed fgets buffer at 5000+ columns)
|
||||
## ~~Large map support (5000x5000)~~ ✓
|
||||
Audited and fixed all engine bottlenecks for maps up to 8192x8192:
|
||||
- `MAX_MAP_SIZE` constant (8192) replaces hard-coded 4096 caps in tilemap
|
||||
loader and editor resize. Tile layers allocate fine at 5000x5000 (~143 MB).
|
||||
- Dynamic line reader in `tilemap_load()` replaces fixed 16 KB `fgets` buffer;
|
||||
handles arbitrarily long tile rows without truncation.
|
||||
- `MAX_ENTITY_SPAWNS` raised from 128 to 512; `MAX_EXIT_ZONES` from 8 to 16.
|
||||
- Entity distance culling: `entity_update_all()` skips entities beyond 2×
|
||||
screen width from the camera; `entity_render_all()` skips entities outside
|
||||
the viewport + 64 px margin. Player, spacecraft, and drone use
|
||||
`ENTITY_ALWAYS_UPDATE` flag to opt out of culling.
|
||||
- Editor flood fill replaced with scanline algorithm — O(height) stack usage
|
||||
instead of O(area), safe for very large maps.
|
||||
- Verified: tilemap rendering already viewport-culled, physics queries are O(1)
|
||||
local tile lookups, float precision fine up to ~1M pixels (62 K tiles).
|
||||
|
||||
## ~~Spacecraft at level exit~~ ✓
|
||||
Implemented: `spacecraft_spawn_exit()` with `is_exit_ship` flag. Proximity
|
||||
|
||||
Reference in New Issue
Block a user