Remove usage of VoxelDataLoader from VoxelTerrain
parent
57d306a033
commit
d8a8936f34
|
@ -278,16 +278,15 @@ void VoxelTerrain::make_block_dirty(Vector3i bpos) {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct ScheduleSaveAction {
|
struct ScheduleSaveAction {
|
||||||
std::vector<VoxelDataLoader::InputBlock> &blocks_to_save;
|
std::vector<VoxelTerrain::BlockToSave> &blocks_to_save;
|
||||||
bool with_copy;
|
bool with_copy;
|
||||||
|
|
||||||
void operator()(VoxelBlock *block) {
|
void operator()(VoxelBlock *block) {
|
||||||
if (block->is_modified()) {
|
if (block->is_modified()) {
|
||||||
//print_line(String("Scheduling save for block {0}").format(varray(block->position.to_vec3())));
|
//print_line(String("Scheduling save for block {0}").format(varray(block->position.to_vec3())));
|
||||||
VoxelDataLoader::InputBlock b;
|
VoxelTerrain::BlockToSave b;
|
||||||
b.data.voxels_to_save = with_copy ? block->voxels->duplicate() : block->voxels;
|
b.voxels = with_copy ? block->voxels->duplicate() : block->voxels;
|
||||||
b.position = block->position;
|
b.position = block->position;
|
||||||
b.can_be_discarded = false;
|
|
||||||
blocks_to_save.push_back(b);
|
blocks_to_save.push_back(b);
|
||||||
block->set_modified(false);
|
block->set_modified(false);
|
||||||
}
|
}
|
||||||
|
@ -320,9 +319,6 @@ void VoxelTerrain::save_all_modified_blocks(bool with_copy) {
|
||||||
Dictionary VoxelTerrain::get_statistics() const {
|
Dictionary VoxelTerrain::get_statistics() const {
|
||||||
Dictionary d;
|
Dictionary d;
|
||||||
|
|
||||||
d["stream"] = VoxelDataLoader::Mgr::to_dictionary(_stats.stream);
|
|
||||||
d["updater"] = VoxelMeshUpdater::Mgr::to_dictionary(_stats.updater);
|
|
||||||
|
|
||||||
// Breakdown of time spent in _process
|
// Breakdown of time spent in _process
|
||||||
d["time_detect_required_blocks"] = _stats.time_detect_required_blocks;
|
d["time_detect_required_blocks"] = _stats.time_detect_required_blocks;
|
||||||
d["time_request_blocks_to_load"] = _stats.time_request_blocks_to_load;
|
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
|
// Blocks to save
|
||||||
for (unsigned int i = 0; i < _blocks_to_save.size(); ++i) {
|
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())));
|
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
|
// 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())));
|
//print_line(String("Sending {0} block requests").format(varray(input.blocks_to_emerge.size())));
|
||||||
|
@ -880,10 +876,6 @@ void VoxelTerrain::_process() {
|
||||||
|
|
||||||
// Send mesh updates
|
// Send mesh updates
|
||||||
{
|
{
|
||||||
VoxelMeshUpdater::Input input;
|
|
||||||
input.priority_position = viewer_block_pos;
|
|
||||||
input.priority_direction = viewer_direction;
|
|
||||||
|
|
||||||
unsigned int min_padding;
|
unsigned int min_padding;
|
||||||
unsigned int max_padding;
|
unsigned int max_padding;
|
||||||
VoxelServer::get_singleton()->get_min_max_block_padding(_volume_id, min_padding, max_padding);
|
VoxelServer::get_singleton()->get_min_max_block_padding(_volume_id, min_padding, max_padding);
|
||||||
|
|
|
@ -3,17 +3,11 @@
|
||||||
|
|
||||||
#include "../server/voxel_server.h"
|
#include "../server/voxel_server.h"
|
||||||
#include "../util/zprofiling.h"
|
#include "../util/zprofiling.h"
|
||||||
#include "voxel_data_loader.h"
|
|
||||||
#include "voxel_map.h"
|
#include "voxel_map.h"
|
||||||
#include "voxel_mesh_updater.h"
|
|
||||||
|
|
||||||
#include <scene/3d/spatial.h>
|
#include <scene/3d/spatial.h>
|
||||||
|
|
||||||
class VoxelMap;
|
|
||||||
class VoxelLibrary;
|
|
||||||
class VoxelStream;
|
|
||||||
class VoxelTool;
|
class VoxelTool;
|
||||||
class VoxelBlock;
|
|
||||||
|
|
||||||
// Infinite paged terrain made of voxel blocks all with the same level of detail.
|
// 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.
|
// Voxels are polygonized around the viewer by distance in a large cubic space.
|
||||||
|
@ -62,8 +56,6 @@ public:
|
||||||
void restart_stream();
|
void restart_stream();
|
||||||
|
|
||||||
struct Stats {
|
struct Stats {
|
||||||
VoxelMeshUpdater::Stats updater;
|
|
||||||
VoxelDataLoader::Stats stream;
|
|
||||||
int updated_blocks = 0;
|
int updated_blocks = 0;
|
||||||
int dropped_block_loads = 0;
|
int dropped_block_loads = 0;
|
||||||
int dropped_block_meshs = 0;
|
int dropped_block_meshs = 0;
|
||||||
|
@ -74,6 +66,11 @@ public:
|
||||||
uint64_t time_process_update_responses = 0;
|
uint64_t time_process_update_responses = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct BlockToSave {
|
||||||
|
Ref<VoxelBuffer> voxels;
|
||||||
|
Vector3i position;
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
|
||||||
|
@ -130,7 +127,7 @@ private:
|
||||||
Vector<Vector3i> _blocks_pending_load;
|
Vector<Vector3i> _blocks_pending_load;
|
||||||
Vector<Vector3i> _blocks_pending_update;
|
Vector<Vector3i> _blocks_pending_update;
|
||||||
|
|
||||||
std::vector<VoxelDataLoader::InputBlock> _blocks_to_save;
|
std::vector<BlockToSave> _blocks_to_save;
|
||||||
|
|
||||||
Ref<VoxelStream> _stream;
|
Ref<VoxelStream> _stream;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue