No announcement yet.

BasicTessellator performance issue

  • Filter
  • Time
  • Show
Clear All
new posts

  • BasicTessellator performance issue

    Something wrong with terrain tessellation.

    Each time, when terrain level of details changed by user, BasicTessellator adds some top level tiles to current tiles collection (probably by mistake in tile.mustSubdivide() method).
    This situation spoil BasicTerrain.sector value (e.g. make it equals half globe -90 to 90, even if you are looking on a small terrain part from small altitude).
    This problem disappears after some time when all detailed tiles become loaded (than top level tiles start to be ignored by tile.mustSubdivide()).
    But when you change zoom little bit again, than problem comes back.

    Wrong sector value cause to render useless drawables, which are based on terrain sector clipping sector.

    By the way, WWJ version does not have this issue (it always return correct dc.getViewingSector size).

    To reproduce this issue, place break point in BasicTessellator loop on top level tiles:

    // Subdivide the top level tiles until the desired resolution is achieved in each part of the scene.
    for (int idx = 0, len = this.topLevelTiles.size(); idx < len; idx++) {
    this.addTileOrDescendants(rc, (TerrainTile) this.topLevelTiles.get(idx));

    and inside this check:

    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

    and check what tiles to be added into collection.

    You will find that sometimes condition tile.mustSubdivide(rc, this.detailControl) for several top level tiles return false and this tile is added to the tile list together with detailed tiles subdivided from other top level tiles. This top level tile will union with terrain Sector and override its values by -90 to 90 degrees even if you are looking very close to the ground.

    public void addTile(TerrainTile tile) {
    if (tile == null) {
    throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "BasicTerrain", "addTile", "missingTile"));