Add an internal option to run the terrain in editor, which defaults to false because editor integration currently isn't thread-safe

This commit is contained in:
Marc Gilleron 2018-09-28 01:10:35 +01:00
parent 4d6765130d
commit 1cac9beec4
2 changed files with 8 additions and 2 deletions

View File

@ -21,6 +21,9 @@ VoxelTerrain::VoxelTerrain()
_provider_thread = NULL; _provider_thread = NULL;
_block_updater = NULL; _block_updater = NULL;
_generate_collisions = false;
_run_in_editor = false;
} }
VoxelTerrain::~VoxelTerrain() { VoxelTerrain::~VoxelTerrain() {
@ -403,6 +406,7 @@ void VoxelTerrain::_notification(int p_what) {
break; break;
case NOTIFICATION_PROCESS: case NOTIFICATION_PROCESS:
if (!Engine::get_singleton()->is_editor_hint() || _run_in_editor)
_process(); _process();
break; break;
@ -656,7 +660,8 @@ void VoxelTerrain::_process() {
int queue_index = 0; int queue_index = 0;
// The following is done on the main thread because Godot doesn't really support multithreaded Mesh allocation. // The following is done on the main thread because Godot doesn't really support multithreaded Mesh allocation.
// This also proved to be very slow compared to the meshing process itself... hopefully Vulkan will improve this? // This also proved to be very slow compared to the meshing process itself...
// hopefully Vulkan will allow us to upload graphical resources without stalling rendering as they upload?
for (; queue_index < _blocks_pending_main_thread_update.size() && os.get_ticks_msec() < timeout; ++queue_index) { for (; queue_index < _blocks_pending_main_thread_update.size() && os.get_ticks_msec() < timeout; ++queue_index) {

View File

@ -135,6 +135,7 @@ private:
int _last_view_distance_blocks; int _last_view_distance_blocks;
bool _generate_collisions; bool _generate_collisions;
bool _run_in_editor;
Ref<Material> _materials[VoxelMesher::MAX_MATERIALS]; Ref<Material> _materials[VoxelMesher::MAX_MATERIALS];