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] Triangle segment spilling has some weird issues. #11

Closed FractalFir closed 1 year ago

FractalFir commented 1 year ago

Describe the bug Triangle segment spiriting should not change the mesh in any way, besides reducing file size. Basic tests show that there are no issues with spilling segments, but when a real mesh(Suzanne) is saved/read and then exported, one triangle is always wrong.

To Reproduce Read/save and the export a mesh.

Expected behavior Exported mesh is the same as imported one.

FractalFir commented 1 year ago

It seems that while segment splitting causes the issue to show up, it is not the root cause. Index with value 4096 is saved as one with value 0. The precision of the segment with the issue is 12 bits, so it can save the values in range 0-4095. It means that the value 0b1000000000000 is saved as 0b000000000000, with the last one cut off, since it is the 13 bit. The bug likely stems from an off-by-one error in segment precision calculations.

FractalFir commented 1 year ago

Fixed in fde563ef990367a82457287fe1c5ce7c1ae07083.