orangeduck / BVHView

A simple viewer for the .bvh animation file format written using raylib.
MIT License
254 stars 14 forks source link

Error parsing floats with really small exponents #4

Closed enekoatxa closed 4 months ago

enekoatxa commented 4 months ago

Hello, I have been trying the web version to visualize some BVH files, and I think i found a small bug when the parser tries to parse floats with exponents that have 2 digits in them. I append an image that shows the error. error

Even though I am not sure that having 2 digits is the problem, I think that is the case, because the line the error occurs in (shown in the next image) fails with the e-40 exponent, and if I remove the 0 to leave a e-4 exponent, the error goes away, and catches the next 2 digit exponent. error2

Thanks in advance.

orangeduck commented 4 months ago

Thanks again for the big report @enekoatxa - can you upload the file causing issues so I can take a look? I suspect the problem is the number is too small to be represented as a float. I can potentially switch the parser to parse doubles and then convert to floats. As a work-around you might be able to get it to work by converting to floats before you write out the bvh file you are exporting (assuming it is your own script doing the export).

enekoatxa commented 4 months ago

Oh, you may be completely right. I deleted the file, sorry, but I generated a new one, that also fails. This one fails at line 541:287, with a number with exponent e-39.

randomGenerator.zip

Meanwhile, I will change my script to export in a better format (I overlooked the unnecessary precision of the output that I generate). Thank you so much!

orangeduck commented 4 months ago

I've pushed up a fix for this here:

https://github.com/orangeduck/BVHView/commit/800e4035a988249ca17c63a882c0db119b4210a7

Now it can open that file. As mentioned in the other thread I will update the pre-compiled windows binaries and web demo next week :)

Thanks,

Dan

enekoatxa commented 4 months ago

Thank you so much, again!

orangeduck commented 4 months ago

Okay web demo and binary updated. Thanks!