BuildingLayer: allow mesh in renderer, minor refactor (#457)

This commit is contained in:
Gustl22 2017-12-19 10:01:48 +01:00 committed by Emux
parent f8776ffe5f
commit 95bbc5ea3e
No known key found for this signature in database
GPG Key ID: 89C6921D7AF2BDD0

View File

@ -54,7 +54,7 @@ public class BuildingLayer extends Layer implements TileLoaderThemeHook {
private static final Object BUILDING_DATA = BuildingLayer.class.getName();
// Can replace with Multimap in Java 8
// Can be replaced with Multimap in Java 8
private HashMap<Integer, List<BuildingElement>> mBuildings = new HashMap<>();
class BuildingElement {
@ -70,10 +70,14 @@ public class BuildingLayer extends Layer implements TileLoaderThemeHook {
}
public BuildingLayer(Map map, VectorTileLayer tileLayer) {
this(map, tileLayer, MIN_ZOOM, MAX_ZOOM);
this(map, tileLayer, MIN_ZOOM, MAX_ZOOM, false);
}
public BuildingLayer(Map map, VectorTileLayer tileLayer, int zoomMin, int zoomMax) {
public BuildingLayer(Map map, VectorTileLayer tileLayer, boolean mesh) {
this(map, tileLayer, MIN_ZOOM, MAX_ZOOM, mesh);
}
public BuildingLayer(Map map, VectorTileLayer tileLayer, int zoomMin, int zoomMax, boolean mesh) {
super(map);
@ -81,7 +85,7 @@ public class BuildingLayer extends Layer implements TileLoaderThemeHook {
mRenderer = new BuildingRenderer(tileLayer.tileRenderer(),
zoomMin, zoomMax,
false, TRANSLUCENT);
mesh, !mesh && TRANSLUCENT); // alpha must be disabled for mesh renderer
if (POST_AA)
mRenderer = new OffscreenRenderer(Mode.SSAO_FXAA, mRenderer);
}
@ -211,13 +215,17 @@ public class BuildingLayer extends Layer implements TileLoaderThemeHook {
mBuildings.remove(tile.hashCode());
}
/**
* @param tile the MapTile
* @return ExtrusionBuckets of the tile
*/
public static ExtrusionBuckets get(MapTile tile) {
ExtrusionBuckets eb = (ExtrusionBuckets) tile.getData(BUILDING_DATA);
if (eb == null) {
eb = new ExtrusionBuckets(tile);
tile.addData(BUILDING_DATA, eb);
ExtrusionBuckets ebs = (ExtrusionBuckets) tile.getData(BUILDING_DATA);
if (ebs == null) {
ebs = new ExtrusionBuckets(tile);
tile.addData(BUILDING_DATA, ebs);
}
return eb;
return ebs;
}
@Override