diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-10-29 12:08:15 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-10-29 12:08:15 +0300 |
commit | 51b6f00666d2b44bc5f978bb6cea515b0695e5f2 (patch) | |
tree | 4b84e06802d50ccec6704b2fe2c60420013ff32e /add_curve_sapling/utils.py | |
parent | b714750bf00bd6aaf2c87afad533eb01b68861b8 (diff) |
Fix T42138: division by zero in sapling addon
Note sapling code probably has other places where that kind of issues may happen,
would need a full recheck, but that's outside of scope of basic bugfix.
Patch by mangostaniko (Nikolaus Leopold) with minor changes, thanks!
Revision: D844
Diffstat (limited to 'add_curve_sapling/utils.py')
-rw-r--r-- | add_curve_sapling/utils.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/add_curve_sapling/utils.py b/add_curve_sapling/utils.py index acc95b4e..f17ecb8b 100644 --- a/add_curve_sapling/utils.py +++ b/add_curve_sapling/utils.py @@ -196,7 +196,7 @@ def interpStem(stem,tVals,lPar,parRad): # Loop through all the parametric values to be determined for t in tVals: if (t >= checkVal) and (t < 1.0): - scaledT = (t-checkVal)/(tVals[-1]-checkVal) + scaledT = (t - checkVal) / max(tVals[-1] - checkVal, 1e-6) length = (numPoints-1)*t#scaledT index = int(length) if scaledT == 1.0: @@ -586,13 +586,13 @@ def fabricate_stems(addsplinetobone, addstem, baseSize, branches, childP, cu, cu tempPos.rotate(rotMat) tempPos.rotate(p.quat) newPoint.handle_right = p.co + tempPos - if (storeN>= levels-1): + if (storeN >= levels): # If this is the last level before leaves then we need to generate the child points differently branchL = (length[n] + uniform(-lengthV[n], lengthV[n])) * (p.lengthPar - 0.6 * p.offset) if leaves < 0: childStems = False else: - childStems = leaves * shapeRatio(leafDist, p.offset / p.lengthPar) + childStems = leaves * shapeRatio(leafDist, p.offset / max(p.lengthPar, 1e-6)) elif n == 1: # If this is the first level of branching then upward attraction has no effect and a special formula is used to find branch length and the number of child stems vertAtt = 0.0 |