-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Importing Student Art Gallery.glb crashes #57362
Comments
https://github.khronos.org/glTF-Validator/ report. {
"uri": "Student%20Art%20Gallery.glb",
"mimeType": "model/gltf-binary",
"validatorVersion": "2.0.0-dev.3.4",
"validatedAt": "2022-01-28T16:38:56.550Z",
"issues": {
"numErrors": 0,
"numWarnings": 0,
"numInfos": 9,
"numHints": 0,
"messages": [
{
"code": "UNSUPPORTED_EXTENSION",
"message": "Cannot validate an extension as it is not supported by the validator: 'MOZ_hubs_components'.",
"severity": 2,
"pointer": "/extensionsUsed/0"
},
{
"code": "NODE_EMPTY",
"message": "Empty node encountered.",
"severity": 2,
"pointer": "/nodes/0"
},
{
"code": "NODE_EMPTY",
"message": "Empty node encountered.",
"severity": 2,
"pointer": "/nodes/4"
},
{
"code": "NODE_EMPTY",
"message": "Empty node encountered.",
"severity": 2,
"pointer": "/nodes/5"
},
{
"code": "NODE_EMPTY",
"message": "Empty node encountered.",
"severity": 2,
"pointer": "/nodes/15"
},
{
"code": "NODE_EMPTY",
"message": "Empty node encountered.",
"severity": 2,
"pointer": "/nodes/16"
},
{
"code": "NODE_EMPTY",
"message": "Empty node encountered.",
"severity": 2,
"pointer": "/nodes/17"
},
{
"code": "NODE_EMPTY",
"message": "Empty node encountered.",
"severity": 2,
"pointer": "/nodes/18"
},
{
"code": "NODE_EMPTY",
"message": "Empty node encountered.",
"severity": 2,
"pointer": "/nodes/19"
}
],
"truncated": false
},
"info": {
"version": "2.0",
"generator": "Mozilla Spoke 1.0.0.20211203163739",
"extensionsUsed": [
"MOZ_hubs_components",
"KHR_materials_unlit"
],
"resources": [
{
"pointer": "/buffers/0",
"mimeType": "application/gltf-buffer",
"storage": "glb",
"byteLength": 4849108
},
{
"pointer": "/images/0",
"mimeType": "image/jpeg",
"storage": "buffer-view",
"image": {
"width": 2048,
"height": 2048,
"format": "rgb",
"bits": 8
}
},
{
"pointer": "/images/1",
"mimeType": "image/jpeg",
"storage": "buffer-view",
"image": {
"width": 2048,
"height": 2048,
"format": "rgb",
"bits": 8
}
}
],
"animationCount": 0,
"materialCount": 5,
"hasMorphTargets": false,
"hasSkins": false,
"hasTextures": true,
"hasDefaultScene": true,
"drawCallCount": 5,
"totalVertexCount": 35301,
"totalTriangleCount": 24483,
"maxUVs": 1,
"maxInfluences": 0,
"maxAttributes": 2
}
} |
Did a initial test but didn't cover all the cases. diff --git a/scene/resources/importer_mesh.cpp b/scene/resources/importer_mesh.cpp
index 8af0a5533a..87055a4537 100644
--- a/scene/resources/importer_mesh.cpp
+++ b/scene/resources/importer_mesh.cpp
@@ -290,6 +290,7 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli
if (normals.is_empty()) {
normals.resize(vertices.size());
Vector3 *n_ptr = normals.ptrw();
+ ERR_FAIL_COND(normals.size() % 3);
for (unsigned int j = 0; j < index_count; j += 3) {
const Vector3 &v0 = vertices_ptr[indices_ptr[j + 0]];
const Vector3 &v1 = vertices_ptr[indices_ptr[j + 1]];
@@ -1051,7 +1052,9 @@ Error ImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform,
uv_indices.resize(vertex_ofs + vc);
for (int j = 0; j < vc; j++) {
+ ERR_FAIL_INDEX_V(j, rvertices.size(), ERR_INVALID_DATA);
Vector3 v = transform.xform(rvertices[j]);
+ ERR_FAIL_INDEX_V(j, rnormals.size(), ERR_INVALID_DATA);
Vector3 n = normal_basis.xform(rnormals[j]).normalized();
vertices[(j + vertex_ofs) * 3 + 0] = v.x;
@@ -1069,6 +1072,7 @@ Error ImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform,
float eps = 1.19209290e-7F; // Taken from xatlas.h
if (ic == 0) {
for (int j = 0; j < vc / 3; j++) {
+ ERR_FAIL_INDEX_V(j * 3 + 0, rvertices.size(), FAILED);
Vector3 p0 = transform.xform(rvertices[j * 3 + 0]);
Vector3 p1 = transform.xform(rvertices[j * 3 + 1]);
Vector3 p2 = transform.xform(rvertices[j * 3 + 2]);
@@ -1084,6 +1088,9 @@ Error ImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform,
} else {
for (int j = 0; j < ic / 3; j++) {
+ ERR_FAIL_INDEX_V(j * 3 + 0, rindices.size(), FAILED);
+ ERR_FAIL_INDEX_V(j * 3 + 1, rindices.size(), FAILED);
+ ERR_FAIL_INDEX_V(j * 3 + 2, rindices.size(), FAILED);
Vector3 p0 = transform.xform(rvertices[rindices[j * 3 + 0]]);
Vector3 p1 = transform.xform(rvertices[rindices[j * 3 + 1]]);
Vector3 p2 = transform.xform(rvertices[rindices[j * 3 + 2]]);
@@ -1091,7 +1098,6 @@ Error ImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform,
if ((p0 - p1).length_squared() < eps || (p1 - p2).length_squared() < eps || (p2 - p0).length_squared() < eps) {
continue;
}
-
indices.push_back(vertex_ofs + rindices[j * 3 + 0]);
indices.push_back(vertex_ofs + rindices[j * 3 + 1]);
indices.push_back(vertex_ofs + rindices[j * 3 + 2]); |
|
I cannot reproduce this crash anymore in Godot Engine beta 1. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Godot version
4.0 dev 82d412a
System information
Windows 11, Nvidia 3000 series, Vulkan
Issue description
Importing Student Art Gallery.glb crashes Godot.
My best guess is LOD generation and with the normals array out of bounds usage. @JFonS
Steps to reproduce
Minimal reproduction project
godot-gltf-sandbox.zip
The text was updated successfully, but these errors were encountered: