cesium-native  0.41.0
TileOcclusionRendererProxy.h
1 #pragma once
2 
3 #include "Library.h"
4 #include "Tile.h"
5 
6 #include <cstdint>
7 #include <unordered_map>
8 #include <vector>
9 
13 namespace Cesium3DTilesSelection {
14 enum class CESIUM3DTILESSELECTION_API TileOcclusionState {
26 
31 
35  Occluded
36 };
37 
42 class CESIUM3DTILESSELECTION_API TileOcclusionRendererProxy {
43 public:
57 
58 protected:
59  friend class TileOcclusionRendererProxyPool;
68  virtual void reset(const Tile* pTile) = 0;
69 
70 private:
71  bool _usedLastFrame = false;
72  TileOcclusionRendererProxy* _pNext = nullptr;
73 };
74 
80 class CESIUM3DTILESSELECTION_API TileOcclusionRendererProxyPool {
81 public:
88  TileOcclusionRendererProxyPool(int32_t maximumPoolSize);
89 
94 
98  void destroyPool();
99 
111  fetchOcclusionProxyForTile(const Tile& tile, int32_t currentFrame);
112 
120 
121 protected:
128 
134  virtual void destroyProxy(TileOcclusionRendererProxy* pProxy) = 0;
135 
136 private:
137  // Singly linked list representing the free proxies in the pool
138  TileOcclusionRendererProxy* _pFreeProxiesHead;
139  int32_t _currentSize;
140  int32_t _maxSize;
141  // The currently used proxies in the pool
142  std::unordered_map<const Tile*, TileOcclusionRendererProxy*>
143  _tileToOcclusionProxyMappings;
144 };
145 
146 } // namespace Cesium3DTilesSelection
A pool of TileOcclusionRendererProxy objects. Allows quick remapping of tiles to occlusion renderer p...
TileOcclusionRendererProxyPool(int32_t maximumPoolSize)
Constructs a new instance.
virtual ~TileOcclusionRendererProxyPool()
Destroys this pool.
const TileOcclusionRendererProxy * fetchOcclusionProxyForTile(const Tile &tile, int32_t currentFrame)
Get the TileOcclusionRendererProxy mapped to the tile. Attempts to create a new mapping if one does n...
void pruneOcclusionProxyMappings()
Prunes the occlusion proxy mappings and removes any mappings that were unused the last frame....
virtual TileOcclusionRendererProxy * createProxy()=0
Create a TileOcclusionRendererProxy.
virtual void destroyProxy(TileOcclusionRendererProxy *pProxy)=0
Destroy a TileOcclusionRendererProxy that is done being used.
An interface for client renderers to use to represent tile bounding volumes that should be occlusion ...
virtual TileOcclusionState getOcclusionState() const =0
Get the occlusion state for this tile. If this is OcclusionUnavailable, the traversal may decide to w...
virtual void reset(const Tile *pTile)=0
Reset this proxy to target a new tile. If nullptr, this proxy is back in the pool and will not be use...
A tile in a Tileset.
Definition: Tile.h:97
Classes that implement the 3D Tiles standard.
@ Occluded
The tile's bounding volume is known by the renderer to be occluded.
@ OcclusionUnavailable
The renderer does not yet know if the tile's bounding volume is occluded or not.
@ NotOccluded
The tile's bounding volume is known by the renderer to be visible.