diff options
| author | Juan Linietsky | 2017-12-14 08:59:46 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2017-12-14 09:01:27 -0300 |
| commit | f3ad14224e27f2a25196575e3c43ebc792c90894 (patch) | |
| tree | 84e60bc2fafda809f51bd0892e39205da9423068 /scene/resources/mesh.cpp | |
| parent | aa6772d7abb3ff1ff77b1b658617904bb0af1fbb (diff) | |
| download | godot-f3ad14224e27f2a25196575e3c43ebc792c90894.tar.gz godot-f3ad14224e27f2a25196575e3c43ebc792c90894.tar.zst godot-f3ad14224e27f2a25196575e3c43ebc792c90894.zip | |
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 0b352efca..bb33962be 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); } } |
