Removed the thread from VoxelChunkDefault.

This commit is contained in:
Relintai 2020-08-04 09:49:40 +02:00
parent cff203fc49
commit bf58b94a99
2 changed files with 3 additions and 87 deletions

View File

@ -189,39 +189,6 @@ void VoxelChunkDefault::build_step() {
_build_step_in_progress = true; _build_step_in_progress = true;
ThreadPool::get_singleton()->add_job(_job); ThreadPool::get_singleton()->add_job(_job);
/*
if (get_is_build_threaded()) {
if (_build_thread) {
wait_and_finish_thread();
}
_build_thread = Thread::create(_build_step_threaded, this);
return;
}
while (has_next_phase() && _active_build_phase_type == BUILD_PHASE_TYPE_NORMAL) {
build_phase();
if (!get_build_phase_done())
break;
}
_build_step_in_progress = false;
*/
}
void VoxelChunkDefault::_build_step_threaded(void *_userdata) {
VoxelChunkDefault *vc = (VoxelChunkDefault *)_userdata;
while (vc->has_next_phase() && vc->_active_build_phase_type == BUILD_PHASE_TYPE_NORMAL) {
vc->build_phase();
if (!vc->get_build_phase_done())
break;
}
vc->_build_step_in_progress = false;
} }
void VoxelChunkDefault::build_phase() { void VoxelChunkDefault::build_phase() {
@ -945,11 +912,7 @@ void VoxelChunkDefault::_enter_tree() {
} }
void VoxelChunkDefault::_exit_tree() { void VoxelChunkDefault::_exit_tree() {
if (_build_thread) { _abort_build = true;
_abort_build = true;
wait_and_finish_thread();
}
free_rids(); free_rids();
@ -1149,7 +1112,6 @@ VoxelChunkDefault::VoxelChunkDefault() {
_build_prioritized = false; _build_prioritized = false;
_build_phase_done = false; _build_phase_done = false;
_build_thread = NULL;
_build_step_in_progress = false; _build_step_in_progress = false;
_active_build_phase_type = BUILD_PHASE_TYPE_NORMAL; _active_build_phase_type = BUILD_PHASE_TYPE_NORMAL;
@ -1163,10 +1125,7 @@ VoxelChunkDefault::VoxelChunkDefault() {
} }
VoxelChunkDefault::~VoxelChunkDefault() { VoxelChunkDefault::~VoxelChunkDefault() {
if (_build_thread) { _abort_build = true;
_abort_build = true;
wait_and_finish_thread();
}
_lights.clear(); _lights.clear();
@ -1288,41 +1247,7 @@ void VoxelChunkDefault::_build_phase(int phase) {
return; return;
} }
if (_is_build_threaded) { //&& Engine::get_singleton()->is_editor_hint()? set_active_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS);
set_active_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS);
return;
}
if (temp_arr_collider.size() != 0) {
if (!has_meshes(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_BODY)) {
create_colliders(MESH_INDEX_TERRARIN);
}
PhysicsServer::get_singleton()->shape_set_data(get_mesh_rid(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_SHAPE), temp_arr_collider);
temp_arr_collider.resize(0);
}
if (temp_arr_collider_liquid.size() != 0) {
if (Engine::get_singleton()->is_editor_hint()) {
if (!has_meshes(MESH_INDEX_LIQUID, MESH_TYPE_INDEX_BODY)) {
create_colliders(MESH_INDEX_LIQUID);
}
}
/*
else {
if (!has_meshes(MESH_INDEX_LIQUID, MESH_TYPE_INDEX_AREA)) {
create_colliders_area(MESH_INDEX_LIQUID);
}
}*/
PhysicsServer::get_singleton()->shape_set_data(get_mesh_rid(MESH_INDEX_LIQUID, MESH_TYPE_INDEX_SHAPE), temp_arr_collider_liquid);
temp_arr_collider_liquid.resize(0);
}
next_phase();
return; return;
} }
case BUILD_PHASE_LIGHTS: { case BUILD_PHASE_LIGHTS: {
@ -1821,11 +1746,6 @@ void VoxelChunkDefault::_build(bool immediate) {
} }
void VoxelChunkDefault::wait_and_finish_thread() { void VoxelChunkDefault::wait_and_finish_thread() {
if (_build_thread) {
Thread::wait_to_finish(_build_thread);
memdelete(_build_thread);
_build_thread = NULL;
}
} }
void VoxelChunkDefault::_bind_methods() { void VoxelChunkDefault::_bind_methods() {

View File

@ -157,9 +157,6 @@ public:
//Data Management functions //Data Management functions
void generate_ao(); void generate_ao();
//Meshing
static void _build_step_threaded(void *_userdata);
void build_step(); void build_step();
void build_phase(); void build_phase();
@ -289,7 +286,6 @@ protected:
bool _build_prioritized; bool _build_prioritized;
bool _build_phase_done; bool _build_phase_done;
Thread *_build_thread;
bool _build_step_in_progress; bool _build_step_in_progress;
PoolVector<Vector3> temp_arr_collider; PoolVector<Vector3> temp_arr_collider;