[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59319] trunk/blender/source/blender: add is_finite_v# functions, use bool's
Campbell Barton
ideasman42 at gmail.com
Tue Aug 20 11:34:52 CEST 2013
Revision: 59319
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59319
Author: campbellbarton
Date: 2013-08-20 09:34:52 +0000 (Tue, 20 Aug 2013)
Log Message:
-----------
add is_finite_v# functions, use bool's
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_math_vector.h
trunk/blender/source/blender/blenlib/intern/math_vector_inline.c
trunk/blender/source/blender/python/bmesh/bmesh_py_types_customdata.c
Modified: trunk/blender/source/blender/blenlib/BLI_math_vector.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_vector.h 2013-08-20 08:41:34 UTC (rev 59318)
+++ trunk/blender/source/blender/blenlib/BLI_math_vector.h 2013-08-20 09:34:52 UTC (rev 59319)
@@ -196,19 +196,25 @@
/********************************* 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 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 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 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 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_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;
/********************************** Angles ***********************************/
Modified: trunk/blender/source/blender/blenlib/intern/math_vector_inline.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_vector_inline.c 2013-08-20 08:41:34 UTC (rev 59318)
+++ trunk/blender/source/blender/blenlib/intern/math_vector_inline.c 2013-08-20 09:34:52 UTC (rev 59319)
@@ -771,61 +771,76 @@
/********************************* 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 @@
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])
Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_types_customdata.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_types_customdata.c 2013-08-20 08:41:34 UTC (rev 59318)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_types_customdata.c 2013-08-20 09:34:52 UTC (rev 59319)
@@ -32,6 +32,7 @@
#include <Python.h>
+#include "BLI_utildefines.h"
#include "BLI_string.h"
#include "BLI_math_vector.h"
More information about the Bf-blender-cvs
mailing list