protected void assembleTiles(RenderContext rc) { // TODO // The need to create Tiles with a defined image source couples the need to determine a tile's visibility with // he need to know its image source. Decoupling the two would mean we only need to know the image source when // the texture is actually requested Could the tile-based operations done here be implicit on level/row/column, // or use transient pooled tile objects not tied to an image source? if (this.topLevelTiles.isEmpty()) { this.createTopLevelTiles(); } for (int idx = 0, len = this.topLevelTiles.size(); idx < len; idx++) { this.addTileOrDescendants(rc, (ImageTile) this.topLevelTiles.get(idx)); } }
protected void addTileOrDescendants(RenderContext rc, ImageTile tile) { if (!tile.intersectsSector(this.levelSet.sector) || !tile.intersectsFrustum(rc, rc.frustum)) { return; // ignore the tile and its descendants if it's not needed or not visible } if (tile.level.isLastLevel() || !tile.mustSubdivide(rc, this.detailControl)) { this.addTile(rc, tile); return; // use the tile if it does not need to be subdivided } ImageTile currentAncestorTile = this.ancestorTile; Texture currentAncestorTexture = this.ancestorTexture; ImageSource tileImageSource = tile.getImageSource(); if (tileImageSource != null) { // tile has an image source; its level is not empty Texture tileTexture = rc.getTexture(tileImageSource); if (tileTexture != null) { // tile has a texture; use it as a fallback tile for descendants this.ancestorTile = tile; this.ancestorTexture = tileTexture; } } for (Tile child : tile.subdivideToCache(this.tileFactory, this.tileCache, 4)) { // each tile has a cached size of 1 this.addTileOrDescendants(rc, (ImageTile) child); // recursively process the tile's children } this.ancestorTile = currentAncestorTile; // restore the last fallback tile, even if it was null this.ancestorTexture = currentAncestorTexture; }