JuliaIO / MeshIO.jl

IO for Meshes
Other
79 stars 31 forks source link

Fix index remapping #93

Closed ffreyer closed 6 days ago

ffreyer commented 1 week ago

While trying to fix https://github.com/MakieOrg/Makie.jl/pull/3993 I noticed that you get an uninitialized normal (and probably position) when loading the cat mesh (test.obj here). This is due to the index remapping not working correctly. (As a reminder - object files can specify independent indices for positions, normals and texture coordinates within a vertex of a face. OpenGL only allows one index buffer, i.e. one index per vertex, so we need to combine vertex indices into a single unique index and reorder the position, normal and texture coordinate arrays accordingly.)

To fix this I just rewrote the remapping code with a Dict instead of whatever it was doing. That should make it faster and easier to understand/reason with. In the end this removes one position and normal from the cat mesh which should be that undefined first normal/position. I also added a short test for the remapping function.

codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 96.96970% with 1 line in your changes missing coverage. Please review.

Project coverage is 77.08%. Comparing base (d9a3602) to head (a92967a).

Files Patch % Lines
src/util.jl 96.15% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #93 +/- ## ========================================== - Coverage 77.56% 77.08% -0.49% ========================================== Files 10 11 +1 Lines 575 576 +1 ========================================== - Hits 446 444 -2 - Misses 129 132 +3 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.