Avoid creating ArrayMesh instance if empty
This commit is contained in:
parent
7277a6a79f
commit
646618e78a
@ -25,7 +25,6 @@ Ref<ArrayMesh> build_mesh(
|
||||
Span<const Array> surfaces, Mesh::PrimitiveType primitive, int flags, Ref<Material> material) {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
Ref<ArrayMesh> mesh;
|
||||
mesh.instantiate();
|
||||
|
||||
unsigned int surface_index = 0;
|
||||
for (unsigned int i = 0; i < surfaces.size(); ++i) {
|
||||
@ -40,6 +39,10 @@ Ref<ArrayMesh> build_mesh(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mesh.is_null()) {
|
||||
mesh.instantiate();
|
||||
}
|
||||
|
||||
// TODO Use `add_surface`, it's about 20% faster after measuring in Tracy (though we may see if Godot 4 expects
|
||||
// the same)
|
||||
mesh->add_surface_from_arrays(primitive, surface, Array(), Dictionary(), flags);
|
||||
|
Loading…
x
Reference in New Issue
Block a user