Page MenuHome

Correct float comparison in when adding shape keys in BKE_keyblock_add_ctime
AbandonedPublic

Authored by Arno Mayrhofer (azrael3000) on Apr 6 2019, 12:22 PM.

Details

Summary

Bug T63326 is caused by a floating point comparison of style a == b which fails due to precission errors. This patch fixes this. Note that the *pos variables are incremented by 0.1 and because of that a difference of 1e-2 is accurate enough.

Diff Detail

Event Timeline

Bastien Montagne (mont29) requested changes to this revision.Apr 7 2019, 11:53 AM

We have compare_ff() in BLI_math, better to use it. Also think 1e-6f would be a better epsilon value here, we want it to be as small as possible (pretty sure you can find users doing crazy stuff and needing sub-millisecond precision ;) ).

This revision now requires changes to proceed.Apr 7 2019, 11:53 AM

For some reason frame numbers here are stored as frame / 100 = frame * 1e-2. I suggest to use 1e-3 for the epsilon.

1e-2 seems too big because it matches one frame step, while 1e-6 will give issues with large frame numbers.

Updated with compare_ff according to Bastien's request. I used Brecht's suggestion for the limit as I agree with him that 1e-6 would be too small if there is a significant number of shape keys.