Disable mesh compression if vertex position.z is always 0

This commit is contained in:
jsjtxietian 2023-12-13 19:18:50 +08:00
parent 9d6bdbc56e
commit 077e20cd51
3 changed files with 36 additions and 2 deletions

View file

@ -384,7 +384,22 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes,
if (p_disable_compression) {
mesh_flags = 0;
} else {
bool is_mesh_2d = true;
// Disable compression if all z equals 0 (the mesh is 2D).
for (int i = 0; i < vertices.size(); i++) {
if (!Math::is_zero_approx(vertices[i].z)) {
is_mesh_2d = false;
break;
}
}
if (is_mesh_2d) {
mesh_flags = 0;
}
}
//groups are too annoying
if (surf_tool->get_vertex_array().size()) {
//another group going on, commit it