Skip to content

Collision system v2: binary format, close-doors, and overlay visualization#31

Closed
PapaBlooD wants to merge 1 commit intoMaxBittker:mainfrom
PapaBlooD:collision-v2-binary-overlay
Closed

Collision system v2: binary format, close-doors, and overlay visualization#31
PapaBlooD wants to merge 1 commit intoMaxBittker:mainfrom
PapaBlooD:collision-v2-binary-overlay

Conversation

@PapaBlooD
Copy link
Contributor

Summary

Builds on the binary collision cache concept from PR #29 by @grumpyowlbear. Migrates the collision system to a v2 binary format, adds close-door handling, and generates a collision overlay PNG with dungeons.

  • Binary v2 format: 18MB JSON → 7MB binary (67% smaller, 13x faster init)
  • Close-doors: Detect default-open doors (op1=Close) and add wall collision so pathfinder treats them as blocked
  • Wall diagnostics: Export endpoint returns all wall-layer locs for debugging
  • PNG overlay: Auto-generated visualization with overworld, dungeons, wilderness dungeons, and legend key

Detailed File Changes

sdk/pathfinding.ts (+93/-60 lines)

  • Replaced JSON import (collision-data.json) with binary file reader (collision-data.bin)
  • Added unpackCoord() to decompress packed 32-bit coordinates (z:14, x:14, level:2)
  • Added binary header validation (magic "COLL", version 1 or 2)
  • Added close-doors section: reads v2 closeDoors and calls rsmod.changeWall(..., add=true) to wall off default-open doors
  • Added close-doors to doorIndex so findDoorsAlongPath can detect them
  • Changed tile/zone/door loading from array iteration to sequential binary reads

server/engine/src/web/pages/api.ts (+21/-7 lines)

  • Added closeDoors array — locs with "Close" option (default-open doors)
  • Added wallLocs array — ALL wall-layer locs with blockwalk for diagnostics (locId, name, shape, angle, blockrange)
  • Changed door scanning to categorize: hasOpen → doors, hasClose → closeDoors, all → wallLocs
  • Updated response to return { tiles, zones, doors, closeDoors, wallLocs }

server/engine/tools/export-collision.ts (+424/-3 lines)

  • Added binary v2 output (24-byte header + packed tiles/zones/doors/closeDoors sections)
  • Added full PNG overlay generation with 3 map sections:
    • Overworld (X=2300-3600, Z=2800-3600)
    • Dungeons (X=2240-3520, Z=9216-9984)
    • Wilderness Dungeons (X=1856-3072, Z=4608-4928)
  • Added large legend key panel with scaled font, color swatches, and stats
  • Added diagonal wall rendering (NW/NE/SE/SW) with perpendicular-offset thickness
  • Added pure JS PNG encoder (zlib deflate, no dependencies)
  • Output always overwrites sdk/collision-overlay.png

sdk/collision-data.json (data change)

  • Now includes closeDoors (104 entries) and wallLocs (94,441 entries) fields

sdk/collision-data.json.gz (data change)

  • Updated compressed version (2.8MB → 3.2MB due to new fields)

sdk/collision-data.bin (NEW — 6.96 MB)

  • Binary v2 format used by pathfinding.ts (replaces JSON loading)
  • 67.5% smaller than JSON, loads in <20ms vs ~260ms

sdk/collision-overlay.png (NEW — 1.1 MB)

  • Generated collision visualization with overworld, dungeons, wilderness dungeons, and legend

Test plan

  • Export script produces all 4 outputs (JSON, gzip, binary, PNG)
  • Pathfinding tests: 30/30 pass with binary loader
  • Close-doors: 104 default-open doors correctly walled
  • PNG overlay: 5700x7600 with all 3 map sections and legend key

🤖 Generated with Claude Code

@PapaBlooD PapaBlooD force-pushed the collision-v2-binary-overlay branch from d2e3962 to 263663f Compare February 11, 2026 22:06
…ation

Builds on the binary collision cache concept from PR MaxBittker#29 by grumpyowlbear.

- Migrate pathfinding from JSON to binary v2 format (18MB -> 7MB, 13x faster init)
- Add close-door detection (default-open doors that need wall collision added)
- Export endpoint now returns closeDoors and wallLocs for diagnostics
- Export script generates JSON, gzip, binary v2, and PNG overlay in one run
- PNG overlay includes overworld, dungeons, wilderness dungeons, and legend key

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@PapaBlooD PapaBlooD force-pushed the collision-v2-binary-overlay branch from 263663f to f9ba863 Compare February 11, 2026 22:10
@PapaBlooD PapaBlooD closed this Feb 11, 2026
@PapaBlooD
Copy link
Contributor Author

Wrong upload. Ignore.

@PapaBlooD PapaBlooD deleted the collision-v2-binary-overlay branch February 11, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant