diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-10-03 18:16:27 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-10-03 18:16:27 +0400 |
commit | 157d1205a42b07042d8abdb590034940b68f0b12 (patch) | |
tree | cdf1383d103835dd094ef3f7d9df1e4018f72aa5 /source/blender/blenlib/intern | |
parent | ed7ffb111a7021275738c1710ca34218d851e652 (diff) |
added len_squared_v2v2, use instead of len_v3v3 for font handle tests, also fixed some warnings.
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/freetypefont.c | 14 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_vector_inline.c | 12 |
2 files changed, 17 insertions, 9 deletions
diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index 6d6abc88999..fc41839c303 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -252,15 +252,15 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf } // get the handles that are aligned, tricky... - // DistVL2Dfl, check if the three beztriple points are on one line - // VecLenf, see if there's a distance between the three points - // VecLenf again, to check the angle between the handles + // dist_to_line_v2, check if the three beztriple points are on one line + // len_squared_v2v2, see if there's a distance between the three points + // len_squared_v2v2 again, to check the angle between the handles // finally, check if one of them is a vector handle if((dist_to_line_v2(bezt->vec[0],bezt->vec[1],bezt->vec[2]) < 0.001) && - (len_v3v3(bezt->vec[0], bezt->vec[1]) > 0.0001) && - (len_v3v3(bezt->vec[1], bezt->vec[2]) > 0.0001) && - (len_v3v3(bezt->vec[0], bezt->vec[2]) > 0.0002) && - (len_v3v3(bezt->vec[0], bezt->vec[2]) > MAX2(len_v3v3(bezt->vec[0], bezt->vec[1]), len_v3v3(bezt->vec[1], bezt->vec[2]))) && + (len_squared_v2v2(bezt->vec[0], bezt->vec[1]) > 0.0001*0.0001) && + (len_squared_v2v2(bezt->vec[1], bezt->vec[2]) > 0.0001*0.0001) && + (len_squared_v2v2(bezt->vec[0], bezt->vec[2]) > 0.0002*0.0001) && + (len_squared_v2v2(bezt->vec[0], bezt->vec[2]) > MAX2(len_squared_v2v2(bezt->vec[0], bezt->vec[1]), len_squared_v2v2(bezt->vec[1], bezt->vec[2]))) && bezt->h1 != HD_VECT && bezt->h2 != HD_VECT) { bezt->h1= bezt->h2= HD_ALIGN; diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 84d96d1d22a..2f75fcead79 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -302,7 +302,7 @@ MINLINE void star_m3_v3(float mat[][3], float *vec) MINLINE float len_v2(const float v[2]) { - return (float)sqrt(v[0]*v[0] + v[1]*v[1]); + return (float)sqrtf(v[0]*v[0] + v[1]*v[1]); } MINLINE float len_v2v2(const float v1[2], const float v2[2]) @@ -311,7 +311,7 @@ MINLINE float len_v2v2(const float v1[2], const float v2[2]) x = v1[0]-v2[0]; y = v1[1]-v2[1]; - return (float)sqrt(x*x+y*y); + return (float)sqrtf(x*x+y*y); } MINLINE float len_v3(const float a[3]) @@ -319,6 +319,14 @@ MINLINE float len_v3(const float a[3]) return sqrtf(dot_v3v3(a, a)); } +MINLINE float len_squared_v2v2(const float a[3], const float b[3]) +{ + float d[2]; + + sub_v2_v2v2(d, b, a); + return dot_v2v2(d, d); +} + MINLINE float len_v3v3(const float a[3], const float b[3]) { float d[3]; |