From 1cac9beec4062a21a02e806aa70fff50d0b68ed2 Mon Sep 17 00:00:00 2001 From: Marc Gilleron Date: Fri, 28 Sep 2018 01:10:35 +0100 Subject: [PATCH] Add an internal option to run the terrain in editor, which defaults to false because editor integration currently isn't thread-safe --- voxel_terrain.cpp | 9 +++++++-- voxel_terrain.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/voxel_terrain.cpp b/voxel_terrain.cpp index c4ffe72..bc4982a 100644 --- a/voxel_terrain.cpp +++ b/voxel_terrain.cpp @@ -21,6 +21,9 @@ VoxelTerrain::VoxelTerrain() _provider_thread = NULL; _block_updater = NULL; + + _generate_collisions = false; + _run_in_editor = false; } VoxelTerrain::~VoxelTerrain() { @@ -403,7 +406,8 @@ void VoxelTerrain::_notification(int p_what) { break; case NOTIFICATION_PROCESS: - _process(); + if (!Engine::get_singleton()->is_editor_hint() || _run_in_editor) + _process(); break; case NOTIFICATION_EXIT_TREE: @@ -656,7 +660,8 @@ void VoxelTerrain::_process() { int queue_index = 0; // 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) { diff --git a/voxel_terrain.h b/voxel_terrain.h index d7ecbe4..7c81087 100644 --- a/voxel_terrain.h +++ b/voxel_terrain.h @@ -135,6 +135,7 @@ private: int _last_view_distance_blocks; bool _generate_collisions; + bool _run_in_editor; Ref _materials[VoxelMesher::MAX_MATERIALS];