Skip to content
Krazer edited this page Aug 22, 2020 · 5 revisions

Some info on thoughts and internal workings

Voxigen is mainly built for the handling of Voxel data. There is a simple rendering system but it is used mainly for debugging purposes.

Voxigen is heavily templated with the size of both chunks and regions determined at compile time. The grid size however is a runtime option and although it is not infinite in size the worlds can easily be planet size.

Coordinates: voxigen assumes a world where X/Y are the planes of the terrain and Z is the height of the world. Data is stored X, Y Z ordering.

Main classes:

RegularGrid<typename _Cell, size_t _ChunkSizeX=64, size_t _ChunkSizeY=64, size_t _ChunkSizeZ=64, size_t _RegionSizeX=16, size_t _RegionSizeY=16, size_t _RegionSizeZ=16, bool _Thread=true>

  • _Cell - is a struct/class that the grid will use for each voxel
  • _ChunkSizeX
  • _ChunkSizeY - Compile time chunk size
  • _ChunkSizeZ
  • _RegionSizeX
  • _RegionSizeY - Compile time region size
  • _RegionSizeZ
  • _Thread - class will create its own load/read/write/generate thread

Threading: (see notes for more)

voxigen works with a rather simplistic threading system.

First off all status updates to chunks are handled in the main_thread, before a chunk is handed off to worker_thread is status is changed by the main thread and can not be given to another thread till the it is returned to the main thread.

All thread requests are queued into a local vector and a single lock per main_thread/worker_thread is taken and all the queued requests are passed. The worker_thread also queues all completed request and those request are passed back to the main thread under the same lock.

There is no per chunk locking, the thread safety is handled by the status field of each chunk and again only controlled from the main_thread

Current threads in operation

  • main_thread
    • rendering
    • texture and mesh upload
    • chunks status updates
  • io_thread
    • generating of chunks and regions
    • reading of chunks and regions
    • writing of chunks and regions
  • meshing_thread
    • meshing of chunks and regions

Active Volume

class ActiveVolume Is used to store information about what chunks are available around the player. As the player moves the active volume will load and unload chunks as needed.

Simple Renderer

class SimpleRenderer uses and ActiveVolume and renderer(Chunk and Region) to display chunk information around the player. It also handles the request for meshing and the upload of meshes to the gpu.

*note on mesh upload, mesh are requested for upload but are not immediately used as opengl does not have notifications for when the upload is complete. Therefore in order to get around possible stall issues the meshes are not used for at least 2 frames after the upload has been acknowledged by the driver. (see notes for more)

Generators

Currently there is only one generator available.

EquiRectWorldGenerator Generates a world map with an equirectangular mapping. It includes an influence map for the individual chunk and region generation. The influence map use a crude approximation of plate tectonics, weather patterns and temperature map to provide height, moisture and temperature information for the entire map.