Blender Git Commit Log

Git Commits -> Revision 7837f0e

Revision 7837f0e by Bastien Montagne (master)
July 10, 2015, 13:02 (GMT)
BLI_math 'compare' cleanup & enhancements.

This commit:
* Adds a 'compare_ff' function for absolute 'almost equal' comparison of floats.
* Makes 'compare_vxvx' functions use that new 'compare_ff' one.
* Adds a 'compare_ff_relative' function for secured ulp-based relative comparison of floats.
* Adds matching 'compare_vxvx_relative' functions.
* Adds some basic tests for compare_ff_relative.

See https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

Note that we could replace our python/mathutils' EXPP_FloatsAreEqual() by BLI's compare_ff_relative
(using a very small absolute max_diff), but these do not have exact same behavior...
Left a comment there for now, we can do it later if/when we are sure it won't break anything!

Commit Details:

Full Hash: 7837f0e8332f3726e0322b0c48b0da4d7c2d5813
Parent Commit: bbcbd2e
Lines Changed: +182, -24

1 Added Path:

/tests/gtests/blenlib/BLI_math_base_test.cc (+87, -0) (View)

6 Modified Paths:

/source/blender/blenlib/BLI_math_base.h (+3, -0) (Diff)
/source/blender/blenlib/BLI_math_vector.h (+8, -3) (Diff)
/source/blender/blenlib/intern/math_base_inline.c (+40, -0) (Diff)
/source/blender/blenlib/intern/math_vector_inline.c (+34, -21) (Diff)
/source/blender/python/mathutils/mathutils.c (+9, -0) (Diff)
/tests/gtests/blenlib/CMakeLists.txt (+1, -0) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021