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.
accellbaker
FennelFetish 6 years ago committed by Stephen Gold
parent 304550a0f4
commit 0f9cf090e7
  1. 6
      jme3-core/src/main/java/com/jme3/scene/Node.java

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

Loading…
Cancel
Save