BatchNode now properly unbatch subgraph when a Node is removed from it
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10112 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
d127a7389e
commit
3a809e61f5
@ -247,6 +247,34 @@ public class BatchNode extends Node implements Savable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//in case the detached spatial is a node, we unbatch all geometries in its subegraph
|
||||||
|
@Override
|
||||||
|
public Spatial detachChildAt(int index) {
|
||||||
|
Spatial s = super.detachChildAt(index);
|
||||||
|
if (s instanceof Node) {
|
||||||
|
unbatchSubGraph(s);
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* recursively visit the subgraph and unbatch geometries
|
||||||
|
* @param s
|
||||||
|
*/
|
||||||
|
private void unbatchSubGraph(Spatial s) {
|
||||||
|
if (s instanceof Node) {
|
||||||
|
for (Spatial sp : ((Node) s).getChildren()) {
|
||||||
|
unbatchSubGraph(sp);
|
||||||
|
}
|
||||||
|
} else if (s instanceof Geometry) {
|
||||||
|
Geometry g = (Geometry) s;
|
||||||
|
if (g.isBatched()) {
|
||||||
|
g.unBatch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void gatherGeomerties(Map<Material, List<Geometry>> map, Spatial n, boolean rebatch) {
|
private void gatherGeomerties(Map<Material, List<Geometry>> map, Spatial n, boolean rebatch) {
|
||||||
|
|
||||||
if (n instanceof Geometry) {
|
if (n instanceof Geometry) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user