Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tileset traversal #7011

Merged
merged 3 commits into from
Sep 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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