Added a method to manually clean up any Terrain lod control threads.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10877 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
experimental
bre..om 11 years ago
parent 61c3d27942
commit fe1f90dbf6
  1. 10
      engine/src/terrain/com/jme3/terrain/geomipmap/TerrainLodControl.java
  2. 13
      engine/src/test/jme3test/terrain/TerrainTestAdvanced.java

@ -156,6 +156,16 @@ public class TerrainLodControl extends AbstractControl {
updateLOD(cameraLocations, lodCalculator); updateLOD(cameraLocations, lodCalculator);
} }
} }
/**
* Call this when you remove the terrain or this control from the scene.
* It will clear up any threads it had.
*/
public void detachAndCleanUpControl() {
if (executor != null)
executor.shutdownNow();
getSpatial().removeControl(this);
}
// do all of the LOD calculations // do all of the LOD calculations
protected void updateLOD(List<Vector3f> locations, LodCalculator lodCalculator) { protected void updateLOD(List<Vector3f> locations, LodCalculator lodCalculator) {

@ -220,8 +220,8 @@ public class TerrainTestAdvanced extends SimpleApplication {
inputManager.addListener(actionListener, "triPlanar"); inputManager.addListener(actionListener, "triPlanar");
inputManager.addMapping("WardIso", new KeyTrigger(KeyInput.KEY_9)); inputManager.addMapping("WardIso", new KeyTrigger(KeyInput.KEY_9));
inputManager.addListener(actionListener, "WardIso"); inputManager.addListener(actionListener, "WardIso");
inputManager.addMapping("Minnaert", new KeyTrigger(KeyInput.KEY_0)); inputManager.addMapping("DetachControl", new KeyTrigger(KeyInput.KEY_0));
inputManager.addListener(actionListener, "Minnaert"); inputManager.addListener(actionListener, "DetachControl");
} }
private ActionListener actionListener = new ActionListener() { private ActionListener actionListener = new ActionListener() {
@ -253,6 +253,15 @@ public class TerrainTestAdvanced extends SimpleApplication {
matTerrain.setFloat("DiffuseMap_3_scale", rockScale); matTerrain.setFloat("DiffuseMap_3_scale", rockScale);
matTerrain.setFloat("DiffuseMap_4_scale", rockScale); matTerrain.setFloat("DiffuseMap_4_scale", rockScale);
} }
} if (name.equals("DetachControl") && !pressed) {
TerrainLodControl control = terrain.getControl(TerrainLodControl.class);
if (control != null)
control.detachAndCleanUpControl();
else {
control = new TerrainLodControl(terrain, cam);
terrain.addControl(control);
}
} }
} }
}; };

Loading…
Cancel
Save