Skip to content

Commit

Permalink
Merge branch 'main' into additional-component-types
Browse files Browse the repository at this point in the history
  • Loading branch information
kring authored Nov 5, 2024
2 parents 1a31735 + 9b29b67 commit 6d56282
Show file tree
Hide file tree
Showing 206 changed files with 5,593 additions and 1,075 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
submodules: recursive
- name: Generate Documentation
run: |
npm install
cmake -B build -S .
cmake --build build --target cesium-native-docs
- name: Publish Documentation Artifact
Expand Down
35 changes: 35 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,41 @@

- Added support for `EXT_accessor_additional_types` in `AccessorView`.

### v0.41.0 - 2024-11-01

##### Breaking Changes :mega:

- Renamed `CesiumUtility/Gunzip.h` to `CesiumUtility/Gzip.h`.
- Renamed `ImageCesium` to `ImageAsset`.
- The `cesium` field in `CesiumGltf::Image` is now named `pAsset` and is an `IntrusivePointer` to an `ImageAsset`.
- The `image` field in `LoadedRasterOverlayImage` is now named `pImage` and is an `IntrusivePointer` to an `ImageAsset`.
- Deprecated the `readImage` and `generateMipMaps` methods on `GltfReader`. These methods are now found on `ImageDecoder`.

##### Additions :tada:

- Added `CesiumUtility::gzip`.
- Added `CesiumGeometry::Transforms::getUpAxisTransform` to get the transform that converts from one up axis to another.
- Added `TilesetSharedAssetSystem` to `Cesium3DTilesSelection` and `GltfSharedAssetSystem` to `CesiumGltfReader`.
- Added `SharedAsset` to `CesiumUtility` to serve as the base class for assets such as `ImageAsset`.
- Added `SharedAssetDepot` to `CesiumAsync` for managing assets, such as images, that can be shared among multiple models or other objects.
- Added `NetworkAssetDescriptor` and `NetworkImageAssetDescriptor`.
- `ImageAsset` (formerly `ImageCesium`) is now an `ExtensibleObject`.
- Added `VertexAttributeSemantics` to `CesiumGltf`.
- Added `ImageDecoder` to `CesiumGltfReader`.
- Added `DoublyLinkedListAdvanced` to `CesiumUtility`. It is equivalent to `DoublyLinkedList` except it allows the next and previous pointers to be in a base class of the node class.
- Added `contains` method to `DoublyLinkedList` (and `DoublyLinkedListAdvanced`).
- Added static `error` and `warning` methods to `ErrorList`, making it easy to create an instance with a single error or warning.
- `ExtensibleObject::addExtension` now takes arguments that are passed through to the extension's constructor.
- Added `Hash` to `CesiumUtility`.
- Added `emplace` and `reset` methods to `IntrusivePointer`.
- Added `Result<T>` and `ResultPointer<T>` classes to represent the result of an operation that might complete with warnings and errors.

##### Fixes :wrench:

- Fixed missing ellipsoid parameters that would lead to incorrect results when using non-WGS84 ellipsoids.
- Fixed a bug in `AsyncSystem::all` where the resolved values of individual futures were copied instead of moved into the output array.
- Improved the hash function for `QuadtreeTileID`.

### v0.40.1 - 2024-10-01

##### Fixes :wrench:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ endif()
include("cmake/defaults.cmake")

project(cesium-native
VERSION 0.1.0
VERSION 0.41.0
LANGUAGES CXX C
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ struct Rectangle;
}

namespace CesiumGltf {
struct ImageCesium;
struct Model;
} // namespace CesiumGltf

Expand Down
10 changes: 10 additions & 0 deletions Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tileset.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
#include <vector>

namespace Cesium3DTilesSelection {

class TilesetContentManager;
class TilesetMetadata;
class TilesetHeightQuery;
class TilesetHeightRequest;
class TilesetSharedAssetSystem;

/**
* @brief A <a
Expand Down Expand Up @@ -181,6 +183,14 @@ class CESIUM3DTILESSELECTION_API Tileset final {
/** @copydoc Tileset::getOverlays() */
const RasterOverlayCollection& getOverlays() const noexcept;

/**
* @brief Returns the {@link TilesetSharedAssetSystem} of this tileset.
*/
TilesetSharedAssetSystem& getSharedAssetSystem() noexcept;

/** @copydoc Tileset::getSharedAssetSystem() */
const TilesetSharedAssetSystem& getSharedAssetSystem() const noexcept;

/**
* @brief Updates this view but waits for all tiles that meet sse to finish
* loading and ready to be rendered before returning the function. This method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "Library.h"
#include "TileOcclusionRendererProxy.h"
#include "TilesetSharedAssetSystem.h"
#include "spdlog-cesium.h"

#include <CesiumAsync/AsyncSystem.h>
Expand Down Expand Up @@ -69,6 +70,13 @@ class CESIUM3DTILESSELECTION_API TilesetExternals final {
*/
std::shared_ptr<TileOcclusionRendererProxyPool> pTileOcclusionProxyPool =
nullptr;

/**
* @brief The shared asset system used to facilitate sharing of common assets,
* such as images, between and within tilesets.
*/
CesiumUtility::IntrusivePointer<TilesetSharedAssetSystem> pSharedAssetSystem =
TilesetSharedAssetSystem::getDefault();
};

} // namespace Cesium3DTilesSelection
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include <CesiumGltfReader/GltfSharedAssetSystem.h>

