Skip to content

feat: add TileMap2D support with multi-layer editing and physics collisions - #20

Open
mkh-user wants to merge 1 commit into
mainfrom
feat/tilemap-support
Open

mkh-user wants to merge 1 commit into
mainfrom
feat/tilemap-support

Conversation

@mkh-user

@mkh-user mkh-user commented Nov 5, 2026

Copy link
Copy Markdown
Member

Summary

This PR adds first-class 2D tilemap support to Pite via the TileMap2D node type, backed by an external .ptmap TOML specification, greedy 2D rectangle collider merging with Rapier2D static bodies, frustum-culled rendering, embedded Python scripting, asset verification, and interactive editor tools.

Key Changes

  • Core (pite-core): Registered "TileMap2D" in NodeTypeRegistry.
  • Scene (pite-scene): Added tilemap module with TileMapDoc, TileMapLayer, and TileCell schemas (sparse [col, row, "frame"]), coordinate conversion helpers (world_to_map, map_to_world), and canonical TOML serialization (load_tilemap, save_tilemap).
  • Physics (pite-physics): Implemented greedy 2D rectangle merger (merge_tile_cells) to eliminate internal edge snagging for character controllers (move_and_slide()), and added add_tilemap_colliders in PhysicsWorld.
  • Runtime (pite-runtime): Added .ptmap loading, hot-reloading on file change, static collider building in rebuild_physics, and frustum-culled batch sprite rendering in draw_into.
  • Scripting (pite-script): Implemented pite.TileMap2D Python class exposing cell query/mutations (get_cell, set_cell, erase_cell, clear), coordinate mapping (world_to_map, map_to_world), layer introspection (layers, get_used_cells), and tile_size.
  • Asset Checking (pite-cli): Extended pite check to validate TileMap2D node properties, ensuring referenced .ptmap files, atlas sheets, and tile frame names exist.
  • Editor (pite-editor): Added inspector panel with active layer selector, collision toggles, brush/eraser tool buttons, and atlas tile palette; added viewport snapped grid hover preview and left-click paint / right-click erase with auto-saving.
  • Documentation (docs/): Documented the .ptmap schema in scene-format.md, Python API in scripting-api.md, and editing workflows in editor.md.

Verification

  • cargo fmt --all -- --check: Passed with no formatting diffs.
  • cargo build --workspace --locked: Built with zero errors.
  • cargo test --workspace --locked: 100% test suite passing across all workspace crates.
  • cargo run --locked -p pite -- check: Passed on examples/minimal-2d.

…isions

- Register TileMap2D node in pite-core.
- Add .ptmap TOML schema, coordinate math, and serialization in pite-scene.
- Implement greedy 2D rectangle collider merger and Rapier2D static bodies in pite-physics.
- Add frustum-culled rendering, hot reload, and collision loading in pite-runtime.
- Implement Python scripting API (pite.TileMap2D) in pite-script.
- Add tilemap validation and atlas frame usage verification to pite check in pite-cli.
- Add interactive tile palette, layer switcher, and viewport painting/erasing in pite-editor.
- Update documentation in docs/scene-format.md, docs/scripting-api.md, and docs/editor.md.
- Add unit and integration tests across crates.

Signed-off-by: Mahan Khalili <khalili1388mahan@gmail.com>
@mkh-user
mkh-user force-pushed the feat/tilemap-support branch from b10eb53 to 6217f05 Compare November 5, 2026 11:54
@mkh-user
mkh-user force-pushed the main branch 11 times, most recently from b7a3248 to 9d909ae Compare November 5, 2026 18:20
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