From c83a0e81314e1c65b7b52b303f2ced9277c19c0b Mon Sep 17 00:00:00 2001
From: Andrew Hale <TrumanBlending@gmail.com>
Date: Sun, 31 Jul 2011 06:15:24 +0000
Subject: [PATCH] Fixed an issue when levels > 4 were used, causing tree
 generation failure

---
 add_curve_sapling/utils.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/add_curve_sapling/utils.py b/add_curve_sapling/utils.py
index d9868749b..59b792193 100644
--- a/add_curve_sapling/utils.py
+++ b/add_curve_sapling/utils.py
@@ -589,7 +589,7 @@ def addTree(props):
                         childStems = branches[2]*(0.2 + 0.8*(branchL/p.lengthPar)/lMax)
                     elif storeN <= levels - 2:
                         branchL = (length[n] + uniform(-lengthV[n],lengthV[n]))*(p.lengthPar - 0.6*p.offset)
-                        childStems = branches[n+1]*(1.0 - 0.5*p.offset/p.lengthPar)
+                        childStems = branches[min(3,n+1)]*(1.0 - 0.5*p.offset/p.lengthPar)
                     # If this is the last level before leaves then we need to generate the child points differently
                     else:
                         branchL = (length[n] + uniform(-lengthV[n],lengthV[n]))*(p.lengthPar - 0.6*p.offset)
@@ -915,4 +915,4 @@ def addTree(props):
             for p in armOb.pose.bones:
                 p.rotation_mode = 'XYZ'
             treeOb.parent = armOb
-        #print(time.time()-startTime)
+        #print(time.time()-startTime)
\ No newline at end of file
-- 
GitLab