Skip to content

Commit

Permalink
Merge pull request #335 from CesiumGS/unconditional-refine
Browse files Browse the repository at this point in the history
Fixed external tilesets not loading when frustum culling was disabled
  • Loading branch information
kring authored Sep 13, 2021
2 parents 51e4b17 + 388ed45 commit d3e90d0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
##### Fixes :wrench:

- Fixed a bug introduced in v0.7.0 where Bing credits were not being collected.
- Fixed a bug where disabling frustum culling caused external tilesets to not load.

### v0.7.0 - 2021-09-01

Expand Down
25 changes: 25 additions & 0 deletions Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
#include "CesiumGeospatial/Projection.h"
#include "CesiumUtility/DoublyLinkedList.h"
#include <atomic>
#include <glm/common.hpp>
#include <glm/mat4x4.hpp>
#include <gsl/span>
#include <limits>
#include <memory>
#include <optional>
#include <string>
Expand Down Expand Up @@ -294,6 +296,29 @@ class CESIUM3DTILESSELECTION_API Tile final {
this->_geometricError = value;
}

/**
* @brief Returns whether to unconditionally refine this tile.
*
* This is useful in cases such as with external tilesets, where instead of a
* tile having any content, it points to an external tileset's root. So the
* tile always needs to be refined otherwise the external tileset will not be
* displayed.
*
* @return Whether to uncoditionally refine this tile.
*/
bool getUnconditionallyRefine() const noexcept {
return glm::isinf(this->_geometricError);
}

/**
* @brief Marks that this tile should be unconditionally refined.
*
* This function is not supposed to be called by clients.
*/
void setUnconditionallyRefine() noexcept {
this->_geometricError = std::numeric_limits<double>::infinity();
}

/**
* @brief The refinement strategy of this tile.
*
Expand Down
10 changes: 5 additions & 5 deletions Cesium3DTilesSelection/src/Tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,12 +629,12 @@ void Tile::update(
std::move(this->_pContent->pNewTileContext));
}

// If this tile has no model, set its geometric error very high so we
// refine past it. Note that "no" model is different from having a model,
// but it is blank. In the latter case, we'll happily render nothing in
// the space of this tile, which is sometimes useful.
// If this tile has no model, we want to unconditionally refine past it.
// Note that "no" model is different from having a model, but it is blank.
// In the latter case, we'll happily render nothing in the space of this
// tile, which is sometimes useful.
if (!this->_pContent->model) {
this->setGeometricError(999999999.0);
this->setUnconditionallyRefine();
}

// A new and improved bounding volume.
Expand Down
4 changes: 3 additions & 1 deletion Cesium3DTilesSelection/src/Tileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1682,11 +1682,13 @@ Tileset::TraversalDetails Tileset::_visitTile(
return _renderLeaf(frameState, tile, distances, result);
}

bool unconditionallyRefine = tile.getUnconditionallyRefine();
bool meetsSse = _meetsSse(frameState.frustums, tile, distances, culled);
bool waitingForChildren =
_queueLoadOfChildrenRequiredForRefinement(frameState, tile, distances);

if (meetsSse || ancestorMeetsSse || waitingForChildren) {
if (!unconditionallyRefine &&
(meetsSse || ancestorMeetsSse || waitingForChildren)) {
// This tile (or an ancestor) is the one we want to render this frame, but
// we'll do different things depending on the state of this tile and on what
// we did _last_ frame.
Expand Down
5 changes: 2 additions & 3 deletions Cesium3DTilesSelection/test/TestTilesetSelectionAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,8 @@ TEST_CASE("Test additive refinement") {
"tileset3/tileset3.json") {
REQUIRE(doesTileMeetSSE(viewState, child, tileset));
} else {
// external tileset has always geometric error over 999999, so it
// won't meet sse
REQUIRE(!doesTileMeetSSE(viewState, child, tileset));
// external tilesets get unconditionally refined
REQUIRE(root->getUnconditionallyRefine());

// expect the children to meet sse and begin loading the content
REQUIRE(child.getChildren().size() == 1);
Expand Down

0 comments on commit d3e90d0

Please sign in to comment.