Now the prop job is using the job steps.

This commit is contained in:
Relintai 2022-02-09 13:48:13 +01:00
parent 9ee54a48c4
commit cf36f5369a
2 changed files with 40 additions and 36 deletions

View File

@ -135,7 +135,7 @@ void VoxelPropJob::phase_physics_process() {
next_phase(); next_phase();
} }
void VoxelPropJob::phase_prop() { void VoxelPropJob::old_phase_prop() {
#ifdef MESH_DATA_RESOURCE_PRESENT #ifdef MESH_DATA_RESOURCE_PRESENT
Ref<VoxelChunkDefault> chunk = _chunk; Ref<VoxelChunkDefault> chunk = _chunk;
@ -219,6 +219,8 @@ void VoxelPropJob::phase_prop() {
} }
} }
// OK UP
if (get_prop_mesher()->get_vertex_count() != 0) { if (get_prop_mesher()->get_vertex_count() != 0) {
if (should_do()) { if (should_do()) {
temp_mesh_arr = get_prop_mesher()->build_mesh(); temp_mesh_arr = get_prop_mesher()->build_mesh();
@ -263,6 +265,8 @@ void VoxelPropJob::phase_prop() {
} }
} }
// OK UP
if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_CREATE_LODS) != 0) { if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_CREATE_LODS) != 0) {
if (should_do()) { if (should_do()) {
if (chunk->get_lod_num() >= 1) { if (chunk->get_lod_num() >= 1) {
@ -279,7 +283,7 @@ void VoxelPropJob::phase_prop() {
return; return;
} }
} }
// OK UP
if (should_do()) { if (should_do()) {
if (chunk->get_lod_num() >= 2) { if (chunk->get_lod_num() >= 2) {
Array temp_mesh_arr2 = merge_mesh_array(temp_mesh_arr); Array temp_mesh_arr2 = merge_mesh_array(temp_mesh_arr);
@ -294,7 +298,7 @@ void VoxelPropJob::phase_prop() {
return; return;
} }
} }
// OK UP
// if (should_do()) { // if (should_do()) {
if (chunk->get_lod_num() >= 3) { if (chunk->get_lod_num() >= 3) {
Ref<ShaderMaterial> mat = chunk->get_library()->prop_material_get(0); Ref<ShaderMaterial> mat = chunk->get_library()->prop_material_get(0);
@ -318,6 +322,7 @@ void VoxelPropJob::phase_prop() {
} }
} }
// OK UP
#ifdef MESH_UTILS_PRESENT #ifdef MESH_UTILS_PRESENT
if (should_do()) { if (should_do()) {
if (chunk->get_lod_num() > 4) { if (chunk->get_lod_num() > 4) {
@ -355,7 +360,7 @@ void VoxelPropJob::phase_prop() {
next_job(); next_job();
} }
void VoxelPropJob::new_phase_prop() { void VoxelPropJob::phase_prop() {
#ifdef MESH_DATA_RESOURCE_PRESENT #ifdef MESH_DATA_RESOURCE_PRESENT
Ref<VoxelChunkDefault> chunk = _chunk; Ref<VoxelChunkDefault> chunk = _chunk;
@ -442,12 +447,39 @@ void VoxelPropJob::new_phase_prop() {
next_phase(); next_phase();
} }
void VoxelPropJob::_physics_process(float delta) { void VoxelPropJob::_physics_process(float delta) {
if (_phase == 0) if (_phase == 0)
phase_physics_process(); phase_physics_process();
} }
void VoxelPropJob::old_execute_phase() {
ERR_FAIL_COND(!_chunk.is_valid());
Ref<VoxelLibrary> library = _chunk->get_library();
ERR_FAIL_COND(!library.is_valid());
Ref<VoxelChunkDefault> chunk = _chunk;
if (!chunk.is_valid()
#ifdef MESH_DATA_RESOURCE_PRESENT
|| chunk->mesh_data_resource_get_count() == 0
#endif
) {
set_complete(true);
next_job();
return;
}
if (_phase == 1) {
old_phase_prop();
} else if (_phase > 1) {
set_complete(true); //So threadpool knows it's done
next_job();
ERR_FAIL_MSG("VoxelPropJob: _phase is too high!");
}
}
void VoxelPropJob::_execute_phase() { void VoxelPropJob::_execute_phase() {
ERR_FAIL_COND(!_chunk.is_valid()); ERR_FAIL_COND(!_chunk.is_valid());
@ -467,38 +499,10 @@ void VoxelPropJob::_execute_phase() {
return; return;
} }
if (_phase == 1) {
phase_prop();
} else if (_phase > 1) {
set_complete(true); //So threadpool knows it's done
next_job();
ERR_FAIL_MSG("VoxelPropJob: _phase is too high!");
}
}
void VoxelPropJob::new_execute_phase() {
ERR_FAIL_COND(!_chunk.is_valid());
Ref<VoxelLibrary> library = _chunk->get_library();
ERR_FAIL_COND(!library.is_valid());
Ref<VoxelChunkDefault> chunk = _chunk;
if (!chunk.is_valid()
#ifdef MESH_DATA_RESOURCE_PRESENT
|| chunk->mesh_data_resource_get_count() == 0
#endif
) {
set_complete(true);
next_job();
return;
}
if (_phase == 1) { if (_phase == 1) {
phase_setup(); phase_setup();
} else if (_phase == 2) { } else if (_phase == 2) {
new_phase_prop(); phase_prop();
} else if (_phase == 3) { } else if (_phase == 3) {
phase_steps(); phase_steps();
} else if (_phase > 3) { } else if (_phase > 3) {

View File

@ -43,12 +43,12 @@ public:
int get_jobs_step_count() const; int get_jobs_step_count() const;
void phase_physics_process(); void phase_physics_process();
void old_phase_prop();
void phase_prop(); void phase_prop();
void new_phase_prop();
void _physics_process(float delta); void _physics_process(float delta);
void old_execute_phase();
void _execute_phase(); void _execute_phase();
void new_execute_phase();
void _reset(); void _reset();
void phase_setup(); void phase_setup();