diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-05-09 02:11:16 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-05-09 02:11:16 +0400 |
commit | d93a93596527911155911a307b102e09c35c37f1 (patch) | |
tree | c7a5f7ed9c52e0e41b3691358d2efeb555dcc59e /intern | |
parent | 56342f222f60cffbc636b01407079bfa1d2fb2da (diff) |
Fix division by zero case in dualcon.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/dualcon/intern/Projections.h | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/intern/dualcon/intern/Projections.h b/intern/dualcon/intern/Projections.h index be49fafb310..7740b0d1634 100644 --- a/intern/dualcon/intern/Projections.h +++ b/intern/dualcon/intern/Projections.h @@ -783,19 +783,17 @@ float getIntersectionPrimary(int edgeInd) LONG proj0 = cubeProj[i][0]; LONG proj1 = cubeProj[i][0] + cubeProj[i][edgeInd + 1]; LONG proj2 = inherit->trigProj[i][1]; + LONG d = proj1 - proj0; + double alpha; - // double alpha = (double)( ( proj2 - proj0 ) * cubeProj[edgeInd][edgeInd + 1] ) / (double)( proj1 - proj0 ) ; - double alpha = (double)( (proj2 - proj0) ) / (double)(proj1 - proj0); - - if (alpha < 0) - { + if (d == 0) alpha = 0.5; - } - else if (alpha > 1) - { - alpha = 0.5; - } + else { + alpha = (double)((proj2 - proj0)) / (double)d; + if (alpha < 0 || alpha > 1) + alpha = 0.5; + } return (float)alpha; }; |