Skip to content

Commit a643cf5

Browse files
committed
Use exact device screen density on tile details calculation.
1 parent ec309f0 commit a643cf5

3 files changed

Lines changed: 9 additions & 14 deletions

File tree

worldwind/src/main/java/gov/nasa/worldwind/globe/BasicTessellator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class BasicTessellator implements Tessellator, TileFactory {
3535
// ~0.6 meter resolution
3636
protected LevelSet levelSet = new LevelSet(new Sector().setFullSphere(), new Location(-90, -180), new Location(90, 90), 20, 32, 32);
3737

38-
protected double detailControl = 80;
38+
protected double detailControl = 32;
3939

4040
protected final List<Tile> topLevelTiles = new ArrayList<>();
4141

worldwind/src/main/java/gov/nasa/worldwind/shape/TiledSurfaceImage.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ public class TiledSurfaceImage extends AbstractRenderable {
3434

3535
protected ImageOptions imageOptions;
3636

37-
protected double detailControl = 4;
37+
protected double detailControl = 1;
3838

3939
protected final List<Tile> topLevelTiles = new ArrayList<>();
4040

4141
/**
4242
* Memory cache for this layer's subdivision tiles. Each entry contains an array of four image tiles corresponding
43-
* to the subdivision of the group's common parent tile. The cache is configured to hold 500 groups, a number
43+
* to the subdivision of the group's common parent tile. The cache is configured to hold 1000 groups, a number
4444
* empirically determined to be sufficient for storing the tiles needed to navigate a small region.
4545
*/
46-
protected final LruMemoryCache<String, Tile[]> tileCache = new LruMemoryCache<>(500);
46+
protected final LruMemoryCache<String, Tile[]> tileCache = new LruMemoryCache<>(1000);
4747

4848
protected SurfaceTextureProgram activeProgram;
4949

@@ -158,6 +158,10 @@ protected void addTileOrDescendants(RenderContext rc, ImageTile tile) {
158158
ImageSource tileImageSource = tile.getImageSource();
159159
if (tileImageSource != null) { // tile has an image source; its level is not empty
160160
Texture tileTexture = rc.getTexture(tileImageSource);
161+
// retrieve top level tiles to avoid black holes when navigating and zooming out camera
162+
if (tileTexture == null) {
163+
tileTexture = rc.retrieveTexture(tileImageSource, this.imageOptions); // puts retrieved textures in the cache
164+
}
161165
if (tileTexture != null) { // tile has a texture; use it as a fallback tile for descendants
162166
this.ancestorTile = tile;
163167
this.ancestorTexture = tileTexture;

worldwind/src/main/java/gov/nasa/worldwind/util/Tile.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
package gov.nasa.worldwind.util;
77

8-
import android.util.DisplayMetrics;
9-
108
import java.util.Arrays;
119
import java.util.Collection;
1210

@@ -291,14 +289,7 @@ public boolean mustSubdivide(RenderContext rc, double detailFactor) {
291289
this.distanceToCamera = this.distanceToCamera(rc);
292290
double texelSize = this.texelSizeFactor * rc.globe.getEquatorialRadius();
293291
double pixelSize = rc.pixelSizeAtDistance(this.distanceToCamera);
294-
double densityFactor = 1.0;
295-
296-
// Adjust the subdivision factory when the display density is low. Values of detailFactor have been calibrated
297-
// against high density devices. Low density devices need roughly half the detailFactor.
298-
if (rc.resources.getDisplayMetrics().densityDpi <= DisplayMetrics.DENSITY_MEDIUM) {
299-
densityFactor = 0.5;
300-
}
301-
292+
double densityFactor = rc.resources.getDisplayMetrics().density;
302293
return texelSize > (pixelSize * detailFactor * densityFactor);
303294
}
304295

0 commit comments

Comments
 (0)