Skip to content

Commit 5f742be

Browse files
committed
Const-only getRootTile, const tileset traversal.
This is an experiment.
1 parent c5fc641 commit 5f742be

File tree

11 files changed

+151
-134
lines changed

11 files changed

+151
-134
lines changed

Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tile.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class CESIUM3DTILESSELECTION_API Tile final {
128128
* and it may also keep its content from unloading. See {@link addReference}
129129
* for details.
130130
*/
131-
using Pointer = CesiumUtility::IntrusivePointer<Tile>;
131+
using Pointer = CesiumUtility::IntrusivePointer<const Tile>;
132132

133133
/**
134134
* @brief Construct a tile with unknown content and a loader that is used to
@@ -582,7 +582,7 @@ class CESIUM3DTILESSELECTION_API Tile final {
582582
* added. This can help debug reference counts when compiled with
583583
* `CESIUM_DEBUG_TILE_UNLOADING`.
584584
*/
585-
void addReference(const char* reason = nullptr) noexcept;
585+
void addReference(const char* reason = nullptr) const noexcept;
586586

587587
/**
588588
* @brief Removes a reference from this tile. A live reference will keep this
@@ -606,7 +606,7 @@ class CESIUM3DTILESSELECTION_API Tile final {
606606
* removed. This can help debug reference counts when compiled with
607607
* `CESIUM_DEBUG_TILE_UNLOADING`.
608608
*/
609-
void releaseReference(const char* reason = nullptr) noexcept;
609+
void releaseReference(const char* reason = nullptr) const noexcept;
610610

611611
/**
612612
* @brief Gets the current number of references to this tile.
@@ -697,7 +697,7 @@ class CESIUM3DTILESSELECTION_API Tile final {
697697
// mapped raster overlay
698698
std::vector<RasterMappedTo3DTile> _rasterTiles;
699699

700-
int32_t _referenceCount;
700+
mutable int32_t _referenceCount;
701701

702702
friend class TilesetContentManager;
703703
friend class MockTilesetContentManagerTestFixture;

Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileLoadRequester.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class TileLoadRequester {
6464
*
6565
* @return The next tile to load in a worker thread.
6666
*/
67-
virtual Tile* getNextTileToLoadInWorkerThread() = 0;
67+
virtual const Tile* getNextTileToLoadInWorkerThread() = 0;
6868

6969
/**
7070
* @brief Determines if this requester has any more tiles that need to be
@@ -92,7 +92,7 @@ class TileLoadRequester {
9292
*
9393
* @return The next tile to load in the main thread.
9494
*/
95-
virtual Tile* getNextTileToLoadInMainThread() = 0;
95+
virtual const Tile* getNextTileToLoadInMainThread() = 0;
9696

9797
/**
9898
* @brief Unregister this requester with the {link Tileset} with which it is

Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tileset.h

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,6 @@ class CESIUM3DTILESSELECTION_API Tileset final {
188188
return this->_options.ellipsoid;
189189
}
190190

191-
/**
192-
* @brief Gets the root tile of this tileset.
193-
*
194-
* This may be `nullptr` if there is currently no root tile.
195-
*/
196-
Tile* getRootTile() noexcept;
197-
198191
/** @copydoc Tileset::getRootTile() */
199192
const Tile* getRootTile() const noexcept;
200193

@@ -515,16 +508,16 @@ class CESIUM3DTILESSELECTION_API Tileset final {
515508

516509
TraversalDetails _renderLeaf(
517510
const TilesetFrameState& frameState,
518-
Tile& tile,
511+
const Tile& tile,
519512
double tilePriority,
520513
ViewUpdateResult& result);
521514
TraversalDetails _renderInnerTile(
522515
const TilesetFrameState& frameState,
523-
Tile& tile,
516+
const Tile& tile,
524517
ViewUpdateResult& result);
525518
bool _kickDescendantsAndRenderTile(
526519
const TilesetFrameState& frameState,
527-
Tile& tile,
520+
const Tile& tile,
528521
ViewUpdateResult& result,
529522
TraversalDetails& traversalDetails,
530523
size_t firstRenderedDescendantIndex,
@@ -538,7 +531,7 @@ class CESIUM3DTILESSELECTION_API Tileset final {
538531
uint32_t depth,
539532
bool meetsSse,
540533
bool ancestorMeetsSse,
541-
Tile& tile,
534+
const Tile& tile,
542535
double tilePriority,
543536
ViewUpdateResult& result);
544537

@@ -569,13 +562,13 @@ class CESIUM3DTILESSELECTION_API Tileset final {
569562
const TilesetFrameState& frameState,
570563
uint32_t depth,
571564
bool ancestorMeetsSse,
572-
Tile& tile,
565+
const Tile& tile,
573566
ViewUpdateResult& result);
574567
TraversalDetails _visitVisibleChildrenNearToFar(
575568
const TilesetFrameState& frameState,
576569
uint32_t depth,
577570
bool ancestorMeetsSse,
578-
Tile& tile,
571+
const Tile& tile,
579572
ViewUpdateResult& result);
580573

581574
/**
@@ -595,7 +588,7 @@ class CESIUM3DTILESSELECTION_API Tileset final {
595588
*/
596589
bool _loadAndRenderAdditiveRefinedTile(
597590
const TilesetFrameState& frameState,
598-
Tile& tile,
591+
const Tile& tile,
599592
ViewUpdateResult& result,
600593
double tilePriority,
601594
bool queuedForLoad);
@@ -631,7 +624,7 @@ class CESIUM3DTILESSELECTION_API Tileset final {
631624

632625
void addTileToLoadQueue(
633626
const TilesetFrameState& frameState,
634-
Tile& tile,
627+
const Tile& tile,
635628
TileLoadPriorityGroup priorityGroup,
636629
double priority);
637630

Cesium3DTilesSelection/src/Tile.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ bool isContentReferenced(const Tile& tile) {
392392

393393
} // namespace
394394

395-
void Tile::addReference([[maybe_unused]] const char* reason) noexcept {
395+
void Tile::addReference([[maybe_unused]] const char* reason) const noexcept {
396396
++this->_referenceCount;
397397

398398
#ifdef CESIUM_DEBUG_TILE_UNLOADING
@@ -430,7 +430,8 @@ void Tile::addReference([[maybe_unused]] const char* reason) noexcept {
430430
}
431431
}
432432

433-
void Tile::releaseReference([[maybe_unused]] const char* reason) noexcept {
433+
void Tile::releaseReference(
434+
[[maybe_unused]] const char* reason) const noexcept {
434435
CESIUM_ASSERT(this->_referenceCount > 0);
435436
--this->_referenceCount;
436437

0 commit comments

Comments
 (0)