Fixes depth-first-traversal order in Node.

DFSMode needs to be passed to the recursive calls so the selected order is also applied further down the scenegraph.
This commit is contained in:
FennelFetish 2019-02-01 16:55:32 +01:00 committed by Stephen Gold
parent dbb1bba646
commit bee38da3b8

View File

@ -769,20 +769,22 @@ public class Node extends Spatial {
} }
} }
} }
@Override @Override
public void depthFirstTraversal(SceneGraphVisitor visitor, DFSMode mode) { public void depthFirstTraversal(SceneGraphVisitor visitor, DFSMode mode) {
if (mode == DFSMode.POST_ORDER) { if (mode == DFSMode.POST_ORDER) {
for (Spatial child : children.getArray()) { for (Spatial child : children.getArray()) {
child.depthFirstTraversal(visitor); child.depthFirstTraversal(visitor, mode);
} }
visitor.visit(this); visitor.visit(this);
} else { //pre order } else { //pre order
visitor.visit(this); visitor.visit(this);
for (Spatial child : children.getArray()) { for (Spatial child : children.getArray()) {
child.depthFirstTraversal(visitor); child.depthFirstTraversal(visitor, mode);
} }
} }
} }
@Override @Override
protected void breadthFirstTraversal(SceneGraphVisitor visitor, Queue<Spatial> queue) { protected void breadthFirstTraversal(SceneGraphVisitor visitor, Queue<Spatial> queue) {
queue.addAll(children); queue.addAll(children);