diff --git a/CHANGES.md b/CHANGES.md index d639df268..937f2e337 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -88,6 +88,7 @@ - Added an overload of `Math::equalsEpsilon` for glm matrices. - A tile's bounding volume and content bounding volume are now included in `TileLoadResult` for use in `prepareInLoadThread`. - Added `convertAccessorTypeToPropertyType` and `convertPropertyTypeToAccessorType` to `CesiumGltf::PropertyType`. +- Added `Cesium3DTilesSelection::Tile::setRenderEngineReadiness(bool)`: pass false to delay the point at which the tile can be shown, while waiting for some asynchronous post-processing to finish for example. ##### Fixes :wrench: diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tile.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tile.h index d1c0feced..873499e66 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tile.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tile.h @@ -501,6 +501,17 @@ class CESIUM3DTILESSELECTION_API Tile final { */ bool isRenderable() const noexcept; + /** + * @brief Set by the render engine to notify when a tile needs post-load + * processing before being actually renderable, that will have to happen + * over one or more several main thread loop cycles. + * By default, tiles are assumed immediately renderable when they reach + * TileLoadState::Done status. Render engine can toggle readiness off to + * signify that the tile should not be considered renderable until the flag + * is turned on again. + */ + void setRenderEngineReadiness(bool const renderEngineReady) noexcept; + /** * @brief Determines if this tile has mesh content. */ @@ -687,6 +698,7 @@ class CESIUM3DTILESSELECTION_API Tile final { TilesetContentLoader* _pLoader; TileLoadState _loadState; bool _mightHaveLatentChildren; + bool _renderEngineReadiness = true; ///< Relevant only when _loadState is Done // mapped raster overlay std::vector _rasterTiles; diff --git a/Cesium3DTilesSelection/src/Tile.cpp b/Cesium3DTilesSelection/src/Tile.cpp index aed4f8351..5781bf33f 100644 --- a/Cesium3DTilesSelection/src/Tile.cpp +++ b/Cesium3DTilesSelection/src/Tile.cpp @@ -220,6 +220,8 @@ bool Tile::isRenderable() const noexcept { } if (getState() == TileLoadState::Done) { + if (!_renderEngineReadiness) + return false; // An unconditionally-refined tile is never renderable... UNLESS it has no // children, in which case waiting longer will be futile. if (!getUnconditionallyRefine() || this->_children.empty()) { @@ -235,6 +237,10 @@ bool Tile::isRenderable() const noexcept { return false; } +void Tile::setRenderEngineReadiness(bool const renderEngineReady) noexcept { + _renderEngineReadiness = renderEngineReady; +} + bool Tile::isRenderContent() const noexcept { return this->_content.isRenderContent(); }