Optimize updateGeometricState to not recurse all children when not necessary
Conflicts: jme3-core/src/main/java/com/jme3/scene/Node.java
This commit is contained in:
parent
9cd1a514a6
commit
a400cb1c58
@ -114,6 +114,16 @@ public class Node extends Spatial implements Savable {
|
||||
|
||||
child.setLightListRefresh();
|
||||
}
|
||||
|
||||
Spatial p = parent;
|
||||
while (p != null) {
|
||||
if (p.refreshFlags != 0) {
|
||||
return; //any refresh flag is sufficient, as each propagates to the root Node
|
||||
}
|
||||
p.refreshFlags |= RF_CHILD_LIGHTLIST;
|
||||
p = p.parent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -154,6 +164,9 @@ public class Node extends Spatial implements Savable {
|
||||
|
||||
@Override
|
||||
public void updateGeometricState(){
|
||||
boolean somethingToRefresh = (refreshFlags != 0);
|
||||
if (!somethingToRefresh) return;
|
||||
|
||||
if ((refreshFlags & RF_LIGHTLIST) != 0){
|
||||
updateWorldLightList();
|
||||
}
|
||||
@ -170,6 +183,7 @@ public class Node extends Spatial implements Savable {
|
||||
// a round-trip later on.
|
||||
// NOTE 9/19/09
|
||||
// Although it does save a round trip,
|
||||
refreshFlags &= ~RF_CHILD_LIGHTLIST;
|
||||
for (Spatial child : children.getArray()) {
|
||||
child.updateGeometricState();
|
||||
}
|
||||
@ -638,5 +652,4 @@ public class Node extends Spatial implements Savable {
|
||||
protected void breadthFirstTraversal(SceneGraphVisitor visitor, Queue<Spatial> queue) {
|
||||
queue.addAll(children);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -118,7 +118,8 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
|
||||
*/
|
||||
protected static final int RF_TRANSFORM = 0x01, // need light resort + combine transforms
|
||||
RF_BOUND = 0x02,
|
||||
RF_LIGHTLIST = 0x04; // changes in light lists
|
||||
RF_LIGHTLIST = 0x04, // changes in light lists
|
||||
RF_CHILD_LIGHTLIST = 0x08; // some child need geometry update
|
||||
|
||||
protected CullHint cullHint = CullHint.Inherit;
|
||||
protected BatchHint batchHint = BatchHint.Inherit;
|
||||
|
Loading…
x
Reference in New Issue
Block a user