diff options
Diffstat (limited to 'scene/resources/mesh.cpp')
-rw-r--r-- | scene/resources/mesh.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index b8c83ac89e..3e7b0a2808 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -188,7 +188,10 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const { Vector<Vector3> faces; faces.resize(faces_size); + Vector<int32_t> surface_indices; + surface_indices.resize(faces_size / 3); Vector3 *facesw = faces.ptrw(); + int32_t *surface_indicesw = surface_indices.ptrw(); int widx = 0; @@ -210,6 +213,8 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const { Vector<Vector3> vertices = a[ARRAY_VERTEX]; const Vector3 *vr = vertices.ptr(); + int32_t from_index = widx / 3; + if (surface_get_format(i) & ARRAY_FORMAT_INDEX) { int ic = surface_get_array_index_len(i); Vector<int> indices = a[ARRAY_INDEX]; @@ -241,6 +246,12 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const { } } } + + int32_t to_index = widx / 3; + + for (int j = from_index; j < to_index; j++) { + surface_indicesw[j] = i; + } } triangle_mesh = Ref<TriangleMesh>(memnew(TriangleMesh)); |