Skip to content

Commit

Permalink
Merge branch 'main' of github.com:CesiumGS/cesium-native into ada-url
Browse files Browse the repository at this point in the history
  • Loading branch information
azrogers committed Jan 23, 2025
2 parents 605ea5a + ff1f6b9 commit 40d4ba9
Show file tree
Hide file tree
Showing 34 changed files with 871 additions and 81 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@

### v0.44.0 - 2025-02-03

##### Breaking Changes :mega:

- cesium-native no longer uses the `GLM_FORCE_SIZE_T_LENGTH` option with the `glm` library

##### Additions :tada:

- Added conversion of I3dm batch table metadata to `EXT_structural_metadata` and `EXT_instance_features` extensions.
- Added `CesiumIonClient::Connection::geocode` method for making geocoding queries against the Cesium ion geocoder API.
- Added `UrlTemplateRasterOverlay` for requesting raster tiles from services using a templated URL.
- `upsampleGltfForRasterOverlays` is now compatible with meshes using TRIANGLE_STRIP, TRIANGLE_FAN, or non-indexed TRIANGLES primitives.
- Added `requestHeaders` field to `TilesetOptions` to allow per-tileset request headers to be specified.

##### Fixes :wrench:

- Fixed a crash in `GltfWriter` that would happen when the `EXT_structural_metadata` `schema` property was null.
- Fixed a bug in `SharedAssetDepot` that could cause assertion failures in debug builds, and could rarely cause premature deletion of shared assets even in release builds.
- Fixed a bug that could cause `Tileset::sampleHeightMostDetailed` to return a height that is not the highest one when the sampled tileset contained multiple heights at the given location.

### v0.43.0 - 2025-01-02

Expand Down
3 changes: 2 additions & 1 deletion Cesium3DTilesContent/src/I3dmToGltfConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <CesiumUtility/Uri.h>

