How renzaccio/3dsand works
3DSand is a desktop 3D falling-sand simulation. The main loop handles camera movement and user controls, advances and spawns voxel sand, refreshes visibility, then draws the scene and status UI. The world layer owns voxel storage, movement, visibility, and block counting; camera controls, UI widgets, and small coordinate/counter helpers support it. Raylib and its math/graphics headers provide the framework surface. Source excerpts show the main orchestration and key world behavior, but not every draw or statistics call, so uncertain links are omitted.
Main entry points: main.cpp Simulation loop · i3dspace.hpp Voxel world · raylib.h Raylib API · camera.hpp Camera controls
Components 11
Application loop
- Simulation loop
main.cpp
Voxel simulation
- Voxel world
i3dspace.hpp - Block types
blocks.hpp - Grid coordinates
i3dvector.hpp
Controls and UI
- Camera controls
camera.hpp - Button UI
ui.hpp - Layout counter
counter.hpp
Graphics framework
- Raylib API
include/raylib.h - Raymath
include/raymath.h - RLGL graphics
include/rlgl.h
Other components
- Player
Connections 13
- Player → Simulation loop: operates
main.cpp - Simulation loop → Camera controls: moves camera
main.cpp - Simulation loop → Voxel world: steps and spawns
main.cpp - Simulation loop → Button UI: checks buttons
main.cpp - Simulation loop → Layout counter: positions text
main.cpp - Simulation loop → Raylib API: draws and polls
main.cpp - Voxel world → Block types: uses block types
i3dspace.hpp - Voxel world → Grid coordinates: uses coordinates
i3dspace.hpp - Voxel world → Raylib API: draws voxels
i3dspace.hpp - Camera controls → Raylib API: reads input
camera.hpp - Camera controls → Raymath: uses vector math
camera.hpp - Button UI → Raylib API: draws and tests
ui.hpp - Grid coordinates → Raymath: uses math types
i3dvector.hpp