def growth_start(self): # Grow the shoot apical meristem until it is w/in sensing distance of a leaf found = False sam = Branch(None, self.start, PVector( 0, 0, 0, ), 10) self.branches.append(sam) while not found: for leaf in self.leaves: d = leaf.pos.dist(sam.pos) if d < self.max_distance: found = True """ # This chunk finds normalized vectors of all leaves to determine growth dir, very SLOW if not found: print('nf') vsum = PVector(0,0,0) for leaf in self.leaves: print(leaf.pos - sam.pos) vsum += leaf.pos - sam.pos vsum.normalize() print("vsum : {}".format(vsum)) sam.dir = vsum sam = sam.grow_branch() """ # delete this if statement if you want above code instead if not found: sam.dir = PVector(0, -1, 0) sam = sam.grow_branch() sam.parent = self.start self.branches.append(sam) for branch in self.branches: branch.reset()