-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathTilesetOptions.h
More file actions
346 lines (305 loc) · 12.6 KB
/
TilesetOptions.h
File metadata and controls
346 lines (305 loc) · 12.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
#pragma once
#include <Cesium3DTilesSelection/Library.h>
#include <CesiumAsync/IAssetAccessor.h>
#include <CesiumGeospatial/Ellipsoid.h>
#include <CesiumGltf/Ktx2TranscodeTargets.h>
#include <any>
#include <functional>
#include <memory>
#include <optional>
#include <string>
#include <vector>
namespace Cesium3DTilesSelection {
class ITileExcluder;
class TilesetLoadFailureDetails;
/**
* @brief Options for configuring the parsing of a {@link Tileset}'s content
* and construction of Gltf models.
*/
struct CESIUM3DTILESSELECTION_API TilesetContentOptions {
/**
* @brief Whether to include a water mask within the Gltf extras.
*
* Currently only applicable for quantized-mesh tilesets that support the
* water mask extension.
*/
bool enableWaterMask = false;
/**
* @brief Whether to generate smooth normals when normals are missing in the
* original Gltf.
*
* According to the Gltf spec: "When normals are not specified, client
* implementations should calculate flat normals." However, calculating flat
* normals requires duplicating vertices. This option allows the gltfs to be
* sent with explicit smooth normals when the original gltf was missing
* normals.
*/
bool generateMissingNormalsSmooth = false;
/**
* @brief For each possible input transmission format, this struct names
* the ideal target gpu-compressed pixel format to transcode to.
*/
CesiumGltf::Ktx2TranscodeTargets ktx2TranscodeTargets;
/**
* @brief Whether or not to transform texture coordinates during load when
* textures have the `KHR_texture_transform` extension. Set this to false if
* texture coordinates will be transformed another way, such as in a vertex
* shader.
*/
bool applyTextureTransform = true;
/**
* @brief Whether to translate vector feature data, e.g. GeoJSON content, to
* glTF, or leave it in its native format.
*/
bool translateVectorFeatures = true;
};
/**
* @brief Defines the fog density at a certain height.
*
* @see TilesetOptions::fogDensityTable
*/
struct CESIUM3DTILESSELECTION_API FogDensityAtHeight {
/** @brief The height. */
double cameraHeight;
/** @brief The fog density. */
double fogDensity;
};
/**
* @brief Additional options for configuring a {@link Tileset}.
*/
struct CESIUM3DTILESSELECTION_API TilesetOptions {
/**
* @brief A credit text for this tileset, if needed.
*/
std::optional<std::string> credit;
/**
* @brief Whether or not to display tileset's credits on the screen.
*/
bool showCreditsOnScreen = false;
/**
* @brief The maximum number of pixels of error when rendering this tileset.
* This is used to select an appropriate level-of-detail.
*
* When a tileset uses the older layer.json / quantized-mesh format rather
* than 3D Tiles, this value is effectively divided by 8.0. So the default
* value of 16.0 corresponds to the standard value for quantized-mesh terrain
* of 2.0.
*/
double maximumScreenSpaceError = 16.0;
/**
* @brief The maximum number of tiles that may simultaneously be in the
* process of loading.
*/
uint32_t maximumSimultaneousTileLoads = 20;
/**
* @brief Indicates whether the ancestors of rendered tiles should be
* preloaded. Setting this to true optimizes the zoom-out experience and
* provides more detail in newly-exposed areas when panning. The down side is
* that it requires loading more tiles.
*/
bool preloadAncestors = true;
/**
* @brief Indicates whether the siblings of rendered tiles should be
* preloaded. Setting this to true causes tiles with the same parent as a
* rendered tile to be loaded, even if they are culled. Setting this to true
* may provide a better panning experience at the cost of loading more tiles.
*/
bool preloadSiblings = true;
/**
* @brief The number of loading descendant tiles that is considered "too
* many". If a tile has too many loading descendants, that tile will be loaded
* and rendered before any of its descendants are loaded and rendered. This
* means more feedback for the user that something is happening at the cost of
* a longer overall load time. Setting this to 0 will cause each tile level to
* be loaded successively, significantly increasing load time. Setting it to a
* large number (e.g. 1000) will minimize the number of tiles that are loaded
* but tend to make detail appear all at once after a long wait.
*/
uint32_t loadingDescendantLimit = 20;
/**
* @brief Never render a tileset with missing tiles.
*
* When true, the tileset will guarantee that the tileset will never be
* rendered with holes in place of tiles that are not yet loaded. It does this
* by refusing to refine a parent tile until all of its child tiles are ready
* to render. Thus, when the camera moves, we will always have something -
* even if it's low resolution - to render any part of the tileset that
* becomes visible. When false, overall loading will be faster, but
* newly-visible parts of the tileset may initially be blank.
*/
bool forbidHoles = false;
/**
* @brief Enable culling of tiles against the frustum.
*/
bool enableFrustumCulling = true;
/**
* @brief Enable culling of occluded tiles, as reported by the renderer.
*/
bool enableOcclusionCulling = true;
/**
* @brief Wait to refine until the occlusion state of a tile is known.
*
* Only applicable when enableOcclusionInfo is true. Enabling this option may
* cause a small delay between when a tile is needed according to the SSE and
* when the tile load is kicked off. On the other hand, this delay could
* allow the occlusion system to avoid loading a tile entirely if it is
* found to be unnecessary a few frames later.
*/
bool delayRefinementForOcclusion = true;
/**
* @brief Enable culling of tiles that cannot be seen through atmospheric fog.
*/
bool enableFogCulling = true;
/**
* @brief Whether culled tiles should be refined until they meet
* culledScreenSpaceError.
*
* When true, any culled tile from a disabled culling stage will be refined
* until it meets the specified culledScreenSpaceError. Otherwise, its
* screen-space error check will be disabled altogether and it will not bother
* to refine any futher.
*/
bool enforceCulledScreenSpaceError = true;
/**
* @brief The screen-space error to refine until for culled tiles from
* disabled culling stages.
*
* When enforceCulledScreenSpaceError is true, culled tiles from disabled
* culling stages will be refined until they meet this screen-space error
* value.
*/
double culledScreenSpaceError = 64.0;
/**
* @brief The maximum number of bytes that may be cached.
*
* Note that this value, even if 0, will never
* cause tiles that are needed for rendering to be unloaded. However, if the
* total number of loaded bytes is greater than this value, tiles will be
* unloaded until the total is under this number or until only required tiles
* remain, whichever comes first.
*/
int64_t maximumCachedBytes = 512LL * 1024 * 1024;
/**
* @brief A table that maps the camera height above the ellipsoid to a fog
* density. Tiles that are in full fog are culled. The density of the fog
* increases as this number approaches 1.0 and becomes less dense as it
* approaches zero. The more dense the fog is, the more aggressively the tiles
* are culled. For example, if the camera is a height of 1000.0m above the
* ellipsoid, increasing the value to 3.0e-3 will cause many tiles close to
* the viewer be culled. Decreasing the value will push the fog further from
* the viewer, but decrease performance as more of the tiles are rendered.
* Tiles are culled when `1.0 - glm::exp(-(distance * distance * fogDensity *
* fogDensity))` is >= 1.0.
*/
std::vector<FogDensityAtHeight> fogDensityTable = {
{359.393, 2.0e-5}, {800.749, 2.0e-4}, {1275.6501, 1.0e-4},
{2151.1192, 7.0e-5}, {3141.7763, 5.0e-5}, {4777.5198, 4.0e-5},
{6281.2493, 3.0e-5}, {12364.307, 1.9e-5}, {15900.765, 1.0e-5},
{49889.0549, 8.5e-6}, {78026.8259, 6.2e-6}, {99260.7344, 5.8e-6},
{120036.3873, 5.3e-6}, {151011.0158, 5.2e-6}, {156091.1953, 5.1e-6},
{203849.3112, 4.2e-6}, {274866.9803, 4.0e-6}, {319916.3149, 3.4e-6},
{493552.0528, 2.6e-6}, {628733.5874, 2.2e-6}, {1000000.0, 0.0}};
/**
* @brief Whether to render tiles directly under the camera, even if they're
* not in the view frustum.
*
* This is useful for detecting the camera's collision with terrain and other
* models. NOTE: This option currently only works with tiles that use a
* `region` as their bounding volume. It is ignored for other bounding volume
* types.
*/
bool renderTilesUnderCamera = true;
/**
* @brief A list of interfaces that are given an opportunity to exclude tiles
* from loading and rendering. If any of the excluders indicate that a tile
* should not be loaded, it will not be loaded.
*/
std::vector<std::shared_ptr<ITileExcluder>> excluders;
/**
* @brief A callback function that is invoked when a tileset resource fails to
* load.
*
* Tileset resources include a Cesium ion asset endpoint, a tileset's root
* tileset.json or layer.json, an individual tile's content, or an implicit
* tiling subtree.
*/
std::function<void(const TilesetLoadFailureDetails&)> loadErrorCallback;
/**
* @brief Whether to keep tiles loaded during a transition period when
* switching to a different LOD tile.
*
* For each tile, {@link TileRenderContent::getLodTransitionFadePercentage} will
* indicate to the client how faded to render the tile throughout the
* transition. Tile fades can be used to mask LOD transitions and make them
* appear less abrupt and jarring.
*
* Because each tile currently has only one transition fade percentage, it is
* recommended that this option be set to `false` when using multiple
* {@link TilesetViewGroup} instances.
*/
bool enableLodTransitionPeriod = false;
/**
* @brief How long it should take to transition between tiles of different
* LODs, in seconds.
*
* This property is ignored if {@link enableLodTransitionPeriod} is false.
*
* When a tile refines or unrefines to a higher or lower LOD tile, a fade
* can optionally be applied to smooth the transition. This value determines
* how many seconds the whole transition should take. Note that the old tile
* doesn't start fading out until the new tile fully fades in.
*/
float lodTransitionLength = 1.0f;
/**
* @brief Whether to kick descendants while a tile is still fading in.
*
* This property is ignored if {@link enableLodTransitionPeriod} is false.
*
* This does not delay loading of descendants, but it keeps them off the
* render list while the tile is fading in. If this is false, the tile
* currently fading in will pop in to full opacity if descendants are
* rendered (this counteracts the benefits of LOD transition blending).
*/
bool kickDescendantsWhileFadingIn = true;
/**
* @brief A soft limit on how long (in milliseconds) to spend on the
* main-thread part of tile loading each frame (each call to
* {@link Tileset::loadTiles}). A value of 0.0 indicates that all pending
* main-thread loads should be completed each tick.
*
* Setting this to too low of a value will impede overall tile load progress,
* creating a discernable load latency.
*/
double mainThreadLoadingTimeLimit = 0.0;
/**
* @brief A soft limit on how long (in milliseconds) to spend unloading
* cached tiles each frame (each call to {@link Tileset::loadTiles}). A value
* of 0.0 indicates that the tile cache should not throttle unloading tiles.
*/
double tileCacheUnloadTimeLimit = 0.0;
/**
* @brief Options for configuring the parsing of a {@link Tileset}'s content
* and construction of Gltf models.
*/
TilesetContentOptions contentOptions;
/**
* @brief Arbitrary data that will be passed to {@link IPrepareRendererResources::prepareInLoadThread}.
*
* This object is copied and given to tile preparation threads,
* so it must be inexpensive to copy.
*/
std::any rendererOptions;
/**
* @brief The ellipsoid to use for this tileset.
* This value shouldn't be changed after the tileset is constructed. If you
* need to change a tileset's ellipsoid, please recreate the tileset.
*
* If no ellipsoid is set, Ellipsoid::WGS84 will be used by default.
*/
CesiumGeospatial::Ellipsoid ellipsoid = CesiumGeospatial::Ellipsoid::WGS84;
/**
* @brief HTTP headers to attach to requests made for this tileset.
*/
std::vector<CesiumAsync::IAssetAccessor::THeader> requestHeaders;
};
} // namespace Cesium3DTilesSelection