Twinklebear / tobj

Tiny OBJ Loader in Rust
MIT License
233 stars 47 forks source link

triangulate_faces does not guarantee triangle-only mesh #36

Closed virtualritz closed 3 years ago

virtualritz commented 3 years ago

I saw this in the docs:

Indices for vertices of each face. If loaded with triangulate_faces, each face in the mesh is a triangle, [...]

This is not true. Even with triangulate_faces the mesh may still contain (degenerate) faces with two points (type Line). And then the length in the buffer for those is 2, not 3. So that the indices for face n in the buffer do not start at n * 3 in this case.

I suggest blowing up such faces into degenerate triangles when triangulate_faces is on and making the resp. index in an Option. I will include this change in my fork so you can have a look.

Twinklebear commented 3 years ago

This is part of the PR and now in 3.0.0 correct? So we can close this?

virtualritz commented 3 years ago

Correct.