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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2010-01-22 14:10:24 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-01-22 14:10:24 +0300
commit8ec59c7c687b9e50c48a9d455b31ff4c01df69d2 (patch)
tree32bf65aad65475c5dd9aeefa9067eba21e7324fb /source/blender/blenlib/intern/math_vector_inline.c
parent2d2339a70992b819a23e8c71f68027022b395f46 (diff)
Math Lib:
* inline some more functions, from math_base and math_vector * also made some changes to the way inline is done so it can work for more than one file * reflect_v3_v3v3 requires input vectors to be normalized now. * added rgb_to_grayscale * added zero_v4, copy_v4_v4, swap_v4_v4, is_one_v3 * added box_clip_bounds_m4 to clip a bounding box against a projection matrix
Diffstat (limited to 'source/blender/blenlib/intern/math_vector_inline.c')
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 9011234dccb..2181150f640 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -45,6 +45,14 @@ MINLINE void zero_v3(float r[3])
r[2]= 0.0f;
}
+MINLINE void zero_v4(float r[4])
+{
+ r[0]= 0.0f;
+ r[1]= 0.0f;
+ r[2]= 0.0f;
+ r[3]= 0.0f;
+}
+
MINLINE void copy_v2_v2(float r[2], const float a[2])
{
r[0]= a[0];
@@ -58,6 +66,14 @@ MINLINE void copy_v3_v3(float r[3], const float a[3])
r[2]= a[2];
}
+MINLINE void copy_v4_v4(float r[4], float a[4])
+{
+ r[0]= a[0];
+ r[1]= a[1];
+ r[2]= a[2];
+ r[3]= a[3];
+}
+
MINLINE void swap_v2_v2(float a[2], float b[2])
{
SWAP(float, a[0], b[0]);
@@ -71,6 +87,14 @@ MINLINE void swap_v3_v3(float a[3], float b[3])
SWAP(float, a[2], b[2]);
}
+MINLINE void swap_v4_v4(float a[4], float b[4])
+{
+ SWAP(float, a[0], b[0]);
+ SWAP(float, a[1], b[1]);
+ SWAP(float, a[2], b[2]);
+ SWAP(float, a[3], b[3]);
+}
+
/********************************* Arithmetic ********************************/
MINLINE void add_v2_v2(float *r, float *a)
@@ -338,5 +362,54 @@ MINLINE void normal_float_to_short_v3(short *out, float *in)
out[2] = (short)(in[2]*32767.0f);
}
+/********************************* Comparison ********************************/
+
+MINLINE int is_zero_v3(float *v)
+{
+ return (v[0] == 0 && v[1] == 0 && v[2] == 0);
+}
+
+MINLINE int is_one_v3(float *v)
+{
+ return (v[0] == 1 && v[1] == 1 && v[2] == 1);
+}
+
+MINLINE int equals_v3v3(float *v1, float *v2)
+{
+ return ((v1[0]==v2[0]) && (v1[1]==v2[1]) && (v1[2]==v2[2]));
+}
+
+MINLINE int compare_v3v3(float *v1, float *v2, float limit)
+{
+ if(fabs(v1[0]-v2[0])<limit)
+ if(fabs(v1[1]-v2[1])<limit)
+ if(fabs(v1[2]-v2[2])<limit)
+ return 1;
+
+ return 0;
+}
+
+MINLINE int compare_len_v3v3(float *v1, float *v2, float limit)
+{
+ 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*limit));
+}
+
+MINLINE int compare_v4v4(float *v1, float *v2, float limit)
+{
+ if(fabs(v1[0]-v2[0])<limit)
+ if(fabs(v1[1]-v2[1])<limit)
+ if(fabs(v1[2]-v2[2])<limit)
+ if(fabs(v1[3]-v2[3])<limit)
+ return 1;
+
+ return 0;
+}
+
#endif /* BLI_MATH_VECTOR_INLINE */