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-12 22:47:54 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-01-12 22:47:54 +0300
commitff353b49395c81305af5cec9ce4d9354e50d4cf7 (patch)
tree9e4595c8328d1dcfd0d201a026c4e33486013112 /source/blender/blenlib
parent489ef9cff1abd74a938b06c3505705affd1b9d31 (diff)
Math lib: added normalize_v3_v3 in addition to normalize_v3.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_vector.h5
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c35
2 files changed, 30 insertions, 10 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 4719a835788..9fb9e36bd2b 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -70,8 +70,9 @@ MINLINE void sub_v3_v3(float r[3], float a[3]);
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3]);
MINLINE void mul_v2_fl(float r[2], float f);
+MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f);
MINLINE void mul_v3_fl(float r[3], float f);
-MINLINE void mul_v3_v3fl(float r[3], float a[3], float f);
+MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f);
MINLINE void mul_v2_v2(float r[2], const float a[2]);
MINLINE void mul_v3_v3(float r[3], float a[3]);
MINLINE void mul_v3_v3v3(float r[3], float a[3], float b[3]);
@@ -101,7 +102,9 @@ MINLINE float len_v3(const float a[3]);
MINLINE float len_v3v3(const float a[3], const float b[3]);
MINLINE float normalize_v2(float r[2]);
+MINLINE float normalize_v2_v2(float r[2], const float a[2]);
MINLINE float normalize_v3(float r[3]);
+MINLINE float normalize_v3_v3(float r[3], const float a[3]);
/******************************* Interpolation *******************************/
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 86a0d0f49a1..9011234dccb 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -131,6 +131,12 @@ MINLINE void mul_v2_fl(float *v1, float f)
v1[1]*= f;
}
+MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
+{
+ r[0]= a[0]*f;
+ r[1]= a[1]*f;
+}
+
MINLINE void mul_v3_fl(float r[3], float f)
{
r[0] *= f;
@@ -138,7 +144,7 @@ MINLINE void mul_v3_fl(float r[3], float f)
r[2] *= f;
}
-MINLINE void mul_v3_v3fl(float r[3], float a[3], float f)
+MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
{
r[0]= a[0]*f;
r[1]= a[1]*f;
@@ -275,38 +281,49 @@ MINLINE float len_v3v3(const float a[3], const float b[3])
return len_v3(d);
}
-MINLINE float normalize_v2(float n[2])
+MINLINE float normalize_v2_v2(float r[2], const float a[2])
{
- float d= dot_v2v2(n, n);
+ float d= dot_v2v2(a, a);
if(d > 1.0e-35f) {
d= sqrtf(d);
- mul_v2_fl(n, 1.0f/d);
+ mul_v2_v2fl(r, a, 1.0f/d);
} else {
- zero_v2(n);
+ zero_v2(r);
d= 0.0f;
}
+
return d;
}
-MINLINE float normalize_v3(float n[3])
+MINLINE float normalize_v2(float n[2])
+{
+ return normalize_v2_v2(n, n);
+}
+
+MINLINE float normalize_v3_v3(float r[3], const float a[3])
{
- float d= dot_v3v3(n, n);
+ float d= dot_v3v3(a, a);
/* a larger value causes normalize errors in a
scaled down models with camera xtreme close */
if(d > 1.0e-35f) {
d= sqrtf(d);
- mul_v3_fl(n, 1.0f/d);
+ mul_v3_v3fl(r, a, 1.0f/d);
}
else {
- zero_v3(n);
+ zero_v3(r);
d= 0.0f;
}
return d;
}
+MINLINE float normalize_v3(float n[3])
+{
+ return normalize_v3_v3(n, n);
+}
+
MINLINE void normal_short_to_float_v3(float *out, short *in)
{
out[0] = in[0]*(1.0f/32767.0f);