diff options
Diffstat (limited to 'scene/resources/mesh.cpp')
-rw-r--r-- | scene/resources/mesh.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 0b352efca2..bb33962be6 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -1123,27 +1123,29 @@ Error ArrayMesh::lightmap_unwrap(const Transform &p_base_transform, float p_texe PoolVector<int> rindices = arrays[Mesh::ARRAY_INDEX]; int ic = rindices.size(); - int index_ofs = indices.size(); if (ic == 0) { - indices.resize(index_ofs + vc); - face_materials.resize((index_ofs + vc) / 3); - for (int j = 0; j < vc; j++) { - indices[index_ofs + j] = vertex_ofs + j; - } + for (int j = 0; j < vc / 3; j++) { - face_materials[(index_ofs / 3) + j] = i; + if (Face3(r[j * 3 + 0], r[j * 3 + 1], r[j * 3 + 2]).is_degenerate()) + continue; + + indices.push_back(vertex_ofs + j * 3 + 0); + indices.push_back(vertex_ofs + j * 3 + 1); + indices.push_back(vertex_ofs + j * 3 + 2); + face_materials.push_back(i); } } else { PoolVector<int>::Read ri = rindices.read(); - indices.resize(index_ofs + ic); - face_materials.resize((index_ofs + ic) / 3); - for (int j = 0; j < ic; j++) { - indices[index_ofs + j] = vertex_ofs + ri[j]; - } + for (int j = 0; j < ic / 3; j++) { - face_materials[(index_ofs / 3) + j] = i; + if (Face3(r[ri[j * 3 + 0]], r[ri[j * 3 + 1]], r[ri[j * 3 + 2]]).is_degenerate()) + continue; + indices.push_back(vertex_ofs + ri[j * 3 + 0]); + indices.push_back(vertex_ofs + ri[j * 3 + 1]); + indices.push_back(vertex_ofs + ri[j * 3 + 2]); + face_materials.push_back(i); } } |