diff options
author | Ton Roosendaal <ton@blender.org> | 2004-05-12 23:17:00 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2004-05-12 23:17:00 +0400 |
commit | cf2aef1df9155f73ed26639dc57e7a8d6cbc4ed5 (patch) | |
tree | f7ac8963e7570e35a5b6717a694fcc6079d8f079 /source/blender | |
parent | 2825750330c297fd405feb6f3f581459670d2add (diff) |
Secured division by extreme values with a FLT_EPSILON. This might
prevent hanging on optimized windows build. That's going to be tested
now!
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/render/intern/source/ray.c | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/source/blender/render/intern/source/ray.c b/source/blender/render/intern/source/ray.c index a1c64997664..040c4a00caa 100644 --- a/source/blender/render/intern/source/ray.c +++ b/source/blender/render/intern/source/ray.c @@ -56,6 +56,8 @@ #define DDA_SHADOW_TRA 2 #define DEPTH_SHADOW_TRA 10 +/* from float.h */ +#define FLT_EPSILON 1.19209290e-07F /* ********** structs *************** */ @@ -1134,49 +1136,43 @@ static int d3dda(Isect *is) dox= ox1-ox2; doy= oy1-oy2; doz= oz1-oz2; - - if(dox!=0.0) { - if(dox<0.0) { - labdax= (ox1-ocx1-1.0)/dox; - ldx= -1.0/dox; - dx= 1; - } else { - labdax= (ox1-ocx1)/dox; - ldx= 1.0/dox; - dx= -1; - } + + if(dox<-FLT_EPSILON) { + labdax= (ox1-ocx1-1.0)/dox; + ldx= -1.0/dox; + dx= 1; + } else if(dox>FLT_EPSILON) { + labdax= (ox1-ocx1)/dox; + ldx= 1.0/dox; + dx= -1; } else { labdax=1.0; ldx=0; dx= 0; } - if(doy!=0.0) { - if(doy<0.0) { - labday= (oy1-ocy1-1.0)/doy; - ldy= -1.0/doy; - dy= 1; - } else { - labday= (oy1-ocy1)/doy; - ldy= 1.0/doy; - dy= -1; - } + if(doy<-FLT_EPSILON) { + labday= (oy1-ocy1-1.0)/doy; + ldy= -1.0/doy; + dy= 1; + } else if(doy>FLT_EPSILON) { + labday= (oy1-ocy1)/doy; + ldy= 1.0/doy; + dy= -1; } else { labday=1.0; ldy=0; dy= 0; } - if(doz!=0.0) { - if(doz<0.0) { - labdaz= (oz1-ocz1-1.0)/doz; - ldz= -1.0/doz; - dz= 1; - } else { - labdaz= (oz1-ocz1)/doz; - ldz= 1.0/doz; - dz= -1; - } + if(doz<-FLT_EPSILON) { + labdaz= (oz1-ocz1-1.0)/doz; + ldz= -1.0/doz; + dz= 1; + } else if(doz>FLT_EPSILON) { + labdaz= (oz1-ocz1)/doz; + ldz= 1.0/doz; + dz= -1; } else { labdaz=1.0; ldz=0; |