Skip to main content

VIVIA โ€” Architecture

Source Layout (as built โ€” matches Core/Src/ 1:1)โ€‹

Core/Src/
โ”œโ”€โ”€ main.rs # App loop, input, world/actor orchestration
โ”œโ”€โ”€ gameplay.rs # GameClock, PlayerStats, animals, enemies, achievements
โ”œโ”€โ”€ inventory.rs # Hotbar, inventory slots, stacking
โ”œโ”€โ”€ crafting.rs # RecipeRegistry โ€” shaped & shapeless recipes (NVCrafter)
โ”œโ”€โ”€ commands.rs # Chat commands (/tp, /give, /help, /ai_*)
โ”œโ”€โ”€ settings.rs # SharedSettings (render radius, low_end_pc, perf profiles)
โ”œโ”€โ”€ assets.rs # Asset loading
โ”œโ”€โ”€ input.rs # Keyboard/mouse state
โ”œโ”€โ”€ interaction.rs # Block place/break interactions
โ”œโ”€โ”€ egs.rs # Epic Online Services bridge (runtime-loaded, keyless)
โ”œโ”€โ”€ renderer/
โ”‚ โ”œโ”€โ”€ mod.rs # GPU pipeline, draw calls, world mesh cache
โ”‚ โ”œโ”€โ”€ camera.rs # First-person camera
โ”‚ โ”œโ”€โ”€ mesh.rs # Chunk meshing
โ”‚ โ”œโ”€โ”€ instance.rs # Instance buffer management
โ”‚ โ”œโ”€โ”€ texture_atlas.rs # Block texture atlas
โ”‚ โ”œโ”€โ”€ texture_registry.rs # blockname.png / *_side.png conventions
โ”‚ โ”œโ”€โ”€ dynamic_atlas.rs # Runtime atlas updates (AI textures)
โ”‚ โ”œโ”€โ”€ text.rs # Text rendering
โ”‚ โ”œโ”€โ”€ menu.rs # Main menu
โ”‚ โ””โ”€โ”€ *.wgsl # Shaders: terrain, sky, weather, animals, text, UI
โ””โ”€โ”€ world/
โ”œโ”€โ”€ mod.rs # World state, block access, spawn logic
โ”œโ”€โ”€ block.rs # BlockType registry (~124 types: hardness, tool tiers)
โ”œโ”€โ”€ chunk.rs # 16ร—512ร—16 chunk storage (CHUNK_H = 512)
โ”œโ”€โ”€ generator.rs # OpenSimplex2 terrain generation
โ”œโ”€โ”€ worldgen.rs # World generation orchestration
โ”œโ”€โ”€ biomes.rs # 9 climate-driven biomes (BiomeId)
โ”œโ”€โ”€ vegetation.rs # Tree/plant placement per biome
โ”œโ”€โ”€ decorations.rs # Decorative elements
โ”œโ”€โ”€ decoration_ai.rs # AI-driven decoration placement
โ”œโ”€โ”€ ai_generator.rs # MeMLP application to world generation
โ”œโ”€โ”€ ai_feedback.rs # Player preference learning
โ”œโ”€โ”€ memplp.rs # Modular MLP (VEGETATION/BIOME/TEXTURE archs)
โ”œโ”€โ”€ online_trainer.rs # Open-Meteo API training loop (8 cities)
โ”œโ”€โ”€ meteo.rs # Embedded NASA POWER climate grid + seasons
โ”œโ”€โ”€ liquid.rs # Water/lava simulation
โ”œโ”€โ”€ palette.rs # Block color palettes
โ”œโ”€โ”€ storage.rs # Block storage optimization
โ””โ”€โ”€ raycast.rs # Block raycasting

Data Flowโ€‹

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Seed โ†’ coord โ”‚โ”€โ”€โ”€โ–บโ”‚ NASA POWER โ”‚โ”€โ”€โ”€โ–บโ”‚ Biome table โ”‚
โ”‚ (Earth map) โ”‚ โ”‚ climatologyโ”‚ โ”‚ + weather โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ GPU upload โ”‚โ—„โ”€โ”€โ”€โ”‚ Chunk โ”‚โ—„โ”€โ”€โ”€โ”‚ OpenSimplex2โ”‚
โ”‚ (wgpu) โ”‚ โ”‚ meshing โ”‚ โ”‚ + MeMLP veg โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Chunk Lifecycleโ€‹

  1. Request โ€” player position triggers chunk generation requests
  2. Generate โ€” OpenSimplex2 heightmap + cave/ore placement (rayon-parallel)
  3. Decorate โ€” climate-driven vegetation, AI decoration placement
  4. Mesh + Upload โ€” chunk meshing, vertex/index buffers to GPU
  5. Render โ€” instanced draw calls per chunk
  6. Unload โ€” chunks beyond cleanup_radius are evicted

Block Registryโ€‹

~124 block types (BlockType), each with:

  • Hardness (hardness()) โ€” mining time
  • Tool tier (required_tool_tier()) โ€” wood โ†’ stone โ†’ iron โ†’ diamond
  • Display name โ€” inventory tooltip
  • Special interactions (Chest, NVCrafter, Cactus break-speed rules)

What is intentionally NOT here yetโ€‹

Multiplayer networking, quest system, spatial audio, GLB model pipeline and pathfinding are designed but not implemented โ€” see the roadmap on the index and the multiplayer protocol design page. This document describes only code that exists in the repository.