fixed bug with terrain grid and cached neighbours in terrainQuad not being reset

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8673 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
bre..ns 13 years ago
parent 253334fd07
commit 0342cceaaf
  1. 2
      engine/src/terrain/com/jme3/terrain/geomipmap/TerrainGrid.java
  2. 18
      engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.java

@ -105,6 +105,7 @@ public class TerrainGrid extends TerrainQuad {
public Object call() throws Exception { public Object call() throws Exception {
attachQuadAt(newQuad, quadrant, temp); attachQuadAt(newQuad, quadrant, temp);
newQuad.resetCachedNeighbours();
return null; return null;
} }
}); });
@ -255,7 +256,6 @@ public class TerrainGrid extends TerrainQuad {
for (TerrainGridListener l : listeners.values()) { for (TerrainGridListener l : listeners.values()) {
l.tileAttached(cam, q); l.tileAttached(cam, q);
} }
System.err.println("attachQuadAt "+quadrant+", children: "+this.getChildren().size());
updateModelBound(); updateModelBound();
} }

@ -545,6 +545,24 @@ public class TerrainQuad extends Node implements Terrain {
} }
} }
/**
* TerrainQuad caches neighbours for faster LOD checks.
* Sometimes you might want to reset this cache (for instance in TerrainGrid)
*/
protected void resetCachedNeighbours() {
if (children != null) {
for (int x = children.size(); --x >= 0;) {
Spatial child = children.get(x);
if (child instanceof TerrainQuad) {
((TerrainQuad) child).resetCachedNeighbours();
} else if (child instanceof TerrainPatch) {
TerrainPatch patch = (TerrainPatch) child;
patch.searchedForNeighboursAlready = false;
}
}
}
}
/** /**
* Find any neighbours that should have their edges seamed because another neighbour * Find any neighbours that should have their edges seamed because another neighbour
* changed its LOD to a greater value (less detailed) * changed its LOD to a greater value (less detailed)

Loading…
Cancel
Save