Clear surfaces in ImmediateMesh before adding a new one.

This commit is contained in:
Relintai 2022-08-11 18:09:33 +02:00
parent 4db7bba945
commit 15a5bea727

View File

@ -256,6 +256,12 @@ void ImmediateMesh::surface_end() {
}
}
int sc = VisualServer::get_singleton()->mesh_get_surface_count(mesh);
for (int i = 0; i < sc; ++i) {
VisualServer::get_singleton()->mesh_remove_surface(mesh, 0);
}
VisualServer::get_singleton()->mesh_add_surface(mesh, format, static_cast<VS::PrimitiveType>(active_surface_data.primitive), surface_array_create_cache, vertices.size(), PoolByteArray(), 0, aabb);
if (active_surface_data.material.is_valid()) {