Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into height-query
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Sep 10, 2024
2 parents ef273ac + 7ecb171 commit 06c47d8
Show file tree
Hide file tree
Showing 17 changed files with 155 additions and 113 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Change Log

### ? - ?
### v0.39.0 - 2024-09-02

##### Breaking Changes :mega:

Expand All @@ -19,6 +19,7 @@

- Fixed a bug in `WebMapTileServiceRasterOverlay` that caused it to compute the `TileRow` incorrectly when used with a tiling scheme with multiple tiles in the Y direction at the root.
- `KHR_texture_transform` is now removed from `extensionsUsed` and `extensionsRequired` after it is applied by `GltfReader`.
- Fixed a bug in the i3dm loader that caused glTF with multiple nodes to not be instanced correctly.

### v0.38.0 - 2024-08-01

Expand Down
59 changes: 38 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ if (NOT VCPKG_LIBRARY_LINKAGE)
set(VCPKG_LIBRARY_LINKAGE static)
endif()

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ezvcpkg/ezvcpkg.cmake)
if(NOT VCPKG_MANIFEST_MODE)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ezvcpkg/ezvcpkg.cmake)
endif()

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/detect-vcpkg-triplet.cmake)

if (NOT VCPKG_TRIPLET)
Expand Down Expand Up @@ -39,20 +42,22 @@ set(PACKAGES_PRIVATE
# Packages only used for testing
set(PACKAGES_TEST catch2)

set(PACKAGES_ALL ${PACKAGES_PUBLIC})
list(APPEND PACKAGES_ALL ${PACKAGES_PRIVATE})
list(APPEND PACKAGES_ALL ${PACKAGES_TEST})

ezvcpkg_fetch(
COMMIT 2024.07.12
PACKAGES ${PACKAGES_ALL}
# Clean the build trees after building, so that we don't use a ton a disk space on the CI cache
CLEAN_BUILDTREES
# Update the cmake toolchain so it can find the above packages
UPDATE_TOOLCHAIN
# Force the installation of each package one at a time, or the Travis CI build will time out waiting for output
SERIALIZE
)
if(NOT VCPKG_MANIFEST_MODE)
set(PACKAGES_ALL ${PACKAGES_PUBLIC})
list(APPEND PACKAGES_ALL ${PACKAGES_PRIVATE})
list(APPEND PACKAGES_ALL ${PACKAGES_TEST})

ezvcpkg_fetch(
COMMIT 2024.07.12
PACKAGES ${PACKAGES_ALL}
# Clean the build trees after building, so that we don't use a ton a disk space on the CI cache
CLEAN_BUILDTREES
# Update the cmake toolchain so it can find the above packages
UPDATE_TOOLCHAIN
# Force the installation of each package one at a time, or the Travis CI build will time out waiting for output
SERIALIZE
)
endif()

if (NOT CMAKE_TOOLCHAIN_FILE)
message(FATAL_ERROR "Specify the VCPKG toolchain on the command line as '-DCMAKE_TOOLCHAIN_FILE=<VCPKG_ROOT>/scripts/buildsystems/vcpkg.cmake'")
Expand All @@ -70,15 +75,25 @@ project(cesium-native

include(GNUInstallDirs)

message(STATUS "EZVCPKG_PACKAGES_DIR ${EZVCPKG_PACKAGES_DIR}")
set(PACKAGE_BASE_DIR "${EZVCPKG_PACKAGES_DIR}")
set(PACKAGE_BUILD_DIR "${EZVCPKG_DIR}")

if(VCPKG_MANIFEST_MODE)
set(PACKAGE_BUILD_DIR "${VCPKG_INSTALLED_DIR}/${VCPKG_TRIPLET}/")
set(PACKAGE_BASE_DIR "$ENV{VCPKG_ROOT}/packages")
endif()

message(STATUS "PACKAGE_BASE_DIR ${PACKAGE_BASE_DIR}")
message(STATUS "PACKAGE_BUILD_DIR ${PACKAGE_BUILD_DIR}")


option(CESIUM_INSTALL_STATIC_LIBS "Whether to install the static libraries of cesium-native and its dependencies." ON)
option(CESIUM_INSTALL_HEADERS "Whether to install the header files of cesium-native and its public dependencies." ON)

if(CESIUM_INSTALL_STATIC_LIBS OR CESIUM_INSTALL_HEADERS)
foreach(PACKAGE ${PACKAGES_PUBLIC})
string(REGEX REPLACE "\[.*\]" "" PACKAGE ${PACKAGE})
set(PACKAGE_DIR ${EZVCPKG_PACKAGES_DIR}/${PACKAGE}_${VCPKG_TRIPLET})
set(PACKAGE_DIR ${PACKAGE_BASE_DIR}/${PACKAGE}_${VCPKG_TRIPLET})
message(DEBUG "PACKAGE_DIR ${PACKAGE_DIR}")

if(CESIUM_INSTALL_HEADERS AND NOT PACKAGE IN_LIST CESIUM_EXCLUDE_INSTALL_HEADERS)
Expand All @@ -99,7 +114,7 @@ endif()

if(CESIUM_INSTALL_STATIC_LIBS)
foreach(PACKAGE ${PACKAGES_PRIVATE})
set(PACKAGE_DIR ${EZVCPKG_PACKAGES_DIR}/${PACKAGE}_${VCPKG_TRIPLET})
set(PACKAGE_DIR ${PACKAGE_BASE_DIR}/${PACKAGE}_${VCPKG_TRIPLET})
message(DEBUG "PACKAGE_DIR ${PACKAGE_DIR}")
if (NOT PACKAGE IN_LIST CESIUM_EXCLUDE_INSTALL_STATIC_LIBS AND EXISTS ${PACKAGE_DIR}/lib)
install(
Expand Down Expand Up @@ -173,9 +188,11 @@ endif()

# On the CI builds, I have to do this explicitly for some reason or it fails to find the vcpkg packages.
# The toolchain is supposed to manage this, but I haven't figured out why it isn't yet.
list(APPEND CMAKE_PREFIX_PATH "${EZVCPKG_DIR}/share/s2")
list(APPEND CMAKE_PREFIX_PATH "${EZVCPKG_DIR}/share")
list(APPEND CMAKE_PREFIX_PATH "${EZVCPKG_DIR}")

list(APPEND CMAKE_PREFIX_PATH "${PACKAGE_BUILD_DIR}/share/s2")
list(APPEND CMAKE_PREFIX_PATH "${PACKAGE_BUILD_DIR}/share")
list(APPEND CMAKE_PREFIX_PATH "${PACKAGE_BUILD_DIR}")

# Find the VCPKG dependnecies
# Note that while we could push these into the extern/CMakeLists.txt as an organization tidy-up, that would require
# us to update the minimum version of CMake to 3.24 and to add the GLOBAL option to the find_package calls, otherwise
Expand Down
22 changes: 13 additions & 9 deletions Cesium3DTilesContent/src/I3dmToGltfConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,27 +650,31 @@ void copyInstanceToBuffer(
const glm::dvec3& position,
const glm::dquat& rotation,
const glm::dvec3& scale,
std::byte* bufferLoc) {
std::byte* pBufferLoc) {
glm::vec3 fposition(position);
std::memcpy(bufferLoc, &fposition, sizeof(fposition));
std::memcpy(pBufferLoc, &fposition, sizeof(fposition));
glm::quat frotation(rotation);
std::memcpy(bufferLoc + rotOffset, &frotation, sizeof(frotation));
std::memcpy(pBufferLoc + rotOffset, &frotation, sizeof(frotation));
glm::vec3 fscale(scale);
std::memcpy(bufferLoc + scaleOffset, &fscale, sizeof(fscale));
std::memcpy(pBufferLoc + scaleOffset, &fscale, sizeof(fscale));
}

void copyInstanceToBuffer(
const glm::dvec3& position,
const glm::dquat& rotation,
const glm::dvec3& scale,
std::vector<std::byte>& bufferData,
std::byte* pBufferData,
size_t i) {
copyInstanceToBuffer(position, rotation, scale, &bufferData[i * totalStride]);
copyInstanceToBuffer(
position,
rotation,
scale,
pBufferData + (i * totalStride));
}

bool copyInstanceToBuffer(
const glm::dmat4& instanceTransform,
std::vector<std::byte>& bufferData,
std::byte* pBufferData,
size_t i) {
bool result = true;
glm::dvec3 position, scale, skew;
Expand All @@ -688,7 +692,7 @@ bool copyInstanceToBuffer(
scale = glm::dvec3(1.0);
result = false;
}
copyInstanceToBuffer(position, rotation, scale, bufferData, i);
copyInstanceToBuffer(position, rotation, scale, pBufferData, i);
return result;
}

Expand Down Expand Up @@ -764,7 +768,7 @@ void instantiateGltfInstances(
instanceTransform * modelInstanceTransform;
if (!copyInstanceToBuffer(
finalTransform,
instanceBuffer.cesium.data,
&instanceBuffer.cesium.data[dataBaseOffset],
destInstanceIndx++)) {
result.errors.emplaceWarning(
"Matrix decompose failed. Default identity values copied to "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,6 @@ class Cartographic;
*/
class CESIUMGEOSPATIAL_API EarthGravitationalModel1996Grid final {
public:
/**
* @brief Attempts to create a {@link EarthGravitationalModel1996Grid} from the given file.
*
* This method expects a file in the format of the WW15MGH.DAC 15-arcminute
* grid. The file must be at least 721 * 1440 * 2 = 2,076,480 bytes.
* Any additional bytes at the end of the file are ignored.
*
* @returns The instance created from the file, or `std::nullopt` if the file
* could not be loaded or is invalid.
*/
static std::optional<EarthGravitationalModel1996Grid>
fromFile(const std::string& filename);

/**
* @brief Attempts to create a {@link EarthGravitationalModel1996Grid} from the given buffer.
*
Expand Down
1 change: 1 addition & 0 deletions CesiumGeospatial/include/CesiumGeospatial/S2CellID.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <array>
#include <cstdint>
#include <string>
#include <string_view>

namespace CesiumGeometry {
Expand Down
18 changes: 0 additions & 18 deletions CesiumGeospatial/src/EarthGravitationalModel1996Grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,6 @@ constexpr size_t TOTAL_BYTES = TOTAL_VALUES * sizeof(int16_t);

} // namespace

std::optional<EarthGravitationalModel1996Grid>
CesiumGeospatial::EarthGravitationalModel1996Grid::fromFile(
const std::string& filename) {
std::ifstream file(
std::filesystem::u8path(filename),
std::ios::binary | std::ios::ate);
if (!file.good()) {
return std::nullopt;
}

size_t size = std::min(size_t(file.tellg()), size_t(TOTAL_BYTES));
file.seekg(0, std::ios::beg);

std::vector<std::byte> buffer(size);
file.read(reinterpret_cast<char*>(buffer.data()), std::streamsize(size));
return fromBuffer(buffer);
}

std::optional<EarthGravitationalModel1996Grid>
CesiumGeospatial::EarthGravitationalModel1996Grid::fromBuffer(
const gsl::span<const std::byte>& buffer) {
Expand Down
32 changes: 1 addition & 31 deletions CesiumGeospatial/test/TestEarthGravitationalModel1996Grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,36 +193,6 @@ const Egm96TestCase boundsCases[] = {

const std::byte zeroByte{0};

TEST_CASE("EarthGravitationalModel1996Grid::fromFile") {
SECTION("Loads a valid WW15MGH.DAC from file") {
auto grid =
EarthGravitationalModel1996Grid::fromFile(testFilePath.u8string());
CHECK(grid.has_value());
}

SECTION("Fails on missing file") {
auto grid = EarthGravitationalModel1996Grid::fromFile("_does_not_exist");
CHECK(!grid.has_value());
}

SECTION("Fails on too-short file") {
OwnedTempFile file(std::vector<std::byte>(4, zeroByte));
auto grid =
EarthGravitationalModel1996Grid::fromFile(file.getPath().u8string());
CHECK(!grid.has_value());
}

// While EGM96 is meant to only parse the one WW15MGH.DAC file, there's no
// reason it shouldn't be able to parse any file that meets the same
// requirements.
SECTION("Loads an arbitrary correctly-formed file") {
OwnedTempFile file(std::vector<std::byte>(3000000, zeroByte));
auto grid =
EarthGravitationalModel1996Grid::fromFile(file.getPath().u8string());
CHECK(grid.has_value());
}
}

TEST_CASE("EarthGravitationalModel1996Grid::fromBuffer") {
SECTION("Loads a valid WW15MGH.DAC from buffer") {
auto grid =
Expand All @@ -245,7 +215,7 @@ TEST_CASE("EarthGravitationalModel1996Grid::fromBuffer") {

TEST_CASE("EarthGravitationalModel1996Grid::sampleHeight") {
std::optional<EarthGravitationalModel1996Grid> grid =
EarthGravitationalModel1996Grid::fromFile(testFilePath.u8string());
EarthGravitationalModel1996Grid::fromBuffer(readFile(testFilePath));

SECTION("Correct values at bounds") {
REQUIRE(grid.has_value());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <glm/fwd.hpp>

#include <optional>
#include <string>
#include <string_view>
#include <vector>

Expand Down
5 changes: 3 additions & 2 deletions CesiumGltfContent/src/GltfUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <glm/gtc/quaternion.hpp>

#include <algorithm>
#include <cstring>
#include <unordered_set>
#include <vector>
Expand Down Expand Up @@ -1059,8 +1060,8 @@ void GltfUtilities::removeUnusedMaterials(
}

void GltfUtilities::compactBuffers(CesiumGltf::Model& gltf) {
for (size_t i = 0;
i < gltf.buffers.size() && i < std::numeric_limits<int32_t>::max();
for (size_t i = 0; i < gltf.buffers.size() &&
i < size_t(std::numeric_limits<int32_t>::max());
++i) {
GltfUtilities::compactBuffer(gltf, int32_t(i));
}
Expand Down
2 changes: 1 addition & 1 deletion CesiumGltfContent/src/ImageManipulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Cesium {
#define STBIRDEF
#include <stb_image_resize.h>
#undef STBIRDEF
}; // namespace Cesium
} // namespace Cesium

using namespace Cesium;

Expand Down
2 changes: 1 addition & 1 deletion CesiumGltfReader/src/GltfReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace Cesium {
#define STB_IMAGE_RESIZE_IMPLEMENTATION
#include <stb_image_resize.h>
#undef STBIRDEF
}; // namespace Cesium
} // namespace Cesium

#define STB_IMAGE_STATIC
#define STB_IMAGE_IMPLEMENTATION
Expand Down
1 change: 1 addition & 0 deletions CesiumJsonReader/include/CesiumJsonReader/IJsonHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Library.h"

#include <cstdint>
#include <string>
#include <string_view>
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions CesiumJsonWriter/include/CesiumJsonWriter/JsonWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <cstdint>
#include <functional>
#include <memory>
#include <string>
#include <string_view>
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions CesiumUtility/src/Uri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <uriparser/Uri.h>

#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <filesystem>
Expand Down
Loading

0 comments on commit 06c47d8

Please sign in to comment.