diff options
author | Max Hilbrunner <mhilbrunner@users.noreply.github.com> | 2022-08-20 05:32:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-20 05:32:28 +0200 |
commit | 5e0d2b5097d5091490f6ca84c5e9188c4ebefa4b (patch) | |
tree | 29b5b599efcc072253b6686068e259a971973b48 /scene | |
parent | 47d3fd99a2515345229d9d247b79eb36d0f67884 (diff) | |
parent | bbbcdd725ac8786722b6d327be5ae91344ec7d96 (diff) |
Merge pull request #62046 from clayjohn/vertexless-draw
Allow creating meshes without vertex positions
Diffstat (limited to 'scene')
-rw-r--r-- | scene/resources/mesh.cpp | 5 | ||||
-rw-r--r-- | scene/resources/mesh.h | 1 |
2 files changed, 5 insertions, 1 deletions
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index ec9db89794..3f73df2e5d 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -201,7 +201,9 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const { continue; } int len = (surface_get_format(i) & ARRAY_FORMAT_INDEX) ? surface_get_array_index_len(i) : surface_get_array_len(i); - if ((primitive == PRIMITIVE_TRIANGLES && (len == 0 || (len % 3) != 0)) || (primitive == PRIMITIVE_TRIANGLE_STRIP && len < 3)) { + if ((primitive == PRIMITIVE_TRIANGLES && (len == 0 || (len % 3) != 0)) || + (primitive == PRIMITIVE_TRIANGLE_STRIP && len < 3) || + (surface_get_format(i) & ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY)) { // Error was already shown, just skip (including zero). continue; } @@ -211,6 +213,7 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const { int vc = surface_get_array_len(i); Vector<Vector3> vertices = a[ARRAY_VERTEX]; + ERR_FAIL_COND_V(vertices.is_empty(), Ref<TriangleMesh>()); const Vector3 *vr = vertices.ptr(); int32_t from_index = widx / 3; diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h index 142373ce7f..63dbda92d0 100644 --- a/scene/resources/mesh.h +++ b/scene/resources/mesh.h @@ -144,6 +144,7 @@ public: ARRAY_FLAG_USE_DYNAMIC_UPDATE = RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE, ARRAY_FLAG_USE_8_BONE_WEIGHTS = RS::ARRAY_FLAG_USE_8_BONE_WEIGHTS, + ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY = RS::ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY, }; virtual int get_surface_count() const; |