Skip to content
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

[rmodels] Crash when loading OBJ file with no normals (?) #4616

Open
AndreaBoroni opened this issue Dec 18, 2024 · 1 comment
Open

[rmodels] Crash when loading OBJ file with no normals (?) #4616

AndreaBoroni opened this issue Dec 18, 2024 · 1 comment

Comments

@AndreaBoroni
Copy link
Contributor

I am trying to load an .OBJ file and I get a Segmentation Fault in LoadOBJ() when copying over the normals (

for (int i = 0; i < 3; i++) model.meshes[meshIndex].normals[localMeshVertexCount*3 + i] = objAttributes.normals[normalIndex*3 + i];
). I traced the issue to tinyobj_loader_c.h leaving the normals indexes invalid (0x80000000) if it does not detect normals. I downloaded the model from the internet so I am not 100% sure, but my guess is that it does not have any normals defined in the .OBJ file.

It should be easy to check before copying over if the indexes are valid (also for the textcoord). I can make a PR myself if this is in line with what we want.

Here is a zip of the .OBJ file
Low_Poly_City_Cars.zip

@raysan5
Copy link
Owner

raysan5 commented Dec 18, 2024

@AndreaBoroni The issue could be related to other than normals, I checked the .obj and it contains up to 14 meshes, some define texture coordinates and some not. I think that's the issue, not the normals.

no_name     -> v, vt
o Plane     -> v, vt
o Car_12    -> v
o Car_11    -> v
o Car_10    -> v, vt
o Car_09    -> v
o Car_08    -> v
o Car_07    -> v, vt
o Car_06    -> v
o Car_05    -> v
o Car_04    -> v, vt
o CAR_03    -> v
o CAR_02    -> v
o CAR_01    -> v

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants