VoxelStream
Implements loading and saving voxel blocks, mainly using files.
Implements loading and saving voxel blocks, mainly using files.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties2
CompressionModeProperty
public VoxelBlockSerializer.Compression CompressionMode { get; set; }Specifies which compression algorithm is used when saving blocks. This can reduce the size of save files at the cost of save/load performance. Existing blocks that formerly used a different compression mode can still be loaded, and will use the new mode if saved again.
SaveGeneratorOutputProperty
public bool SaveGeneratorOutput { get; set; }When this is enabled, if a block cannot be found in the stream and it gets generated, then the generated block will immediately be saved into the stream. This can be used if the generator is too expensive to run on the fly (like Minecraft does), but it will require more disk usage (amount of I/Os and space) and increase network traffic. If this setting is off, only modified blocks will be saved.
Methods9
Flushvoid
public void Flush();Forces cached data to be saved to the filesystem. Some streams might use a cache to improve performance of frequent I/Os.
This should not be called frequently if performance is a concern. May be used if you require all data to be written now. Note that implementations should already do this automatically when the resource is destroyed or their configuration changes. Some implementations may do nothing if they have no cache.
Note that terrains save asynchronously, so flushing might not always fulfill your goal if saving tasks are still queued and haven't called into VoxelStream yet. See VoxelTerrain.SaveModifiedBlocks or VoxelLodTerrain.SaveModifiedBlocks.
GetBlockSizeVector3
public Vector3 GetBlockSize();Vector3GetCompressionModeVoxelBlockSerializer.Compression
public VoxelBlockSerializer.Compression GetCompressionMode();VoxelBlockSerializer.CompressionGetSaveGeneratorOutputbool
public bool GetSaveGeneratorOutput();boolGetUsedChannelsMaskint
public int GetUsedChannelsMask();intLoadVoxelBlockVoxelStream.ResultCode
public VoxelStream.ResultCode LoadVoxelBlock(VoxelBuffer outBuffer, Vector3I blockPosition, int lodIndex);out_buffer: Block of voxels to load. Must be a pre-created instance (not null).
block_position: Position of the block in block coordinates within the specified LOD.
| Name | Type | Default |
|---|---|---|
outBuffer | VoxelBuffer | — |
blockPosition | Vector3I | — |
lodIndex | int | — |
VoxelStream.ResultCodeSaveVoxelBlockvoid
public void SaveVoxelBlock(VoxelBuffer buffer, Vector3I blockPosition, int lodIndex);buffer: Block of voxels to save. It is strongly recommended to not keep a reference to that data afterward, because streams are allowed to cache it, and saved data must represent either snapshots (copies) or last references to the data after the volume they belonged to is destroyed.
block_position: Position of the block in block coordinates within the specified LOD.
| Name | Type | Default |
|---|---|---|
buffer | VoxelBuffer | — |
blockPosition | Vector3I | — |
lodIndex | int | — |
SetCompressionModevoid
public void SetCompressionMode(VoxelBlockSerializer.Compression mode);| Name | Type | Default |
|---|---|---|
mode | VoxelBlockSerializer.Compression | — |
SetSaveGeneratorOutputvoid
public void SetSaveGeneratorOutput(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
VoxelStream.ResultCode
| Value | Description |
|---|---|
BlockFound = 2 | The block was found. |
BlockNotFound = 1 | The block was not found. The requester may fallback on using the generator, if any. |
Error = 0 | An error occurred when loading the block. The request will be aborted. |