perf: SmallVec inline storage, TOML drop tables, seeded deterministic RNG

- SmallVec<[DropEntry; 2]> replaces Vec in DropTable: zero heap allocation for
  all current tiles (0 or 1 entries), spills to heap only at 3+
- DropEntry fields packed to u8 (chance_pct, min_count, max_count): ~12 bytes ->
  4 bytes; derives Copy so no extra clones
- Replaced SystemTime pseudo-RNG with dig_rng(pos): PCG-style hash of world SEED
  + tile position. Deterministic per world, same dig = same roll every time
- TOML-driven drop tables: assets/drop_tables.toml (grass=5%/1-2, rock=10%/1,
  dirt/air=none). TOML parsed at startup into DropTableRegistry resource
- OnceLock global map for async terrain generation tasks to access drop tables
  without Bevy resource borrowing
- terrain.rs: DropTableRegistry::global_get("tile") replaces hardcoded drop_table_for
This commit is contained in:
2026-03-21 16:06:41 +00:00
parent f03651e0cf
commit 5b563bad67
7 changed files with 124 additions and 59 deletions
+1
View File
@@ -14,6 +14,7 @@ serde = { version = "1.0", features = ["derive"] }
toml = "0.9.8"
rayon = "1.11.0"
rustc-hash = "2.1.1"
smallvec = { version = "1", features = ["union"] }
ahash = "0.8.12"
nohash-hasher = "0.2.0"
futures-lite = "2.6.1"