FractalFir / tmf

Tight Model format is an experimental lossy 3D model format focused on reducing file size as much as posible without decreasing visual quality of the viewed model or read speeds.
MIT License
100 stars 6 forks source link

[BUG] find_best_vertex_spilt in tmf_exporter.rs panics if best_split_index is the last vertex #22

Open dbartussek opened 3 months ago

dbartussek commented 3 months ago

The find_best_vertex_split function iterates over all vertices: https://github.com/FractalFir/tmf/blob/9c5f61ba037fa65a1edba7ffcb7e615e14831ca8/src/tmf_exporter.rs#L319

However, immediately after the loop, there is an assertion that best_split_index may not be the last vertex: https://github.com/FractalFir/tmf/blob/9c5f61ba037fa65a1edba7ffcb7e615e14831ca8/src/tmf_exporter.rs#L339

While testing file sizes of different formats, I've encountered a model that apparently meets this edge case, resulting in an assertion error.

This is the mesh I am trying to export. It's the dragon sample model from the official glTF samples with computed tangents, run through meshopt: dragon.zip

FractalFir commented 2 months ago

It was a stupid logic error. The assertion was supposed to check that the algo never returns Some(last_index). I moved the assertion to the Some-returning arm of the if statement.

Should be fixed in 0.2.1