#include <fmt/format.h>
#include <glm/detail/setup.hpp>
#include <glm/ext/matrix_double4x4.hpp>
#include <glm/ext/matrix_transform.hpp>
#include <glm/ext/vector_double3.hpp>
Expand Down Expand Up @@ -492,7 +493,7 @@ CesiumAsync::Future<ConvertedI3dm> convertI3dmContent(
decodedInstances.positions.begin(),
[&parsedContent](auto&& posQuantized) {
glm::vec3 position;
for (unsigned j = 0; j < 3; ++j) {
for (glm::length_t j = 0; j < 3; ++j) {
position[j] = static_cast<float>(
posQuantized[j] / 65535.0 *
(*parsedContent.quantizedVolumeScale)[j] +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <Cesium3DTilesSelection/Library.h>
#include <CesiumAsync/IAssetAccessor.h>
#include <CesiumGeospatial/Ellipsoid.h>
#include <CesiumGltf/Ktx2TranscodeTargets.h>

Expand Down Expand Up @@ -328,6 +329,11 @@ struct CESIUM3DTILESSELECTION_API TilesetOptions {
* 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
1 change: 0 additions & 1 deletion Cesium3DTilesSelection/src/Tileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ Tileset::Tileset(
_loadedTiles,
externals,
options.ellipsoid},
std::vector<CesiumAsync::IAssetAccessor::THeader>{},
std::move(pCustomLoader),
std::move(pRootTile)),
} {}
Expand Down
11 changes: 5 additions & 6 deletions Cesium3DTilesSelection/src/TilesetContentManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ void calcRasterOverlayDetailsInWorkerThread(
const TileContentLoadInfo& tileLoadInfo) {
CesiumGltf::Model& model = std::get<CesiumGltf::Model>(result.contentKind);

// we will use the fittest bounding volume to calculate raster overlay details
// below
// we will use the best-fitting bounding volume to calculate raster overlay
// details below
const BoundingVolume& contentBoundingVolume =
getEffectiveContentBoundingVolume(
tileLoadInfo.tileBoundingVolume,
Expand Down Expand Up @@ -705,11 +705,10 @@ TilesetContentManager::TilesetContentManager(
const TilesetExternals& externals,
const TilesetOptions& tilesetOptions,
RasterOverlayCollection&& overlayCollection,
std::vector<CesiumAsync::IAssetAccessor::THeader>&& requestHeaders,
std::unique_ptr<TilesetContentLoader>&& pLoader,
std::unique_ptr<Tile>&& pRootTile)
: _externals{externals},
_requestHeaders{std::move(requestHeaders)},
_requestHeaders{tilesetOptions.requestHeaders},
_pLoader{std::move(pLoader)},
_pRootTile{std::move(pRootTile)},
_userCredit(
Expand Down Expand Up @@ -739,7 +738,7 @@ TilesetContentManager::TilesetContentManager(
RasterOverlayCollection&& overlayCollection,
const std::string& url)
: _externals{externals},
_requestHeaders{},
_requestHeaders{tilesetOptions.requestHeaders},
_pLoader{},
_pRootTile{},
_userCredit(
Expand Down Expand Up @@ -891,7 +890,7 @@ TilesetContentManager::TilesetContentManager(
const std::string& ionAccessToken,
const std::string& ionAssetEndpointUrl)
: _externals{externals},
_requestHeaders{},
_requestHeaders{tilesetOptions.requestHeaders},
_pLoader{},
_pRootTile{},
_userCredit(
Expand Down
1 change: 0 additions & 1 deletion Cesium3DTilesSelection/src/TilesetContentManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class TilesetContentManager
const TilesetExternals& externals,
const TilesetOptions& tilesetOptions,
RasterOverlayCollection&& overlayCollection,
std::vector<CesiumAsync::IAssetAccessor::THeader>&& requestHeaders,
std::unique_ptr<TilesetContentLoader>&& pLoader,
std::unique_ptr<Tile>&& pRootTile);

Expand Down
4 changes: 2 additions & 2 deletions Cesium3DTilesSelection/src/TilesetHeightQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ void TilesetHeightQuery::intersectVisibleTile(
// Set ray info to this hit if closer, or the first hit
if (!this->intersection.has_value()) {
this->intersection = std::move(gltfIntersectResult.hit);
} else {
} else if (gltfIntersectResult.hit) {
double prevDistSq = this->intersection->rayToWorldPointDistanceSq;
double thisDistSq = intersection->rayToWorldPointDistanceSq;
double thisDistSq = gltfIntersectResult.hit->rayToWorldPointDistanceSq;
if (thisDistSq < prevDistSq)
this->intersection = std::move(gltfIntersectResult.hit);
}
Expand Down
11 changes: 0 additions & 11 deletions Cesium3DTilesSelection/test/TestTilesetContentManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ TEST_CASE("Test tile state machine") {
externals,
options,
RasterOverlayCollection{loadedTiles, externals},
{},
std::move(pMockedLoader),
std::move(pRootTile)};

Expand Down Expand Up @@ -612,7 +611,6 @@ TEST_CASE("Test tile state machine") {
externals,
options,
RasterOverlayCollection{loadedTiles, externals},
{},
std::move(pMockedLoader),
std::move(pRootTile)};

Expand Down Expand Up @@ -689,7 +687,6 @@ TEST_CASE("Test tile state machine") {
externals,
options,
RasterOverlayCollection{loadedTiles, externals},
{},
std::move(pMockedLoader),
std::move(pRootTile)};

Expand Down Expand Up @@ -792,7 +789,6 @@ TEST_CASE("Test tile state machine") {
externals,
options,
RasterOverlayCollection{loadedTiles, externals},
{},
std::move(pMockedLoader),
std::move(pRootTile)};

Expand Down Expand Up @@ -947,7 +943,6 @@ TEST_CASE("Test the tileset content manager's post processing for gltf") {
externals,
{},
RasterOverlayCollection{loadedTiles, externals},
{},
std::move(pMockedLoader),
std::move(pRootTile)};

Expand Down Expand Up @@ -1017,7 +1012,6 @@ TEST_CASE("Test the tileset content manager's post processing for gltf") {
externals,
options,
RasterOverlayCollection{loadedTiles, externals},
{},
std::move(pMockedLoader),
std::move(pRootTile)};

Expand Down Expand Up @@ -1083,7 +1077,6 @@ TEST_CASE("Test the tileset content manager's post processing for gltf") {
externals,
{},
RasterOverlayCollection{loadedTiles, externals},
{},
std::move(pMockedLoader),
std::move(pRootTile)};

Expand Down Expand Up @@ -1134,7 +1127,6 @@ TEST_CASE("Test the tileset content manager's post processing for gltf") {
externals,
{},
std::move(rasterOverlayCollection),
{},
std::move(pMockedLoader),
std::move(pRootTile)};

Expand Down Expand Up @@ -1428,7 +1420,6 @@ TEST_CASE("Test the tileset content manager's post processing for gltf") {
externals,
{},
std::move(rasterOverlayCollection),
{},
std::move(pMockedLoader),
std::move(pRootTile)};

Expand Down Expand Up @@ -1651,7 +1642,6 @@ TEST_CASE("Test the tileset content manager's post processing for gltf") {
externals,
{},
std::move(rasterOverlayCollection),
{},
std::move(pMockedLoader),
std::move(pRootTile)};

Expand Down Expand Up @@ -1720,7 +1710,6 @@ TEST_CASE("Test the tileset content manager's post processing for gltf") {
externals,
{},
RasterOverlayCollection{loadedTiles, externals},
{},
std::move(loaderResult.pLoader),
std::move(loaderResult.pRootTile)};

Expand Down
31 changes: 31 additions & 0 deletions Cesium3DTilesSelection/test/TestTilesetHeightQueries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,35 @@ TEST_CASE("Tileset height queries") {
0.0,
Math::Epsilon4));
}

SUBCASE("stacked-cubes") {
// This tileset has two cubes on top of each other, each in a different
// tile, so we can test that the height of the top one is returned.
// The bottom cube has a height of 78.0 meters, the upper cube has a height
// of 83.0 meters.
std::string url =
"file://" +
Uri::nativePathToUriPath(StringHelpers::toStringUtf8(
(testDataPath / "stacked-cubes" / "tileset.json").u8string()));

Tileset tileset(externals, url);

Future<SampleHeightResult> future = tileset.sampleHeightMostDetailed(
{Cartographic::fromDegrees(10.0, 45.0, 0.0)});

while (!future.isReady()) {
tileset.updateView({});
}

SampleHeightResult results = future.waitInMainThread();
CHECK(results.warnings.empty());
REQUIRE(results.positions.size() == 1);

CHECK(results.sampleSuccess[0]);
CHECK(Math::equalsEpsilon(
results.positions[0].height,
83.0,
0.0,
Math::Epsilon1));
}
}
Binary file not shown.
71 changes: 71 additions & 0 deletions Cesium3DTilesSelection/test/data/stacked-cubes/tileset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"asset": {
"version": "1.0"
},
"geometricError": 99999,
"root": {
"geometricError": 99999,
"boundingVolume": {
"region": [
-3.14,
-1.57,
3.14,
1.57,
-100,
200
]
},
"children": [
{
"geometricError": 99999,
"boundingVolume": { "box": [0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1] },
"children": [
{
"boundingVolume": { "box": [0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1] },
"geometricError": 3.4641016151377544,
"children": [
{
"boundingVolume": {
"box": [0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1]
},
"content": { "uri": "cube.b3dm" },
"geometricError": 0
}
]
}
],
"transform": [
-0.17364817766693044, 0.9848077530122081, 5.551115123125782e-17, 0,
-0.6963642682339138, -0.1227878088909457, 0.7071067528420348, 0,
0.696364212406123, 0.12278779904699996, 0.7071068095310592, 0,
4449011.446109926, 784480.7554299649, 4487402.148981291, 1
]
},
{
"geometricError": 99999,
"boundingVolume": { "box": [0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1] },
"children": [
{
"boundingVolume": { "box": [0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1] },
"geometricError": 3.4641016151377544,
"children": [
{
"boundingVolume": {
"box": [0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1]
},
"content": { "uri": "cube.b3dm" },
"geometricError": 0
}
]
}
],
"transform": [
-0.17364817766693044, 0.9848077530122081, 5.551115123125782e-17, 0,
-0.6963642682339138, -0.1227878088909457, 0.7071067528420348, 0,
0.696364212406123, 0.12278779904699996, 0.7071068095310592, 0,
4449014.9279309884, 784481.36936896015, 4487405.6845153384, 1
]
}
]
}
}
10 changes: 8 additions & 2 deletions CesiumAsync/include/CesiumAsync/SharedAssetDepot.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,12 @@ void SharedAssetDepot<TAssetType, TAssetKey>::markDeletionCandidate(
template <typename TAssetType, typename TAssetKey>
void SharedAssetDepot<TAssetType, TAssetKey>::markDeletionCandidateUnderLock(
const TAssetType& asset) {
// Verify that the reference count is still zero.
// See: https://github.com/CesiumGS/cesium-native/issues/1073
if (asset._referenceCount != 0) {
return;
}

auto it = this->_assetsByPointer.find(const_cast<TAssetType*>(&asset));
CESIUM_ASSERT(it != this->_assetsByPointer.end());
if (it == this->_assetsByPointer.end()) {
Expand Down Expand Up @@ -519,8 +525,8 @@ void SharedAssetDepot<TAssetType, TAssetKey>::unmarkDeletionCandidateUnderLock(
AssetEntry& entry = *it->second;
bool isFound = this->_deletionCandidates.contains(entry);

CESIUM_ASSERT(isFound);

// The asset won't necessarily be found in the deletionCandidates set.
// See: https://github.com/CesiumGS/cesium-native/issues/1073
if (isFound) {
this->_totalDeletionCandidateMemoryUsage -= entry.sizeInDeletionList;
this->_deletionCandidates.remove(entry);
Expand Down
4 changes: 2 additions & 2 deletions CesiumGeometry/src/IntersectionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <CesiumUtility/Math.h>

#include <glm/common.hpp>
#include <glm/detail/setup.hpp>
#include <glm/exponential.hpp>
#include <glm/ext/matrix_double3x3.hpp>
#include <glm/ext/vector_double2.hpp>
Expand All @@ -16,7 +17,6 @@
#include <glm/matrix.hpp>

#include <cmath>
#include <cstdint>
#include <limits>
#include <optional>
#include <utility>
Expand Down Expand Up @@ -205,7 +205,7 @@ std::optional<double> IntersectionTests::rayAABBParametric(
double tmin = greatestMin;
double tmax = smallestMax;

for (uint32_t i = 0; i < 3; ++i) {
for (glm::length_t i = 0; i < 3; ++i) {
if (glm::abs(dir[i]) < Math::Epsilon6) {
continue;
} else {
Expand Down
2 changes: 2 additions & 0 deletions CesiumGeospatial/include/CesiumGeospatial/Ellipsoid.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ namespace CesiumGeospatial {
* 1`. This is primarily used by Cesium to represent the shape of planetary
* bodies. Rather than constructing this object directly, one of the provided
* constants is normally used.
*
* @see \ref what-is-an-ellipsoid
*/
class CESIUMGEOSPATIAL_API Ellipsoid final {
public:
Expand Down
2 changes: 1 addition & 1 deletion CesiumGeospatial/include/CesiumGeospatial/GlobeAnchor.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LocalHorizontalCoordinateSystem;
/**
* @brief Anchors an object to the globe by defining a transformation from the
* object's coordinate to the globe-fixed coordinate system (usually
* \ref glossary-ecef).
* \ref what-are-ecef-coordinates).
*
* This class allows the anchored coordinate system to be realized in any
* {@link LocalHorizontalCoordinateSystem}. When the object is moved, either by
Expand Down
Loading

0 comments on commit 40d4ba9

Please sign in to comment.