Skip to content

Commit

Permalink
Updated osgEarthCesium to build against latest cesium-native
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbeverage committed Dec 18, 2023
1 parent 182b7e0 commit 0c6b6a4
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 21 deletions.
10 changes: 10 additions & 0 deletions CMakeModules/FindCesiumNative.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,25 @@ FIND_CESIUM_LIBRARY(CESIUM_NATIVE_GEOSPATIAL_LIBRARY CesiumGeospatial)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_UTILITY_LIBRARY CesiumUtility)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_ION_CLIENT_LIBRARY CesiumIonClient)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_GLTF_READER_LIBRARY CesiumGltfReader)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_3DTILES_READER_LIBRARY Cesium3DTilesReader)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_GEOMETRY_LIBRARY CesiumGeometry)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_GLTF_LIBRARY CesiumGltf)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_KTX_READ_LIBRARY ktx_read)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_DRACO_LIBRARY draco)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_SPDLOG_LIBRARY spdlog)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_ASYNC++_LIBRARY async++)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_WEBPDECODER_LIBRARY webpdecoder)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_MESHOPTIMIZER_LIBRARY meshoptimizer)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_URIPARSER_LIBRARY uriparser)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_TURBOJPEG_LIBRARY turbojpeg)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_CSPRNG_LIBRARY csprng)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_MODPB64_LIBRARY modp_b64)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_JSONREADER_LIBRARY CesiumJsonReader)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_ASYNC_LIBRARY CesiumAsync)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_S2GEOMETRY_LIBRARY s2geometry)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_RASTER_OVERLAYS_LIBRARY CesiumRasterOverlays)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_3DTILES_CONTENT_LIBRARY Cesium3DTilesContent)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_GLTF_CONTENT_LIBRARY CesiumGltfContent)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_TINYXML2_LIBRARY tinyxml2)


