mirror of
https://github.com/Relintai/voxelman.git
synced 2025-04-13 21:00:47 +02:00
Switched to the new scriptable terrain meshing system.
This commit is contained in:
parent
e0b2ac8d79
commit
ad311181c8
@ -648,45 +648,115 @@ void VoxelTerrainJob::new_phase_terrain_mesh() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<VoxelMesher> mesher;
|
if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0) {
|
||||||
for (int i = 0; i < _meshers.size(); ++i) {
|
int starti = 0;
|
||||||
mesher = _meshers.get(i);
|
|
||||||
|
|
||||||
if (mesher.is_valid()) {
|
if (has_meta("bptm_ulm")) {
|
||||||
break;
|
starti = get_meta("bptm_ulm");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = starti; i < _meshers.size(); ++i) {
|
||||||
|
if (should_return()) {
|
||||||
|
set_meta("bptm_ulm", i);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<VoxelMesher> mesher = _meshers.get(i);
|
||||||
|
|
||||||
|
ERR_CONTINUE(!mesher.is_valid());
|
||||||
|
|
||||||
|
mesher->bake_colors(_chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
starti = 0;
|
||||||
|
|
||||||
|
if (has_meta("bptm_ullm")) {
|
||||||
|
starti = get_meta("bptm_ullm");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = starti; i < _liquid_meshers.size(); ++i) {
|
||||||
|
if (should_return()) {
|
||||||
|
set_meta("bptm_ullm", i);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<VoxelMesher> mesher = _liquid_meshers.get(i);
|
||||||
|
|
||||||
|
ERR_CONTINUE(!mesher.is_valid());
|
||||||
|
|
||||||
|
mesher->bake_colors(_chunk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int starti = 0;
|
||||||
|
|
||||||
|
if (has_meta("bptm_mm")) {
|
||||||
|
starti = get_meta("bptm_mm");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<VoxelMesher> mesher;
|
||||||
|
for (int i = starti; i < _meshers.size(); ++i) {
|
||||||
|
if (should_return()) {
|
||||||
|
set_meta("bptm_mm", i);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<VoxelMesher> m = _meshers.get(i);
|
||||||
|
|
||||||
|
ERR_CONTINUE(!m.is_valid());
|
||||||
|
|
||||||
|
if (!mesher.is_valid()) {
|
||||||
|
mesher = m;
|
||||||
|
mesher->set_material(_chunk->get_library()->material_get(0));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
mesher->set_material(_chunk->get_library()->material_get(0));
|
||||||
|
mesher->add_mesher(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
ERR_FAIL_COND(!mesher.is_valid());
|
||||||
|
|
||||||
|
starti = 0;
|
||||||
|
|
||||||
|
if (has_meta("bptm_lmm")) {
|
||||||
|
starti = get_meta("bptm_lmm");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<VoxelMesher> liquid_mesher;
|
Ref<VoxelMesher> liquid_mesher;
|
||||||
for (int i = 0; i < _liquid_meshers.size(); ++i) {
|
for (int i = starti; i < _liquid_meshers.size(); ++i) {
|
||||||
liquid_mesher = _liquid_meshers.get(i);
|
if (should_return()) {
|
||||||
|
set_meta("bptm_lmm", i);
|
||||||
if (liquid_mesher.is_valid()) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0) {
|
Ref<VoxelMesher> m = _liquid_meshers.get(i);
|
||||||
//if (should_do()) {
|
|
||||||
// _mesher->bake_colors(_chunk);
|
|
||||||
|
|
||||||
// if (should_return()) {
|
ERR_CONTINUE(!m.is_valid());
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (should_do()) {
|
if (!liquid_mesher.is_valid()) {
|
||||||
if (liquid_mesher.is_valid()) {
|
liquid_mesher = m;
|
||||||
liquid_mesher->bake_colors(_chunk);
|
liquid_mesher->set_material(_chunk->get_library()->material_get(0));
|
||||||
|
continue;
|
||||||
if (should_return()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
liquid_mesher->set_material(_chunk->get_library()->material_get(0));
|
||||||
|
liquid_mesher->add_mesher(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mesher->get_vertex_count() == 0 && (!liquid_mesher.is_valid() || liquid_mesher->get_vertex_count() == 0)) {
|
if (mesher->get_vertex_count() == 0 && (!liquid_mesher.is_valid() || liquid_mesher->get_vertex_count() == 0)) {
|
||||||
|
if (has_meta("bptm_ulm")) {
|
||||||
|
remove_meta("bptm_ulm");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_meta("bptm_ullm")) {
|
||||||
|
remove_meta("bptm_ullm");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_meta("bptm_mm")) {
|
||||||
|
remove_meta("bptm_mm");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_meta("bptm_lmm")) {
|
||||||
|
remove_meta("bptm_lmm");
|
||||||
|
}
|
||||||
|
|
||||||
reset_stages();
|
reset_stages();
|
||||||
next_phase();
|
next_phase();
|
||||||
|
|
||||||
@ -832,6 +902,22 @@ void VoxelTerrainJob::new_phase_terrain_mesh() {
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (has_meta("bptm_ulm")) {
|
||||||
|
remove_meta("bptm_ulm");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_meta("bptm_ullm")) {
|
||||||
|
remove_meta("bptm_ullm");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_meta("bptm_mm")) {
|
||||||
|
remove_meta("bptm_mm");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_meta("bptm_lmm")) {
|
||||||
|
remove_meta("bptm_lmm");
|
||||||
|
}
|
||||||
|
|
||||||
reset_stages();
|
reset_stages();
|
||||||
next_phase();
|
next_phase();
|
||||||
}
|
}
|
||||||
@ -858,7 +944,7 @@ void VoxelTerrainJob::_execute_phase() {
|
|||||||
} else if (_phase == 3) {
|
} else if (_phase == 3) {
|
||||||
phase_collider();
|
phase_collider();
|
||||||
} else if (_phase == 5) {
|
} else if (_phase == 5) {
|
||||||
phase_terrain_mesh();
|
new_phase_terrain_mesh();
|
||||||
} else if (_phase == 6) {
|
} else if (_phase == 6) {
|
||||||
phase_finalize();
|
phase_finalize();
|
||||||
} else if (_phase > 6) {
|
} else if (_phase > 6) {
|
||||||
@ -1115,7 +1201,6 @@ void VoxelTerrainJob::step_type_simplify_mesh() {
|
|||||||
|
|
||||||
++_current_mesh;
|
++_current_mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user