[Bf-extensions-cvs] [51b6f00] master: Fix T42138: division by zero in sapling addon
Bastien Montagne
noreply at git.blender.org
Wed Oct 29 10:18:50 CET 2014
Commit: 51b6f00666d2b44bc5f978bb6cea515b0695e5f2
Author: Bastien Montagne
Date: Wed Oct 29 10:08:15 2014 +0100
Branches: master
https://developer.blender.org/rBA51b6f00666d2b44bc5f978bb6cea515b0695e5f2
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
===================================================================
M add_curve_sapling/utils.py
===================================================================
diff --git a/add_curve_sapling/utils.py b/add_curve_sapling/utils.py
index acc95b4..f17ecb8 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
More information about the Bf-extensions-cvs
mailing list