namespace Cesium3DTilesSelection {

/**
* @brief Contains assets that are potentially shared across multiple Tilesets.
*/
class TilesetSharedAssetSystem
: public CesiumGltfReader::GltfSharedAssetSystem {
public:
static CesiumUtility::IntrusivePointer<TilesetSharedAssetSystem> getDefault();

virtual ~TilesetSharedAssetSystem() = default;
};

} // namespace Cesium3DTilesSelection
4 changes: 3 additions & 1 deletion Cesium3DTilesSelection/src/Tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ int64_t Tile::computeByteSize() const noexcept {

// sizeBytes is set in TilesetContentManager::ContentKindSetter, if not
// sooner (e.g., by the renderer implementation).
bytes += image.cesium.sizeBytes;
if (image.pAsset) {
bytes += image.pAsset->sizeBytes;
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions Cesium3DTilesSelection/src/TileContentLoadInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ TileContentLoadInfo::TileContentLoadInfo(
const std::shared_ptr<IPrepareRendererResources>&
pPrepareRendererResources_,
const std::shared_ptr<spdlog::logger>& pLogger_,
const CesiumUtility::IntrusivePointer<TilesetSharedAssetSystem>&
pSharedAssetSystem_,
const TilesetContentOptions& contentOptions_,
const Tile& tile)
: asyncSystem(asyncSystem_),
Expand All @@ -18,6 +20,7 @@ TileContentLoadInfo::TileContentLoadInfo(
tileID(tile.getTileID()),
tileBoundingVolume(tile.getBoundingVolume()),
tileContentBoundingVolume(tile.getContentBoundingVolume()),
pSharedAssetSystem{pSharedAssetSystem_},
tileRefine(tile.getRefine()),
tileGeometricError(tile.getGeometricError()),
tileTransform(tile.getTransform()),
Expand Down
4 changes: 4 additions & 0 deletions Cesium3DTilesSelection/src/TileContentLoadInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <Cesium3DTilesSelection/TileID.h>
#include <Cesium3DTilesSelection/TileRefine.h>
#include <Cesium3DTilesSelection/TilesetOptions.h>
#include <Cesium3DTilesSelection/TilesetSharedAssetSystem.h>
#include <CesiumAsync/AsyncSystem.h>
#include <CesiumAsync/IAssetAccessor.h>
#include <CesiumGeometry/Axis.h>
Expand All @@ -24,6 +25,8 @@ struct TileContentLoadInfo {
const std::shared_ptr<IPrepareRendererResources>&
pPrepareRendererResources,
const std::shared_ptr<spdlog::logger>& pLogger,
const CesiumUtility::IntrusivePointer<TilesetSharedAssetSystem>&
pSharedAssetSystem,
const TilesetContentOptions& contentOptions,
const Tile& tile);

Expand All @@ -40,6 +43,7 @@ struct TileContentLoadInfo {
BoundingVolume tileBoundingVolume;

std::optional<BoundingVolume> tileContentBoundingVolume;
CesiumUtility::IntrusivePointer<TilesetSharedAssetSystem> pSharedAssetSystem;

TileRefine tileRefine;

Expand Down
8 changes: 8 additions & 0 deletions Cesium3DTilesSelection/src/Tileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ const RasterOverlayCollection& Tileset::getOverlays() const noexcept {
return this->_pTilesetContentManager->getRasterOverlayCollection();
}

TilesetSharedAssetSystem& Tileset::getSharedAssetSystem() noexcept {
return *this->_pTilesetContentManager->getSharedAssetSystem();
}

const TilesetSharedAssetSystem& Tileset::getSharedAssetSystem() const noexcept {
return *this->_pTilesetContentManager->getSharedAssetSystem();
}

static bool
operator<(const FogDensityAtHeight& fogDensity, double height) noexcept {
return fogDensity.cameraHeight < height;
Expand Down
26 changes: 21 additions & 5 deletions Cesium3DTilesSelection/src/TilesetContentManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ struct ContentKindSetter {

void operator()(CesiumGltf::Model&& model) {
for (CesiumGltf::Image& image : model.images) {
if (!image.pAsset)
continue;

// If the image size hasn't been overridden, store the pixelData
// size now. We'll be adding this number to our total memory usage soon,
// and remove it when the tile is later unloaded, and we must use
// the same size in each case.
if (image.cesium.sizeBytes < 0) {
image.cesium.sizeBytes = int64_t(image.cesium.pixelData.size());
if (image.pAsset->sizeBytes < 0) {
image.pAsset->sizeBytes = int64_t(image.pAsset->pixelData.size());
}
}

Expand Down Expand Up @@ -154,7 +157,8 @@ getTileBoundingRegionForUpsampling(const Tile& parent) {
CesiumGeospatial::BoundingRegion(
globeRectangle,
details.boundingRegion.getMinimumHeight(),
details.boundingRegion.getMaximumHeight()),
details.boundingRegion.getMaximumHeight(),
getProjectionEllipsoid(projection)),
center};
}
}
Expand Down Expand Up @@ -562,6 +566,9 @@ postProcessContentInWorkerThread(
tileLoadInfo.contentOptions.ktx2TranscodeTargets;
gltfOptions.applyTextureTransform =
tileLoadInfo.contentOptions.applyTextureTransform;
if (tileLoadInfo.pSharedAssetSystem) {
gltfOptions.pSharedAssetSystem = tileLoadInfo.pSharedAssetSystem;
}

auto asyncSystem = tileLoadInfo.asyncSystem;
auto pAssetAccessor = tileLoadInfo.pAssetAccessor;
Expand Down Expand Up @@ -599,12 +606,12 @@ postProcessContentInWorkerThread(
"Warning when resolving external gltf buffers from "
"{}:\n- {}",
result.pCompletedRequest->url(),
CesiumUtility::joinToString(gltfResult.errors, "\n- "));
CesiumUtility::joinToString(gltfResult.warnings, "\n- "));
} else {
SPDLOG_LOGGER_ERROR(
tileLoadInfo.pLogger,
"Warning resolving external glTF buffers:\n- {}",
CesiumUtility::joinToString(gltfResult.errors, "\n- "));
CesiumUtility::joinToString(gltfResult.warnings, "\n- "));
}
}

Expand Down Expand Up @@ -660,6 +667,7 @@ TilesetContentManager::TilesetContentManager(
_tileLoadsInProgress{0},
_loadedTilesCount{0},
_tilesDataUsed{0},
_pSharedAssetSystem(externals.pSharedAssetSystem),
_destructionCompletePromise{externals.asyncSystem.createPromise<void>()},
_destructionCompleteFuture{
this->_destructionCompletePromise.getFuture().share()},
Expand Down Expand Up @@ -689,6 +697,7 @@ TilesetContentManager::TilesetContentManager(
_tileLoadsInProgress{0},
_loadedTilesCount{0},
_tilesDataUsed{0},
_pSharedAssetSystem(externals.pSharedAssetSystem),
_destructionCompletePromise{externals.asyncSystem.createPromise<void>()},
_destructionCompleteFuture{
this->_destructionCompletePromise.getFuture().share()},
Expand Down Expand Up @@ -840,6 +849,7 @@ TilesetContentManager::TilesetContentManager(
_tileLoadsInProgress{0},
_loadedTilesCount{0},
_tilesDataUsed{0},
_pSharedAssetSystem(externals.pSharedAssetSystem),
_destructionCompletePromise{externals.asyncSystem.createPromise<void>()},
_destructionCompleteFuture{
this->_destructionCompletePromise.getFuture().share()},
Expand Down Expand Up @@ -985,6 +995,7 @@ void TilesetContentManager::loadTileContent(
this->_externals.pAssetAccessor,
this->_externals.pPrepareRendererResources,
this->_externals.pLogger,
this->_pSharedAssetSystem,
tilesetOptions.contentOptions,
tile};

Expand Down Expand Up @@ -1227,6 +1238,11 @@ TilesetContentManager::getTilesetCredits() const noexcept {
return this->_tilesetCredits;
}

const CesiumUtility::IntrusivePointer<TilesetSharedAssetSystem>&
TilesetContentManager::getSharedAssetSystem() const noexcept {
return this->_pSharedAssetSystem;
}

int32_t TilesetContentManager::getNumberOfTilesLoading() const noexcept {
return this->_tileLoadsInProgress;
}
Expand Down
8 changes: 8 additions & 0 deletions Cesium3DTilesSelection/src/TilesetContentManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

namespace Cesium3DTilesSelection {

class TilesetSharedAssetSystem;

class TilesetContentManager
: public CesiumUtility::ReferenceCountedNonThreadSafe<
TilesetContentManager> {
Expand Down Expand Up @@ -115,6 +117,9 @@ class TilesetContentManager

const std::vector<CesiumUtility::Credit>& getTilesetCredits() const noexcept;

const CesiumUtility::IntrusivePointer<TilesetSharedAssetSystem>&
getSharedAssetSystem() const noexcept;

int32_t getNumberOfTilesLoading() const noexcept;

int32_t getNumberOfTilesLoaded() const noexcept;
Expand Down Expand Up @@ -167,6 +172,9 @@ class TilesetContentManager
int32_t _loadedTilesCount;
int64_t _tilesDataUsed;

// Stores assets that might be shared between tiles.
CesiumUtility::IntrusivePointer<TilesetSharedAssetSystem> _pSharedAssetSystem;

CesiumAsync::Promise<void> _destructionCompletePromise;
CesiumAsync::SharedFuture<void> _destructionCompleteFuture;

Expand Down
Loading

0 comments on commit 6d56282

Please sign in to comment.