master
Marc Gilleron 2019-05-04 00:00:50 +01:00
parent b24a0d4140
commit 9363f54e8d
2 changed files with 12 additions and 9 deletions

View File

@ -285,6 +285,8 @@ void VoxelTerrain::reset_updater() {
params.smooth_surface = _smooth_meshing_enabled;
_block_updater = memnew(VoxelMeshUpdater(_library, params));
// TODO Revert any pending update states!
}
inline int get_border_index(int x, int max) {
@ -447,6 +449,8 @@ void VoxelTerrain::make_area_dirty(Rect3i box) {
}
}
namespace {
struct EnterWorldAction {
World *world;
EnterWorldAction(World *w) :
@ -471,6 +475,8 @@ struct SetVisibilityAction {
}
};
} // namespace
void VoxelTerrain::_notification(int p_what) {
switch (p_what) {
@ -820,7 +826,6 @@ void VoxelTerrain::_process() {
CRASH_COND(surface.size() != Mesh::ARRAY_MAX);
mesh->add_surface_from_arrays(ob.blocky_surfaces.primitive_type, surface);
mesh->surface_set_material(surface_index, _materials[i]);
++surface_index;
}
@ -832,10 +837,8 @@ void VoxelTerrain::_process() {
}
CRASH_COND(surface.size() != Mesh::ARRAY_MAX);
// TODO Problem here, the mesher could be configured to output wireframe! Need to output some MeshData struct instead
mesh->add_surface_from_arrays(ob.smooth_surfaces.primitive_type, surface);
mesh->surface_set_material(surface_index, _materials[i]);
// No material supported yet
++surface_index;
}

View File

@ -14,17 +14,17 @@ class VoxelMap;
class VoxelLibrary;
// Infinite paged terrain made of voxel blocks.
// Voxels are polygonized around the viewer.
// Voxels are polygonized around the viewer by distance in a large cubic space.
// Data is streamed using a VoxelProvider.
class VoxelTerrain : public Spatial {
GDCLASS(VoxelTerrain, Spatial)
public:
enum BlockDirtyState {
BLOCK_NONE,
BLOCK_LOAD,
BLOCK_UPDATE_NOT_SENT,
BLOCK_UPDATE_SENT,
BLOCK_IDLE
BLOCK_NONE, // There is no block
BLOCK_LOAD, // The block is loading
BLOCK_UPDATE_NOT_SENT, // The block needs an update but wasn't sent yet
BLOCK_UPDATE_SENT, // The block needs an update which was sent
BLOCK_IDLE // The block is up to date
};
VoxelTerrain();