VoxelStream¶
Inherits: Resource
Inherited by: VoxelStreamMemory, VoxelStreamRegionFiles, VoxelStreamSQLite, VoxelStreamScript
Implements loading and saving voxel blocks, mainly using files.
Properties:¶
| Type | Name | Default |
|---|---|---|
| Compression | compression_mode | COMPRESSION_LZ4 (1) |
| bool | save_generator_output | false |
Methods:¶
| Return | Signature |
|---|---|
| void | flush ( ) |
| Vector3 | get_block_size ( ) const |
| int | get_used_channels_mask ( ) const |
| ResultCode | load_voxel_block ( VoxelBuffer out_buffer, Vector3i block_position, int lod_index ) |
| void | save_voxel_block ( VoxelBuffer buffer, Vector3i block_position, int lod_index ) |
Enumerations:¶
enum ResultCode:
- RESULT_ERROR = 0 --- An error occurred when loading the block. The request will be aborted.
- RESULT_BLOCK_FOUND = 2 --- The block was found.
- RESULT_BLOCK_NOT_FOUND = 1 --- The block was not found. The requester may fallback on using the generator, if any.
Property Descriptions¶
Compression compression_mode = COMPRESSION_LZ4 (1)¶
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.
bool save_generator_output = false¶
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.
Method Descriptions¶
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.save_modified_blocks or VoxelLodTerrain.save_modified_blocks.
Vector3 get_block_size( )¶
(This method has no documentation)
int get_used_channels_mask( )¶
(This method has no documentation)
ResultCode load_voxel_block( VoxelBuffer out_buffer, Vector3i block_position, int lod_index )¶
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.
void save_voxel_block( VoxelBuffer buffer, Vector3i block_position, int lod_index )¶
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.
Generated on Jan 26, 2026