docs: update README with collision, tile events, rabbit dig, visibility notes

- Add Stage 2 collision section documenting convoy / head-on / E/S yield / W/N right-of-way
- Add TileChangedEvent + path invalidation section
- Add Rabbit digging to implemented list
- Add visibility raycast note (absent tiles in loaded chunks = air)
- Remove stale warning count from build instructions
This commit is contained in:
2026-03-21 15:23:11 +00:00
parent 9d2f41faed
commit 1a170ea9a9
+20 -9
View File
@@ -9,18 +9,18 @@ This is an **engine foundation**, not a complete game. Many features (crafting,
``` ```
src/ src/
├── camera.rs # Panning camera, z-level control (Q/E, scroll) ├── camera.rs # Panning camera, z-level control (Q/E, scroll)
├── config.rs # GameConfig resource ├── config.rs # GameConfig, TileRegistry resources
├── constants.rs # Tile size, pathfinding constants ├── constants.rs # Tile size, pathfinding constants
├── entities/ # Dorfs, pigs, rabbits — ambulatory entities ├── entities/ # Dorfs, pigs, rabbits — ambulatory entities
│ ├── sentient/ │ ├── sentient/
│ ├── livestock/ │ ├── livestock/
│ └── shared_*/ # Ambulatory, pathfinding systems │ └── shared_*/ # Ambulatory, pathfinding, occupancy systems
├── game.rs # ZIndex resource, frame timing ├── game.rs # ZIndex resource, frame timing
├── main.rs # Bevy app bootstrap ├── main.rs # Bevy app bootstrap
└── world/ └── world/
├── chunks/ # ChunkMap, chunk loading/unloading, connectivity ├── chunks/ # ChunkMap, chunk loading/unloading, connectivity
├── generation/ # Terrain blobs, forestry, foliage (stub), fauna (stub) ├── generation/ # Terrain blobs, forestry, foliage (stub), fauna (stub)
└── tiles/ # TileMap, TileRegistry, rendering, visibility └── tiles/ # TileMap, TileRegistry, rendering, visibility, tile change events
``` ```
### Chunk Architecture ### Chunk Architecture
@@ -33,7 +33,7 @@ src/
### Rendering Pipeline ### Rendering Pipeline
1. `handle_tile_occlusion_updates` — raycasts from each tile upward to compute `visible_range` bitmask (which z-levels can see it) 1. `handle_tile_occlusion_updates` — raycasts from each tile upward to compute `visible_range` bitmask (which z-levels can see it). Tiles in loaded chunks with no floor entry are treated as air (open space).
2. `build_quilted_terrain_sprites` — GPU bake: tiles bucketed by `(render_chunk, z_level)`, blitted into pooled pixel buffers, spawned as `TerrainSprite` entities 2. `build_quilted_terrain_sprites` — GPU bake: tiles bucketed by `(render_chunk, z_level)`, blitted into pooled pixel buffers, spawned as `TerrainSprite` entities
3. `update_tile_visibility` — toggles `Visibility` on sprites based on current `ZIndex` (camera z-level) 3. `update_tile_visibility` — toggles `Visibility` on sprites based on current `ZIndex` (camera z-level)
@@ -44,8 +44,16 @@ Three tiers, gated by distance:
- **Tier 2** (48 chunks): provisional path + full path via async queue - **Tier 2** (48 chunks): provisional path + full path via async queue
- **Tier 3** (>8 chunks): hierarchical chunk graph → async segmented A* - **Tier 3** (>8 chunks): hierarchical chunk graph → async segmented A*
**Stage 2 Collision** — when two entities target the same tile, the movement system resolves in four cases:
- **Convoy**: entity ahead moves in ~same direction → follow-through, no avoidance
- **Head-on**: dot product < 0.7 → both yield left (existing sidestep chain)
- **E/S yield**: entity moving east or south → sidestep chain first, excuse-me on failure
- **W/N right-of-way**: entity moving west or north → advance with excuse-me delay
`PathfindingBenchmark` resource tracks sync vs async performance per frame. `PathfindingBenchmark` resource tracks sync vs async performance per frame.
**Tile Change Invalidation**`TileChangedEvent` fires whenever a tile's standability changes at runtime. `PathfindingDirtyChunks` collects affected chunk positions; `invalidate_paths_on_tile_change` clears paths for entities stepping through changed chunks within 8 steps.
### Entity Indexing ### Entity Indexing
Static terrain entities (floor tiles, fixtures, trees) are indexed in `chunk_entity_index: HashMap<IVec2, Vec<Entity>>` at spawn time. When a chunk unloads, the index is retrieved and entities are despawned. This is **O(entities in chunk)**, not O(total entities). Static terrain entities (floor tiles, fixtures, trees) are indexed in `chunk_entity_index: HashMap<IVec2, Vec<Entity>>` at spawn time. When a chunk unloads, the index is retrieved and entities are despawned. This is **O(entities in chunk)**, not O(total entities).
@@ -67,7 +75,7 @@ Mobile entities (dorfs, pigs, rabbits) are **not** in `chunk_entity_index`. They
- `initial_chunk_radius`: chunks loaded around origin at startup (default: 7 → 15×15 = 225 chunks) - `initial_chunk_radius`: chunks loaded around origin at startup (default: 7 → 15×15 = 225 chunks)
- `spawn_counts`: dorfs, pigs, rabbits spawned at game start - `spawn_counts`: dorfs, pigs, rabbits spawned at game start
`tiles.toml`: tile registry — floor tiles, fixture tiles. Each tile has `id`, `astar_weight`, `can_stand_in`, `can_stand_on`, `transparent` flags. `tiles.toml`: tile registry — floor tiles, fixture tiles. Each floor tile has `id`, `astar_weight`, `can_stand_in`, `can_stand_on`, `transparent` flags.
## Status ## Status
@@ -76,7 +84,7 @@ Mobile entities (dorfs, pigs, rabbits) are **not** in `chunk_entity_index`. They
- [x] Tile registry (`tiles.toml`) with A* weights - [x] Tile registry (`tiles.toml`) with A* weights
- [x] Floor tiles, fixture tiles, item tiles - [x] Floor tiles, fixture tiles, item tiles
- [x] Z-levels with quilted GPU sprite rendering - [x] Z-levels with quilted GPU sprite rendering
- [x] Tile occlusion / visibility raycasting - [x] Tile occlusion / visibility raycasting (treats absent tiles in loaded chunks as air)
- [x] Forestry: tree trunks + leaves spawned per chunk - [x] Forestry: tree trunks + leaves spawned per chunk
- [x] Dorfs, pigs, rabbits spawning at startup - [x] Dorfs, pigs, rabbits spawning at startup
- [x] Hierarchical async pathfinding (3 tiers) - [x] Hierarchical async pathfinding (3 tiers)
@@ -85,6 +93,9 @@ Mobile entities (dorfs, pigs, rabbits) are **not** in `chunk_entity_index`. They
- [x] Camera panning + z-level control - [x] Camera panning + z-level control
- [x] GPU texture pooling (pixel buffer reuse across bakes) - [x] GPU texture pooling (pixel buffer reuse across bakes)
- [x] Render chunk dirty-tracking for incremental rebakes - [x] Render chunk dirty-tracking for incremental rebakes
- [x] Stage 2 collision resolution (convoy, E/S yield, W/N right-of-way)
- [x] TileChangedEvent + path invalidation on tile change
- [x] Rabbit digging (debug) — removes floor tile, replaces with air, fires occlusion + path invalidation
### Stubs (exist as empty functions, wired into schedules) ### Stubs (exist as empty functions, wired into schedules)
- [ ] Foliage generation per chunk (`generate_chunk_foliage`) - [ ] Foliage generation per chunk (`generate_chunk_foliage`)
@@ -95,18 +106,18 @@ Mobile entities (dorfs, pigs, rabbits) are **not** in `chunk_entity_index`. They
- [ ] Crafting, stockpiles, resource gathering - [ ] Crafting, stockpiles, resource gathering
- [ ] Needs, mood, stress systems - [ ] Needs, mood, stress systems
- [ ] Job assignment and task automation - [ ] Job assignment and task automation
- [ ] Building and construction (digging/mining) - [ ] Building and construction (beyond debug rabbit digging)
- [ ] Combat and squad management - [ ] Combat and squad management
- [ ] Item persistence and inventory - [ ] Item persistence and inventory
- [ ] Dynamic chunk loading (player/NPC-centered, not just radius-at-startup)
- [ ] Save/load world state - [ ] Save/load world state
- [ ] World history and procedural storytelling - [ ] World history and procedural storytelling
- [ ] UI (menus, z-level overlay, workshop assignment) - [ ] UI (menus, z-level overlay, workshop assignment)
- [ ] Dynamic chunk loading (player/NPC-centered, not just radius-at-startup)
## Building ## Building
```sh ```sh
cargo build # dev profile, ~1.2K warnings (pre-existing) cargo build # dev profile
cargo run # dev mode cargo run # dev mode
``` ```