Remove usage of VoxelDataLoader from VoxelTerrain

master
Marc Gilleron 2020-08-26 19:49:30 +01:00
parent 57d306a033
commit d8a8936f34
2 changed files with 11 additions and 22 deletions

View File

@ -278,16 +278,15 @@ void VoxelTerrain::make_block_dirty(Vector3i bpos) {
namespace {
struct ScheduleSaveAction {
std::vector<VoxelDataLoader::InputBlock> &blocks_to_save;
std::vector<VoxelTerrain::BlockToSave> &blocks_to_save;
bool with_copy;
void operator()(VoxelBlock *block) {
if (block->is_modified()) {
//print_line(String("Scheduling save for block {0}").format(varray(block->position.to_vec3())));
VoxelDataLoader::InputBlock b;
b.data.voxels_to_save = with_copy ? block->voxels->duplicate() : block->voxels;
VoxelTerrain::BlockToSave b;
b.voxels = with_copy ? block->voxels->duplicate() : block->voxels;
b.position = block->position;
b.can_be_discarded = false;
blocks_to_save.push_back(b);
block->set_modified(false);
}
@ -320,9 +319,6 @@ void VoxelTerrain::save_all_modified_blocks(bool with_copy) {
Dictionary VoxelTerrain::get_statistics() const {
Dictionary d;
d["stream"] = VoxelDataLoader::Mgr::to_dictionary(_stats.stream);
d["updater"] = VoxelMeshUpdater::Mgr::to_dictionary(_stats.updater);
// Breakdown of time spent in _process
d["time_detect_required_blocks"] = _stats.time_detect_required_blocks;
d["time_request_blocks_to_load"] = _stats.time_request_blocks_to_load;
@ -686,9 +682,9 @@ void VoxelTerrain::send_block_data_requests() {
// Blocks to save
for (unsigned int i = 0; i < _blocks_to_save.size(); ++i) {
PRINT_VERBOSE(String("Requesting save of block {0}").format(varray(_blocks_to_save[i].position.to_vec3())));
const VoxelDataLoader::InputBlock ib = _blocks_to_save[i];
const BlockToSave b = _blocks_to_save[i];
// TODO Batch request
VoxelServer::get_singleton()->request_block_save(_volume_id, ib.data.voxels_to_save, ib.position, 0);
VoxelServer::get_singleton()->request_block_save(_volume_id, b.voxels, b.position, 0);
}
//print_line(String("Sending {0} block requests").format(varray(input.blocks_to_emerge.size())));
@ -880,10 +876,6 @@ void VoxelTerrain::_process() {
// Send mesh updates
{
VoxelMeshUpdater::Input input;
input.priority_position = viewer_block_pos;
input.priority_direction = viewer_direction;
unsigned int min_padding;
unsigned int max_padding;
VoxelServer::get_singleton()->get_min_max_block_padding(_volume_id, min_padding, max_padding);

View File

@ -3,17 +3,11 @@
#include "../server/voxel_server.h"
#include "../util/zprofiling.h"
#include "voxel_data_loader.h"
#include "voxel_map.h"
#include "voxel_mesh_updater.h"
#include <scene/3d/spatial.h>
class VoxelMap;
class VoxelLibrary;
class VoxelStream;
class VoxelTool;
class VoxelBlock;
// Infinite paged terrain made of voxel blocks all with the same level of detail.
// Voxels are polygonized around the viewer by distance in a large cubic space.
@ -62,8 +56,6 @@ public:
void restart_stream();
struct Stats {
VoxelMeshUpdater::Stats updater;
VoxelDataLoader::Stats stream;
int updated_blocks = 0;
int dropped_block_loads = 0;
int dropped_block_meshs = 0;
@ -74,6 +66,11 @@ public:
uint64_t time_process_update_responses = 0;
};
struct BlockToSave {
Ref<VoxelBuffer> voxels;
Vector3i position;
};
protected:
void _notification(int p_what);
@ -130,7 +127,7 @@ private:
Vector<Vector3i> _blocks_pending_load;
Vector<Vector3i> _blocks_pending_update;
std::vector<VoxelDataLoader::InputBlock> _blocks_to_save;
std::vector<BlockToSave> _blocks_to_save;
Ref<VoxelStream> _stream;