X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fsave%2FPovExporter.java;h=c00274787a0f458ebddadbe092070045e1a6ce7f;hb=a6197ddcaac11c0b943183da7d46169742d024af;hp=1f29d4a70bb075420db66a471ca7a9d7e730c28d;hpb=326f489e36aa7f235bc19409a57bf4955cd50f24;p=GpsPrune.git diff --git a/tim/prune/save/PovExporter.java b/tim/prune/save/PovExporter.java index 1f29d4a..c002747 100644 --- a/tim/prune/save/PovExporter.java +++ b/tim/prune/save/PovExporter.java @@ -43,6 +43,8 @@ import tim.prune.gui.map.MapSource; import tim.prune.gui.map.MapSourceLibrary; import tim.prune.load.GenericFileFilter; import tim.prune.threedee.ImageDefinition; +import tim.prune.threedee.TerrainCache; +import tim.prune.threedee.TerrainDefinition; import tim.prune.threedee.TerrainHelper; import tim.prune.threedee.ThreeDModel; @@ -319,8 +321,11 @@ public class PovExporter extends Export3dFunction { // file saved - store directory in config for later Config.setConfigString(Config.KEY_TRACK_DIR, povFile.getParentFile().getAbsolutePath()); - // also store exaggeration + // also store exaggeration and grid size Config.setConfigInt(Config.KEY_HEIGHT_EXAGGERATION, (int) (_altFactor * 100)); + if (_terrainPanel.getUseTerrain() && _terrainPanel.getGridSize() > 20) { + Config.setConfigInt(Config.KEY_TERRAIN_GRID_SIZE, _terrainPanel.getGridSize()); + } } else { @@ -392,19 +397,29 @@ public class PovExporter extends Export3dFunction if (useTerrain) { TerrainHelper terrainHelper = new TerrainHelper(_terrainPanel.getGridSize()); - Track terrainTrack = terrainHelper.createGridTrack(_track); - // Get the altitudes from SRTM for all the points in the track - LookupSrtmFunction srtmLookup = (LookupSrtmFunction) FunctionLibrary.FUNCTION_LOOKUP_SRTM; - srtmLookup.begin(terrainTrack); - while (srtmLookup.isRunning()) + // See if there's a previously saved terrain track we can reuse + TerrainDefinition terrainDef = new TerrainDefinition(_terrainPanel.getUseTerrain(), _terrainPanel.getGridSize()); + Track terrainTrack = TerrainCache.getTerrainTrack(_app.getCurrentDataStatus(), terrainDef); + if (terrainTrack == null) { - try { - Thread.sleep(750); // just polling in a wait loop isn't ideal but simple + // Construct the terrain track according to these extents and the grid size + terrainTrack = terrainHelper.createGridTrack(_track); + // Get the altitudes from SRTM for all the points in the track + LookupSrtmFunction srtmLookup = (LookupSrtmFunction) FunctionLibrary.FUNCTION_LOOKUP_SRTM; + srtmLookup.begin(terrainTrack); + while (srtmLookup.isRunning()) + { + try { + Thread.sleep(750); // just polling in a wait loop isn't ideal but simple + } + catch (InterruptedException e) {} } - catch (InterruptedException e) {} + // Fix the voids + terrainHelper.fixVoids(terrainTrack); + + // Store this back in the cache, maybe we'll need it again + TerrainCache.storeTerrainTrack(terrainTrack, _app.getCurrentDataStatus(), terrainDef); } - // Fix the voids - terrainHelper.fixVoids(terrainTrack); model.setTerrain(terrainTrack); model.scale();