Skip to content

Commit

Permalink
Merge pull request #8996 from CesiumGS/fix-empty-traversal
Browse files Browse the repository at this point in the history
Fix tile refinement when leaf is empty
  • Loading branch information
loshjawrence authored Jul 9, 2020
2 parents 2422b6b + e047077 commit 5e0cce6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

### 1.72 - 2020-08-03

##### Fixes :wrench:

- Fixed 3D Tileset replacement refinement when leaf is empty. [#8996](https://github.com/CesiumGS/cesium/8996)

### 1.71 - 2020-07-01

##### Breaking Changes :mega:
Expand Down
13 changes: 8 additions & 5 deletions Source/Scene/Cesium3DTilesetTraversal.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,11 +652,14 @@ function executeEmptyTraversal(tileset, root, frameState) {
var childrenLength = children.length;

// Only traverse if the tile is empty - traversal stop at descendants with content
var traverse = hasEmptyContent(tile) && canTraverse(tileset, tile);

// Traversal stops but the tile does not have content yet.
// There will be holes if the parent tries to refine to its children, so don't refine.
if (!traverse && !tile.contentAvailable) {
var emptyContent = hasEmptyContent(tile);
var traverse = emptyContent && canTraverse(tileset, tile);
var emptyLeaf = emptyContent && tile.children.length === 0;

// Traversal stops but the tile does not have content yet
// There will be holes if the parent tries to refine to its children, so don't refine
// One exception: a parent may refine even if one of its descendants is an empty leaf
if (!traverse && !tile.contentAvailable && !emptyLeaf) {
allDescendantsLoaded = false;
}

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

it("replacement refinement - refines if descendant is empty leaf tile", function () {
// Check that the root is refinable once its children with content are loaded
//
// C
// C C C E
//
viewAllTiles();
var originalLoadJson = Cesium3DTileset.loadJson;
spyOn(Cesium3DTileset, "loadJson").and.callFake(function (tilesetUrl) {
return originalLoadJson(tilesetUrl).then(function (tilesetJson) {
tilesetJson.root.refine = "REPLACE";
tilesetJson.root.children[3].content = undefined;
return tilesetJson;
});
});

return Cesium3DTilesTester.loadTileset(scene, tilesetUrl).then(function (
tileset
) {
tileset.skipLevelOfDetail = false;
var statistics = tileset._statistics;
scene.renderForSpecs();
expect(statistics.numberOfCommands).toEqual(3);
});
});

it("replacement and additive refinement", function () {
// A
// A R (not rendered)
Expand Down

0 comments on commit 5e0cce6

Please sign in to comment.