Skip to content

Commit

Permalink
Use exact device screen density on tile details calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ComBatVision committed Jul 25, 2022
1 parent ec309f0 commit a643cf5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class BasicTessellator implements Tessellator, TileFactory {
// ~0.6 meter resolution
protected LevelSet levelSet = new LevelSet(new Sector().setFullSphere(), new Location(-90, -180), new Location(90, 90), 20, 32, 32);

protected double detailControl = 80;
protected double detailControl = 32;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ public class TiledSurfaceImage extends AbstractRenderable {

protected ImageOptions imageOptions;

protected double detailControl = 4;
protected double detailControl = 1;

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

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

protected SurfaceTextureProgram activeProgram;

Expand Down Expand Up @@ -158,6 +158,10 @@ protected void addTileOrDescendants(RenderContext rc, ImageTile tile) {
ImageSource tileImageSource = tile.getImageSource();
if (tileImageSource != null) { // tile has an image source; its level is not empty
Texture tileTexture = rc.getTexture(tileImageSource);
// retrieve top level tiles to avoid black holes when navigating and zooming out camera
if (tileTexture == null) {
tileTexture = rc.retrieveTexture(tileImageSource, this.imageOptions); // puts retrieved textures in the cache
}
if (tileTexture != null) { // tile has a texture; use it as a fallback tile for descendants
this.ancestorTile = tile;
this.ancestorTexture = tileTexture;
Expand Down
11 changes: 1 addition & 10 deletions worldwind/src/main/java/gov/nasa/worldwind/util/Tile.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

package gov.nasa.worldwind.util;

import android.util.DisplayMetrics;

import java.util.Arrays;
import java.util.Collection;

Expand Down Expand Up @@ -291,14 +289,7 @@ public boolean mustSubdivide(RenderContext rc, double detailFactor) {
this.distanceToCamera = this.distanceToCamera(rc);
double texelSize = this.texelSizeFactor * rc.globe.getEquatorialRadius();
double pixelSize = rc.pixelSizeAtDistance(this.distanceToCamera);
double densityFactor = 1.0;

// Adjust the subdivision factory when the display density is low. Values of detailFactor have been calibrated
// against high density devices. Low density devices need roughly half the detailFactor.
if (rc.resources.getDisplayMetrics().densityDpi <= DisplayMetrics.DENSITY_MEDIUM) {
densityFactor = 0.5;
}

double densityFactor = rc.resources.getDisplayMetrics().density;
return texelSize > (pixelSize * detailFactor * densityFactor);
}

Expand Down

0 comments on commit a643cf5

Please sign in to comment.