Now generation works again. Also removed some stray debug prints, and small cleanups.

This commit is contained in:
Relintai 2020-10-06 00:05:06 +02:00
parent 14735b8569
commit 8c06a778f2
3 changed files with 24 additions and 27 deletions

View File

@ -75,18 +75,6 @@ void VoxelJob::_execute() {
ActiveBuildPhaseType origpt = _build_phase_type;
if (get_cancelled())
print_error("get_cancelled()");
if (!_in_tree)
print_error("_in_tree");
if (_build_done)
print_error("_build_done");
if (should_return())
print_error("should_return()");
while (!get_cancelled() && _in_tree && !_build_done && origpt == _build_phase_type && !should_return()) {
execute_phase();
}

View File

@ -206,6 +206,7 @@ void VoxelTerrarinJob::phase_collider() {
}
if (temp_arr_collider.size() == 0 && temp_arr_collider_liquid.size() == 0) {
next_phase();
next_phase();
return;
}
@ -245,20 +246,13 @@ void VoxelTerrarinJob::phase_physics_process() {
temp_arr_collider_liquid.resize(0);
}
//TODO this should only update the differences
for (int i = 0; i < chunk->get_collider_count(); ++i) {
PhysicsServer::get_singleton()->free(chunk->get_collider_body(i));
}
chunk->clear_colliders();
set_build_phase_type(BUILD_PHASE_TYPE_NORMAL);
next_phase();
}
void VoxelTerrarinJob::phase_terrarin_mesh() {
Ref<VoxelChunkDefault> chunk = _chunk;
/*
if (should_do()) {
for (int i = 0; i < _meshers.size(); ++i) {
Ref<VoxelMesher> mesher = _meshers.get(i);
@ -278,7 +272,7 @@ void VoxelTerrarinJob::phase_terrarin_mesh() {
if (should_return())
return;
}
}*/
if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0) {
int starti = 0;
@ -622,9 +616,9 @@ void VoxelTerrarinJob::_execute_phase() {
phase_terrarin_mesh_setup();
else if (_phase == 2)
phase_collider();
else if (_phase == 3)
phase_terrarin_mesh();
else if (_phase == 4)
phase_terrarin_mesh();
else if (_phase == 5)
phase_finalize();
}
@ -666,8 +660,8 @@ void VoxelTerrarinJob::_reset() {
}
void VoxelTerrarinJob::_physics_process(float delta) {
if (_phase == 5)
phase_finalize_physics_process();
if (_phase == 3)
phase_physics_process();
}
VoxelTerrarinJob::VoxelTerrarinJob() {

View File

@ -263,8 +263,7 @@ void VoxelChunk::next_job() {
if (j->get_build_phase_type() == VoxelJob::BUILD_PHASE_TYPE_NORMAL) {
#if THREAD_POOL_PRESENT
//ThreadPool::get_singleton()->add_job(j);
j->execute();
ThreadPool::get_singleton()->add_job(j);
#else
j->execute();
#endif
@ -1036,6 +1035,14 @@ void VoxelChunk::_generation_process(const float delta) {
return;
job->process(delta);
if (job->get_build_phase_type() == VoxelJob::BUILD_PHASE_TYPE_NORMAL) {
#if THREAD_POOL_PRESENT
ThreadPool::get_singleton()->add_job(job);
#else
job->execute();
#endif
}
}
}
void VoxelChunk::_generation_physics_process(const float delta) {
@ -1050,6 +1057,14 @@ void VoxelChunk::_generation_physics_process(const float delta) {
return;
job->physics_process(delta);
if (job->get_build_phase_type() == VoxelJob::BUILD_PHASE_TYPE_NORMAL) {
#if THREAD_POOL_PRESENT
ThreadPool::get_singleton()->add_job(job);
#else
job->execute();
#endif
}
}
}