Expand All @@ -52,13 +57,15 @@ IF(CESIUM_NATIVE_3DTILES_LIBRARY AND
CESIUM_NATIVE_UTILITY_LIBRARY AND
CESIUM_NATIVE_ION_CLIENT_LIBRARY AND
CESIUM_NATIVE_GLTF_READER_LIBRARY AND
CESIUM_NATIVE_3DTILES_READER_LIBRARY AND
CESIUM_NATIVE_GEOMETRY_LIBRARY AND
CESIUM_NATIVE_GLTF_LIBRARY AND
CESIUM_NATIVE_KTX_READ_LIBRARY AND
CESIUM_NATIVE_DRACO_LIBRARY AND
CESIUM_NATIVE_SPDLOG_LIBRARY AND
CESIUM_NATIVE_ASYNC++_LIBRARY AND
CESIUM_NATIVE_WEBPDECODER_LIBRARY AND
CESIUM_NATIVE_MESHOPTIMIZER_LIBRARY AND
CESIUM_NATIVE_URIPARSER_LIBRARY AND
CESIUM_NATIVE_TURBOJPEG_LIBRARY AND
CESIUM_NATIVE_CSPRNG_LIBRARY AND
Expand All @@ -67,6 +74,9 @@ IF(CESIUM_NATIVE_3DTILES_LIBRARY AND
CESIUM_NATIVE_ASYNC_LIBRARY AND
CESIUM_NATIVE_S2GEOMETRY_LIBRARY AND
CESIUM_NATIVE_TINYXML2_LIBRARY AND
CESIUM_NATIVE_RASTER_OVERLAYS_LIBRARY AND
CESIUM_NATIVE_3DTILES_CONTENT_LIBRARY AND
CESIUM_NATIVE_GLTF_CONTENT_LIBRARY AND
CESIUM_NATIVE_INCLUDE_DIR)
SET(CESIUM_NATIVE_FOUND "YES")
ENDIF()
5 changes: 5 additions & 0 deletions src/osgEarthCesium/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,14 @@ LINK_WITH_VARIABLES(${LIB_NAME}
CESIUM_NATIVE_3DTILES_SELECTION_LIBRARY
CESIUM_NATIVE_UTILITY_LIBRARY
CESIUM_NATIVE_GLTF_READER_LIBRARY
CESIUM_NATIVE_3DTILES_READER_LIBRARY
CESIUM_NATIVE_ION_CLIENT_LIBRARY
CESIUM_NATIVE_GEOSPATIAL_LIBRARY
CESIUM_NATIVE_GEOMETRY_LIBRARY
CESIUM_NATIVE_GLTF_LIBRARY
CESIUM_NATIVE_KTX_READ_LIBRARY
CESIUM_NATIVE_DRACO_LIBRARY
CESIUM_NATIVE_MESHOPTIMIZER_LIBRARY
CESIUM_NATIVE_SPDLOG_LIBRARY
CESIUM_NATIVE_ASYNC++_LIBRARY
CESIUM_NATIVE_WEBPDECODER_LIBRARY
Expand All @@ -101,6 +103,9 @@ LINK_WITH_VARIABLES(${LIB_NAME}
CESIUM_NATIVE_ASYNC_LIBRARY
CESIUM_NATIVE_S2GEOMETRY_LIBRARY
CESIUM_NATIVE_TINYXML2_LIBRARY
CESIUM_NATIVE_3DTILES_CONTENT_LIBRARY
CESIUM_NATIVE_GLTF_CONTENT_LIBRARY
CESIUM_NATIVE_RASTER_OVERLAYS_LIBRARY
)
LINK_CORELIB_DEFAULT(${LIB_NAME} ${CMAKE_THREAD_LIBS_INIT} ${MATH_LIBRARY})

Expand Down
8 changes: 4 additions & 4 deletions src/osgEarthCesium/CesiumTilesetNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ CesiumTilesetNode::CesiumTilesetNode(unsigned int assetID, const std::string& to

for (auto& overlay = overlays.begin(); overlay != overlays.end(); ++overlay)
{
Cesium3DTilesSelection::RasterOverlayOptions rasterOptions;
const auto ionRasterOverlay = new Cesium3DTilesSelection::IonRasterOverlay("", *overlay, token, rasterOptions);
CesiumRasterOverlays::RasterOverlayOptions rasterOptions;
const auto ionRasterOverlay = new CesiumRasterOverlays::IonRasterOverlay("", *overlay, token, rasterOptions);
tileset->getOverlays().add(ionRasterOverlay);
}
_tileset = tileset;
Expand All @@ -63,8 +63,8 @@ CesiumTilesetNode::CesiumTilesetNode(const std::string& url, const std::string&
Cesium3DTilesSelection::Tileset* tileset = new Cesium3DTilesSelection::Tileset(externals, url, options);
for (auto& overlay = overlays.begin(); overlay != overlays.end(); ++overlay)
{
Cesium3DTilesSelection::RasterOverlayOptions rasterOptions;
const auto ionRasterOverlay = new Cesium3DTilesSelection::IonRasterOverlay("", *overlay, token, rasterOptions);
CesiumRasterOverlays::RasterOverlayOptions rasterOptions;
const auto ionRasterOverlay = new CesiumRasterOverlays::IonRasterOverlay("", *overlay, token, rasterOptions);
tileset->getOverlays().add(ionRasterOverlay);
}
_tileset = tileset;
Expand Down
8 changes: 4 additions & 4 deletions src/osgEarthCesium/Context
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
#include "TaskProcessor"

#include <gsl/gsl>
#include <Cesium3DTilesSelection/GltfUtilities.h>
#include <Cesium3DTilesSelection/registerAllTileContentTypes.h>
#include <CesiumGltfContent/GltfUtilities.h>
#include <Cesium3DTilesContent/registerAllTileContentTypes.h>
#include <CesiumGltf/AccessorView.h>
#include <Cesium3DTilesSelection/Tileset.h>
#include <Cesium3DTilesSelection/IonRasterOverlay.h>
#include <CesiumRasterOverlays/IonRasterOverlay.h>
#include <CesiumAsync/AsyncSystem.h>

#include <glm/gtc/type_ptr.hpp>
Expand Down Expand Up @@ -62,7 +62,7 @@ namespace osgEarth {
std::shared_ptr<AssetAccessor> assetAccessor;
std::shared_ptr<TaskProcessor> taskProcessor;
std::shared_ptr< spdlog::logger > logger;
std::shared_ptr< Cesium3DTilesSelection::CreditSystem > creditSystem;
std::shared_ptr< CesiumUtility::CreditSystem > creditSystem;
CesiumAsync::AsyncSystem asyncSystem;
std::unique_ptr<Context> context;
};
Expand Down
4 changes: 2 additions & 2 deletions src/osgEarthCesium/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ Context::Context():
taskProcessor(std::make_shared<TaskProcessor>()),
asyncSystem(taskProcessor)
{
Cesium3DTilesSelection::registerAllTileContentTypes();
Cesium3DTilesContent::registerAllTileContentTypes();
assetAccessor = std::make_shared<AssetAccessor>();
prepareRenderResources = std::make_shared< PrepareRendererResources >();
logger = spdlog::default_logger();
creditSystem = std::make_shared<Cesium3DTilesSelection::CreditSystem>();
creditSystem = std::make_shared<CesiumUtility::CreditSystem>();
}

Context::~Context()
Expand Down
8 changes: 4 additions & 4 deletions src/osgEarthCesium/PrepareRenderResources
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,26 @@ namespace osgEarth {
const std::any& rendererOptions);

virtual void* prepareRasterInMainThread(
Cesium3DTilesSelection::RasterOverlayTile& rasterTile,
CesiumRasterOverlays::RasterOverlayTile& rasterTile,
void* pLoadThreadResult);

virtual void freeRaster(
const Cesium3DTilesSelection::RasterOverlayTile& rasterTile,
const CesiumRasterOverlays::RasterOverlayTile& rasterTile,
void* pLoadThreadResult,
void* pMainThreadResult) noexcept;

virtual void attachRasterInMainThread(
const Cesium3DTilesSelection::Tile& tile,
int32_t overlayTextureCoordinateID,
const Cesium3DTilesSelection::RasterOverlayTile& rasterTile,
const CesiumRasterOverlays::RasterOverlayTile& rasterTile,
void* pMainThreadRendererResources,
const glm::dvec2& translation,
const glm::dvec2& scale);

virtual void detachRasterInMainThread(
const Cesium3DTilesSelection::Tile& tile,
int32_t overlayTextureCoordinateID,
const Cesium3DTilesSelection::RasterOverlayTile& rasterTile,
const CesiumRasterOverlays::RasterOverlayTile& rasterTile,
void* pMainThreadRendererResources) noexcept;
};
}
Expand Down
14 changes: 7 additions & 7 deletions src/osgEarthCesium/PrepareRenderResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#include "PrepareRenderResources"
#include <Cesium3DTilesSelection/GltfUtilities.h>
#include <CesiumGltfContent/GltfUtilities.h>
#include <CesiumGltf/AccessorView.h>

#include <osg/Texture2D>
Expand Down Expand Up @@ -187,8 +187,8 @@ class NodeBuilder
osg::Matrixd matrix;

glm::dmat4x4 rootTransform = _transform;
rootTransform = Cesium3DTilesSelection::GltfUtilities::applyRtcCenter(*_model, rootTransform);
rootTransform = Cesium3DTilesSelection::GltfUtilities::applyGltfUpAxisTransform(*_model, rootTransform);
rootTransform = CesiumGltfContent::GltfUtilities::applyRtcCenter(*_model, rootTransform);
rootTransform = CesiumGltfContent::GltfUtilities::applyGltfUpAxisTransform(*_model, rootTransform);
matrix.set(glm::value_ptr(rootTransform));

//matrix.set(glm::value_ptr(_transform));
Expand Down Expand Up @@ -636,7 +636,7 @@ void* PrepareRendererResources::prepareRasterInLoadThread(
}

void* PrepareRendererResources::prepareRasterInMainThread(
Cesium3DTilesSelection::RasterOverlayTile& rasterTile,
CesiumRasterOverlays::RasterOverlayTile& rasterTile,
void* pLoadThreadResult)
{
LoadRasterThreadResult* loadThreadResult = reinterpret_cast<LoadRasterThreadResult*>(pLoadThreadResult);
Expand All @@ -654,7 +654,7 @@ void* PrepareRendererResources::prepareRasterInMainThread(
}

void PrepareRendererResources::freeRaster(
const Cesium3DTilesSelection::RasterOverlayTile& rasterTile,
const CesiumRasterOverlays::RasterOverlayTile& rasterTile,
void* pLoadThreadResult,
void* pMainThreadResult) noexcept
{
Expand Down Expand Up @@ -718,7 +718,7 @@ const char* raster_overlay_fs = R"(
void PrepareRendererResources::attachRasterInMainThread(
const Cesium3DTilesSelection::Tile& tile,
int32_t overlayTextureCoordinateID,
const Cesium3DTilesSelection::RasterOverlayTile& rasterTile,
const CesiumRasterOverlays::RasterOverlayTile& rasterTile,
void* pMainThreadRendererResources,
const glm::dvec2& translation,
const glm::dvec2& scale)
Expand Down Expand Up @@ -762,7 +762,7 @@ void PrepareRendererResources::attachRasterInMainThread(
void PrepareRendererResources::detachRasterInMainThread(
const Cesium3DTilesSelection::Tile& tile,
int32_t overlayTextureCoordinateID,
const Cesium3DTilesSelection::RasterOverlayTile& rasterTile,
const CesiumRasterOverlays::RasterOverlayTile& rasterTile,
void* pMainThreadRendererResources) noexcept
{
}

0 comments on commit 0c6b6a4

Please sign in to comment.