diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-08-20 13:34:52 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-08-20 13:34:52 +0400 |
commit | 38338a51c92e3f47601199689c294da8a20bec18 (patch) | |
tree | 5126a8841dc87de0b81e09d9348e74fa550c0e0b /source/blender/blenlib/intern | |
parent | f3654ce6b66ead081345f62aea3dec3461e4d1e2 (diff) |
add is_finite_v# functions, use bool's
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/math_vector_inline.c | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 8e5040d983b..ce5d9657c7f 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -771,61 +771,76 @@ MINLINE void normal_float_to_short_v3(short out[3], const float in[3]) /********************************* Comparison ********************************/ -MINLINE int is_zero_v2(const float v[2]) +MINLINE bool is_zero_v2(const float v[2]) { return (v[0] == 0 && v[1] == 0); } -MINLINE int is_zero_v3(const float v[3]) +MINLINE bool is_zero_v3(const float v[3]) { return (v[0] == 0 && v[1] == 0 && v[2] == 0); } -MINLINE int is_zero_v4(const float v[4]) +MINLINE bool is_zero_v4(const float v[4]) { return (v[0] == 0 && v[1] == 0 && v[2] == 0 && v[3] == 0); } -MINLINE int is_one_v3(const float v[3]) +MINLINE bool is_finite_v2(const float v[2]) +{ + return (finite(v[0]) && finite(v[1])); +} + +MINLINE bool is_finite_v3(const float v[3]) +{ + return (finite(v[0]) && finite(v[1]) && finite(v[2])); +} + +MINLINE bool is_finite_v4(const float v[4]) +{ + return (finite(v[0]) && finite(v[1]) && finite(v[2]) && finite(v[3])); +} + +MINLINE bool is_one_v3(const float v[3]) { return (v[0] == 1 && v[1] == 1 && v[2] == 1); } -MINLINE int equals_v2v2(const float v1[2], const float v2[2]) +MINLINE bool equals_v2v2(const float v1[2], const float v2[2]) { return ((v1[0] == v2[0]) && (v1[1] == v2[1])); } -MINLINE int equals_v3v3(const float v1[3], const float v2[3]) +MINLINE bool equals_v3v3(const float v1[3], const float v2[3]) { return ((v1[0] == v2[0]) && (v1[1] == v2[1]) && (v1[2] == v2[2])); } -MINLINE int equals_v4v4(const float v1[4], const float v2[4]) +MINLINE bool equals_v4v4(const float v1[4], const float v2[4]) { return ((v1[0] == v2[0]) && (v1[1] == v2[1]) && (v1[2] == v2[2]) && (v1[3] == v2[3])); } -MINLINE int compare_v2v2(const float v1[2], const float v2[2], const float limit) +MINLINE bool compare_v2v2(const float v1[2], const float v2[2], const float limit) { if (fabsf(v1[0] - v2[0]) < limit) if (fabsf(v1[1] - v2[1]) < limit) - return 1; + return true; - return 0; + return false; } -MINLINE int compare_v3v3(const float v1[3], const float v2[3], const float limit) +MINLINE bool compare_v3v3(const float v1[3], const float v2[3], const float limit) { if (fabsf(v1[0] - v2[0]) < limit) if (fabsf(v1[1] - v2[1]) < limit) if (fabsf(v1[2] - v2[2]) < limit) - return 1; + return true; - return 0; + return false; } -MINLINE int compare_len_v3v3(const float v1[3], const float v2[3], const float limit) +MINLINE bool compare_len_v3v3(const float v1[3], const float v2[3], const float limit) { float x, y, z; @@ -836,15 +851,15 @@ MINLINE int compare_len_v3v3(const float v1[3], const float v2[3], const float l return ((x * x + y * y + z * z) < (limit * limit)); } -MINLINE int compare_v4v4(const float v1[4], const float v2[4], const float limit) +MINLINE bool compare_v4v4(const float v1[4], const float v2[4], const float limit) { if (fabsf(v1[0] - v2[0]) < limit) if (fabsf(v1[1] - v2[1]) < limit) if (fabsf(v1[2] - v2[2]) < limit) if (fabsf(v1[3] - v2[3]) < limit) - return 1; + return true; - return 0; + return false; } MINLINE float line_point_side_v2(const float l1[2], const float l2[2], const float pt[2]) |