minor issue with tree generator (Sapling add-on) #41099

Closed
opened 2014-07-16 07:48:12 +02:00 by Ernst Hammann · 8 comments

System Information
Operating system and graphics Card
Windows 7 Pro 64 bit, Intel on board grapics

Blender Version
Broken: 2.71

Short description of error
When creating a tree, the number of leaves doesn't change if branch splitting level is 2. With level 3 it works.

Exact steps for others to reproduce the error
Add curve -> Tree -> check "bevel". All of the other settings can remain as they are. Then goto section "Leaves" and check "show leaves". The number of leaves attached to the tree doesn't change if you change the value in the belonging input field. If you go to section "branch splitting" and increase the branch level to 3 then you can set the number of the leaves as you want and they are shown / attached correctly.
(Maybe this is actually a feature but to me it appears like a bug.)

Thanks.

**System Information** Operating system and graphics Card Windows 7 Pro 64 bit, Intel on board grapics **Blender Version** Broken: 2.71 **Short description of error** When creating a tree, the number of leaves doesn't change if branch splitting level is 2. With level 3 it works. **Exact steps for others to reproduce the error** Add curve -> Tree -> check "bevel". All of the other settings can remain as they are. Then goto section "Leaves" and check "show leaves". The number of leaves attached to the tree doesn't change if you change the value in the belonging input field. If you go to section "branch splitting" and increase the branch level to 3 then you can set the number of the leaves as you want and they are shown / attached correctly. (Maybe this is actually a feature but to me it appears like a bug.) Thanks.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @JASMS

Added subscriber: @JASMS
Andrew Hale was assigned by Bastien Montagne 2014-07-16 08:09:33 +02:00

Added subscriber: @mont29

Added subscriber: @mont29

Added subscriber: @mutantbob

Added subscriber: @mutantbob

I found what I believe to be the problem. in the add_curve_sapling/utils.py:

        if 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
            lMax = length[1] + uniform(-lengthV[1], lengthV[1])
            branchL = p.lengthPar * lMax * shapeRatio(shape,
                                                      (p.lengthPar - p.offset) / (p.lengthPar - baseSize * scaleVal))
            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[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)
            if leaves < 0:
                childStems = False
            else:
                childStems = leaves * shapeRatio(leafDist, p.offset / p.lengthPar)

When levels==2, then the n==1 clause shadows the leaf clause at the end. If we move the leaf clause to the top it works like you want:

        if (storeN>= levels-1):
        # 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)
        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
            lMax = length[1] + uniform(-lengthV[1], lengthV[1])
            branchL = p.lengthPar * lMax * shapeRatio(shape,
                                                      (p.lengthPar - p.offset) / (p.lengthPar - baseSize * scaleVal))
            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[min(3, n + 1)] * (1.0 - 0.5 * p.offset / p.lengthPar)
I found what I believe to be the problem. in the add_curve_sapling/utils.py: ``` if 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 lMax = length[1] + uniform(-lengthV[1], lengthV[1]) branchL = p.lengthPar * lMax * shapeRatio(shape, (p.lengthPar - p.offset) / (p.lengthPar - baseSize * scaleVal)) 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[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) if leaves < 0: childStems = False else: childStems = leaves * shapeRatio(leafDist, p.offset / p.lengthPar) ``` When levels==2, then the n==1 clause shadows the leaf clause at the end. If we move the leaf clause to the top it works like you want: ``` if (storeN>= levels-1): # 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) 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 lMax = length[1] + uniform(-lengthV[1], lengthV[1]) branchL = p.lengthPar * lMax * shapeRatio(shape, (p.lengthPar - p.offset) / (p.lengthPar - baseSize * scaleVal)) 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[min(3, n + 1)] * (1.0 - 0.5 * p.offset / p.lengthPar) ```
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Member

Added subscriber: @BrendonMurphy

Added subscriber: @BrendonMurphy
Member
fixed https://developer.blender.org/rBA0e536cd1b7225ef7b6c9edd982b2d9d5c527ce92 closing
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#41099
No description provided.