mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-11 10:30:06 +01:00
Clear meshes as needed in TerrainTerrainJob.
This commit is contained in:
parent
4a2d4af692
commit
952553e9ad
@ -331,17 +331,6 @@ void TerrainTerrainJob::phase_terrain_mesh() {
|
||||
//allocate
|
||||
if (count > 0)
|
||||
chunk->meshes_create(TerrainChunkDefault::MESH_INDEX_TERRAIN, count);
|
||||
|
||||
} else {
|
||||
//we have the meshes, just clear
|
||||
int count = chunk->mesh_rid_get_count(TerrainChunkDefault::MESH_INDEX_TERRAIN, TerrainChunkDefault::MESH_TYPE_INDEX_MESH);
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
mesh_rid = chunk->mesh_rid_get_index(TerrainChunkDefault::MESH_INDEX_TERRAIN, TerrainChunkDefault::MESH_TYPE_INDEX_MESH, i);
|
||||
|
||||
if (RS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
|
||||
RS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -399,14 +388,15 @@ void TerrainTerrainJob::phase_terrain_mesh() {
|
||||
mesh_rid = chunk->mesh_rid_get_index(TerrainChunkDefault::MESH_INDEX_LIQUID, TerrainChunkDefault::MESH_TYPE_INDEX_MESH, 0);
|
||||
}
|
||||
|
||||
if (RS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
|
||||
RS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
|
||||
|
||||
if (should_return()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (RS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0) {
|
||||
RS::get_singleton()->mesh_clear(mesh_rid);
|
||||
}
|
||||
|
||||
RS::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, RenderingServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
Ref<Material> lmat;
|
||||
@ -506,6 +496,10 @@ void TerrainTerrainJob::step_type_normal() {
|
||||
|
||||
RID mesh_rid = chunk->mesh_rid_get_index(TerrainChunkDefault::MESH_INDEX_TERRAIN, TerrainChunkDefault::MESH_TYPE_INDEX_MESH, _current_mesh);
|
||||
|
||||
if (RS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0) {
|
||||
RS::get_singleton()->mesh_clear(mesh_rid);
|
||||
}
|
||||
|
||||
RS::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, RenderingServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
Ref<Material> lmat;
|
||||
@ -543,6 +537,10 @@ void TerrainTerrainJob::step_type_normal_lod() {
|
||||
|
||||
RID mesh_rid = chunk->mesh_rid_get_index(TerrainChunkDefault::MESH_INDEX_TERRAIN, TerrainChunkDefault::MESH_TYPE_INDEX_MESH, _current_mesh);
|
||||
|
||||
if (RS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0) {
|
||||
RS::get_singleton()->mesh_clear(mesh_rid);
|
||||
}
|
||||
|
||||
RS::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, RenderingServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
Ref<Material> lmat;
|
||||
@ -567,6 +565,10 @@ void TerrainTerrainJob::step_type_drop_uv2() {
|
||||
|
||||
temp_mesh_arr[RenderingServer::ARRAY_TEX_UV2] = Variant();
|
||||
|
||||
if (RS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0) {
|
||||
RS::get_singleton()->mesh_clear(mesh_rid);
|
||||
}
|
||||
|
||||
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, RenderingServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
Ref<Material> lmat;
|
||||
@ -591,6 +593,10 @@ void TerrainTerrainJob::step_type_merge_verts() {
|
||||
Ref<TerrainChunkDefault> chunk = _chunk;
|
||||
RID mesh_rid = chunk->mesh_rid_get_index(TerrainChunkDefault::MESH_INDEX_TERRAIN, TerrainChunkDefault::MESH_TYPE_INDEX_MESH, _current_mesh);
|
||||
|
||||
if (RS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0) {
|
||||
RS::get_singleton()->mesh_clear(mesh_rid);
|
||||
}
|
||||
|
||||
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, RenderingServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
Ref<Material> lmat;
|
||||
@ -635,6 +641,10 @@ void TerrainTerrainJob::step_type_bake_texture() {
|
||||
|
||||
RID mesh_rid = chunk->mesh_rid_get_index(TerrainChunkDefault::MESH_INDEX_TERRAIN, TerrainChunkDefault::MESH_TYPE_INDEX_MESH, _current_mesh);
|
||||
|
||||
if (RS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0) {
|
||||
RS::get_singleton()->mesh_clear(mesh_rid);
|
||||
}
|
||||
|
||||
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, RenderingServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
if (lmat.is_valid()) {
|
||||
@ -662,6 +672,10 @@ void TerrainTerrainJob::step_type_simplify_mesh() {
|
||||
|
||||
RID mesh_rid = chunk->mesh_rid_get_index(TerrainChunkDefault::MESH_INDEX_TERRAIN, TerrainChunkDefault::MESH_TYPE_INDEX_MESH, _current_mesh);
|
||||
|
||||
if (RS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0) {
|
||||
RS::get_singleton()->mesh_clear(mesh_rid);
|
||||
}
|
||||
|
||||
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, RenderingServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
Ref<Material> lmat;
|
||||
|
Loading…
Reference in New Issue
Block a user