diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-03-25 12:20:19 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-03-25 12:20:19 +0400 |
commit | 3b711a6ed009b35bb69cd0ca878eeb8d55fa0e77 (patch) | |
tree | b3fdb366cb49bdea5b57dfa6ba4a82635c68d0ee /source/blender/blenlib/intern/math_vector_inline.c | |
parent | a2ebfc82dbe954acc432ae017ac62a30a11b6a16 (diff) | |
parent | e99a23fc6b33b5097eab44aac19c2a089ddebce6 (diff) |
Merged changes in the trunk up to revision 45133.
Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/bmesh/intern/bmesh_construct.c
source/blender/bmesh/intern/bmesh_mesh_conv.c
source/blender/bmesh/intern/bmesh_mesh_conv.h
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/bmesh_select.c
source/blender/editors/mesh/bmesh_tools.c
source/blender/editors/space_view3d/drawobject.c
source/blender/render/intern/source/shadeoutput.c
Diffstat (limited to 'source/blender/blenlib/intern/math_vector_inline.c')
-rw-r--r-- | source/blender/blenlib/intern/math_vector_inline.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 6414245fb3e..9c26c1ee79a 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -547,10 +547,11 @@ MINLINE float normalize_v2_v2(float r[2], const float a[2]) { float d= dot_v2v2(a, a); - if(d > 1.0e-35f) { + if (d > 1.0e-35f) { d= sqrtf(d); mul_v2_v2fl(r, a, 1.0f/d); - } else { + } + else { zero_v2(r); d= 0.0f; } @@ -569,7 +570,7 @@ MINLINE float normalize_v3_v3(float r[3], const float a[3]) /* a larger value causes normalize errors in a * scaled down models with camera xtreme close */ - if(d > 1.0e-35f) { + if (d > 1.0e-35f) { d= sqrtf(d); mul_v3_v3fl(r, a, 1.0f/d); } @@ -587,7 +588,7 @@ MINLINE double normalize_v3_d(double n[3]) /* a larger value causes normalize errors in a * scaled down models with camera xtreme close */ - if(d > 1.0e-35) { + if (d > 1.0e-35) { double mul; d= sqrt(d); @@ -596,7 +597,8 @@ MINLINE double normalize_v3_d(double n[3]) n[0] *= mul; n[1] *= mul; n[2] *= mul; - } else { + } + else { n[0] = n[1] = n[2] = 0; d= 0.0; } @@ -625,6 +627,12 @@ MINLINE void normal_float_to_short_v3(short out[3], const float in[3]) /********************************* Comparison ********************************/ + +MINLINE int is_zero_v2(const float v[3]) +{ + return (v[0] == 0 && v[1] == 0); +} + MINLINE int is_zero_v3(const float v[3]) { return (v[0] == 0 && v[1] == 0 && v[2] == 0); @@ -657,9 +665,9 @@ MINLINE int equals_v4v4(const float v1[4], const float v2[4]) MINLINE int 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 1; return 0; @@ -678,10 +686,10 @@ MINLINE int compare_len_v3v3(const float v1[3], const float v2[3], const float l MINLINE int 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 1; return 0; |