cesium-native  0.41.0
TileSelectionState.h
1 #pragma once
2 
3 #include "Library.h"
4 
5 #include <cstdint>
6 
7 namespace Cesium3DTilesSelection {
8 
21 class TileSelectionState final {
22 public:
26  enum class CESIUM3DTILESSELECTION_API Result {
32  None = 0,
33 
37  Culled = 1,
38 
42  Rendered = 2,
43 
48  Refined = 3,
49 
56  RenderedAndKicked = 4,
57 
65  RefinedAndKicked = 5
66  };
67 
72  constexpr TileSelectionState() noexcept
73  : _frameNumber(0), _result(Result::None) {}
74 
82  constexpr TileSelectionState(int32_t frameNumber, Result result) noexcept
83  : _frameNumber(frameNumber), _result(result) {}
84 
88  constexpr int32_t getFrameNumber() const noexcept {
89  return this->_frameNumber;
90  }
91 
102  constexpr Result getResult(int32_t frameNumber) const noexcept {
103  if (this->_frameNumber != frameNumber) {
104  return Result::None;
105  }
106  return this->_result;
107  }
108 
120  constexpr bool wasKicked(int32_t frameNumber) const noexcept {
121  const Result result = this->getResult(frameNumber);
122  return result == Result::RenderedAndKicked ||
123  result == Result::RefinedAndKicked;
124  }
125 
134  constexpr Result getOriginalResult(int32_t frameNumber) const noexcept {
135  const Result result = this->getResult(frameNumber);
136 
137  switch (result) {
139  return Result::Refined;
141  return Result::Rendered;
142  default:
143  return result;
144  }
145  }
146 
150  constexpr void kick() noexcept {
151  switch (this->_result) {
152  case Result::Rendered:
153  this->_result = Result::RenderedAndKicked;
154  break;
155  case Result::Refined:
156  this->_result = Result::RefinedAndKicked;
157  break;
158  default:
159  break;
160  }
161  }
162 
163 private:
164  int32_t _frameNumber;
165  Result _result;
166 };
167 
168 } // namespace Cesium3DTilesSelection
A description of the state of a Tile during the rendering process.
constexpr TileSelectionState(int32_t frameNumber, Result result) noexcept
Initializes a new instance with a given TileSelectionState::Result.
Result
Enumeration of possible results of a TileSelectionState.
@ RenderedAndKicked
This tile was rendered but then removed from the render list.
@ Rendered
The tile was selected for rendering.
@ RefinedAndKicked
This tile was refined but then removed from the render list.
@ Refined
This tile did not meet the required screen-space error and was refined.
constexpr int32_t getFrameNumber() const noexcept
Gets the frame number in which selection took place.
constexpr Result getOriginalResult(int32_t frameNumber) const noexcept
Gets the original selection result prior to being kicked.
constexpr void kick() noexcept
Marks this tile as "kicked".
constexpr TileSelectionState() noexcept
Initializes a new instance with TileSelectionState::Result::None.
constexpr Result getResult(int32_t frameNumber) const noexcept
Gets the result of selection.
constexpr bool wasKicked(int32_t frameNumber) const noexcept
Determines if this tile or its descendents were kicked from the render list.
Classes that implement the 3D Tiles standard.