config cleanup
This commit is contained in:
@@ -1,134 +0,0 @@
|
||||
# Session Summary: Data-Oriented Chunks Optimization
|
||||
|
||||
## Date: 2026-03-19
|
||||
|
||||
## Completed Work
|
||||
|
||||
### Phase 1-3 Optimization (Implemented over multiple sessions)
|
||||
1. **Bit-Packed Standability** - ChunkData with bitsets for O(1) pathfinding
|
||||
2. **Reactive Connectivity** - Dirty flag system for O(d) connectivity updates
|
||||
3. **Async Terrain Baking** - AsyncComputeTaskPool for terrain generation
|
||||
|
||||
### Recent Session Changes
|
||||
|
||||
1. **External Tile Registry** (`tiles.toml`)
|
||||
- Hot-reloadable tile definitions without recompiling
|
||||
- TileRegistry singleton for async-safe access
|
||||
- Configurable weights, IDs, standability flags
|
||||
|
||||
2. **Pathfinding Weight System**
|
||||
- Lower weight = preferred path (rock=50 best, bedrock=150 worst)
|
||||
- Movement speed affected by tile weight
|
||||
- `calculate_movement_cost(move_dir, tile_weight)` signature change
|
||||
|
||||
3. **Bug Fixes**
|
||||
- Fixed infinite spawner with `Local<bool>` state guards
|
||||
- Fixed `world_to_chunk` to use `CHUNK_SIZE_TILE` (128) not `CHUNK_SIZE` (8)
|
||||
- Fixed spawn coordinate grid alignment
|
||||
- Fixed standability logic (reverted to original)
|
||||
|
||||
4. **Standability Logic (Working Version)**
|
||||
```rust
|
||||
fn is_standable_slow(&self, pos: IVec3) -> bool {
|
||||
let can_stand_in_floor = self.floor_tiles.get(&pos)
|
||||
.map(|t| t.can_stand_in()).unwrap_or(false);
|
||||
let can_stand_in_fixture = self.fixture_tiles.get(&pos)
|
||||
.map(|t| t.can_stand_in()).unwrap_or(false);
|
||||
let pos_below = IVec3::new(pos.x, pos.y, pos.z - ITILE_SIZE);
|
||||
let can_stand_on_floor = self.floor_tiles.get(&pos_below)
|
||||
.map(|t| t.can_stand_on()).unwrap_or(false);
|
||||
let can_stand_on_fixture = self.fixture_tiles.get(&pos_below)
|
||||
.map(|t| t.can_stand_on()).unwrap_or(false);
|
||||
(can_stand_in_floor || can_stand_in_fixture)
|
||||
&& (can_stand_on_floor || can_stand_on_fixture)
|
||||
}
|
||||
```
|
||||
|
||||
## Current Bug: Zigzag Pathfinding
|
||||
|
||||
### Symptom
|
||||
Entities no longer walk in straight lines to their targets. Movement shows erratic zigzag behavior instead of direct paths.
|
||||
|
||||
### Working Hypothesis
|
||||
The zigzag behavior likely stems from:
|
||||
1. Path validation failing and paths being constantly regenerated
|
||||
2. Weight system causing cost calculation issues
|
||||
3. Movement speed modifier causing step recovery inconsistencies
|
||||
4. The tile weight being applied incorrectly in movement
|
||||
|
||||
### What Was Working Before Recent Changes
|
||||
- Straight-line pathfinding
|
||||
- Entities would walk directly to targets
|
||||
|
||||
### What Changed That Might Cause Zigzag
|
||||
- `calculate_movement_cost` now takes `tile_weight` parameter
|
||||
- Movement speed now varies by tile weight
|
||||
- `get_tile_weight()` retrieves weight from tilemap
|
||||
|
||||
### Relevant Code Locations
|
||||
- `src/entities/shared_systems/pathfinding.rs`
|
||||
- `calculate_movement_cost()` lines ~600
|
||||
- `get_tile_weight()` lines ~440
|
||||
- Movement system lines ~482
|
||||
- `src/world/tiles/tilemap.rs`
|
||||
- `get_astar_weight()` method
|
||||
- `tiles.toml`
|
||||
- Weight values: rock=50, grass=100, bedrock=150
|
||||
|
||||
---
|
||||
|
||||
# Next Agent Prompt
|
||||
|
||||
## Starting From Zero Context
|
||||
|
||||
You are investigating a zigzag pathfinding bug in a Bevy game engine project called "Dorf".
|
||||
|
||||
### Project Overview
|
||||
- Voxel-style game with procedural terrain generation
|
||||
- Pathfinding system with A* implementation
|
||||
- Tile-based world with gravity for entities
|
||||
- Coordinates: TILE_SIZE=16, ITILE_SIZE=16
|
||||
|
||||
### The Bug
|
||||
After recent commits, entities exhibit zigzag movement instead of walking in straight lines to their targets.
|
||||
|
||||
### Investigation Steps
|
||||
1. **Read the pathfinding system** (`src/entities/shared_systems/pathfinding.rs`)
|
||||
- Focus on `movement()` function (line ~482)
|
||||
- Focus on `calculate_movement_cost()` (line ~600)
|
||||
- Focus on path validation (`validate_next_steps()`)
|
||||
|
||||
2. **Understand the weight system**
|
||||
- How does `tile_weight` affect `calculate_movement_cost()`?
|
||||
- Does varying movement costs cause zigzag paths?
|
||||
|
||||
3. **Check movement speed modifier**
|
||||
- `threshold = walk_speed * (tile_weight / 50.0)`
|
||||
- Could this cause inconsistent stepping?
|
||||
|
||||
4. **Compare with git history**
|
||||
- Run `git log --oneline -10` to see recent commits
|
||||
- `git diff HEAD~1` to see last commit changes
|
||||
- Find when zigzag started by checking commits
|
||||
|
||||
5. **Hypothesize and test**
|
||||
- Disable weight system temporarily
|
||||
- Compare path cost calculations
|
||||
- Verify path validation is working
|
||||
|
||||
### Key Files
|
||||
- `src/entities/shared_systems/pathfinding.rs` - Main pathfinding logic
|
||||
- `src/entities/shared_components/ambulatory.rs` - Movement state
|
||||
- `src/world/tiles/tilemap.rs` - Tile lookups
|
||||
- `tiles.toml` - Tile weight definitions
|
||||
|
||||
### Expected Behavior
|
||||
Entities should walk in straight lines from start to goal when no obstacles.
|
||||
|
||||
### Actual Behavior
|
||||
Entities zigzag/wander instead of walking straight.
|
||||
|
||||
### Success Criteria
|
||||
- Entities walk in straight lines to targets
|
||||
- Path costs are consistent
|
||||
- No erratic movement behavior
|
||||
@@ -1,65 +0,0 @@
|
||||
# Last 48h Git Diff
|
||||
|
||||
## Commit: 9535d65 (HEAD)
|
||||
### Message: feat: data-oriented chunks optimization with tile registry
|
||||
|
||||
Files changed (14 files, +423 -84):
|
||||
|
||||
```
|
||||
tiles.toml | +186 (NEW)
|
||||
src/config.rs | +50
|
||||
src/entities/shared_systems/pathfinding.rs | +45 -4
|
||||
src/entities/shared_components/ambulatory.rs | +10 -10
|
||||
src/entities/livestock/pig.rs | +10 -2
|
||||
src/entities/livestock/rabbit.rs | +8
|
||||
src/entities/sentient/dorf.rs | +8
|
||||
src/game.rs | +12
|
||||
src/main.rs | +16 -16
|
||||
src/world/generation/terrain.rs | +123 -3
|
||||
src/world/mod.rs | +12
|
||||
src/world/tiles/chunk_data.rs | +21
|
||||
src/world/tiles/prefabs.rs | +85 -19
|
||||
src/world/tiles/tilemap.rs | +14
|
||||
```
|
||||
|
||||
### Key Changes:
|
||||
|
||||
#### 1. External Tile Registry (tiles.toml)
|
||||
- New `tiles.toml` for hot-reloadable tile definitions
|
||||
- Floor tiles: air, grass, dirt, rock, bedrock with weight/standability
|
||||
- Fixture tiles: walls, log, leaves
|
||||
- IDs, weights, can_stand_in, can_stand_on all configurable
|
||||
|
||||
#### 2. Config.rs additions
|
||||
- `TileRegistry` struct with `OnceLock` global singleton
|
||||
- `FloorTileDef` and `FixtureTileDef` structs
|
||||
- Loads from `tiles.toml` at first access
|
||||
- `global()` method for async-safe access
|
||||
|
||||
#### 3. Pathfinding.rs changes
|
||||
- `calculate_movement_cost(move_dir, tile_weight)` - now takes weight param
|
||||
- `get_tile_weight(tilemap, pos)` - retrieves weight from tile
|
||||
- Movement speed modifier: `threshold = walk_speed * (tile_weight / 50)`
|
||||
- `SpawnDelay` resource for delayed spawning
|
||||
|
||||
#### 4. Chunk data improvements
|
||||
- `ChunkData::is_standable()` bit-packed standability checks
|
||||
- `get_astar_weight()` method for pathfinding cost
|
||||
|
||||
#### 5. world_to_chunk fix
|
||||
- Changed from `CHUNK_SIZE` (8) to `CHUNK_SIZE_TILE` (128)
|
||||
|
||||
#### 6. Entity spawning fixes
|
||||
- `Local<bool>` state guards prevent infinite spawning
|
||||
- Grid-aligned spawn coordinates
|
||||
- Delayed spawning with `SpawnDelay` resource
|
||||
|
||||
---
|
||||
|
||||
## Commit: 50788af
|
||||
### Message: feat(optimization): implement data-oriented chunk architecture
|
||||
|
||||
Previous optimization phases:
|
||||
- ChunkData with bit-packed standability
|
||||
- Dirty chunk tracking for O(d) connectivity
|
||||
- Async terrain generation
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
# Floor tiles: IDs are used for texture lookup.
|
||||
# Weight: lower = faster to traverse (rock=50 is best, bedrock=150 is worst).
|
||||
# Weight: higher = slower to traverse (rock=50 is fastest, bedrock=150 is slowest).
|
||||
# Stand flags: can_stand_in (air pocket), can_stand_on (solid surface), transparent (see-through).
|
||||
|
||||
[floor_tiles.air]
|
||||
@@ -35,7 +35,7 @@ id = 4
|
||||
can_stand_in = false
|
||||
can_stand_on = true
|
||||
transparent = false
|
||||
astar_weight = 50
|
||||
astar_weight = 150
|
||||
|
||||
# Fixture tiles: walls and objects above floors.
|
||||
# IDs are relative to FIXTURE_ID_OFFSET (500000).
|
||||
|
||||
Reference in New Issue
Block a user