Skip to content

Commit

Permalink
Merge pull request CesiumGS#766 from CesiumGS/bake-overlays-to-gltf
Browse files Browse the repository at this point in the history
Refactoring to support baking raster overlays into a glTF
  • Loading branch information
csciguy8 committed Nov 29, 2023
2 parents 940f102 + b44274a commit 381528a
Show file tree
Hide file tree
Showing 52 changed files with 936 additions and 216 deletions.
14 changes: 11 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@

- Moved `ErrorList`, `CreditSystem`, and `Credit` from `Cesium3DTilesSelection` to `CesiumUtility`.
- Moved `GltfUtilities` from `Cesium3DTilesSelection` to `Cesium3DTilesContent`.
- Moved `createRasterOverlayTextureCoordinates` method from `GltfUtilities` to a new `RasterOverlayUtilities` class in the `Cesium3DTilesSelection` library.
- Moved `RasterOverlay`, `RasterOverlayTileProvider`, `RasterOverlayTile`, `QuadtreeRasterOverlayTileProvider`, `RasterOverlayLoadFailure`, `RasterOverlayDetails`, and all of the `RasterOverlay`-derived types to a new `CesiumRasterOverlays` library and namespace.
- Moved `createRasterOverlayTextureCoordinates` method from `GltfUtilities` to a new `RasterOverlayUtilities` class in the `CesiumRasterOverlays` library.
- `GltfUtilities::parseGltfCopyright` now returns the credits as a vector of string_views. Previously it took a `CreditSystem` and created credits directly.
- The `SubtreeAvailability` constructor and `loadSubtree` static method now take an `ImplicitTileSubdivisionScheme` enumeration parameter instead of a `powerOf2` parameter. They also now require a `levelsInSubtree` parameter, which is needed when switching from constant to bitstream availability. Lastly, the constructor now takes a `Subtree` parameter instead of a `std::vector<std::vector<std::byte>>` representing the buffers.
- `SubtreeConstantAvailability`, `SubtreeBufferViewAvailability`, and `AvailabilityView` are now members of `SubtreeAvailability`.
- Moved `RasterOverlay`, `RasterOverlayTileProvider`, `RasterOverlayTile`, `QuadtreeRasterOverlayTileProvider`, `RasterOverlayLoadFailure`, and all of the `RasterOverlay`-derived types to a new `CesiumRasterOverlays` library and namespace.
- Moved `ImageManipulation` from `CesiumGltfReader` to `CesiumGltfContent`.
- Added some new parameters to `RasterOverlayUtilities::createRasterOverlayTextureCoordinates` and changed the order of some existing parameters.

##### Additions :tada:

- Added `Cesium3DTilesContent` library and namespace. It has classes for loading, converting, and manipulating 3D Tiles tile content.
- Added new `Cesium3DTilesContent` library and namespace. It has classes for loading, converting, and manipulating 3D Tiles tile content.
- Added new `CesiumGltfContent` library and namespace. It has classes for manipulating in-memory glTF files.
- Added new `CesiumRasterOverlays` library and namespace. It has classes for working with massive textures draped over glTFs and 3D Tiles.
- Added `MetadataConversions`, which enables metadata values to be converted to different types for better usability in runtime engines.
- Added various `typedef`s to catch all possible types of `AccessorView`s for an attribute, including `FeatureIdAccessorType` for feature ID attribute accessors, `IndexAccessorType` for index accessors, and `TexCoordAccessorType` for texture coordinate attribute accessors.
- Added `getFeatureIdAccessorView`, `getIndexAccessorView`, and `getTexCoordAccessorView` to retrieve the `AccessorView` as a `FeatureIdAccessorType`, `IndexAccessorType`, or `TexCoordAccessorType` respectively.
Expand All @@ -34,6 +38,10 @@
- Added `pointInTriangle2D` static method to `CesiumGeometry::IntersectionTests`.
- Added `rectangleIsWithinPolygons` and `rectangleIsOutsidePolygons` static methods to `CartographicPolygon`.
- Raster overlays now use `IPrepareRasterOverlayRendererResources`, which contains only overlay-related methods, instead of `IPrepareRendererResources`, which contains tileset-related methods as well. `IPrepareRendererResources` derives from `IPrepareRasterOverlayRendererResources` so existing code should continue to work without modification.
- Added `collapseToSingleBuffer` and `moveBufferContent` methods to `GltfUtilities`.
- Added `savePng` method to `ImageManipulation`.
- `RasterOverlayTileProvider::loadTile` now returns a future that resolves when the tile is done loading.
- Added `computeDesiredScreenPixels` and `computeTranslationAndScale` methods to `RasterOverlayUtilities`.
- Added `Future<T>::thenPassThrough`, used to easily pass additional values through to the next continuation.

