User Tools

Site Tools


editing_voxels

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
editing_voxels [2018/01/25 12:25]
gobrosse
editing_voxels [2018/02/10 23:52]
gobrosse
Line 1: Line 1:
 ====== Programming::​Editing Voxel Data ====== ====== Programming::​Editing Voxel Data ======
 +
 +===== Voxel Data Storage =====
 +
 +Chunk Stories makes use of a hierarchical model for it's voxel storage. A **World** contains many Regions, a **Region** is made out of 8x8x8 **Chunk**s, themselves made out of 32x32x32 **Cell**s. Cells are what voxels are stored in. The **Voxel** class in the codebase actually refers to the idea of voxel **type**, be aware of that !
 +
 +The base CellData interface exposes two things:
 +
 + * A Location, ie a 4-uple (world, x, y, z)
 + * The data associated with this location ( [[mod_generalities#​voxeldatastorage|more detail here]] )
 +   * The voxel type: an instance of the '​Voxel.class'​ class.
 +   * Two 4-bit nibbles : sunlight and blocklight, representing the voxel flood-fill lightning values
 +   * A byte (8 bits) of metadata
 +
 +It is recommanded to use Cells rather than directly using '​raw'​ cell data and unstable voxel ids.
 +
 +  * CellData: base interface.
 +    * WorldCell: Associated with a real World, getWorld() guaranteed not to return null. If corresponding chunks are loaded, getNeighbor functions will work.
 +       * ChunkCell: Associated with a real, loaded chunk. ​
 +
 +    * EditableCell:​ Additional interface editing the voxel data it represents
 +      * FutureCell: Describes future changes you wish to make to a cell
 +      * DummyCell: Describe a voxel cell outside of any real world (without context if you will)
 +
 +
 +===== Peek types and what they mean =====
 +
 +| Name | Arguments | Return | Throws Exceptions |
 +| world.peek() | int x, int y, int z | ChunkCell | Yes |
 +| world.peek() | Vector3dc location | ChunkCell | Yes |
 +| world.peekSafely() | int x, int y, int z | WorldCell| No |
 +| world.peekSafely() | Vector3dc location | WorldCell| No |
 +| world.peekSimple() | int x, int y, int z | Voxel | No |
 +| world.peekRaw() | int x, int y, int z | int | No |
 +| chunk.peek() | int x, int y, int z | ChunkCell | No |
 +| chunk.peek() | Vector3dc location | ChunkCell | No|
 +| chunk.peekSimple() | int x, int y, int z | Voxel | No |
 +| chunk.peekRaw() | int x, int y, int z | int | No |
  
 ===== Poke types and what they mean ===== ===== Poke types and what they mean =====
  
-| Name | Arguments | Return | Causes ​Updates | Throws Exceptions | +| Name | Arguments | Return | Triggers ​Updates | Throws Exceptions | 
-| poke() | x, y, z, voxel, sunlight, blocklight, metadata, cause | VoxelContext ​| Yes | Yes | +world.poke() | x, y, z, voxel, sunlight, blocklight, metadata, cause | CellData ​| Yes | Yes | 
-| poke() | futureVoxelContext, cause | VoxelContext ​| Yes | Yes | +world.poke() | futureCell, cause | CellData ​| Yes | Yes | 
-| pokeSimple() | x, y, z, voxel, sunlight, blocklight, metadata | void | Yes | No |+world.pokeSimple() | x, y, z, voxel, sunlight, blocklight, metadata | void | Yes | No | 
 +| world.pokeSimple() | futureCell | void | Yes | No | 
 +| world.pokeSimpleSilently() | x, y, z, voxel, sunlight, blocklight, metadata | void | No| No | 
 +| world.pokeSimpleSilently() | futureCell | void | No| No | 
 +| world.pokeRaw() | x, y, z, raw\_data\_bits | void | Yes | No | 
 +| world.pokeRawSilently() | x, y, z, raw\_data\_bits | void | No | No | 
 +| chunk.poke() | x, y, z, voxel, sunlight, blocklight, metadata, cause | CellData | Yes | Yes| 
 +| chunk.pokeSimple() | x, y, z, voxel, sunlight, blocklight, metadata | void | Yes | No | 
 +| chunk.pokeSimpleSilently() | x, y, z, voxel, sunlight, blocklight, metadata | void | No| No | 
 +| chunk.pokeRaw() | x, y, z, raw\_data\_bits | void | Yes | No | 
 +| chunk.pokeRawSilently() | x, y, z, raw\_data\_bits | void | No | No |
editing_voxels.txt · Last modified: 2018/02/10 23:52 by gobrosse