Commit: 4f08b3cf83c5f9c0fd8b7c0f3d05a84d3f59a6a0
Author: Bastien Montagne
Date: Tue Mar 17 18:13:35 2015 +0100
Branches: blender-v2.74-release
https://developer.blender.org/rB4f08b3cf83c5f9c0fd8b7c0f3d05a84d3f59a6a0
BLI math vec: add 'abs' functions to get absolute values of a vector.
Unseful when handling e.g. scale, sometimes.
===================================================================
M source/blender/blenlib/BLI_math_vector.h
M source/blender/blenlib/intern/math_vector_inline.c
===================================================================
diff --git a/source/blender/blenlib/BLI_math_vector.h
b/source/blender/blenlib/BLI_math_vector.h
index ffd80f4..de712cb 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -146,6 +146,13 @@ MINLINE void negate_v4_v4(float r[4], const float a[3]);
MINLINE void negate_v3_short(short r[3]);
+MINLINE void abs_v2(float r[2]);
+MINLINE void abs_v2_v2(float r[2], const float a[2]);
+MINLINE void abs_v3(float r[3]);
+MINLINE void abs_v3_v3(float r[3], const float a[3]);
+MINLINE void abs_v4(float r[4]);
+MINLINE void abs_v4_v4(float r[4], const float a[4]);
+
MINLINE float dot_v2v2(const float a[2], const float b[2])
ATTR_WARN_UNUSED_RESULT;
MINLINE float dot_v3v3(const float a[3], const float b[3])
ATTR_WARN_UNUSED_RESULT;
MINLINE float dot_v3v3v3(const float p[3], const float a[3], const float b[3])
ATTR_WARN_UNUSED_RESULT;
diff --git a/source/blender/blenlib/intern/math_vector_inline.c
b/source/blender/blenlib/intern/math_vector_inline.c
index 6b6a311..89ae23f 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -611,6 +611,48 @@ MINLINE void negate_v3_short(short r[3])
r[2] = (short)-r[2];
}
+MINLINE void abs_v2(float r[2])
+{
+ r[0] = fabs(r[0]);
+ r[1] = fabs(r[1]);
+}
+
+MINLINE void abs_v2_v2(float r[2], const float a[2])
+{
+ r[0] = fabs(a[0]);
+ r[1] = fabs(a[1]);
+}
+
+MINLINE void abs_v3(float r[3])
+{
+ r[0] = fabs(r[0]);
+ r[1] = fabs(r[1]);
+ r[2] = fabs(r[2]);
+}
+
+MINLINE void abs_v3_v3(float r[3], const float a[3])
+{
+ r[0] = fabs(a[0]);
+ r[1] = fabs(a[1]);
+ r[2] = fabs(a[2]);
+}
+
+MINLINE void abs_v4(float r[4])
+{
+ r[0] = fabs(r[0]);
+ r[1] = fabs(r[1]);
+ r[2] = fabs(r[2]);
+ r[3] = fabs(r[3]);
+}
+
+MINLINE void abs_v4_v4(float r[4], const float a[4])
+{
+ r[0] = fabs(a[0]);
+ r[1] = fabs(a[1]);
+ r[2] = fabs(a[2]);
+ r[3] = fabs(a[3]);
+}
+
MINLINE float dot_v2v2(const float a[2], const float b[2])
{
return a[0] * b[0] + a[1] * b[1];
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs