TerrainLodControl now refreshes when first added to the scene
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10557 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
8cb1a8ed9e
commit
ff4c38e20a
@ -92,6 +92,7 @@ public class TerrainLodControl extends AbstractControl {
|
||||
|
||||
protected ExecutorService executor;
|
||||
protected Future<HashMap<String, UpdatedTerrainPatch>> indexer;
|
||||
private boolean forceUpdate = true;
|
||||
|
||||
public TerrainLodControl() {
|
||||
}
|
||||
@ -175,10 +176,11 @@ public class TerrainLodControl extends AbstractControl {
|
||||
lodOffCount = 0;
|
||||
|
||||
if (lastCameraLocations != null) {
|
||||
if (lastCameraLocationsTheSame(locations) && !lodCalculator.isLodOff())
|
||||
if (!forceUpdate && lastCameraLocationsTheSame(locations) && !lodCalculator.isLodOff())
|
||||
return; // don't update if in same spot
|
||||
else
|
||||
lastCameraLocations = cloneVectorList(locations);
|
||||
forceUpdate = false;
|
||||
}
|
||||
else {
|
||||
lastCameraLocations = cloneVectorList(locations);
|
||||
@ -190,10 +192,6 @@ public class TerrainLodControl extends AbstractControl {
|
||||
}
|
||||
setLodCalcRunning(true);
|
||||
|
||||
//if (getParent() instanceof TerrainQuad) {
|
||||
// return; // we just want the root quad to perform this.
|
||||
//}
|
||||
|
||||
if (executor == null)
|
||||
executor = createExecutorService();
|
||||
|
||||
@ -202,6 +200,14 @@ public class TerrainLodControl extends AbstractControl {
|
||||
UpdateLOD updateLodThread = getLodThread(locations, lodCalculator);
|
||||
indexer = executor.submit(updateLodThread);
|
||||
}
|
||||
|
||||
/**
|
||||
* Force the LOD to update instantly, does not wait for the camera to move.
|
||||
* It will reset once it has updated.
|
||||
*/
|
||||
public void forceUpdate() {
|
||||
this.forceUpdate = true;
|
||||
}
|
||||
|
||||
protected void prepareTerrain() {
|
||||
TerrainQuad terrain = (TerrainQuad)getSpatial();
|
||||
@ -237,24 +243,8 @@ public class TerrainLodControl extends AbstractControl {
|
||||
}
|
||||
}
|
||||
}
|
||||
/*synchronized (updatePatchesLock) {
|
||||
|
||||
if (updatedPatches == null || updatedPatches.isEmpty())
|
||||
return;
|
||||
|
||||
// do the actual geometry update here
|
||||
for (UpdatedTerrainPatch utp : updatedPatches.values()) {
|
||||
utp.updateAll();
|
||||
}
|
||||
|
||||
updatedPatches = null;
|
||||
}*/
|
||||
}
|
||||
|
||||
//public boolean hasPatchesToUpdate() {
|
||||
// return updatedPatches != null && !updatedPatches.isEmpty();
|
||||
//}
|
||||
|
||||
private boolean lastCameraLocationsTheSame(List<Vector3f> locations) {
|
||||
boolean theSame = true;
|
||||
for (Vector3f l : locations) {
|
||||
|
@ -151,6 +151,12 @@ public class TerrainTestAdvanced extends SimpleApplication {
|
||||
matTerrain.setTexture("NormalMap_2", normalMap2);
|
||||
matTerrain.setTexture("NormalMap_4", normalMap2);
|
||||
|
||||
|
||||
// WIREFRAME material (used to debug the terrain, only useful for this test case)
|
||||
matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
matWire.getAdditionalRenderState().setWireframe(true);
|
||||
matWire.setColor("Color", ColorRGBA.Green);
|
||||
|
||||
createSky();
|
||||
|
||||
// CREATE HEIGHTMAP
|
||||
|
Loading…
x
Reference in New Issue
Block a user