##### Fixes :wrench:
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ add_subdirectory(CesiumGeometry)
add_subdirectory(CesiumGeospatial)
add_subdirectory(CesiumJsonReader)
add_subdirectory(CesiumJsonWriter)
add_subdirectory(CesiumGltfContent)
add_subdirectory(CesiumGltfReader)
add_subdirectory(CesiumGltfWriter)
add_subdirectory(CesiumAsync)
Expand Down
1 change: 1 addition & 0 deletions Cesium3DTilesContent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ target_link_libraries(Cesium3DTilesContent
CesiumGeometry
CesiumGeospatial
CesiumGltf
CesiumGltfContent
CesiumGltfReader
CesiumUtility
)
Expand Down
3 changes: 2 additions & 1 deletion Cesium3DTilesContent/src/QuantizedMeshLoader.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <Cesium3DTilesContent/QuantizedMeshLoader.h>
#include <Cesium3DTilesContent/SkirtMeshMetadata.h>
#include <CesiumAsync/IAssetResponse.h>
#include <CesiumGeometry/QuadtreeTileRectangularRange.h>
#include <CesiumGeospatial/GlobeRectangle.h>
#include <CesiumGeospatial/calcQuadtreeMaxGeometricError.h>
#include <CesiumGltfContent/SkirtMeshMetadata.h>
#include <CesiumUtility/AttributeCompression.h>
#include <CesiumUtility/JsonHelpers.h>
#include <CesiumUtility/Math.h>
Expand All @@ -22,6 +22,7 @@ using namespace Cesium3DTilesContent;
using namespace CesiumUtility;
using namespace CesiumGeospatial;
using namespace CesiumGeometry;
using namespace CesiumGltfContent;

