More work on the logic.

This commit is contained in:
Relintai 2020-10-03 21:58:24 +02:00
parent eb1d55f05b
commit 08c2fc8fc1
8 changed files with 35 additions and 13 deletions

View File

@ -59,7 +59,7 @@ void VoxelJob::set_build_done(const bool val) {
}
void VoxelJob::next_job() {
//chunk->next_job();
_chunk->next_job();
set_build_done(true);
}
@ -75,6 +75,18 @@ 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();
}
@ -352,6 +364,7 @@ void VoxelJob::_bind_methods() {
BIND_VMETHOD(MethodInfo("_execute_phase"));
ClassDB::bind_method(D_METHOD("execute_phase"), &VoxelJob::execute_phase);
ClassDB::bind_method(D_METHOD("_execute_phase"), &VoxelJob::_execute_phase);
ClassDB::bind_method(D_METHOD("generate_ao"), &VoxelJob::generate_ao);
ClassDB::bind_method(D_METHOD("generate_random_ao", "seed", "octaves", "period", "persistence", "scale_factor"), &VoxelJob::generate_random_ao, DEFVAL(4), DEFVAL(30), DEFVAL(0.3), DEFVAL(0.6));

View File

@ -71,7 +71,7 @@ void VoxelLightJob::phase_light() {
next_phase();
}
void VoxelLightJob::_execute() {
void VoxelLightJob::_execute_phase() {
ERR_FAIL_COND(!_chunk.is_valid());
Ref<VoxelmanLibrary> library = _chunk->get_library();
@ -79,6 +79,7 @@ void VoxelLightJob::_execute() {
ERR_FAIL_COND(!library.is_valid());
phase_light();
next_job();
//finish
}

View File

@ -33,7 +33,7 @@ class VoxelLightJob : public VoxelJob {
public:
void phase_light();
void _execute();
void _execute_phase();
VoxelLightJob();
~VoxelLightJob();

View File

@ -320,10 +320,12 @@ void VoxelPropJob::phase_prop() {
}
}
next_phase();
//next_phase();
return;
#endif
next_job();
}
void VoxelPropJob::_execute() {
@ -333,7 +335,9 @@ void VoxelPropJob::_execute() {
ERR_FAIL_COND(!library.is_valid());
phase_prop();
next_job();
//phase_prop();
//finish
}

View File

@ -598,7 +598,9 @@ void VoxelTerrarinJob::phase_finalize() {
//add vs meshes to chunk
set_complete(true); //So threadpool knows it's done
set_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS);
//set_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS);
next_job();
}
void VoxelTerrarinJob::phase_finalize_physics_process() {
@ -624,8 +626,6 @@ void VoxelTerrarinJob::_execute_phase() {
phase_terrarin_mesh();
else if (_phase == 4)
phase_finalize();
else if (_phase == 5)
phase_finalize_physics_process();
}
void VoxelTerrarinJob::_reset() {
@ -665,6 +665,11 @@ void VoxelTerrarinJob::_reset() {
}
}
void VoxelTerrarinJob::_physics_process(float delta) {
if (_phase == 5)
phase_finalize_physics_process();
}
VoxelTerrarinJob::VoxelTerrarinJob() {
}
@ -686,5 +691,5 @@ void VoxelTerrarinJob::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_liquid_mesher", "mesher"), &VoxelTerrarinJob::add_liquid_mesher);
ClassDB::bind_method(D_METHOD("get_liquid_mesher_count"), &VoxelTerrarinJob::get_liquid_mesher_count);
ClassDB::bind_method(D_METHOD("_execute_phase"), &VoxelTerrarinJob::_execute_phase);
ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &VoxelTerrarinJob::_physics_process);
}

View File

@ -56,6 +56,7 @@ public:
void _execute_phase();
void _reset();
void _physics_process(float delta);
VoxelTerrarinJob();
~VoxelTerrarinJob();

View File

@ -247,6 +247,7 @@ void VoxelChunk::next_job() {
if (_current_job >= _jobs.size()) {
_current_job = -1;
set_is_generating(false);
finalize_build();
return;
}
@ -257,6 +258,7 @@ void VoxelChunk::next_job() {
next_job();
}
j->reset();
j->set_complete(false);
if (j->get_build_phase_type() == VoxelJob::BUILD_PHASE_TYPE_NORMAL) {

View File

@ -432,8 +432,6 @@ Ref<VoxelChunk> VoxelWorld::_create_chunk(const int x, const int y, const int z,
void VoxelWorld::generate_chunk(Ref<VoxelChunk> chunk) {
ERR_FAIL_COND(!chunk.is_valid());
chunk->set_is_generating(true);
if (has_method("_prepare_chunk_for_generation"))
call("_prepare_chunk_for_generation", chunk);
@ -879,8 +877,6 @@ void VoxelWorld::_notification(int p_what) {
_chunks.set(pos, chunk);
chunk->enter_tree();
chunk->build();
}
}
} break;