Skip to content

feature: unbounded world size -- chunk-based worldgen limited by RAM, not menu slider #104

@abix-

Description

@abix-

Type

  • feature (architecture / worldgen)

Problem

World size is currently capped by a menu slider (8K-64K pixels). Players who want Factorio-style exploration are limited to a fixed boundary. The world should grow as the player explores, limited only by available RAM.

Design Direction

Replace the fixed-size world grid with a chunk-based system where terrain is generated on demand as entities or the camera move into unloaded regions.

Key Challenges

  1. WorldGrid: currently a flat Vec<WorldCell> sized at init. Needs chunk-based storage (HashMap<ChunkCoord, Chunk>) with lazy generation.
  2. GPU compute: spatial grid is a fixed 256x256 grid uploaded each frame. Needs viewport-relative or hierarchical approach.
  3. Pathfinding: HPA* cache assumes a fixed grid. Needs incremental chunk loading/unloading for the abstract graph.
  4. Tilemap rendering: Bevy tilemap chunks need dynamic load/unload based on camera position.
  5. EntityMap spatial buckets: currently sized for fixed world bounds. Needs dynamic resizing or chunk-aligned buckets.
  6. Save/load: must serialize only loaded chunks + entity positions. Unvisited chunks regenerate from seed.
  7. Town placement: raider towns need to spawn at appropriate distances as the player expands, not all at world init.

Factorio Parallels

  • Chunks generated on demand (16x16 tile chunks in Factorio)
  • Deterministic generation from world seed -- same seed = same terrain
  • Only active chunks (near players/entities) are simulated
  • Inactive chunks are frozen or unloaded

Scope Estimate

This is a multi-week architectural change touching nearly every system. Recommend breaking into slices:

  1. Chunk storage format + lazy terrain generation
  2. Camera-driven chunk loading/unloading
  3. Pathfinding adaptation (incremental HPA* rebuild)
  4. GPU buffer adaptation (viewport-relative spatial grid)
  5. Dynamic town/raider spawning at world edges
  6. Save/load for chunk-based worlds
  7. Remove world size slider, add seed input

Acceptance Criteria

  • World generates new terrain as camera/entities move beyond current bounds
  • No fixed world size limit (grows until RAM is exhausted)
  • Deterministic from seed (same seed = same world)
  • Pathfinding works across chunk boundaries
  • Save/load preserves explored chunks, regenerates unvisited from seed
  • Performance maintains 60 UPS at 50K NPCs within loaded chunk radius

Status

Waiting -- needs design discussion and slice planning before implementation begins.
This is a foundational architecture change, not a simple feature add.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew functionality, behavior changes, or larger feature workwaitingWaiting on a decision, dependency, or prerequisite

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions