Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenlib/BLI_math_vector.h30
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c49
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_customdata.c1
3 files changed, 51 insertions, 29 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index e163c06440c..0a819ce062e 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -196,18 +196,24 @@ void flip_v2_v2v2(float v[2], const float v1[2], const float v2[2]);
/********************************* Comparison ********************************/
-MINLINE int is_zero_v3(const float a[3]) UNUSED_RESULT_ATTR;
-MINLINE int is_zero_v4(const float a[4]) UNUSED_RESULT_ATTR;
-MINLINE int is_one_v3(const float a[3]) UNUSED_RESULT_ATTR;
-
-MINLINE int equals_v2v2(const float v1[2], const float v2[2]) UNUSED_RESULT_ATTR;
-MINLINE int equals_v3v3(const float a[3], const float b[3]) UNUSED_RESULT_ATTR;
-MINLINE int compare_v2v2(const float a[2], const float b[2], const float limit) UNUSED_RESULT_ATTR;
-MINLINE int compare_v3v3(const float a[3], const float b[3], const float limit) UNUSED_RESULT_ATTR;
-MINLINE int compare_len_v3v3(const float a[3], const float b[3], const float limit) UNUSED_RESULT_ATTR;
-
-MINLINE int compare_v4v4(const float a[4], const float b[4], const float limit) UNUSED_RESULT_ATTR;
-MINLINE int equals_v4v4(const float a[4], const float b[4]) UNUSED_RESULT_ATTR;
+MINLINE bool is_zero_v2(const float a[3]) UNUSED_RESULT_ATTR;
+MINLINE bool is_zero_v3(const float a[3]) UNUSED_RESULT_ATTR;
+MINLINE bool is_zero_v4(const float a[4]) UNUSED_RESULT_ATTR;
+
+MINLINE bool is_finite_v2(const float a[3]) UNUSED_RESULT_ATTR;
+MINLINE bool is_finite_v3(const float a[3]) UNUSED_RESULT_ATTR;
+MINLINE bool is_finite_v4(const float a[4]) UNUSED_RESULT_ATTR;
+
+MINLINE bool is_one_v3(const float a[3]) UNUSED_RESULT_ATTR;
+
+MINLINE bool equals_v2v2(const float v1[2], const float v2[2]) UNUSED_RESULT_ATTR;
+MINLINE bool equals_v3v3(const float a[3], const float b[3]) UNUSED_RESULT_ATTR;
+MINLINE bool compare_v2v2(const float a[2], const float b[2], const float limit) UNUSED_RESULT_ATTR;
+MINLINE bool compare_v3v3(const float a[3], const float b[3], const float limit) UNUSED_RESULT_ATTR;
+MINLINE bool compare_len_v3v3(const float a[3], const float b[3], const float limit) UNUSED_RESULT_ATTR;
+
+MINLINE bool compare_v4v4(const float a[4], const float b[4], const float limit) UNUSED_RESULT_ATTR;
+MINLINE bool equals_v4v4(const float a[4], const float b[4]) UNUSED_RESULT_ATTR;
MINLINE float line_point_side_v2(const float l1[2], const float l2[2], const float pt[2]) UNUSED_RESULT_ATTR;
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])
diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c
index b0604fa2dbc..30902c615a1 100644
--- a/source/blender/python/bmesh/bmesh_py_types_customdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c
@@ -32,6 +32,7 @@
#include <Python.h>
+#include "BLI_utildefines.h"
#include "BLI_string.h"
#include "BLI_math_vector.h"