struct QuantizedMeshHeader {
// The center of the tile in Earth-centered Fixed coordinates.
Expand Down
3 changes: 2 additions & 1 deletion Cesium3DTilesContent/src/upsampleGltfForRasterOverlays.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <Cesium3DTilesContent/SkirtMeshMetadata.h>
#include <Cesium3DTilesContent/upsampleGltfForRasterOverlays.h>
#include <CesiumGeometry/clipTriangleAtAxisAlignedThreshold.h>
#include <CesiumGeospatial/Cartographic.h>
#include <CesiumGeospatial/Ellipsoid.h>
#include <CesiumGltf/AccessorView.h>
#include <CesiumGltf/ExtensionModelExtStructuralMetadata.h>
#include <CesiumGltfContent/SkirtMeshMetadata.h>
#include <CesiumUtility/Math.h>
#include <CesiumUtility/Tracing.h>

Expand All @@ -14,6 +14,7 @@
#include <vector>

using namespace CesiumGltf;
using namespace CesiumGltfContent;

namespace Cesium3DTilesContent {
struct EdgeVertex {
Expand Down
4 changes: 2 additions & 2 deletions Cesium3DTilesContent/test/TestSkirtMeshMetadata.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <Cesium3DTilesContent/SkirtMeshMetadata.h>
#include <CesiumGltfContent/SkirtMeshMetadata.h>
#include <CesiumUtility/Math.h>

#include <catch2/catch.hpp>

using namespace Cesium3DTilesContent;
using namespace CesiumGltfContent;
using namespace CesiumUtility;

TEST_CASE("Test converting skirt mesh metadata to gltf extras") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <Cesium3DTilesContent/SkirtMeshMetadata.h>
#include <Cesium3DTilesContent/upsampleGltfForRasterOverlays.h>
#include <CesiumGeospatial/Cartographic.h>
#include <CesiumGeospatial/Ellipsoid.h>
#include <CesiumGltf/AccessorView.h>
#include <CesiumGltfContent/SkirtMeshMetadata.h>
#include <CesiumUtility/Math.h>

#include <catch2/catch.hpp>
Expand All @@ -15,6 +15,7 @@ using namespace Cesium3DTilesContent;
using namespace CesiumUtility;
using namespace CesiumGeospatial;
using namespace CesiumGltf;
using namespace CesiumGltfContent;

static void checkSkirt(
const Ellipsoid& ellipsoid,
Expand Down
14 changes: 12 additions & 2 deletions Cesium3DTilesSelection/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,23 @@ target_link_libraries(Cesium3DTilesSelection
CesiumUtility
spdlog
# PRIVATE
tinyxml2
uriparser
libmorton
expected-lite
${CESIUM_NATIVE_DRACO_LIBRARY}
)

target_link_libraries_system(
Cesium3DTilesSelection
PUBLIC
expected-lite
)

target_link_libraries_system(
Cesium3DTilesSelection
PRIVATE
tinyxml2
)

install(TARGETS Cesium3DTilesSelection
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Cesium3DTilesSelection
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once

#include "Library.h"
#include "RasterOverlayDetails.h"
#include "TilesetMetadata.h"

#include <CesiumGeospatial/Projection.h>
#include <CesiumGltf/Model.h>
#include <CesiumRasterOverlays/RasterOverlayDetails.h>
#include <CesiumUtility/CreditSystem.h>

#include <memory>
Expand Down Expand Up @@ -102,29 +102,32 @@ class CESIUM3DTILESSELECTION_API TileRenderContent {
*
* @return The {@link RasterOverlayDetails} that is owned by this content
*/
const RasterOverlayDetails& getRasterOverlayDetails() const noexcept;
const CesiumRasterOverlays::RasterOverlayDetails&
getRasterOverlayDetails() const noexcept;

/**
* @brief Get the {@link RasterOverlayDetails} which is the result of generating raster overlay UVs for the glTF model
*
* @return The {@link RasterOverlayDetails} that is owned by this content
*/
RasterOverlayDetails& getRasterOverlayDetails() noexcept;
CesiumRasterOverlays::RasterOverlayDetails&
getRasterOverlayDetails() noexcept;

/**
* @brief Set the {@link RasterOverlayDetails} which is the result of generating raster overlay UVs for the glTF model
*
* @param rasterOverlayDetails The {@link RasterOverlayDetails} that will be owned by this content
*/
void
setRasterOverlayDetails(const RasterOverlayDetails& rasterOverlayDetails);
void setRasterOverlayDetails(
const CesiumRasterOverlays::RasterOverlayDetails& rasterOverlayDetails);

/**
* @brief Set the {@link RasterOverlayDetails} which is the result of generating raster overlay UVs for the glTF model
*
* @param rasterOverlayDetails The {@link RasterOverlayDetails} that will be owned by this content
*/
void setRasterOverlayDetails(RasterOverlayDetails&& rasterOverlayDetails);
void setRasterOverlayDetails(
CesiumRasterOverlays::RasterOverlayDetails&& rasterOverlayDetails);

/**
* @brief Get the list of {@link Credit} of the content
Expand Down Expand Up @@ -192,7 +195,7 @@ class CESIUM3DTILESSELECTION_API TileRenderContent {
private:
CesiumGltf::Model _model;
void* _pRenderResources;
RasterOverlayDetails _rasterOverlayDetails;
CesiumRasterOverlays::RasterOverlayDetails _rasterOverlayDetails;
std::vector<CesiumUtility::Credit> _credits;
float _lodTransitionFadePercentage;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once

#include "BoundingVolume.h"
#include "RasterOverlayDetails.h"
#include "TileContent.h"

#include <CesiumAsync/IAssetRequest.h>
#include <CesiumGeometry/Axis.h>
#include <CesiumGltf/Model.h>
#include <CesiumRasterOverlays/RasterOverlayDetails.h>

#include <functional>
#include <memory>
Expand Down Expand Up @@ -98,7 +98,8 @@ struct CESIUM3DTILESSELECTION_API TileLoadResult {
* @brief Holds details of the {@link TileRenderContent} that are useful
* for raster overlays.
*/
std::optional<RasterOverlayDetails> rasterOverlayDetails;
std::optional<CesiumRasterOverlays::RasterOverlayDetails>
rasterOverlayDetails;

/**
* @brief The request that is created to download the tile content.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "BoundingVolume.h"
#include "Library.h"
#include "RasterOverlayDetails.h"
#include "TileContent.h"
#include "TileLoadResult.h"
#include "TilesetOptions.h"
Expand All @@ -12,6 +11,7 @@
#include <CesiumAsync/IAssetAccessor.h>
#include <CesiumGeometry/Axis.h>
#include <CesiumGltf/Model.h>
#include <CesiumRasterOverlays/RasterOverlayDetails.h>

#include <spdlog/logger.h>

Expand Down
11 changes: 7 additions & 4 deletions Cesium3DTilesSelection/src/LayerJsonTerrainLoader.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "LayerJsonTerrainLoader.h"

#include <Cesium3DTilesContent/GltfUtilities.h>
#include <Cesium3DTilesContent/QuantizedMeshLoader.h>
#include <Cesium3DTilesContent/upsampleGltfForRasterOverlays.h>
#include <Cesium3DTilesSelection/RasterOverlayUtilities.h>
#include <CesiumAsync/IAssetResponse.h>
#include <CesiumGeospatial/calcQuadtreeMaxGeometricError.h>
#include <CesiumGltfContent/GltfUtilities.h>
#include <CesiumRasterOverlays/RasterOverlayUtilities.h>
#include <CesiumUtility/JsonHelpers.h>
#include <CesiumUtility/Uri.h>

Expand All @@ -17,6 +17,7 @@ using namespace Cesium3DTilesContent;
using namespace Cesium3DTilesSelection;
using namespace CesiumGeometry;
using namespace CesiumGeospatial;
using namespace CesiumRasterOverlays;
using namespace CesiumUtility;

namespace {
Expand Down Expand Up @@ -214,11 +215,13 @@ void generateRasterOverlayUVs(
RasterOverlayUtilities::createRasterOverlayTextureCoordinates(
*pModel,
tileTransform,
0,
pParentRegion ? std::make_optional<GlobeRectangle>(
pParentRegion->getRectangle())
: std::nullopt,
{projection});
{projection},
false,
"_CESIUMOVERLAY_",
0);
}
}

Expand Down
Loading

0 comments on commit 381528a

Please sign in to comment.