feat: apply_mesh for chunks is smeared over frames
This commit is contained in:
parent
226c821454
commit
1e44fcd09f
5 changed files with 47 additions and 11 deletions
|
|
@ -5,10 +5,6 @@
|
|||
|
||||
void TerrainChunkMesh::_bind_methods() {}
|
||||
|
||||
void TerrainChunkMesh::apply_new_mesh() {
|
||||
set_mesh(this->new_mesh);
|
||||
}
|
||||
|
||||
void TerrainChunkMesh::generate_vertices() {
|
||||
ERR_FAIL_COND_EDMSG(this->terrain == nullptr, "TerrainChunkMesh::generate_vertices: no terrain assigned");
|
||||
ERR_FAIL_COND_EDMSG(this->size <= 0.f, "TerrainChunkMesh::generate_vertices: size <= 0");
|
||||
|
|
@ -68,6 +64,12 @@ void TerrainChunkMesh::_notification(int what) {
|
|||
}
|
||||
}
|
||||
|
||||
void TerrainChunkMesh::apply_new_mesh() {
|
||||
this->lock.lock();
|
||||
set_mesh(this->new_mesh);
|
||||
this->lock.unlock();
|
||||
}
|
||||
|
||||
void TerrainChunkMesh::update_mesh() {
|
||||
ERR_FAIL_COND_EDMSG(this->size <= 0.f, "TerrainChunkMesh::generate: size <= 0");
|
||||
ERR_FAIL_COND_EDMSG(points_per_side() <= 0, "TerrainChunkMesh::generate: points per side <= 0");
|
||||
|
|
@ -80,8 +82,8 @@ void TerrainChunkMesh::update_mesh() {
|
|||
this->surface->generate_tangents();
|
||||
this->new_mesh = memnew(ArrayMesh);
|
||||
this->surface->commit(this->new_mesh);
|
||||
callable_mp(this, &self_type::apply_new_mesh).call_deferred();
|
||||
this->lock.unlock();
|
||||
this->terrain->mesh_dirty(this);
|
||||
}
|
||||
|
||||
size_t TerrainChunkMesh::points_per_side() const {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue