Skip to content

Commit

Permalink
Merge pull request #7011 from AnalyticalGraphicsInc/refinement-fix
Browse files Browse the repository at this point in the history
Fix tileset traversal
  • Loading branch information
ggetz authored Sep 10, 2018
2 parents d6ad77b + 5fd4805 commit 798ff75
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Change Log
##### Additions :tada:
* Added `cartographicLimitRectangle` to `Globe`. Use this to limit terrain and imagery to a specific `Rectangle` area. [#6987](https://github.com/AnalyticalGraphicsInc/cesium/pull/6987)

##### Fixes :wrench:
* Fixed an issue in the 3D Tiles traversal where empty tiles would be selected instead of their nearest loaded ancestors. [#7011](https://github.com/AnalyticalGraphicsInc/cesium/pull/7011)

### 1.49 - 2018-09-04

##### Breaking Changes :mega:
Expand Down
40 changes: 23 additions & 17 deletions Source/Scene/Cesium3DTilesetTraversal.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,15 @@ define([
var childrenLength = children.length;
for (var i = 0; i < childrenLength; ++i) {
var child = children[i];
if (child.contentAvailable) {
updateTile(tileset, child, frameState);
touchTile(tileset, child, frameState);
selectTile(tileset, child, frameState);
} else if (child._depth - root._depth < descendantSelectionDepth) {
// Continue traversing, but not too far
stack.push(child);
if (isVisible(child)) {
if (child.contentAvailable) {
updateTile(tileset, child, frameState);
touchTile(tileset, child, frameState);
selectTile(tileset, child, frameState);
} else if (child._depth - root._depth < descendantSelectionDepth) {
// Continue traversing, but not too far
stack.push(child);
}
}
}
}
Expand Down Expand Up @@ -469,11 +471,17 @@ define([
refines = updateAndPushChildren(tileset, tile, stack, frameState) && parentRefines;
}

var stoppedRefining = !refines && parentRefines;

if (hasEmptyContent(tile)) {
// Add empty tile just to show its debug bounding volume
// If the tile has tileset content load the external tileset
// If the tile cannot refine further select its nearest loaded ancestor
addEmptyTile(tileset, tile, frameState);
loadTile(tileset, tile, frameState);
if (stoppedRefining) {
selectDesiredTile(tileset, tile, frameState);
}
} else if (add) {
// Additive tiles are always loaded and selected
selectDesiredTile(tileset, tile, frameState);
Expand All @@ -483,18 +491,16 @@ define([
// Always load tiles in the base traversal
// Select tiles that can't refine further
loadTile(tileset, tile, frameState);
if (!refines && parentRefines) {
if (stoppedRefining) {
selectDesiredTile(tileset, tile, frameState);
}
} else {
// Load tiles that are not skipped or can't refine further. In practice roughly half the tiles stay unloaded.
// Select tiles that can't refine further. If the tile doesn't have loaded content it will try to select an ancestor with loaded content instead.
if (!refines) { // eslint-disable-line
selectDesiredTile(tileset, tile, frameState);
loadTile(tileset, tile, frameState);
} else if (reachedSkippingThreshold(tileset, tile)) {
loadTile(tileset, tile, frameState);
}
} else if (stoppedRefining) {
// In skip traversal, load and select tiles that can't refine further
selectDesiredTile(tileset, tile, frameState);
loadTile(tileset, tile, frameState);
} else if (reachedSkippingThreshold(tileset, tile)) {
// In skip traversal, load tiles that aren't skipped. In practice roughly half the tiles stay unloaded.
loadTile(tileset, tile, frameState);
}
}

Expand Down
20 changes: 20 additions & 0 deletions Specs/Scene/Cesium3DTilesetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,26 @@ defineSuite([
});
});

it('replacement refinement - selects upwards when traversal stops at empty tile', function() {
// No children have content, but all grandchildren have content
//
// C
// E E
// C C C C
//
return Cesium3DTilesTester.loadTileset(scene, tilesetReplacement1Url).then(function(tileset) {
tileset.root.geometricError = 90;
viewRootOnly();
scene.camera.zoomIn(20);
scene.renderForSpecs();

var statistics = tileset._statistics;
expect(statistics.selected).toEqual(1);
expect(statistics.visited).toEqual(3);
expect(isSelected(tileset, tileset.root)).toBe(true);
});
});

it('replacement refinement - selects root when sse is not met and subtree is not refinable (1)', function() {
// No children have content, but all grandchildren have content
//
Expand Down

0 comments on commit 798ff75

Please sign in to comment.