Open Zylann opened 4 years ago
_on_block_loaded
would have to be fired from inside VoxelTerrain
's _process()
right? Somewhere around:
https://github.com/Zylann/godot_voxel/blob/aa2300866d6147e3f9e85cc8820f063877e6c686/terrain/voxel_terrain.cpp#L802-L807
Somewhere in process after being setup, yes. Careful though, because it only means data has been loaded. The block might not even be visible yet. Depends what you would be fine with. In the case of VoxelLodTerrain
it may be also more complex due to LOD switches.
Just pushed an implementation of the feature for VoxelTerrain
, see 7316e415dc82a3b33f07af5c9336a5a01553315d
It may be a common use case to procedurally spawn regular nodes on top of a voxel terrain. The problem is, it's currently not obvious to know when to do so. The terrain is dynamically loading and streaming, so blocks may be there or not, at various LODs, it's not easy to know.
The idea is to introduce a new signal, or new virtual functions, which will be called each time a block is loaded, or unloaded.
You would then be allowed to access voxels within this block at this LOD level, and use them to spawn nodes. This comes in combination with #98, where you could use metadata produced by the world generator to spawn the nodes that actually represent them. Because it relates to the scene tree, this would be a main thread event. Also, due to the frequency at which such events occur, you would be able to select which LODs you actually want to monitor (always 0 if you use a fixed level of detail).
This may also be used to resume voxel simulation such as fluids or redstone-like circuits.