Skip to content

Commit

Permalink
Better marking of visited tiles.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Sep 16, 2024
1 parent ca62417 commit 5753669
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Cesium3DTilesSelection/src/TilesetHeightQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,27 @@ void TilesetHeightQuery::intersectVisibleTile(
}
}

namespace {

void markTileVisited(Tile::LoadedLinkedList& loadedTiles, Tile* pTile) {
// Don't move the root tile to the tail, because this tile is used to mark the
// beginning of the tiles used in the current frame. If we move it, some tiles
// may be deemed to have most recently been used last frame, and so will be
// unloaded.
if (pTile == nullptr || pTile->getParent() == nullptr)
return;

loadedTiles.insertAtTail(*pTile);
}

} // namespace

void TilesetHeightQuery::findCandidateTiles(
Tile* pTile,
Tile::LoadedLinkedList& loadedTiles,
std::vector<std::string>& warnings) {
// Make sure this tile is not unloaded until we're done with it.
loadedTiles.insertAtTail(*pTile);
markTileVisited(loadedTiles, pTile);

// If tile failed to load, this means we can't complete the intersection
if (pTile->getState() == TileLoadState::Failed) {
Expand Down Expand Up @@ -239,7 +254,7 @@ bool TilesetHeightRequest::tryCompleteHeightRequest(
query.findCandidateTiles(pCandidate, loadedTiles, warnings);
} else {
// Make sure this tile stays loaded.
loadedTiles.insertAtTail(*pCandidate);
markTileVisited(loadedTiles, pCandidate);

// Check again next frame to see if this tile has children.
query.candidateTiles.emplace_back(pCandidate);
Expand Down Expand Up @@ -269,6 +284,11 @@ bool TilesetHeightRequest::tryCompleteHeightRequest(

// If any candidates need loading, add to return set
for (Tile* pTile : query.additiveCandidateTiles) {
// Additive tiles are only enumerated once in findCandidateTiles, so we
// need to continue every frame to make sure they're not unloaded before
// we're done with them.
markTileVisited(loadedTiles, pTile);

checkTile(pTile);
}
for (Tile* pTile : query.candidateTiles) {
Expand Down

0 comments on commit 5753669

Please sign in to comment.