diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-09-18 16:53:41 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-09-18 16:53:41 +0400 |
commit | a53351d204309afb9be74a2075f14a74b2c31165 (patch) | |
tree | b2bdf51fcbab1029787c37fd47e8f19c6d239b89 /source | |
parent | 3069db2216c56748d7ce88dace54799b8420af10 (diff) |
don't divide by zero in get_ss_weights() which would set values - only to be overwritten.
useful when using --debug-fpe since this isnt and exceptional case.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 555ed5890c8..0d1e2276a9f 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -513,10 +513,14 @@ static float *get_ss_weights(WeightTable *wtable, int gridCuts, int faceLen) w2 = (1.0f - fx + fac2 * fx * -fac) * (fy); w4 = (fx) * (1.0f - fy + -fac2 * fy * fac); - fac2 = 1.0f - (w1 + w2 + w4); - fac2 = fac2 / (float)(faceLen - 3); - for (j = 0; j < faceLen; j++) - w[j] = fac2; + /* these values aren't used for tri's and cause divide by zero */ + if (faceLen > 3) { + fac2 = 1.0f - (w1 + w2 + w4); + fac2 = fac2 / (float)(faceLen - 3); + for (j = 0; j < faceLen; j++) { + w[j] = fac2; + } + } w[i] = w1; w[(i - 1 + faceLen) % faceLen] = w2; |