added a pre-order traversal of the scene graph.#170
Conversation
Called depthLastTraversal to keep name coherent with depthFirstTraversal
|
First, it's not at all clear to me that "depthLastTraversal" is the best name for pre-order traversal. While I get it, it sounds backwards. Adding a second depthFirstTraversal that took a preorder flag might have been preferable. I wonder what the use-case is, though. It seems all of the typical use-cases I can think of, post-order is fine. |
|
Yea, I was thinking longer about the name. preOrderTraversal() would break the naming sheme with the other traversal methods. The extra flag is a good solution. I will change it. The use-case is building a tree out of the spatials (e.g. in a UI). There, I need the parent first to create the node and then the children. |
|
But it seems like in that case, that your tree model (I assume there is one) would want to wrap the actual node hierarchy... thus not even really needing the traversal API. What kind of GUI is this for? |
|
I use it in two ways:
|
|
+1 for adding a flag or maybe even an Enum or similar for indicating the strategy for walking the tree (pre-order, in-order, post-order). Preferrably matching the description on wikipedia: Pre-order traversals are convenient for duplicating a tree. |
|
"in order" doesn't really make sense in this case as there is no "left half" and "right half"... which is why I suggested the flag. |
|
Is this pull request now acceptable? |
|
So any answer here? This is kinda long stalled as well, but look sfine for me, merge? |
|
@shadowislord @pspeed42 Any rejections? Else I will merge this(manually) next time I review the open pull requests. |
|
Is it maybe a good idea to add a method rather than replacing it? |
There was a problem hiding this comment.
I didnt see this one, my comment can be ignored.
|
Closing due to merge conflict, however I would like to see this again in a form that just adds methods, as that can be easily applies without braking anything. I personally find different traversal methods usefull. |
|
Oops, I totally forgot that this was still hanging around. |
Adds a new method called depthLastTraversal() to Spatial and subclasses as an extension to depthFirstTraversal() and breathFirstTraversal().