terrain will clear any caches it has now when detached from the scene graph
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10424 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
133d153bbb
commit
13758bd985
@ -982,5 +982,27 @@ public class TerrainPatch extends Geometry {
|
|||||||
return worldTranslationCached;
|
return worldTranslationCached;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes any references when the terrain is being removed.
|
||||||
|
*/
|
||||||
|
protected void clearCaches() {
|
||||||
|
if (leftNeighbour != null) {
|
||||||
|
leftNeighbour.rightNeighbour = null;
|
||||||
|
leftNeighbour = null;
|
||||||
|
}
|
||||||
|
if (rightNeighbour != null) {
|
||||||
|
rightNeighbour.leftNeighbour = null;
|
||||||
|
rightNeighbour = null;
|
||||||
|
}
|
||||||
|
if (topNeighbour != null) {
|
||||||
|
topNeighbour.bottomNeighbour = null;
|
||||||
|
topNeighbour = null;
|
||||||
|
}
|
||||||
|
if (bottomNeighbour != null) {
|
||||||
|
bottomNeighbour.topNeighbour = null;
|
||||||
|
bottomNeighbour = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1807,6 +1807,34 @@ public class TerrainQuad extends Node implements Terrain {
|
|||||||
return quadClone;
|
return quadClone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setParent(Node parent) {
|
||||||
|
super.setParent(parent);
|
||||||
|
if (parent == null) {
|
||||||
|
// if the terrain is being detached
|
||||||
|
clearCaches();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes any cached references this terrain is holding, in particular
|
||||||
|
* the TerrainPatch's neighbour references.
|
||||||
|
* This is called automatically when the root terrainQuad is detached from
|
||||||
|
* its parent or if setParent(null) is called.
|
||||||
|
*/
|
||||||
|
public void clearCaches() {
|
||||||
|
if (children != null) {
|
||||||
|
for (int i = children.size(); --i >= 0;) {
|
||||||
|
Spatial child = children.get(i);
|
||||||
|
if (child instanceof TerrainQuad) {
|
||||||
|
((TerrainQuad) child).clearCaches();
|
||||||
|
} else if (child instanceof TerrainPatch) {
|
||||||
|
((TerrainPatch) child).clearCaches();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int getMaxLod() {
|
public int getMaxLod() {
|
||||||
if (maxLod < 0)
|
if (maxLod < 0)
|
||||||
maxLod = Math.max(1, (int) (FastMath.log(size-1)/FastMath.log(2)) -1); // -1 forces our minimum of 4 triangles wide
|
maxLod = Math.max(1, (int) (FastMath.log(size-1)/FastMath.log(2)) -1); // -1 forces our minimum of 4 triangles wide
|
||||||
|
Loading…
x
Reference in New Issue
Block a user