VoxelTerrain¶
Inherits: VoxelNode
Voxel volume using constant level of detail.
Properties:¶
Type | Name | Default |
---|---|---|
bool | area_edit_notification_enabled | false |
bool | automatic_loading_enabled | true |
bool | block_enter_notification_enabled | false |
AABB | bounds | AABB(-5.36871e+08, -5.36871e+08, -5.36871e+08, 1.07374e+09, 1.07374e+09, 1.07374e+09) |
int | collision_layer | 1 |
float | collision_margin | 0.04 |
int | collision_mask | 1 |
bool | debug_draw_enabled | false |
bool | debug_draw_volume_bounds | false |
bool | generate_collisions | true |
Material | material_override | |
int | max_view_distance | 128 |
int | mesh_block_size | 16 |
bool | run_stream_in_editor | true |
bool | use_gpu_generation | false |
Methods:¶
Return | Signature |
---|---|
void | _on_area_edited ( Vector3i area_origin, Vector3i area_size ) virtual |
void | _on_data_block_entered ( VoxelDataBlockEnterInfo info ) virtual |
Vector3i | data_block_to_voxel ( Vector3i block_pos ) const |
bool | debug_get_draw_flag ( int flag_index ) const |
void | debug_set_draw_flag ( int flag_index, bool enabled ) |
int | get_data_block_size ( ) const |
Dictionary | get_statistics ( ) const |
PackedInt32Array | get_viewer_network_peer_ids_in_area ( Vector3i area_origin, Vector3i area_size ) const |
VoxelTool | get_voxel_tool ( ) |
bool | has_data_block ( Vector3i block_position ) const |
bool | is_area_meshed ( AABB area_in_voxels ) const |
void | save_block ( Vector3i position ) |
VoxelSaveCompletionTracker | save_modified_blocks ( ) |
bool | try_set_block_data ( Vector3i position, VoxelBuffer voxels ) |
Vector3i | voxel_to_data_block ( Vector3 voxel_pos ) const |
Signals:¶
block_loaded( Vector3i position )¶
Emitted when a new data block is loaded from stream. This can happen before the mesh or collider becomes available.
block_unloaded( Vector3i position )¶
Emitted when a data block is unloaded due to being outside view distance.
mesh_block_entered( Vector3i position )¶
Emitted when a mesh block receives its first update since it was added in the range of viewers. This is regardless of the mesh being empty or not. It tracks changes of the same state obtained with VoxelTerrain.is_area_meshed.
mesh_block_exited( Vector3i position )¶
Emitted when a mesh block gets unloaded. It is the counterpart of VoxelTerrain.mesh_block_entered.
Enumerations:¶
enum DebugDrawFlag:
- DEBUG_DRAW_VOLUME_BOUNDS = 0
- DEBUG_DRAW_FLAGS_COUNT = 1
Property Descriptions¶
bool area_edit_notification_enabled = false¶
(This property has no documentation)
bool automatic_loading_enabled = true¶
If turned off, the terrain will no longer automatically load blocks around viewers locally. This may be used in multiplayer scenarios, when the terrain is client-side, because blocks will be sent by the server instead.
bool block_enter_notification_enabled = false¶
(This property has no documentation)
AABB bounds = AABB(-5.36871e+08, -5.36871e+08, -5.36871e+08, 1.07374e+09, 1.07374e+09, 1.07374e+09)¶
Defines the bounds within which the terrain is allowed to have voxels. If an infinite world generator is used, blocks will only generate within this region. Everything outside will be left empty.
int collision_layer = 1¶
(This property has no documentation)
float collision_margin = 0.04¶
(This property has no documentation)
int collision_mask = 1¶
(This property has no documentation)
bool debug_draw_enabled = false¶
(This property has no documentation)
bool debug_draw_volume_bounds = false¶
(This property has no documentation)
bool generate_collisions = true¶
Enables the generation of collision shapes using the classic physics engine. Use this feature if you need realistic or non-trivial collisions or physics.
Note 1: you also need VoxelViewer to request collisions, otherwise they won't generate.
Note 2: If you need simple Minecraft/AABB physics, you can use VoxelBoxMover which may perform better in blocky worlds.
Material material_override¶
(This property has no documentation)
int max_view_distance = 128¶
Sets the maximum distance this terrain can support. If a VoxelViewer requests more, it will be clamped.
Note: there is an internal limit of 512 for constant LOD terrains, because going further can affect performance and memory very badly at the moment.
int mesh_block_size = 16¶
(This property has no documentation)
bool run_stream_in_editor = true¶
Makes the terrain appear in the editor.
Important: this option will turn off automatically if you setup a script world generator. Modifying scripts while they are in use by threads causes undefined behaviors. You can still turn on this option if you need a preview, but it is strongly advised to turn it back off and wait until all generation has finished before you edit the script again.
bool use_gpu_generation = false¶
Enables GPU block generation, which can speed it up. This is only valid for generators that support it. Vulkan is required.
Method Descriptions¶
void _on_area_edited( Vector3i area_origin, Vector3i area_size )¶
(This method has no documentation)
void _on_data_block_entered( VoxelDataBlockEnterInfo info )¶
(This method has no documentation)
Vector3i data_block_to_voxel( Vector3i block_pos )¶
Converts data block coordinates into voxel coordinates. Voxel coordinates of a block correspond to its lowest corner.
bool debug_get_draw_flag( int flag_index )¶
(This method has no documentation)
void debug_set_draw_flag( int flag_index, bool enabled )¶
(This method has no documentation)
int get_data_block_size( )¶
(This method has no documentation)
Dictionary get_statistics( )¶
Gets debug information about how much time is spent processing the terrain.
The returned dictionary has the following structure:
{
"time_detect_required_blocks": int,
"time_request_blocks_to_load": int,
"time_process_load_responses": int,
"time_request_blocks_to_update": int,
"time_process_update_responses": int,
"remaining_main_thread_blocks": int,
"dropped_block_loads": int,
"dropped_block_meshs": int,
"updated_blocks": int
}
PackedInt32Array get_viewer_network_peer_ids_in_area( Vector3i area_origin, Vector3i area_size )¶
(This method has no documentation)
VoxelTool get_voxel_tool( )¶
Creates an instance of VoxelTool bound to this node, to access voxels and edition methods.
You can keep it in a member variable to avoid creating one again, as long as the node still exists.
bool has_data_block( Vector3i block_position )¶
(This method has no documentation)
bool is_area_meshed( AABB area_in_voxels )¶
Returns true if the area has been processed by meshing. It does not mean the area actually contains a mesh.
Returns false if the area has not been processed by meshing (therefore it is unknown whethere there should be a mesh here or not).
When streaming terrain, this can be used to determine if an area has fully "loaded", in case the game relies meshes or mesh colliders.
void save_block( Vector3i position )¶
Forces a specific block to be saved.
Note 1: all modified blocks are automatically saved before the terrain is destroyed.
Note 2: this will only have an effect if the stream setup on this terrain supports saving.
Note 3: saving is asynchronous and won't block the game. the save may complete only a short time after you call this method.
VoxelSaveCompletionTracker save_modified_blocks( )¶
Forces all modified blocks to be saved.
Note 1: all modified blocks are automatically saved before the terrain is destroyed.
Note 2: this will only have an effect if the stream setup on this terrain supports saving.
Note 3: saving is asynchronous and won't block the game. the save may complete only a short time after you call this method.
Use the returned tracker object to know when saving has completed. However, saves occurring after calling this method won't be tracked by this object.
Note that blocks getting unloaded as the viewer moves around can also trigger saving tasks, independently from this function.
bool try_set_block_data( Vector3i position, VoxelBuffer voxels )¶
(This method has no documentation)
Vector3i voxel_to_data_block( Vector3 voxel_pos )¶
(This method has no documentation)
Generated on Apr 06, 2024