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 ExecutorService executor;
|
||||||
protected Future<HashMap<String, UpdatedTerrainPatch>> indexer;
|
protected Future<HashMap<String, UpdatedTerrainPatch>> indexer;
|
||||||
|
private boolean forceUpdate = true;
|
||||||
|
|
||||||
public TerrainLodControl() {
|
public TerrainLodControl() {
|
||||||
}
|
}
|
||||||
@ -175,10 +176,11 @@ public class TerrainLodControl extends AbstractControl {
|
|||||||
lodOffCount = 0;
|
lodOffCount = 0;
|
||||||
|
|
||||||
if (lastCameraLocations != null) {
|
if (lastCameraLocations != null) {
|
||||||
if (lastCameraLocationsTheSame(locations) && !lodCalculator.isLodOff())
|
if (!forceUpdate && lastCameraLocationsTheSame(locations) && !lodCalculator.isLodOff())
|
||||||
return; // don't update if in same spot
|
return; // don't update if in same spot
|
||||||
else
|
else
|
||||||
lastCameraLocations = cloneVectorList(locations);
|
lastCameraLocations = cloneVectorList(locations);
|
||||||
|
forceUpdate = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lastCameraLocations = cloneVectorList(locations);
|
lastCameraLocations = cloneVectorList(locations);
|
||||||
@ -190,10 +192,6 @@ public class TerrainLodControl extends AbstractControl {
|
|||||||
}
|
}
|
||||||
setLodCalcRunning(true);
|
setLodCalcRunning(true);
|
||||||
|
|
||||||
//if (getParent() instanceof TerrainQuad) {
|
|
||||||
// return; // we just want the root quad to perform this.
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (executor == null)
|
if (executor == null)
|
||||||
executor = createExecutorService();
|
executor = createExecutorService();
|
||||||
|
|
||||||
@ -203,6 +201,14 @@ public class TerrainLodControl extends AbstractControl {
|
|||||||
indexer = executor.submit(updateLodThread);
|
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() {
|
protected void prepareTerrain() {
|
||||||
TerrainQuad terrain = (TerrainQuad)getSpatial();
|
TerrainQuad terrain = (TerrainQuad)getSpatial();
|
||||||
terrain.cacheTerrainTransforms();// cache the terrain's world transforms so they can be accessed on the separate thread safely
|
terrain.cacheTerrainTransforms();// cache the terrain's world transforms so they can be accessed on the separate thread safely
|
||||||
@ -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) {
|
private boolean lastCameraLocationsTheSame(List<Vector3f> locations) {
|
||||||
boolean theSame = true;
|
boolean theSame = true;
|
||||||
for (Vector3f l : locations) {
|
for (Vector3f l : locations) {
|
||||||
|
@ -151,6 +151,12 @@ public class TerrainTestAdvanced extends SimpleApplication {
|
|||||||
matTerrain.setTexture("NormalMap_2", normalMap2);
|
matTerrain.setTexture("NormalMap_2", normalMap2);
|
||||||
matTerrain.setTexture("NormalMap_4", 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();
|
createSky();
|
||||||
|
|
||||||
// CREATE HEIGHTMAP
|
// CREATE HEIGHTMAP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user