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:
authorAntony Riakiotakis <kalast@gmail.com>2014-09-08 20:15:42 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-09-08 20:15:42 +0400
commitd9ffc99e66d659ac887d801b9cc071b4c3f9b8ab (patch)
treed88e83b5a9edab115081641d26c811b6aa22296a /source/blender/blenlib/intern/math_vector_inline.c
parent551ebaa3dd758bc1975548c28766bfa3159d3846 (diff)
parentb1490e39dd1017e51984d8a34d226e869bbb25df (diff)
Merge branch 'master' into soc-2014-viewport_fxsoc-2014-viewport_fx
I have resolved some differences, for instance selection code which was more or less a stub, to be the same as master. This will have to be fixed later. Conflicts: CMakeLists.txt intern/ghost/CMakeLists.txt intern/ghost/intern/GHOST_SystemWin32.cpp intern/ghost/intern/GHOST_Window.cpp intern/ghost/intern/GHOST_WindowWin32.cpp intern/ghost/intern/GHOST_WindowX11.cpp source/blender/blenlib/BLI_math_matrix.h source/blender/blenlib/intern/math_matrix.c source/blender/gpu/CMakeLists.txt source/blender/gpu/GPU_select.h source/blender/gpu/intern/gpu_buffers.c source/blender/gpu/intern/gpu_draw.c source/blender/gpu/intern/gpu_extensions.c source/blender/gpu/intern/gpu_select.c source/blender/gpu/shaders/gpu_shader_simple_vert.glsl source/blender/nodes/CMakeLists.txt
Diffstat (limited to 'source/blender/blenlib/intern/math_vector_inline.c')
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c52
1 files changed, 36 insertions, 16 deletions
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 2639767fcb1..3ed4a561698 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -479,7 +479,7 @@ MINLINE float mul_project_m4_v3_zfac(float mat[4][4], const float co[3])
}
/**
- * Has the effect of mul_m3_v3(), on a single axis.
+ * Has the effect of #mul_m3_v3(), on a single axis.
*/
MINLINE float dot_m3_v3_row_x(float M[3][3], const float a[3])
{
@@ -495,7 +495,8 @@ MINLINE float dot_m3_v3_row_z(float M[3][3], const float a[3])
}
/**
- * Almost like mul_m4_v3(), misses adding translation.
+ * Has the effect of #mul_mat3_m4_v3(), on a single axis.
+ * (no adding translation)
*/
MINLINE float dot_m4_v3_row_x(float M[4][4], const float a[3])
{
@@ -863,17 +864,17 @@ MINLINE void normal_float_to_short_v3(short out[3], const float in[3])
MINLINE bool is_zero_v2(const float v[2])
{
- return (v[0] == 0 && v[1] == 0);
+ return (v[0] == 0.0f && v[1] == 0.0f);
}
MINLINE bool is_zero_v3(const float v[3])
{
- return (v[0] == 0 && v[1] == 0 && v[2] == 0);
+ return (v[0] == 0.0f && v[1] == 0.0f && v[2] == 0.0f);
}
MINLINE bool is_zero_v4(const float v[4])
{
- return (v[0] == 0 && v[1] == 0 && v[2] == 0 && v[3] == 0);
+ return (v[0] == 0.0f && v[1] == 0.0f && v[2] == 0.0f && v[3] == 0.0f);
}
MINLINE bool is_finite_v2(const float v[2])
@@ -893,9 +894,15 @@ MINLINE bool is_finite_v4(const float v[4])
MINLINE bool is_one_v3(const float v[3])
{
- return (v[0] == 1 && v[1] == 1 && v[2] == 1);
+ return (v[0] == 1.0f && v[1] == 1.0f && v[2] == 1.0f);
}
+
+/** \name Vector Comparison
+ *
+ * \note use ``value <= limit``, so a limit of zero doesn't fail on an exact match.
+ * \{ */
+
MINLINE bool equals_v2v2(const float v1[2], const float v2[2])
{
return ((v1[0] == v2[0]) && (v1[1] == v2[1]));
@@ -913,8 +920,8 @@ MINLINE bool equals_v4v4(const float v1[4], const float v2[4])
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)
+ if (fabsf(v1[0] - v2[0]) <= limit)
+ if (fabsf(v1[1] - v2[1]) <= limit)
return true;
return false;
@@ -922,9 +929,9 @@ MINLINE bool compare_v2v2(const float v1[2], const float v2[2], const float limi
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)
+ if (fabsf(v1[0] - v2[0]) <= limit)
+ if (fabsf(v1[1] - v2[1]) <= limit)
+ if (fabsf(v1[2] - v2[2]) <= limit)
return true;
return false;
@@ -938,15 +945,26 @@ MINLINE bool compare_len_v3v3(const float v1[3], const float v2[3], const float
y = v1[1] - v2[1];
z = v1[2] - v2[2];
- return ((x * x + y * y + z * z) < (limit * limit));
+ return ((x * x + y * y + z * z) <= (limit * limit));
+}
+
+MINLINE bool compare_len_squared_v3v3(const float v1[3], const float v2[3], const float limit_sq)
+{
+ float x, y, z;
+
+ x = v1[0] - v2[0];
+ y = v1[1] - v2[1];
+ z = v1[2] - v2[2];
+
+ return ((x * x + y * y + z * z) <= limit_sq);
}
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)
+ 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 true;
return false;
@@ -958,4 +976,6 @@ MINLINE float line_point_side_v2(const float l1[2], const float l2[2], const flo
((l2[0] - pt[0]) * (l1[1] - pt[1])));
}
+/** \} */
+
#endif /* __MATH_VECTOR_INLINE_C__ */