Merge branch 'master' into persistence
# Conflicts: # terrain/voxel_data_loader.cpp
This commit is contained in:
commit
f831d03cf5
@ -2,19 +2,19 @@
|
||||
#include "../streams/voxel_stream.h"
|
||||
#include "../util/utility.h"
|
||||
|
||||
VoxelDataLoader::VoxelDataLoader(int thread_count, Ref<VoxelStream> provider, int block_size_pow2) {
|
||||
VoxelDataLoader::VoxelDataLoader(int thread_count, Ref<VoxelStream> stream, int block_size_pow2) {
|
||||
|
||||
CRASH_COND(provider.is_null());
|
||||
CRASH_COND(stream.is_null());
|
||||
|
||||
Processor processors[Mgr::MAX_JOBS];
|
||||
|
||||
if (provider->is_thread_safe()) {
|
||||
if (stream->is_thread_safe()) {
|
||||
|
||||
for (unsigned int i = 0; i < thread_count; ++i) {
|
||||
processors[i].provider = provider;
|
||||
processors[i].stream = stream;
|
||||
}
|
||||
|
||||
} else if (provider->is_cloneable()) {
|
||||
} else if (stream->is_cloneable()) {
|
||||
|
||||
// Note: more than one thread can make sense for generators,
|
||||
// but won't be as useful for file and network streams
|
||||
@ -22,9 +22,9 @@ VoxelDataLoader::VoxelDataLoader(int thread_count, Ref<VoxelStream> provider, in
|
||||
Processor &p = processors[i];
|
||||
p.block_size_pow2 = block_size_pow2;
|
||||
if (i == 0) {
|
||||
p.provider = provider;
|
||||
p.stream = stream;
|
||||
} else {
|
||||
p.provider = provider->duplicate();
|
||||
p.stream = stream->duplicate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ VoxelDataLoader::VoxelDataLoader(int thread_count, Ref<VoxelStream> provider, in
|
||||
ERR_PRINT("Thread count set to higher than 1, but the stream is neither thread-safe nor cloneable. Capping back to 1 thread.");
|
||||
thread_count = 1;
|
||||
}
|
||||
processors[0].provider = provider;
|
||||
processors[0].stream = stream;
|
||||
}
|
||||
|
||||
// TODO Re-enable duplicate rejection, was turned off to investigate some bugs
|
||||
@ -55,7 +55,7 @@ void VoxelDataLoader::Processor::process_block(const InputBlockData &input, Outp
|
||||
buffer->create(bs, bs, bs);
|
||||
|
||||
Vector3i block_origin_in_voxels = block_position * (bs << lod);
|
||||
provider->emerge_block(buffer, block_origin_in_voxels, lod);
|
||||
stream->emerge_block(buffer, block_origin_in_voxels, lod);
|
||||
|
||||
output.voxels_loaded = buffer;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
struct Processor {
|
||||
void process_block(const InputBlockData &input, OutputBlockData &output, Vector3i block_position, unsigned int lod);
|
||||
|
||||
Ref<VoxelStream> provider;
|
||||
Ref<VoxelStream> stream;
|
||||
int block_size_pow2 = 0;
|
||||
};
|
||||
|
||||
@ -30,7 +30,7 @@ public:
|
||||
typedef Mgr::Output Output;
|
||||
typedef Mgr::Stats Stats;
|
||||
|
||||
VoxelDataLoader(int thread_count, Ref<VoxelStream> provider, int block_size_pow2);
|
||||
VoxelDataLoader(int thread_count, Ref<VoxelStream> stream, int block_size_pow2);
|
||||
~VoxelDataLoader();
|
||||
|
||||
void push(const Input &input) { _mgr->push(input); }
|
||||
|
@ -572,7 +572,7 @@ void VoxelLodTerrain::_process() {
|
||||
{
|
||||
VoxelDataLoader::Output output;
|
||||
_stream_thread->pop(output);
|
||||
_stats.provider = output.stats;
|
||||
_stats.stream = output.stats;
|
||||
|
||||
//print_line(String("Loaded {0} blocks").format(varray(output.emerged_blocks.size())));
|
||||
|
||||
@ -612,7 +612,7 @@ void VoxelLodTerrain::_process() {
|
||||
|
||||
if (ob.data.voxels_loaded->get_size() != lod.map->get_block_size()) {
|
||||
// Voxel block size is incorrect, drop it
|
||||
ERR_PRINT("Block size obtained from provider is different from expected size");
|
||||
ERR_PRINT("Block size obtained from stream is different from expected size");
|
||||
++_stats.dropped_block_loads;
|
||||
continue;
|
||||
}
|
||||
@ -785,7 +785,7 @@ Dictionary VoxelLodTerrain::get_stats() const {
|
||||
process["time_process_lod"] = _stats.time_process_lod;
|
||||
|
||||
Dictionary d;
|
||||
d["provider"] = VoxelDataLoader::Mgr::to_dictionary(_stats.provider);
|
||||
d["stream"] = VoxelDataLoader::Mgr::to_dictionary(_stats.stream);
|
||||
d["updater"] = VoxelMeshUpdater::Mgr::to_dictionary(_stats.updater);
|
||||
d["process"] = process;
|
||||
d["blocked_lods"] = _stats.blocked_lods;
|
||||
@ -797,7 +797,7 @@ Dictionary VoxelLodTerrain::get_stats() const {
|
||||
|
||||
void VoxelLodTerrain::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_stream", "provider"), &VoxelLodTerrain::set_stream);
|
||||
ClassDB::bind_method(D_METHOD("set_stream", "stream"), &VoxelLodTerrain::set_stream);
|
||||
ClassDB::bind_method(D_METHOD("get_stream"), &VoxelLodTerrain::get_stream);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_material", "material"), &VoxelLodTerrain::set_material);
|
||||
@ -820,7 +820,7 @@ void VoxelLodTerrain::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_stats"), &VoxelLodTerrain::get_stats);
|
||||
ClassDB::bind_method(D_METHOD("voxel_to_block_position", "lod_index"), &VoxelLodTerrain::voxel_to_block_position);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "provider", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStream"), "set_stream", "get_stream");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStream"), "set_stream", "get_stream");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "view_distance"), "set_view_distance", "get_view_distance");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "lod_count"), "set_lod_count", "get_lod_count");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "lod_split_scale"), "set_lod_split_scale", "get_lod_split_scale");
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
|
||||
struct Stats {
|
||||
VoxelMeshUpdater::Stats updater;
|
||||
VoxelDataLoader::Stats provider;
|
||||
VoxelDataLoader::Stats stream;
|
||||
uint64_t time_request_blocks_to_load = 0;
|
||||
uint64_t time_process_load_responses = 0;
|
||||
uint64_t time_request_blocks_to_update = 0;
|
||||
|
@ -72,15 +72,15 @@ void VoxelTerrain::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
}
|
||||
}
|
||||
|
||||
void VoxelTerrain::set_stream(Ref<VoxelStream> provider) {
|
||||
if (provider != _stream) {
|
||||
void VoxelTerrain::set_stream(Ref<VoxelStream> stream) {
|
||||
if (stream != _stream) {
|
||||
|
||||
if (_stream_thread) {
|
||||
memdelete(_stream_thread);
|
||||
_stream_thread = NULL;
|
||||
}
|
||||
|
||||
_stream = provider;
|
||||
_stream = stream;
|
||||
_stream_thread = memnew(VoxelDataLoader(1, _stream, _map->get_block_size_pow2()));
|
||||
|
||||
// The whole map might change, so make all area dirty
|
||||
@ -248,8 +248,8 @@ void VoxelTerrain::save_all_modified_blocks(bool with_copy) {
|
||||
|
||||
Dictionary VoxelTerrain::get_statistics() const {
|
||||
|
||||
Dictionary provider = VoxelDataLoader::Mgr::to_dictionary(_stats.provider);
|
||||
provider["dropped_blocks"] = _stats.dropped_stream_blocks;
|
||||
Dictionary stream = VoxelDataLoader::Mgr::to_dictionary(_stats.stream);
|
||||
stream["dropped_blocks"] = _stats.dropped_stream_blocks;
|
||||
|
||||
Dictionary updater = VoxelMeshUpdater::Mgr::to_dictionary(_stats.updater);
|
||||
updater["updated_blocks"] = _stats.updated_blocks;
|
||||
@ -258,7 +258,7 @@ Dictionary VoxelTerrain::get_statistics() const {
|
||||
updater["remaining_main_thread_blocks"] = _stats.remaining_main_thread_blocks;
|
||||
|
||||
Dictionary d;
|
||||
d["provider"] = provider;
|
||||
d["stream"] = stream;
|
||||
d["updater"] = updater;
|
||||
|
||||
// Breakdown of time spent in _process
|
||||
@ -673,7 +673,7 @@ void VoxelTerrain::_process() {
|
||||
_stream_thread->pop(output);
|
||||
//print_line(String("Receiving {0} blocks").format(varray(output.emerged_blocks.size())));
|
||||
|
||||
_stats.provider = output.stats;
|
||||
_stats.stream = output.stats;
|
||||
_stats.dropped_stream_blocks = 0;
|
||||
|
||||
for (int i = 0; i < output.blocks.size(); ++i) {
|
||||
@ -1001,7 +1001,7 @@ VoxelTerrain::BlockDirtyState VoxelTerrain::get_block_state(Vector3 p_bpos) cons
|
||||
|
||||
void VoxelTerrain::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_stream", "provider"), &VoxelTerrain::set_stream);
|
||||
ClassDB::bind_method(D_METHOD("set_stream", "stream"), &VoxelTerrain::set_stream);
|
||||
ClassDB::bind_method(D_METHOD("get_stream"), &VoxelTerrain::get_stream);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_voxel_library", "library"), &VoxelTerrain::set_voxel_library);
|
||||
@ -1032,7 +1032,7 @@ void VoxelTerrain::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_statistics"), &VoxelTerrain::get_statistics);
|
||||
ClassDB::bind_method(D_METHOD("get_block_state", "block_pos"), &VoxelTerrain::get_block_state);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "provider", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStream"), "set_stream", "get_stream");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "VoxelStream"), "set_stream", "get_stream");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "voxel_library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelLibrary"), "set_voxel_library", "get_voxel_library");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "view_distance"), "set_view_distance", "get_view_distance");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "viewer_path"), "set_viewer_path", "get_viewer_path");
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
VoxelTerrain();
|
||||
~VoxelTerrain();
|
||||
|
||||
void set_stream(Ref<VoxelStream> provider);
|
||||
void set_stream(Ref<VoxelStream> stream);
|
||||
Ref<VoxelStream> get_stream() const;
|
||||
|
||||
void set_voxel_library(Ref<VoxelLibrary> library);
|
||||
@ -62,7 +62,7 @@ public:
|
||||
|
||||
struct Stats {
|
||||
VoxelMeshUpdater::Stats updater;
|
||||
VoxelDataLoader::Stats provider;
|
||||
VoxelDataLoader::Stats stream;
|
||||
uint32_t mesh_alloc_time;
|
||||
int updated_blocks;
|
||||
int dropped_stream_blocks;
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
|
||||
struct Stats {
|
||||
VoxelMeshUpdater::Stats updater;
|
||||
VoxelStreamThread::Stats provider;
|
||||
VoxelStreamThread::Stats stream;
|
||||
uint64_t time_request_blocks_to_load = 0;
|
||||
uint64_t time_process_load_responses = 0;
|
||||
uint64_t time_request_blocks_to_update = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user