diff --git a/.clang-tidy b/.clang-tidy index 1e40bba3b..45c64ccf5 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -17,7 +17,8 @@ Checks: - "bugprone-dynamic-static-initializers" - "-bugprone-easily-swappable-parameters" - "bugprone-empty-catch" - - "bugprone-exception-escape" + # See https://github.com/CesiumGS/cesium-native/issues/348 + #- "bugprone-exception-escape" - "bugprone-fold-init-type" - "bugprone-forward-declaration-namespace" - "bugprone-forwarding-reference-overload" @@ -36,7 +37,8 @@ Checks: - "bugprone-macro-repeated-side-effects" - "bugprone-misplaced-operator-in-strlen-in-alloc" - "bugprone-misplaced-pointer-arithmetic-in-alloc" - - "bugprone-misplaced-widening-cast" + # Produces a lot of results that are just extra-verbose - skipping for now + #- "bugprone-misplaced-widening-cast" - "bugprone-move-forwarding-reference" - "bugprone-multi-level-implicit-pointer-conversion" - "bugprone-multiple-new-in-one-expression" @@ -53,7 +55,6 @@ Checks: - "bugprone-return-const-ref-from-parameter" - "bugprone-shared-ptr-array-mismatch" - "bugprone-signal-handler" - - "bugprone-signed-char-misuse" - "bugprone-sizeof-container" - "bugprone-sizeof-expression" - "bugprone-spuriously-wake-up-functions" @@ -72,13 +73,12 @@ Checks: - "bugprone-suspicious-string-compare" - "bugprone-suspicious-stringview-data-usage" - "bugprone-swapped-arguments" - - "bugprone-switch-missing-default-case" - "bugprone-terminating-continue" - "bugprone-throw-keyword-missing" - "bugprone-too-small-loop-variable" - "bugprone-undefined-memory-manipulation" - "bugprone-undelegated-constructor" - - "bugprone-unhandled-exception-at-new" + #- "bugprone-unhandled-exception-at-new" - "bugprone-unique-ptr-array-mismatch" - "bugprone-unsafe-functions" - "bugprone-unused-local-non-trivial-variable" @@ -86,10 +86,51 @@ Checks: - "bugprone-unused-return-value" - "bugprone-use-after-move" - "bugprone-virtual-near-miss" + - "cppcoreguidelines-avoid-capturing-lambda-coroutines" + - "cppcoreguidelines-avoid-goto" + - "cppcoreguidelines-avoid-reference-coroutine-parameters" + - "cppcoreguidelines-interfaces-global-init" + - "cppcoreguidelines-misleading-capture-default-by-value" + - "cppcoreguidelines-no-suspend-with-lock" + - "cppcoreguidelines-prefer-member-initializer" + - "cppcoreguidelines-pro-type-cstyle-cast" + - "cppcoreguidelines-pro-type-static-cast-downcast" + - "cppcoreguidelines-pro-type-union-access" + - "cppcoreguidelines-slicing" + - "google-runtime-int" + # We should enable this one at some point, but it produces a huge number of changes + # - "misc-const-correctness" + - "misc-misleading-bidrectional" + - "misc-misleading-identifier" + - "misc-misplaced-const" + - "misc-non-copyable-objects" + - "misc-redundant-expression" + - "misc-unused-parameters" + - "misc-unused-using-decls" + - "misc-use-anonymous-namespace" + - "misc-use-internal-linkage" + - "modernize-deprecated-headers" + #- "modernize-loop-convert" + - "modernize-make-shared" + - "modernize-make-unique" + - "modernize-min-max-use-initializer-list" + - "modernize-raw-string-literal" + - "modernize-redundant-void-arg" + - "modernize-replace-auto-ptr" + #- "modernize-type-traits" + #- "modernize-use-constraints" + - "modernize-use-emplace" + - "modernize-use-equals-default" + - "modernize-use-equals-delete" + - "modernize-use-nullptr" + - "modernize-use-starts-ends-with" + - "modernize-use-std-numbers" + #- "modernize-use-using" + - "performance-*" + - "-performance-enum-size" - "-readability-redundant-member-init" -#WarningsAsErrors: "*" -WarningsAsErrors: "" +WarningsAsErrors: "*" FormatStyle: none CheckOptions: - key: readability-implicit-bool-conversion.AllowPointerConditions @@ -99,7 +140,10 @@ CheckOptions: - key: modernize-use-auto.RemoveStars value: "true" - key: misc-include-cleaner.IgnoreHeaders - value: ".*cesium-async\\+\\+\\.h" + value: ".*cesium-async\\+\\+\\.h;.*bits\/.*.h" + - key: performance-move-const-arg.CheckTriviallyCopyableMove + value: "false" HeaderFilterRegex: ".*" HeaderFileExtensions: ["h"] +ExcludeHeaderFilterRegex: ".*\\.ezvcpkg\/.*" ImplementationFileExtensions: ["cpp"] \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 40f795b03..c41c3914b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,14 +17,18 @@ jobs: steps: - name: Check out repository code uses: actions/checkout@v4 - - name: Install ninja - uses: seanmiddleditch/gha-setup-ninja@master - - name: Install nasm - uses: ilammy/setup-nasm@v1 + - name: Install latest ninja and cmake + uses: lukka/get-cmake@latest - name: ccache uses: hendrikmuhs/ccache-action@v1.2.9 with: key: ccache-ubuntu-24.04-clang-clang-tidy + - name: Install latest clang and clang-tidy + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 19 + sudo apt-get install clang-tidy-19 - name: Cache vcpkg artifacts uses: actions/cache@v4 with: @@ -35,8 +39,8 @@ jobs: vcpkg-ubuntu-24.04-clang - name: Set CC and CXX run: | - echo "CC=clang-18" >> "$GITHUB_ENV" - echo "CXX=clang++-18" >> "$GITHUB_ENV" + echo "CC=/usr/bin/clang-19" >> "$GITHUB_ENV" + echo "CXX=/usr/bin/clang++-19" >> "$GITHUB_ENV" - name: Make more swap space available run: | sudo swapoff -a @@ -47,8 +51,18 @@ jobs: sudo swapon --show - name: Run clang-tidy run: | - cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug - cmake --build build --target clang-tidy + echo `$CC --version | head -n 1`, `cmake --version | head -n 1` + cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug -DCESIUM_CLANG_TIDY_USE_THREADS=4 + cmake --build build --target clang-tidy > output.log + - name: List clang-tidy warnings & errors + if: ${{ !cancelled() }} + run: | + sed -n '/\(error\|warning\):/,/^$/p' output.log + # On macOS, the above doesn't work because the escaped pipe is not supported. + # Instead, use two commands: + # sed -n '/error:/,/^$/p' output.log + # sed -n '/warning:/,/^$/p' output.log + Documentation: runs-on: ubuntu-22.04 steps: diff --git a/CMakeLists.txt b/CMakeLists.txt index baca3fb36..17e780cf5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,6 +116,14 @@ cmake_dependent_option( OFF ) +cmake_dependent_option( + CESIUM_CLANG_TIDY_USE_THREADS + "Sets the number of threads for run-clang-tidy to use." + 14 + CESIUM_ENABLE_CLANG_TIDY + 1 +) + if(CESIUM_INSTALL_STATIC_LIBS OR CESIUM_INSTALL_HEADERS) foreach(PACKAGE ${PACKAGES_PUBLIC}) string(REGEX REPLACE "\[.*\]" "" PACKAGE ${PACKAGE}) diff --git a/Cesium3DTiles/src/MetadataQuery.cpp b/Cesium3DTiles/src/MetadataQuery.cpp index 5705dd845..14238b101 100644 --- a/Cesium3DTiles/src/MetadataQuery.cpp +++ b/Cesium3DTiles/src/MetadataQuery.cpp @@ -1,4 +1,12 @@ +#include +#include +#include #include +#include + +#include +#include +#include namespace Cesium3DTiles { @@ -14,10 +22,8 @@ MetadataQuery::findFirstPropertyWithSemantic( const Cesium3DTiles::Class& klass = classIt->second; - for (auto it = entity.properties.begin(); it != entity.properties.end(); - ++it) { - const std::pair& property = *it; - auto propertyIt = klass.properties.find(property.first); + for (const auto& propertyValue : entity.properties) { + auto propertyIt = klass.properties.find(propertyValue.first); if (propertyIt == klass.properties.end()) continue; @@ -26,9 +32,9 @@ MetadataQuery::findFirstPropertyWithSemantic( return FoundMetadataProperty{ classIt->first, classIt->second, - it->first, + propertyValue.first, propertyIt->second, - it->second}; + propertyValue.second}; } } diff --git a/Cesium3DTiles/test/TestMetadataQuery.cpp b/Cesium3DTiles/test/TestMetadataQuery.cpp index 7108b7e0c..f216ff373 100644 --- a/Cesium3DTiles/test/TestMetadataQuery.cpp +++ b/Cesium3DTiles/test/TestMetadataQuery.cpp @@ -1,8 +1,14 @@ +#include +#include +#include #include +#include +#include -#include #include +#include + using namespace Cesium3DTiles; using namespace CesiumUtility; diff --git a/Cesium3DTilesContent/include/Cesium3DTilesContent/B3dmToGltfConverter.h b/Cesium3DTilesContent/include/Cesium3DTilesContent/B3dmToGltfConverter.h index b442cbc98..136799b6b 100644 --- a/Cesium3DTilesContent/include/Cesium3DTilesContent/B3dmToGltfConverter.h +++ b/Cesium3DTilesContent/include/Cesium3DTilesContent/B3dmToGltfConverter.h @@ -1,7 +1,6 @@ #pragma once -#include "GltfConverterResult.h" - +#include #include #include #include diff --git a/Cesium3DTilesContent/include/Cesium3DTilesContent/GltfConverterResult.h b/Cesium3DTilesContent/include/Cesium3DTilesContent/GltfConverterResult.h index eca794727..e6a6c0c40 100644 --- a/Cesium3DTilesContent/include/Cesium3DTilesContent/GltfConverterResult.h +++ b/Cesium3DTilesContent/include/Cesium3DTilesContent/GltfConverterResult.h @@ -1,7 +1,6 @@ #pragma once -#include "Library.h" - +#include #include #include diff --git a/Cesium3DTilesContent/include/Cesium3DTilesContent/GltfConverterUtility.h b/Cesium3DTilesContent/include/Cesium3DTilesContent/GltfConverterUtility.h index ef64ade0c..f8aad6730 100644 --- a/Cesium3DTilesContent/include/Cesium3DTilesContent/GltfConverterUtility.h +++ b/Cesium3DTilesContent/include/Cesium3DTilesContent/GltfConverterUtility.h @@ -91,7 +91,7 @@ int32_t createAccessorInGltf( const int32_t bufferViewId, const int32_t componentType, const int64_t count, - const std::string type); + const std::string& type); /** * Applies the given relative-to-center (RTC) translation to the transforms of diff --git a/Cesium3DTilesContent/include/Cesium3DTilesContent/GltfConverters.h b/Cesium3DTilesContent/include/Cesium3DTilesContent/GltfConverters.h index 986691b30..2326b7da4 100644 --- a/Cesium3DTilesContent/include/Cesium3DTilesContent/GltfConverters.h +++ b/Cesium3DTilesContent/include/Cesium3DTilesContent/GltfConverters.h @@ -1,8 +1,7 @@ #pragma once -#include "Library.h" - #include +#include #include #include #include diff --git a/Cesium3DTilesContent/include/Cesium3DTilesContent/PntsToGltfConverter.h b/Cesium3DTilesContent/include/Cesium3DTilesContent/PntsToGltfConverter.h index 7443940aa..3a3d95150 100644 --- a/Cesium3DTilesContent/include/Cesium3DTilesContent/PntsToGltfConverter.h +++ b/Cesium3DTilesContent/include/Cesium3DTilesContent/PntsToGltfConverter.h @@ -1,7 +1,6 @@ #pragma once -#include "GltfConverterResult.h" - +#include #include #include #include diff --git a/Cesium3DTilesContent/include/Cesium3DTilesContent/registerAllTileContentTypes.h b/Cesium3DTilesContent/include/Cesium3DTilesContent/registerAllTileContentTypes.h index c6e9a5002..7cb903cd4 100644 --- a/Cesium3DTilesContent/include/Cesium3DTilesContent/registerAllTileContentTypes.h +++ b/Cesium3DTilesContent/include/Cesium3DTilesContent/registerAllTileContentTypes.h @@ -1,4 +1,4 @@ -#include "Library.h" +#include namespace Cesium3DTilesContent { diff --git a/Cesium3DTilesContent/src/B3dmToGltfConverter.cpp b/Cesium3DTilesContent/src/B3dmToGltfConverter.cpp index a0ad5794c..0fb58c849 100644 --- a/Cesium3DTilesContent/src/B3dmToGltfConverter.cpp +++ b/Cesium3DTilesContent/src/B3dmToGltfConverter.cpp @@ -2,9 +2,20 @@ #include #include +#include #include +#include #include -#include +#include +#include + +#include +#include + +#include +#include +#include +#include namespace Cesium3DTilesContent { namespace { @@ -158,6 +169,7 @@ rapidjson::Document parseFeatureTableJsonData( if (rtcIt != document.MemberEnd() && rtcIt->value.IsArray() && rtcIt->value.Size() == 3 && rtcIt->value[0].IsNumber() && rtcIt->value[1].IsNumber() && rtcIt->value[2].IsNumber()) { + CESIUM_ASSERT(result.model.has_value()); // Add the RTC_CENTER value to the glTF as a CESIUM_RTC extension. rapidjson::Value& rtcValue = rtcIt->value; auto& cesiumRTC = diff --git a/Cesium3DTilesContent/src/BatchTableHierarchyPropertyValues.cpp b/Cesium3DTilesContent/src/BatchTableHierarchyPropertyValues.cpp index 14d691a71..4bd03c884 100644 --- a/Cesium3DTilesContent/src/BatchTableHierarchyPropertyValues.cpp +++ b/Cesium3DTilesContent/src/BatchTableHierarchyPropertyValues.cpp @@ -3,6 +3,13 @@ #include #include +#include +#include + +#include +#include +#include +#include using namespace Cesium3DTilesContent::CesiumImpl; diff --git a/Cesium3DTilesContent/src/BatchTableToGltfStructuralMetadata.cpp b/Cesium3DTilesContent/src/BatchTableToGltfStructuralMetadata.cpp index 35163330d..edfd0c953 100644 --- a/Cesium3DTilesContent/src/BatchTableToGltfStructuralMetadata.cpp +++ b/Cesium3DTilesContent/src/BatchTableToGltfStructuralMetadata.cpp @@ -2,22 +2,47 @@ #include "BatchTableHierarchyPropertyValues.h" +#include +#include +#include +#include #include #include #include +#include +#include +#include #include +#include +#include #include #include +#include #include -#include - -#include +#include +#include + +#include +#include +#include +#include +#include #include +#include +#include +#include #include #include +#include +#include +#include +#include #include #include +#include +#include +#include using namespace CesiumGltf; using namespace Cesium3DTilesContent::CesiumImpl; @@ -387,7 +412,7 @@ struct CompatibleTypes { * This is helpful for when a property contains a sentinel value as non-null * data; the sentinel value can then be removed from consideration. */ - void removeSentinelValues(CesiumUtility::JsonValue value) noexcept { + void removeSentinelValues(const CesiumUtility::JsonValue& value) noexcept { if (value.isNumber()) { // Don't try to use string as sentinels for numbers. _canUseNullStringSentinel = false; @@ -406,7 +431,7 @@ struct CompatibleTypes { _canUseZeroSentinel = false; _canUseNegativeOneSentinel = false; - auto stringValue = value.getString(); + const auto& stringValue = value.getString(); if (stringValue == "null") { _canUseNullStringSentinel = false; } @@ -700,19 +725,25 @@ void updateExtensionWithJsonStringProperty( rapidjsonOffsets.emplace_back(rapidjsonStrBuffer.GetLength()); continue; } - if (!it->IsString() || (it->IsNull() && !noDataValue)) { - // Everything else that is not string will be serialized by json - rapidjson::Writer writer(rapidjsonStrBuffer); - it->Accept(writer); - } else { + if (it->IsString() || (it->IsNull() && noDataValue)) { // Because serialized string json will add double quotations in the // buffer which is not needed by us, we will manually add the string to // the buffer - const auto& rapidjsonStr = it->IsNull() ? *noDataValue : it->GetString(); - rapidjsonStrBuffer.Reserve(it->GetStringLength()); - for (rapidjson::SizeType j = 0; j < it->GetStringLength(); ++j) { - rapidjsonStrBuffer.PutUnsafe(rapidjsonStr[j]); + std::string_view value; + if (it->IsString()) { + value = std::string_view(it->GetString(), it->GetStringLength()); + } else { + CESIUM_ASSERT(noDataValue); + value = *noDataValue; } + rapidjsonStrBuffer.Reserve(value.size()); + for (rapidjson::SizeType j = 0; j < value.size(); ++j) { + rapidjsonStrBuffer.PutUnsafe(value[j]); + } + } else { + // Everything else that is not string will be serialized by json + rapidjson::Writer writer(rapidjsonStrBuffer); + it->Accept(writer); } rapidjsonOffsets.emplace_back(rapidjsonStrBuffer.GetLength()); @@ -791,6 +822,7 @@ void updateExtensionWithJsonScalarProperty( for (int64_t i = 0; i < propertyTable.count; ++i, ++p, ++it) { if (it->IsNull()) { + CESIUM_ASSERT(noDataValue.has_value()); *p = *noDataValue; } else { *p = static_cast(it->template Get()); diff --git a/Cesium3DTilesContent/src/BinaryToGltfConverter.cpp b/Cesium3DTilesContent/src/BinaryToGltfConverter.cpp index 1d55dcab4..a49fc7e73 100644 --- a/Cesium3DTilesContent/src/BinaryToGltfConverter.cpp +++ b/Cesium3DTilesContent/src/BinaryToGltfConverter.cpp @@ -1,5 +1,14 @@ #include +#include #include +#include +#include +#include + +#include +#include +#include +#include namespace Cesium3DTilesContent { CesiumGltfReader::GltfReader BinaryToGltfConverter::_gltfReader; diff --git a/Cesium3DTilesContent/src/CmptToGltfConverter.cpp b/Cesium3DTilesContent/src/CmptToGltfConverter.cpp index ae00b7db5..ae6931be0 100644 --- a/Cesium3DTilesContent/src/CmptToGltfConverter.cpp +++ b/Cesium3DTilesContent/src/CmptToGltfConverter.cpp @@ -1,7 +1,16 @@ #include +#include #include +#include +#include -#include +#include + +#include +#include +#include +#include +#include namespace Cesium3DTilesContent { namespace { diff --git a/Cesium3DTilesContent/src/GltfConverterUtility.cpp b/Cesium3DTilesContent/src/GltfConverterUtility.cpp index ceaa91d60..55d717bb1 100644 --- a/Cesium3DTilesContent/src/GltfConverterUtility.cpp +++ b/Cesium3DTilesContent/src/GltfConverterUtility.cpp @@ -4,14 +4,22 @@ #include #include #include -#include +#include -#include +#include +#include +#include +#include +#include +#include -#include +#include +#include #include -#include +#include #include +#include +#include namespace Cesium3DTilesContent { namespace GltfConverterUtility { @@ -106,7 +114,7 @@ int32_t createAccessorInGltf( const int32_t bufferViewId, const int32_t componentType, const int64_t count, - const std::string type) { + const std::string& type) { size_t accessorId = gltf.accessors.size(); Accessor& accessor = gltf.accessors.emplace_back(); accessor.bufferView = bufferViewId; diff --git a/Cesium3DTilesContent/src/GltfConverters.cpp b/Cesium3DTilesContent/src/GltfConverters.cpp index 35e5a4dc7..bafbf3ef4 100644 --- a/Cesium3DTilesContent/src/GltfConverters.cpp +++ b/Cesium3DTilesContent/src/GltfConverters.cpp @@ -1,8 +1,26 @@ +#include #include +#include +#include #include +#include +#include #include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace CesiumUtility; @@ -98,8 +116,8 @@ std::string GltfConverters::toLowerCase(const std::string_view& str) { } std::string GltfConverters::getFileExtension(const std::string_view& filePath) { - std::string_view urlWithoutQueries = filePath.substr(0, filePath.find("?")); - size_t extensionPos = urlWithoutQueries.rfind("."); + std::string_view urlWithoutQueries = filePath.substr(0, filePath.find('?')); + size_t extensionPos = urlWithoutQueries.rfind('.'); if (extensionPos < urlWithoutQueries.size()) { std::string_view extension = urlWithoutQueries.substr(extensionPos); std::string lowerCaseExtension = toLowerCase(extension); diff --git a/Cesium3DTilesContent/src/I3dmToGltfConverter.cpp b/Cesium3DTilesContent/src/I3dmToGltfConverter.cpp index 3e64bd4b8..4f3b4b6cd 100644 --- a/Cesium3DTilesContent/src/I3dmToGltfConverter.cpp +++ b/Cesium3DTilesContent/src/I3dmToGltfConverter.cpp @@ -1,29 +1,51 @@ // Heavily inspired by PntsToGltfConverter.cpp #include +#include #include +#include #include +#include +#include #include +#include #include #include #include +#include +#include #include -#include #include +#include #include -#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include #include +#include +#include #include #include -#include +#include #include #include +#include +#include +#include +#include +#include using namespace CesiumGltf; @@ -318,7 +340,7 @@ CesiumAsync::Future convertI3dmContent( if (!parsedJsonResult) { return finishEarly(); } - const I3dmContent& parsedContent = *parsedJsonResult; + I3dmContent& parsedContent = *parsedJsonResult; decodedInstances.rtcCenter = parsedContent.rtcCenter; decodedInstances.rotationENU = parsedContent.eastNorthUp; @@ -334,7 +356,7 @@ CesiumAsync::Future convertI3dmContent( pBinaryData + *parsedContent.position), numInstances); decodedInstances.positions.assign(rawPositions.begin(), rawPositions.end()); - } else { + } else if (parsedContent.positionQuantized) { std::span rawQuantizedPositions( reinterpret_cast( pBinaryData + *parsedContent.positionQuantized), @@ -353,7 +375,11 @@ CesiumAsync::Future convertI3dmContent( } return position; }); + } else { + parsedContent.errors.emplaceError( + "Missing position or positionQuantized in parsed content"); } + decodedInstances.rotations.resize( numInstances, glm::quat(1.0f, 0.0f, 0.0f, 0.0f)); @@ -490,7 +516,7 @@ CesiumAsync::Future convertI3dmContent( GltfConverterResult&& converterResult) { if (converterResult.model.has_value()) { CesiumGltfReader::GltfReaderResult readerResult{ - std::move(*converterResult.model), + std::move(converterResult.model), {}, {}}; CesiumAsync::HttpHeaders externalRequestHeaders( diff --git a/Cesium3DTilesContent/src/ImplicitTilingUtilities.cpp b/Cesium3DTilesContent/src/ImplicitTilingUtilities.cpp index 5dd06b1fe..f6f529ae6 100644 --- a/Cesium3DTilesContent/src/ImplicitTilingUtilities.cpp +++ b/Cesium3DTilesContent/src/ImplicitTilingUtilities.cpp @@ -5,11 +5,20 @@ #include #include #include +#include +#include #include +#include #include +#include +#include #include +#include +#include +#include + using namespace CesiumGeometry; using namespace CesiumGeospatial; diff --git a/Cesium3DTilesContent/src/PntsToGltfConverter.cpp b/Cesium3DTilesContent/src/PntsToGltfConverter.cpp index 4bc9487cb..b49ff8ecb 100644 --- a/Cesium3DTilesContent/src/PntsToGltfConverter.cpp +++ b/Cesium3DTilesContent/src/PntsToGltfConverter.cpp @@ -1,13 +1,51 @@ #include "BatchTableToGltfStructuralMetadata.h" +#include #include #include +#include #include +#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef _MSC_VER #pragma warning(push) @@ -855,17 +893,15 @@ void decodeDracoMetadata( std::vector& data = parsedContent.dracoBatchTableBinary; const auto& dracoMetadataSemantics = parsedContent.dracoMetadataSemantics; - for (auto dracoSemanticIt = dracoMetadataSemantics.begin(); - dracoSemanticIt != dracoMetadataSemantics.end(); - dracoSemanticIt++) { - DracoMetadataSemantic dracoSemantic = dracoSemanticIt->second; + for (const auto& dracoMetadataSemantic : dracoMetadataSemantics) { + const DracoMetadataSemantic& dracoSemantic = dracoMetadataSemantic.second; draco::PointAttribute* pAttribute = pPointCloud->attribute(dracoSemantic.dracoId); if (!validateDracoMetadataAttribute(pAttribute, dracoSemantic)) { parsedContent.errors.emplaceWarning(fmt::format( "Error decoding {} property in the 3DTILES_draco_compression " "extension. Skip parsing metadata.", - dracoSemanticIt->first)); + dracoMetadataSemantic.first)); parsedContent.dracoMetadataHasErrors = true; return; } @@ -875,7 +911,7 @@ void decodeDracoMetadata( // These do not test for validity since the batch table and extension // were validated in parseDracoExtensionFromBatchTableJson. auto batchTableSemanticIt = - batchTableJson.FindMember(dracoSemanticIt->first.c_str()); + batchTableJson.FindMember(dracoMetadataSemantic.first.c_str()); rapidjson::Value& batchTableSemantic = batchTableSemanticIt->value.GetObject(); auto byteOffsetIt = batchTableSemantic.FindMember("byteOffset"); @@ -918,7 +954,7 @@ void decodeDraco( draco::Decoder decoder; draco::DecoderBuffer buffer; buffer.Init( - (char*)featureTableBinaryData.data() + + reinterpret_cast(featureTableBinaryData.data()) + parsedContent.dracoByteOffset.value(), parsedContent.dracoByteLength.value()); @@ -1102,7 +1138,8 @@ void parsePositionsFromFeatureTableBinary( reinterpret_cast(positionData.data()), pointsLength); - if (parsedContent.positionQuantized) { + if (parsedContent.positionQuantized && parsedContent.quantizedVolumeScale && + parsedContent.quantizedVolumeOffset) { // PERFORMANCE_IDEA: In the future, it might be more performant to detect // if the recipient engine can handle dequantization itself, and if so, use // the KHR_mesh_quantization extension to avoid dequantizing here. @@ -1132,6 +1169,10 @@ void parsePositionsFromFeatureTableBinary( parsedContent.positionMax = glm::max(parsedContent.positionMax, dequantizedPosition); } + } else if (parsedContent.positionQuantized) { + parsedContent.errors.emplaceError( + "Missing quantizedVolumeScale or quantizedVolumeOffset in parsed " + "content"); } else { // The position accessor min / max is required by the glTF spec, so // use a for loop instead of std::memcpy. @@ -1151,6 +1192,7 @@ void parsePositionsFromFeatureTableBinary( void parseColorsFromFeatureTableBinary( const std::span& featureTableBinaryData, PntsContent& parsedContent) { + CESIUM_ASSERT(parsedContent.color.has_value()); PntsSemantic& color = parsedContent.color.value(); std::vector& colorData = color.data; if (colorData.size() > 0) { @@ -1213,6 +1255,7 @@ void parseColorsFromFeatureTableBinary( void parseNormalsFromFeatureTableBinary( const std::span& featureTableBinaryData, PntsContent& parsedContent) { + CESIUM_ASSERT(parsedContent.normal.has_value()); PntsSemantic& normal = parsedContent.normal.value(); std::vector& normalData = normal.data; if (normalData.size() > 0) { @@ -1252,6 +1295,7 @@ void parseNormalsFromFeatureTableBinary( void parseBatchIdsFromFeatureTableBinary( const std::span& featureTableBinaryData, PntsContent& parsedContent) { + CESIUM_ASSERT(parsedContent.batchId.has_value()); PntsSemantic& batchId = parsedContent.batchId.value(); std::vector& batchIdData = batchId.data; if (batchIdData.size() > 0) { @@ -1331,7 +1375,7 @@ int32_t createAccessorInGltf( const int32_t bufferViewId, const int32_t componentType, const int64_t count, - const std::string type) { + const std::string& type) { size_t accessorId = gltf.accessors.size(); Accessor& accessor = gltf.accessors.emplace_back(); accessor.bufferView = bufferViewId; @@ -1375,6 +1419,7 @@ void addPositionsToGltf(PntsContent& parsedContent, Model& gltf) { } void addColorsToGltf(PntsContent& parsedContent, Model& gltf) { + CESIUM_ASSERT(parsedContent.color.has_value()); PntsSemantic& color = parsedContent.color.value(); const int64_t count = static_cast(parsedContent.pointsLength); @@ -1410,6 +1455,7 @@ void addColorsToGltf(PntsContent& parsedContent, Model& gltf) { } void addNormalsToGltf(PntsContent& parsedContent, Model& gltf) { + CESIUM_ASSERT(parsedContent.normal.has_value()); PntsSemantic& normal = parsedContent.normal.value(); const int64_t count = static_cast(parsedContent.pointsLength); @@ -1431,6 +1477,7 @@ void addNormalsToGltf(PntsContent& parsedContent, Model& gltf) { } void addBatchIdsToGltf(PntsContent& parsedContent, CesiumGltf::Model& gltf) { + CESIUM_ASSERT(parsedContent.batchId.has_value()); PntsSemantic& batchId = parsedContent.batchId.value(); const int64_t count = static_cast(parsedContent.pointsLength); @@ -1621,11 +1668,13 @@ void convertPntsContentToGltf( std::span(parsedContent.dracoBatchTableBinary); } - result.errors.merge(BatchTableToGltfStructuralMetadata::convertFromPnts( - featureTableJson, - batchTableJson, - batchTableBinaryData, - result.model.value())); + if (result.model) { + result.errors.merge(BatchTableToGltfStructuralMetadata::convertFromPnts( + featureTableJson, + batchTableJson, + batchTableBinaryData, + result.model.value())); + } } } } // namespace diff --git a/Cesium3DTilesContent/src/SubtreeAvailability.cpp b/Cesium3DTilesContent/src/SubtreeAvailability.cpp index c02073291..b1ab7e233 100644 --- a/Cesium3DTilesContent/src/SubtreeAvailability.cpp +++ b/Cesium3DTilesContent/src/SubtreeAvailability.cpp @@ -1,21 +1,32 @@ -#include +#include +#include +#include #include #include #include #include -#include +#include +#include +#include #include #include +#include #include -#include -#include +#include -#include +#include +#include +#include #include +#include +#include #include #include #include +#include +#include +#include using namespace Cesium3DTiles; using namespace Cesium3DTilesReader; diff --git a/Cesium3DTilesContent/src/TileBoundingVolumes.cpp b/Cesium3DTilesContent/src/TileBoundingVolumes.cpp index ca5654e16..3ebe2cc34 100644 --- a/Cesium3DTilesContent/src/TileBoundingVolumes.cpp +++ b/Cesium3DTilesContent/src/TileBoundingVolumes.cpp @@ -1,6 +1,15 @@ #include #include #include +#include +#include +#include +#include +#include +#include + +#include +#include using namespace Cesium3DTiles; using namespace CesiumGeometry; diff --git a/Cesium3DTilesContent/src/TileTransform.cpp b/Cesium3DTilesContent/src/TileTransform.cpp index 9da4dc48f..1dcedcf8d 100644 --- a/Cesium3DTilesContent/src/TileTransform.cpp +++ b/Cesium3DTilesContent/src/TileTransform.cpp @@ -1,7 +1,10 @@ #include #include -#include +#include + +#include +#include namespace Cesium3DTilesContent { diff --git a/Cesium3DTilesContent/test/ConvertTileToGltf.cpp b/Cesium3DTilesContent/test/ConvertTileToGltf.cpp index c529ca3d0..b0719a1b0 100644 --- a/Cesium3DTilesContent/test/ConvertTileToGltf.cpp +++ b/Cesium3DTilesContent/test/ConvertTileToGltf.cpp @@ -1,12 +1,24 @@ #include "ConvertTileToGltf.h" #include +#include #include #include +#include +#include +#include +#include #include #include #include +#include + +#include +#include +#include +#include + namespace Cesium3DTilesContent { CesiumAsync::AsyncSystem ConvertTileToGltf::asyncSystem( diff --git a/Cesium3DTilesContent/test/TestB3dmToGltfConverter.cpp b/Cesium3DTilesContent/test/TestB3dmToGltfConverter.cpp index d6959ac05..a6dcc76bf 100644 --- a/Cesium3DTilesContent/test/TestB3dmToGltfConverter.cpp +++ b/Cesium3DTilesContent/test/TestB3dmToGltfConverter.cpp @@ -1,10 +1,18 @@ #include "ConvertTileToGltf.h" +#include +#include +#include #include +#include +#include +#include -#include #include +#include +#include + using namespace Cesium3DTilesContent; using namespace CesiumGltf; diff --git a/Cesium3DTilesContent/test/TestI3dmToGltfConverter.cpp b/Cesium3DTilesContent/test/TestI3dmToGltfConverter.cpp index 8fa372a3d..96b6e0947 100644 --- a/Cesium3DTilesContent/test/TestI3dmToGltfConverter.cpp +++ b/Cesium3DTilesContent/test/TestI3dmToGltfConverter.cpp @@ -1,12 +1,14 @@ #include "ConvertTileToGltf.h" +#include #include -#include #include -#include #include -#include +#include +#include + +#include using namespace Cesium3DTilesContent; using namespace CesiumGltf; diff --git a/Cesium3DTilesContent/test/TestImplicitTilingUtilities.cpp b/Cesium3DTilesContent/test/TestImplicitTilingUtilities.cpp index 121ad4719..90ccbff1b 100644 --- a/Cesium3DTilesContent/test/TestImplicitTilingUtilities.cpp +++ b/Cesium3DTilesContent/test/TestImplicitTilingUtilities.cpp @@ -1,15 +1,22 @@ #include #include #include +#include #include +#include #include +#include #include +#include -#include #include +#include #include #include +#include +#include +#include using namespace Cesium3DTiles; using namespace Cesium3DTilesContent; diff --git a/Cesium3DTilesContent/test/TestPntsToGltfConverter.cpp b/Cesium3DTilesContent/test/TestPntsToGltfConverter.cpp index b6b73638e..b4d074fa2 100644 --- a/Cesium3DTilesContent/test/TestPntsToGltfConverter.cpp +++ b/Cesium3DTilesContent/test/TestPntsToGltfConverter.cpp @@ -1,21 +1,38 @@ #include "ConvertTileToGltf.h" -#include -#include +#include +#include +#include +#include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include - +#include +#include +#include +#include +#include +#include +#include + +#include +#include #include #include +#include +#include using namespace CesiumGltf; using namespace Cesium3DTilesContent; diff --git a/Cesium3DTilesContent/test/TestSkirtMeshMetadata.cpp b/Cesium3DTilesContent/test/TestSkirtMeshMetadata.cpp index 8f65adb32..e9ec0bf73 100644 --- a/Cesium3DTilesContent/test/TestSkirtMeshMetadata.cpp +++ b/Cesium3DTilesContent/test/TestSkirtMeshMetadata.cpp @@ -1,9 +1,11 @@ #include +#include #include -#include #include +#include + using namespace CesiumGltfContent; using namespace CesiumUtility; diff --git a/Cesium3DTilesContent/test/TestSubtreeAvailability.cpp b/Cesium3DTilesContent/test/TestSubtreeAvailability.cpp index 8c87606d0..b971ebcd1 100644 --- a/Cesium3DTilesContent/test/TestSubtreeAvailability.cpp +++ b/Cesium3DTilesContent/test/TestSubtreeAvailability.cpp @@ -3,18 +3,32 @@ #include #include #include +#include +#include #include #include #include -#include #include #include #include +#include #include #include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include using namespace Cesium3DTiles; diff --git a/Cesium3DTilesContent/test/TestTileBoundingVolumes.cpp b/Cesium3DTilesContent/test/TestTileBoundingVolumes.cpp index 8861f504c..7d352f37c 100644 --- a/Cesium3DTilesContent/test/TestTileBoundingVolumes.cpp +++ b/Cesium3DTilesContent/test/TestTileBoundingVolumes.cpp @@ -1,9 +1,17 @@ #include #include #include +#include +#include +#include +#include +#include #include #include +#include + +#include using namespace Cesium3DTiles; using namespace Cesium3DTilesContent; diff --git a/Cesium3DTilesContent/test/TestTileTransform.cpp b/Cesium3DTilesContent/test/TestTileTransform.cpp index 95ad9e4c6..ed98cd2f4 100644 --- a/Cesium3DTilesContent/test/TestTileTransform.cpp +++ b/Cesium3DTilesContent/test/TestTileTransform.cpp @@ -2,9 +2,10 @@ #include #include -#include #include -#include +#include + +#include using namespace CesiumUtility; diff --git a/Cesium3DTilesContent/test/TestUpgradeBatchTableToExtStructuralMetadata.cpp b/Cesium3DTilesContent/test/TestUpgradeBatchTableToExtStructuralMetadata.cpp index fcfdde3c7..6eacf3bee 100644 --- a/Cesium3DTilesContent/test/TestUpgradeBatchTableToExtStructuralMetadata.cpp +++ b/Cesium3DTilesContent/test/TestUpgradeBatchTableToExtStructuralMetadata.cpp @@ -1,23 +1,48 @@ #include "BatchTableToGltfStructuralMetadata.h" #include "ConvertTileToGltf.h" -#include -#include +#include +#include +#include +#include #include #include #include +#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include #include #include #include +#include +#include #include +#include #include #include +#include +#include #include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include using namespace CesiumGltf; using namespace Cesium3DTilesContent; diff --git a/Cesium3DTilesReader/src/SubtreeFileReader.cpp b/Cesium3DTilesReader/src/SubtreeFileReader.cpp index f023a956a..ef3f34999 100644 --- a/Cesium3DTilesReader/src/SubtreeFileReader.cpp +++ b/Cesium3DTilesReader/src/SubtreeFileReader.cpp @@ -1,7 +1,25 @@ +#include +#include #include +#include +#include +#include +#include #include +#include +#include #include +#include + +#include +#include +#include +#include +#include +#include +#include + using namespace Cesium3DTiles; using namespace CesiumAsync; using namespace CesiumJsonReader; diff --git a/Cesium3DTilesReader/test/TestTilesetReader.cpp b/Cesium3DTilesReader/test/TestTilesetReader.cpp index dcf1e60cc..d2dda3785 100644 --- a/Cesium3DTilesReader/test/TestTilesetReader.cpp +++ b/Cesium3DTilesReader/test/TestTilesetReader.cpp @@ -1,17 +1,19 @@ #include #include #include +#include #include -#include #include -#include -#include +#include +#include +#include +#include #include -#include #include #include +#include TEST_CASE("Reads tileset JSON") { using namespace std::string_literals; diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/BoundingVolume.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/BoundingVolume.h index b55823bfa..b81d5471e 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/BoundingVolume.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/BoundingVolume.h @@ -1,7 +1,6 @@ #pragma once -#include "Library.h" - +#include #include #include #include diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/EllipsoidTilesetLoader.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/EllipsoidTilesetLoader.h index 36efb21bd..b723a7f9c 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/EllipsoidTilesetLoader.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/EllipsoidTilesetLoader.h @@ -1,7 +1,6 @@ #pragma once -#include "ITilesetHeightSampler.h" - +#include #include #include diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/IPrepareRendererResources.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/IPrepareRendererResources.h index 323686127..dbda49f59 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/IPrepareRendererResources.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/IPrepareRendererResources.h @@ -1,8 +1,7 @@ #pragma once -#include "Library.h" -#include "TileLoadResult.h" - +#include +#include #include #include diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/ITilesetHeightSampler.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/ITilesetHeightSampler.h index 8f9b5f966..a980efa2f 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/ITilesetHeightSampler.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/ITilesetHeightSampler.h @@ -1,8 +1,7 @@ #pragma once -#include "Library.h" -#include "SampleHeightResult.h" - +#include +#include #include #include diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterMappedTo3DTile.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterMappedTo3DTile.h index d8951a67c..942ac8d8b 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterMappedTo3DTile.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterMappedTo3DTile.h @@ -1,7 +1,6 @@ #pragma once -#include "IPrepareRendererResources.h" - +#include #include #include #include diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterOverlayCollection.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterOverlayCollection.h index bd64866ca..864356d6a 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterOverlayCollection.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterOverlayCollection.h @@ -1,8 +1,7 @@ #pragma once -#include "Library.h" -#include "TilesetExternals.h" - +#include +#include #include #include #include diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterizedPolygonsTileExcluder.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterizedPolygonsTileExcluder.h index 644137d48..a0bdb514c 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterizedPolygonsTileExcluder.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/RasterizedPolygonsTileExcluder.h @@ -1,8 +1,7 @@ #pragma once -#include "ITileExcluder.h" -#include "Library.h" - +#include +#include #include namespace CesiumRasterOverlays { diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tile.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tile.h index 5dda2de0b..78c08a56c 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tile.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tile.h @@ -1,13 +1,12 @@ #pragma once -#include "BoundingVolume.h" -#include "Library.h" -#include "RasterMappedTo3DTile.h" -#include "TileContent.h" -#include "TileID.h" -#include "TileRefine.h" -#include "TileSelectionState.h" - +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileContent.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileContent.h index c92fe32dd..01e5ae06b 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileContent.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileContent.h @@ -1,8 +1,7 @@ #pragma once -#include "Library.h" -#include "TilesetMetadata.h" - +#include +#include #include #include #include diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileID.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileID.h index b5ee6833c..6e33e83d0 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileID.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileID.h @@ -1,7 +1,6 @@ #pragma once -#include "Library.h" - +#include #include #include diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileLoadResult.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileLoadResult.h index 8e7288b9b..cd36f1f1f 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileLoadResult.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileLoadResult.h @@ -1,8 +1,7 @@ #pragma once -#include "BoundingVolume.h" -#include "TileContent.h" - +#include +#include #include #include #include diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileOcclusionRendererProxy.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileOcclusionRendererProxy.h index b3f47b5fb..1d4aba0ae 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileOcclusionRendererProxy.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileOcclusionRendererProxy.h @@ -1,7 +1,7 @@ #pragma once -#include "Library.h" -#include "Tile.h" +#include +#include #include #include diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileSelectionState.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileSelectionState.h index dc2797620..9b08272d0 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileSelectionState.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TileSelectionState.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include #include diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tileset.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tileset.h index 1c062ea2f..769822f7d 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tileset.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/Tileset.h @@ -1,16 +1,15 @@ #pragma once -#include "Library.h" -#include "RasterOverlayCollection.h" -#include "SampleHeightResult.h" -#include "Tile.h" -#include "TilesetContentLoader.h" -#include "TilesetExternals.h" -#include "TilesetLoadFailureDetails.h" -#include "TilesetOptions.h" -#include "ViewState.h" -#include "ViewUpdateResult.h" - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -313,6 +312,9 @@ class CESIUM3DTILESSELECTION_API Tileset final { CesiumAsync::Future sampleHeightMostDetailed( const std::vector& positions); + Tileset(const Tileset& rhs) = delete; + Tileset& operator=(const Tileset& rhs) = delete; + private: /** * @brief The result of traversing one branch of the tile hierarchy. @@ -564,9 +566,6 @@ class CESIUM3DTILESSELECTION_API Tileset final { const FrameState& frameState, const Tile& tile, const TileSelectionState& lastFrameSelectionState); - - Tileset(const Tileset& rhs) = delete; - Tileset& operator=(const Tileset& rhs) = delete; }; } // namespace Cesium3DTilesSelection diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TilesetContentLoader.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TilesetContentLoader.h index a852f14e0..cb145f434 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TilesetContentLoader.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TilesetContentLoader.h @@ -1,12 +1,11 @@ #pragma once -#include "BoundingVolume.h" -#include "Library.h" -#include "TileContent.h" -#include "TileLoadResult.h" -#include "TilesetOptions.h" - +#include +#include #include +#include +#include +#include #include #include #include diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TilesetExternals.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TilesetExternals.h index a9f8a4a71..0e5ea3a93 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TilesetExternals.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TilesetExternals.h @@ -1,10 +1,9 @@ #pragma once -#include "Library.h" -#include "TileOcclusionRendererProxy.h" -#include "TilesetSharedAssetSystem.h" -#include "spdlog-cesium.h" - +#include +#include +#include +#include #include #include diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TilesetMetadata.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TilesetMetadata.h index db5b811d7..ad1bd89e3 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TilesetMetadata.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TilesetMetadata.h @@ -1,9 +1,8 @@ #pragma once -#include "Library.h" - #include #include +#include #include #include diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TilesetOptions.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TilesetOptions.h index bb09588cb..6e1d6b755 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TilesetOptions.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/TilesetOptions.h @@ -1,10 +1,10 @@ #pragma once -#include "Library.h" - +#include #include #include +#include #include #include #include @@ -204,7 +204,7 @@ struct CESIUM3DTILESSELECTION_API TilesetOptions { * unloaded until the total is under this number or until only required tiles * remain, whichever comes first. */ - int64_t maximumCachedBytes = 512 * 1024 * 1024; + int64_t maximumCachedBytes = 512LL * 1024 * 1024; /** * @brief A table that maps the camera height above the ellipsoid to a fog diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/ViewState.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/ViewState.h index 240f1e12b..d541276fc 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/ViewState.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/ViewState.h @@ -1,8 +1,7 @@ #pragma once -#include "BoundingVolume.h" -#include "Library.h" - +#include +#include #include #include #include diff --git a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/ViewUpdateResult.h b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/ViewUpdateResult.h index e6497fe70..eded6deb8 100644 --- a/Cesium3DTilesSelection/include/Cesium3DTilesSelection/ViewUpdateResult.h +++ b/Cesium3DTilesSelection/include/Cesium3DTilesSelection/ViewUpdateResult.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include #include #include diff --git a/Cesium3DTilesSelection/src/BoundingVolume.cpp b/Cesium3DTilesSelection/src/BoundingVolume.cpp index c1a046e94..78555f864 100644 --- a/Cesium3DTilesSelection/src/BoundingVolume.cpp +++ b/Cesium3DTilesSelection/src/BoundingVolume.cpp @@ -1,9 +1,22 @@ -#include "Cesium3DTilesSelection/BoundingVolume.h" - -#include "CesiumGeospatial/Cartographic.h" -#include "CesiumGeospatial/GlobeTransforms.h" - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include using namespace CesiumGeometry; using namespace CesiumGeospatial; diff --git a/Cesium3DTilesSelection/src/CesiumIonTilesetLoader.cpp b/Cesium3DTilesSelection/src/CesiumIonTilesetLoader.cpp index 6d39705e6..14460bf14 100644 --- a/Cesium3DTilesSelection/src/CesiumIonTilesetLoader.cpp +++ b/Cesium3DTilesSelection/src/CesiumIonTilesetLoader.cpp @@ -1,15 +1,40 @@ #include "CesiumIonTilesetLoader.h" #include "LayerJsonTerrainLoader.h" +#include "TilesetContentLoaderResult.h" #include "TilesetJsonLoader.h" +#include +#include +#include +#include +#include +#include +#include #include +#include #include +#include +#include +#include #include -#include #include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include #include +#include +#include namespace Cesium3DTilesSelection { diff --git a/Cesium3DTilesSelection/src/DebugTileStateDatabase.cpp b/Cesium3DTilesSelection/src/DebugTileStateDatabase.cpp index 05ec46a39..04a41f462 100644 --- a/Cesium3DTilesSelection/src/DebugTileStateDatabase.cpp +++ b/Cesium3DTilesSelection/src/DebugTileStateDatabase.cpp @@ -1,9 +1,20 @@ #include +#include +#include #include #include +#include +#include #include +#include +#include +#include +#include +#include +#include + using namespace CesiumAsync; namespace { diff --git a/Cesium3DTilesSelection/src/EllipsoidTilesetLoader.cpp b/Cesium3DTilesSelection/src/EllipsoidTilesetLoader.cpp index 910a8faea..fe44f1a5b 100644 --- a/Cesium3DTilesSelection/src/EllipsoidTilesetLoader.cpp +++ b/Cesium3DTilesSelection/src/EllipsoidTilesetLoader.cpp @@ -1,8 +1,42 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace CesiumGltf; using namespace CesiumAsync; @@ -140,7 +174,7 @@ BoundingRegion EllipsoidTilesetLoader::createBoundingRegion( EllipsoidTilesetLoader::Geometry EllipsoidTilesetLoader::createGeometry(const Tile& tile) const { - static constexpr uint16_t resolution = 24; + static constexpr size_t resolution = 24; std::vector indices; indices.reserve(6 * (resolution - 1) * (resolution - 1)); diff --git a/Cesium3DTilesSelection/src/EmptyRasterOverlayTileProvider.cpp b/Cesium3DTilesSelection/src/EmptyRasterOverlayTileProvider.cpp index f386d32ad..6b77c5c9f 100644 --- a/Cesium3DTilesSelection/src/EmptyRasterOverlayTileProvider.cpp +++ b/Cesium3DTilesSelection/src/EmptyRasterOverlayTileProvider.cpp @@ -1,5 +1,12 @@ #include "EmptyRasterOverlayTileProvider.h" +#include +#include +#include +#include + +#include + using namespace CesiumRasterOverlays; namespace Cesium3DTilesSelection { diff --git a/Cesium3DTilesSelection/src/ImplicitOctreeLoader.cpp b/Cesium3DTilesSelection/src/ImplicitOctreeLoader.cpp index e9b8d7d58..2b0b7c977 100644 --- a/Cesium3DTilesSelection/src/ImplicitOctreeLoader.cpp +++ b/Cesium3DTilesSelection/src/ImplicitOctreeLoader.cpp @@ -2,16 +2,38 @@ #include "logTileLoadResult.h" +#include #include #include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include #include -#include +#include #include +#include +#include +#include +#include +#include +#include #include +#include using namespace Cesium3DTilesContent; diff --git a/Cesium3DTilesSelection/src/ImplicitQuadtreeLoader.cpp b/Cesium3DTilesSelection/src/ImplicitQuadtreeLoader.cpp index 9fa5d48a9..069953853 100644 --- a/Cesium3DTilesSelection/src/ImplicitQuadtreeLoader.cpp +++ b/Cesium3DTilesSelection/src/ImplicitQuadtreeLoader.cpp @@ -2,19 +2,39 @@ #include "logTileLoadResult.h" +#include #include #include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include #include +#include #include +#include +#include +#include #include -#include +#include #include +#include +#include +#include +#include +#include #include #include #include +#include using namespace Cesium3DTilesContent; @@ -201,7 +221,7 @@ CesiumAsync::Future requestTileContent( logTileLoadResult(pLogger, tileUrl, result.errors); if (result.errors || !result.model) { return TileLoadResult::createFailedResult( - std::move(pAssetAccessor), + pAssetAccessor, std::move(pCompletedRequest)); } @@ -211,7 +231,7 @@ CesiumAsync::Future requestTileContent( std::nullopt, std::nullopt, std::nullopt, - std::move(pAssetAccessor), + pAssetAccessor, std::move(pCompletedRequest), {}, TileLoadResultState::Success, diff --git a/Cesium3DTilesSelection/src/LayerJsonTerrainLoader.cpp b/Cesium3DTilesSelection/src/LayerJsonTerrainLoader.cpp index f3d044cd2..f90a5bb7f 100644 --- a/Cesium3DTilesSelection/src/LayerJsonTerrainLoader.cpp +++ b/Cesium3DTilesSelection/src/LayerJsonTerrainLoader.cpp @@ -1,16 +1,57 @@ #include "LayerJsonTerrainLoader.h" +#include "TilesetContentLoaderResult.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include +#include +#include #include -#include #include +#include +#include #include #include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace CesiumAsync; using namespace Cesium3DTilesSelection; @@ -334,13 +375,13 @@ Future loadLayersRecursive( creditString = attributionIt->value.GetString(); } - loadLayersResult.layers.emplace_back(LayerJsonTerrainLoader::Layer{ + loadLayersResult.layers.emplace_back( baseUrl, std::move(version), std::move(urls), std::move(availability), static_cast(maxZoom), - availabilityLevels}); + availabilityLevels); loadLayersResult.layerCredits.emplace_back(std::move(creditString)); @@ -878,7 +919,7 @@ LayerJsonTerrainLoader::loadTileContent(const TileLoadInput& loadInput) { // thread based on the projection of the loader since the upsampler // needs this UV to do the upsampling auto finalResult = convertToTileLoadResult( - std::move(pAssetAccessor), + pAssetAccessor, std::move(loadResult), ellipsoid); bool doesTileHaveUpsampledChild = tileHasUpsampledChild(tile); @@ -916,7 +957,7 @@ LayerJsonTerrainLoader::loadTileContent(const TileLoadInput& loadInput) { // based on the projection of the loader since the upsampler needs // this UV to do the upsampling auto result = convertToTileLoadResult( - std::move(pAssetAccessor), + pAssetAccessor, std::move(loadResult), ellipsoid); if (doesTileHaveUpsampledChild && diff --git a/Cesium3DTilesSelection/src/RasterMappedTo3DTile.cpp b/Cesium3DTilesSelection/src/RasterMappedTo3DTile.cpp index 7f57d3a5b..ac659d06a 100644 --- a/Cesium3DTilesSelection/src/RasterMappedTo3DTile.cpp +++ b/Cesium3DTilesSelection/src/RasterMappedTo3DTile.cpp @@ -1,15 +1,26 @@ -#include "TileUtilities.h" - +#include #include #include -#include #include #include -#include #include +#include +#include +#include +#include #include #include #include +#include +#include + +#include + +#include +#include +#include +#include +#include using namespace Cesium3DTilesSelection; using namespace CesiumGeometry; @@ -287,7 +298,8 @@ RasterMappedTo3DTile* addRealTile( return nullptr; } else { return &tile.getMappedRasterTiles().emplace_back( - RasterMappedTo3DTile(pTile, textureCoordinateIndex)); + pTile, + textureCoordinateIndex); } } @@ -303,7 +315,8 @@ RasterMappedTo3DTile* addRealTile( if (tileProvider.isPlaceholder()) { // Provider not created yet, so add a placeholder tile. return &tile.getMappedRasterTiles().emplace_back( - RasterMappedTo3DTile(getPlaceholderTile(placeholder), -1)); + getPlaceholderTile(placeholder), + -1); } const Projection& projection = tileProvider.getProjection(); @@ -336,9 +349,9 @@ RasterMappedTo3DTile* addRealTile( int32_t(overlayDetails.rasterOverlayProjections.size()); int32_t textureCoordinateIndex = existingIndex + addProjectionToList(missingProjections, projection); - return &tile.getMappedRasterTiles().emplace_back(RasterMappedTo3DTile( + return &tile.getMappedRasterTiles().emplace_back( getPlaceholderTile(placeholder), - textureCoordinateIndex)); + textureCoordinateIndex); } } @@ -365,9 +378,9 @@ RasterMappedTo3DTile* addRealTile( textureCoordinateIndex); } else { // No precise rectangle yet, so return a placeholder for now. - return &tile.getMappedRasterTiles().emplace_back(RasterMappedTo3DTile( + return &tile.getMappedRasterTiles().emplace_back( getPlaceholderTile(placeholder), - textureCoordinateIndex)); + textureCoordinateIndex); } } diff --git a/Cesium3DTilesSelection/src/RasterOverlayCollection.cpp b/Cesium3DTilesSelection/src/RasterOverlayCollection.cpp index f9fa5875b..b66529a47 100644 --- a/Cesium3DTilesSelection/src/RasterOverlayCollection.cpp +++ b/Cesium3DTilesSelection/src/RasterOverlayCollection.cpp @@ -1,8 +1,28 @@ #include "EmptyRasterOverlayTileProvider.h" +#include #include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include using namespace CesiumGeometry; using namespace CesiumGeospatial; @@ -96,9 +116,9 @@ void RasterOverlayCollection::add( if (tileState != TileLoadState::Unloaded && tileState != TileLoadState::Unloading && tileState != TileLoadState::Failed) { - tile.getMappedRasterTiles().push_back(RasterMappedTo3DTile( + tile.getMappedRasterTiles().emplace_back( pPlaceholder->getTile(Rectangle(), glm::dvec2(0.0)), - -1)); + -1); } }); diff --git a/Cesium3DTilesSelection/src/RasterOverlayUpsampler.cpp b/Cesium3DTilesSelection/src/RasterOverlayUpsampler.cpp index 36de0b780..dcffc7c67 100644 --- a/Cesium3DTilesSelection/src/RasterOverlayUpsampler.cpp +++ b/Cesium3DTilesSelection/src/RasterOverlayUpsampler.cpp @@ -2,14 +2,26 @@ #include #include +#include +#include +#include +#include +#include #include +#include #include #include #include #include #include +#include +#include +#include +#include +#include #include +#include using namespace CesiumRasterOverlays; diff --git a/Cesium3DTilesSelection/src/RasterizedPolygonsTileExcluder.cpp b/Cesium3DTilesSelection/src/RasterizedPolygonsTileExcluder.cpp index 3b764612d..7b1b67f9a 100644 --- a/Cesium3DTilesSelection/src/RasterizedPolygonsTileExcluder.cpp +++ b/Cesium3DTilesSelection/src/RasterizedPolygonsTileExcluder.cpp @@ -1,9 +1,10 @@ -#include "Cesium3DTilesSelection/RasterizedPolygonsTileExcluder.h" - -#include "Cesium3DTilesSelection/Tile.h" -#include "CesiumRasterOverlays/RasterizedPolygonsOverlay.h" #include "TileUtilities.h" +#include +#include +#include +#include + using namespace Cesium3DTilesSelection; RasterizedPolygonsTileExcluder::RasterizedPolygonsTileExcluder( diff --git a/Cesium3DTilesSelection/src/Tile.cpp b/Cesium3DTilesSelection/src/Tile.cpp index d48fdefe2..82e7f1343 100644 --- a/Cesium3DTilesSelection/src/Tile.cpp +++ b/Cesium3DTilesSelection/src/Tile.cpp @@ -1,14 +1,20 @@ -#include "Cesium3DTilesSelection/Tile.h" - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include +#include +#include #include +#include +#include +#include +#include +#include using namespace CesiumGeometry; using namespace CesiumGeospatial; diff --git a/Cesium3DTilesSelection/src/TileContent.cpp b/Cesium3DTilesSelection/src/TileContent.cpp index 0766f88ef..79fea9f9a 100644 --- a/Cesium3DTilesSelection/src/TileContent.cpp +++ b/Cesium3DTilesSelection/src/TileContent.cpp @@ -1,4 +1,11 @@ #include +#include +#include + +#include +#include +#include +#include using namespace CesiumRasterOverlays; using namespace CesiumUtility; diff --git a/Cesium3DTilesSelection/src/TileContentLoadInfo.cpp b/Cesium3DTilesSelection/src/TileContentLoadInfo.cpp index 136051632..09b16a666 100644 --- a/Cesium3DTilesSelection/src/TileContentLoadInfo.cpp +++ b/Cesium3DTilesSelection/src/TileContentLoadInfo.cpp @@ -1,6 +1,16 @@ #include "TileContentLoadInfo.h" +#include #include +#include +#include +#include +#include +#include + +#include + +#include namespace Cesium3DTilesSelection { TileContentLoadInfo::TileContentLoadInfo( diff --git a/Cesium3DTilesSelection/src/TileID.cpp b/Cesium3DTilesSelection/src/TileID.cpp index 06ba0c2ff..a4264091a 100644 --- a/Cesium3DTilesSelection/src/TileID.cpp +++ b/Cesium3DTilesSelection/src/TileID.cpp @@ -1,4 +1,6 @@ -#include "Cesium3DTilesSelection/TileID.h" +#include +#include +#include #include #include diff --git a/Cesium3DTilesSelection/src/TileOcclusionRendererProxy.cpp b/Cesium3DTilesSelection/src/TileOcclusionRendererProxy.cpp index 78819a78e..1ab5e3fab 100644 --- a/Cesium3DTilesSelection/src/TileOcclusionRendererProxy.cpp +++ b/Cesium3DTilesSelection/src/TileOcclusionRendererProxy.cpp @@ -1,4 +1,8 @@ -#include "Cesium3DTilesSelection/TileOcclusionRendererProxy.h" +#include +#include + +#include +#include namespace Cesium3DTilesSelection { diff --git a/Cesium3DTilesSelection/src/TileUtilities.cpp b/Cesium3DTilesSelection/src/TileUtilities.cpp index 50a45e253..48f787ae2 100644 --- a/Cesium3DTilesSelection/src/TileUtilities.cpp +++ b/Cesium3DTilesSelection/src/TileUtilities.cpp @@ -1,10 +1,12 @@ #include "TileUtilities.h" -#include -#include +#include +#include +#include #include -#include +#include +#include using namespace CesiumGeospatial; diff --git a/Cesium3DTilesSelection/src/TileUtilities.h b/Cesium3DTilesSelection/src/TileUtilities.h index 909ec9026..de785c3fc 100644 --- a/Cesium3DTilesSelection/src/TileUtilities.h +++ b/Cesium3DTilesSelection/src/TileUtilities.h @@ -1,7 +1,6 @@ #pragma once -#include "Cesium3DTilesSelection/BoundingVolume.h" - +#include #include #include diff --git a/Cesium3DTilesSelection/src/Tileset.cpp b/Cesium3DTilesSelection/src/Tileset.cpp index 5d4f052ca..da61c1486 100644 --- a/Cesium3DTilesSelection/src/Tileset.cpp +++ b/Cesium3DTilesSelection/src/Tileset.cpp @@ -1,31 +1,51 @@ -#include "TileUtilities.h" #include "TilesetContentManager.h" #include "TilesetHeightQuery.h" +#include #include -#include +#include +#include +#include #include +#include +#include #include +#include +#include #include -#include +#include +#include +#include #include +#include +#include #include +#include #include #include #include #include #include -#include #include -#include #include -#include +#include +#include +#include #include +#include #include +#include +#include #include +#include +#include +#include +#include #include +#include +#include using namespace CesiumAsync; using namespace CesiumGeometry; @@ -128,8 +148,8 @@ void Tileset::setShowCreditsOnScreen(bool showCreditsOnScreen) noexcept { const std::vector& credits = this->getTilesetCredits(); auto pCreditSystem = this->_externals.pCreditSystem; - for (size_t i = 0, size = credits.size(); i < size; i++) { - pCreditSystem->setShowOnScreen(credits[i], showCreditsOnScreen); + for (auto credit : credits) { + pCreditSystem->setShowOnScreen(credit, showCreditsOnScreen); } } @@ -157,12 +177,16 @@ const TilesetSharedAssetSystem& Tileset::getSharedAssetSystem() const noexcept { return *this->_pTilesetContentManager->getSharedAssetSystem(); } +// NOLINTBEGIN(misc-use-anonymous-namespace) static bool operator<(const FogDensityAtHeight& fogDensity, double height) noexcept { return fogDensity.cameraHeight < height; } +// NOLINTEND(misc-use-anonymous-namespace) -static double computeFogDensity( +namespace { + +double computeFogDensity( const std::vector& fogDensityTable, const ViewState& viewState) { const double height = viewState.getPositionCartographic() @@ -206,6 +230,8 @@ static double computeFogDensity( return density; } +} // namespace + void Tileset::_updateLodTransitions( const FrameState& frameState, float deltaTime, @@ -596,7 +622,8 @@ Tileset::sampleHeightMostDetailed(const std::vector& positions) { return promise.getFuture(); } -static void markTileNonRendered( +namespace { +void markTileNonRendered( TileSelectionState::Result lastResult, Tile& tile, ViewUpdateResult& result) { @@ -611,7 +638,7 @@ static void markTileNonRendered( } } -static void markTileNonRendered( +void markTileNonRendered( int32_t lastFrameNumber, Tile& tile, ViewUpdateResult& result) { @@ -620,7 +647,7 @@ static void markTileNonRendered( markTileNonRendered(lastResult, tile, result); } -static void markChildrenNonRendered( +void markChildrenNonRendered( int32_t lastFrameNumber, TileSelectionState::Result lastResult, Tile& tile, @@ -635,7 +662,7 @@ static void markChildrenNonRendered( } } -static void markChildrenNonRendered( +void markChildrenNonRendered( int32_t lastFrameNumber, Tile& tile, ViewUpdateResult& result) { @@ -644,7 +671,7 @@ static void markChildrenNonRendered( markChildrenNonRendered(lastFrameNumber, lastResult, tile, result); } -static void markTileAndChildrenNonRendered( +void markTileAndChildrenNonRendered( int32_t lastFrameNumber, Tile& tile, ViewUpdateResult& result) { @@ -666,7 +693,7 @@ static void markTileAndChildrenNonRendered( * @return Whether the tile is visible according to the current camera * configuration */ -static bool isVisibleFromCamera( +bool isVisibleFromCamera( const ViewState& viewState, const BoundingVolume& boundingVolume, const Ellipsoid& ellipsoid, @@ -699,7 +726,7 @@ static bool isVisibleFromCamera( * @param fogDensity The fog density * @return Whether the tile is visible in the fog */ -static bool isVisibleInFog(double distance, double fogDensity) noexcept { +bool isVisibleInFog(double distance, double fogDensity) noexcept { if (fogDensity <= 0.0) { return true; } @@ -707,6 +734,7 @@ static bool isVisibleInFog(double distance, double fogDensity) noexcept { const double fogScalar = distance * fogDensity; return glm::exp(-(fogScalar * fogScalar)) > 0.0; } +} // namespace void Tileset::_frustumCull( const Tile& tile, @@ -807,7 +835,9 @@ void Tileset::_fogCull( } } -static double computeTilePriority( +namespace { + +double computeTilePriority( const Tile& tile, const std::vector& frustums, const std::vector& distances) { @@ -855,6 +885,8 @@ void computeDistances( }); } +} // namespace + bool Tileset::_meetsSse( const std::vector& frustums, const Tile& tile, @@ -988,9 +1020,9 @@ Tileset::TraversalDetails Tileset::_visitTileIfNeeded( result); } -static bool isLeaf(const Tile& tile) noexcept { - return tile.getChildren().empty(); -} +namespace { +bool isLeaf(const Tile& tile) noexcept { return tile.getChildren().empty(); } +} // namespace Tileset::TraversalDetails Tileset::_renderLeaf( const FrameState& frameState, @@ -1301,15 +1333,16 @@ Tileset::TraversalDetails Tileset::_visitTile( } const bool unconditionallyRefine = tile.getUnconditionallyRefine(); + const bool refineForSse = !meetsSse && !ancestorMeetsSse; // Determine whether to REFINE or RENDER. Note that even if this tile is // initially marked for RENDER here, it may later switch to REFINE as a // result of `mustContinueRefiningToDeeperTiles`. - VisitTileAction action = VisitTileAction::Render; - if (unconditionallyRefine) - action = VisitTileAction::Refine; - else if (!meetsSse && !ancestorMeetsSse) + VisitTileAction action; + if (unconditionallyRefine || refineForSse) action = VisitTileAction::Refine; + else + action = VisitTileAction::Render; const TileSelectionState lastFrameSelectionState = tile.getLastSelectionState(); @@ -1571,8 +1604,8 @@ void Tileset::_processMainThreadLoadQueue() { double timeBudget = this->_options.mainThreadLoadingTimeLimit; auto start = std::chrono::system_clock::now(); - auto end = - start + std::chrono::milliseconds(static_cast(timeBudget)); + auto end = start + std::chrono::microseconds( + static_cast(1000.0 * timeBudget)); for (TileLoadTask& task : this->_mainThreadLoadQueue) { // We double-check that the tile is still in the ContentLoaded state here, // in case something (such as a child that needs to upsample from this @@ -1602,8 +1635,8 @@ void Tileset::_unloadCachedTiles(double timeBudget) noexcept { auto start = std::chrono::system_clock::now(); auto end = (timeBudget <= 0.0) ? std::chrono::time_point::max() - : (start + std::chrono::milliseconds( - static_cast(timeBudget))); + : (start + std::chrono::microseconds( + static_cast(1000.0 * timeBudget))); while (this->getTotalDataBytes() > maxBytes) { if (pTile == nullptr || pTile == pRootTile) { diff --git a/Cesium3DTilesSelection/src/TilesetContentLoader.cpp b/Cesium3DTilesSelection/src/TilesetContentLoader.cpp index 03905b297..c55ef8c58 100644 --- a/Cesium3DTilesSelection/src/TilesetContentLoader.cpp +++ b/Cesium3DTilesSelection/src/TilesetContentLoader.cpp @@ -1,5 +1,19 @@ +#include +#include #include -#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include namespace Cesium3DTilesSelection { TileLoadInput::TileLoadInput( diff --git a/Cesium3DTilesSelection/src/TilesetContentManager.cpp b/Cesium3DTilesSelection/src/TilesetContentManager.cpp index 9ec3f7aa4..89663c016 100644 --- a/Cesium3DTilesSelection/src/TilesetContentManager.cpp +++ b/Cesium3DTilesSelection/src/TilesetContentManager.cpp @@ -2,25 +2,73 @@ #include "CesiumIonTilesetLoader.h" #include "LayerJsonTerrainLoader.h" +#include "RasterOverlayUpsampler.h" #include "TileContentLoadInfo.h" +#include "TilesetContentLoaderResult.h" #include "TilesetJsonLoader.h" +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include #include #include #include +#include #include -#include +#include +#include #include +#include +#include #include - -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace CesiumGltfContent; using namespace CesiumRasterOverlays; @@ -347,6 +395,11 @@ std::vector mapOverlaysToTile( return projections; } +// Really, these two methods are risky and could easily result in bugs, but +// they're private methods used only in this class, so it's easier to just tell +// clang-tidy to ignore them. + +// NOLINTBEGIN(bugprone-return-const-ref-from-parameter) const BoundingVolume& getEffectiveBoundingVolume( const BoundingVolume& tileBoundingVolume, const std::optional& updatedTileBoundingVolume, @@ -387,6 +440,7 @@ const BoundingVolume& getEffectiveContentBoundingVolume( // And finally the regular tile bounding volume. return tileBoundingVolume; } +// NOLINTEND(bugprone-return-const-ref-from-parameter) void calcRasterOverlayDetailsInWorkerThread( TileLoadResult& result, @@ -1337,7 +1391,7 @@ void TilesetContentManager::setTileContent( } if (result.updatedContentBoundingVolume) { - tile.setContentBoundingVolume(*result.updatedContentBoundingVolume); + tile.setContentBoundingVolume(result.updatedContentBoundingVolume); } auto& content = tile.getContent(); diff --git a/Cesium3DTilesSelection/src/TilesetHeightQuery.cpp b/Cesium3DTilesSelection/src/TilesetHeightQuery.cpp index 65934d73e..170eaa6e6 100644 --- a/Cesium3DTilesSelection/src/TilesetHeightQuery.cpp +++ b/Cesium3DTilesSelection/src/TilesetHeightQuery.cpp @@ -1,14 +1,34 @@ #include "TilesetHeightQuery.h" -#include "TileUtilities.h" #include "TilesetContentManager.h" +#include #include #include +#include +#include +#include #include +#include +#include +#include +#include #include +#include #include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + using namespace Cesium3DTilesSelection; using namespace CesiumGeospatial; using namespace CesiumGeometry; @@ -145,7 +165,7 @@ void TilesetHeightQuery::findCandidateTiles( // If tile failed to load, this means we can't complete the intersection if (pTile->getState() == TileLoadState::Failed) { - warnings.push_back("Tile load failed during query. Ignoring."); + warnings.emplace_back("Tile load failed during query. Ignoring."); return; } diff --git a/Cesium3DTilesSelection/src/TilesetJsonLoader.cpp b/Cesium3DTilesSelection/src/TilesetJsonLoader.cpp index 0414e0261..618d4c103 100644 --- a/Cesium3DTilesSelection/src/TilesetJsonLoader.cpp +++ b/Cesium3DTilesSelection/src/TilesetJsonLoader.cpp @@ -2,28 +2,61 @@ #include "ImplicitOctreeLoader.h" #include "ImplicitQuadtreeLoader.h" +#include "TilesetContentLoaderResult.h" #include "logTileLoadResult.h" +#include #include #include #include #include +#include +#include +#include #include +#include +#include +#include +#include #include +#include +#include +#include #include +#include #include #include #include +#include #include +#include +#include #include +#include #include -#include #include -#include +#include +#include +#include +#include #include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace CesiumUtility; using namespace Cesium3DTilesContent; @@ -905,7 +938,7 @@ TilesetJsonLoader::loadTileContent(const TileLoadInput& loadInput) { ellipsoid, upAxis = _upAxis, externalContentInitializer = std::move(externalContentInitializer), - pAssetAccessor = pAssetAccessor, + pAssetAccessor, asyncSystem, requestHeaders](std::shared_ptr&& pCompletedRequest) mutable { @@ -918,7 +951,7 @@ TilesetJsonLoader::loadTileContent(const TileLoadInput& loadInput) { tileUrl); return asyncSystem.createResolvedFuture( TileLoadResult::createFailedResult( - std::move(pAssetAccessor), + pAssetAccessor, std::move(pCompletedRequest))); } @@ -931,7 +964,7 @@ TilesetJsonLoader::loadTileContent(const TileLoadInput& loadInput) { tileUrl); return asyncSystem.createResolvedFuture( TileLoadResult::createFailedResult( - std::move(pAssetAccessor), + pAssetAccessor, std::move(pCompletedRequest))); } @@ -962,12 +995,13 @@ TilesetJsonLoader::loadTileContent(const TileLoadInput& loadInput) { pLogger, upAxis, tileUrl, - pAssetAccessor = std::move(pAssetAccessor), - pCompletedRequest](GltfConverterResult&& result) { + pAssetAccessor, + pCompletedRequest = std::move(pCompletedRequest)]( + GltfConverterResult&& result) mutable { logTileLoadResult(pLogger, tileUrl, result.errors); if (result.errors) { return TileLoadResult::createFailedResult( - std::move(pAssetAccessor), + pAssetAccessor, std::move(pCompletedRequest)); } return TileLoadResult{ @@ -976,7 +1010,7 @@ TilesetJsonLoader::loadTileContent(const TileLoadInput& loadInput) { std::nullopt, std::nullopt, std::nullopt, - std::move(pAssetAccessor), + pAssetAccessor, std::move(pCompletedRequest), {}, TileLoadResultState::Success, @@ -990,7 +1024,7 @@ TilesetJsonLoader::loadTileContent(const TileLoadInput& loadInput) { upAxis, tileRefine, pLogger, - std::move(pAssetAccessor), + pAssetAccessor, std::move(pCompletedRequest), std::move(externalContentInitializer), ellipsoid)); diff --git a/Cesium3DTilesSelection/src/TilesetMetadata.cpp b/Cesium3DTilesSelection/src/TilesetMetadata.cpp index a42c76eea..236cbf6eb 100644 --- a/Cesium3DTilesSelection/src/TilesetMetadata.cpp +++ b/Cesium3DTilesSelection/src/TilesetMetadata.cpp @@ -1,10 +1,22 @@ #include #include #include +#include #include +#include #include +#include +#include #include +#include + +#include +#include +#include +#include +#include + using namespace CesiumAsync; using namespace Cesium3DTilesReader; using namespace CesiumUtility; diff --git a/Cesium3DTilesSelection/src/TilesetSharedAssetSystem.cpp b/Cesium3DTilesSelection/src/TilesetSharedAssetSystem.cpp index 10ca7454c..be569c639 100644 --- a/Cesium3DTilesSelection/src/TilesetSharedAssetSystem.cpp +++ b/Cesium3DTilesSelection/src/TilesetSharedAssetSystem.cpp @@ -1,4 +1,6 @@ #include +#include +#include using namespace Cesium3DTilesSelection; using namespace CesiumGltfReader; diff --git a/Cesium3DTilesSelection/src/ViewState.cpp b/Cesium3DTilesSelection/src/ViewState.cpp index e72a8720e..5599f538c 100644 --- a/Cesium3DTilesSelection/src/ViewState.cpp +++ b/Cesium3DTilesSelection/src/ViewState.cpp @@ -1,9 +1,23 @@ -#include "Cesium3DTilesSelection/ViewState.h" - +#include +#include +#include +#include #include - +#include +#include +#include +#include +#include +#include + +#include +#include +#include #include +#include +#include + using namespace CesiumGeometry; using namespace CesiumGeospatial; @@ -53,8 +67,9 @@ ViewState::ViewState( horizontalFieldOfView, verticalFieldOfView)) {} +namespace { template -static bool isBoundingVolumeVisible( +bool isBoundingVolumeVisible( const T& boundingVolume, const CullingVolume& cullingVolume) noexcept { const CullingResult left = @@ -83,6 +98,7 @@ static bool isBoundingVolumeVisible( return true; } +} // namespace bool ViewState::isBoundingVolumeVisible( const BoundingVolume& boundingVolume) const noexcept { diff --git a/Cesium3DTilesSelection/src/logTileLoadResult.cpp b/Cesium3DTilesSelection/src/logTileLoadResult.cpp index 68918e7a0..3da32d510 100644 --- a/Cesium3DTilesSelection/src/logTileLoadResult.cpp +++ b/Cesium3DTilesSelection/src/logTileLoadResult.cpp @@ -1,5 +1,13 @@ #include "logTileLoadResult.h" +#include + +#include +#include + +#include +#include + using namespace CesiumUtility; namespace Cesium3DTilesSelection { diff --git a/Cesium3DTilesSelection/test/MockTilesetContentManager.cpp b/Cesium3DTilesSelection/test/MockTilesetContentManager.cpp index 5f1afcc53..1c1ef913e 100644 --- a/Cesium3DTilesSelection/test/MockTilesetContentManager.cpp +++ b/Cesium3DTilesSelection/test/MockTilesetContentManager.cpp @@ -1,5 +1,7 @@ #include "MockTilesetContentManager.h" +#include + namespace Cesium3DTilesSelection { void MockTilesetContentManagerTestFixture::setTileLoadState( Cesium3DTilesSelection::Tile& tile, diff --git a/Cesium3DTilesSelection/test/SimplePrepareRendererResource.h b/Cesium3DTilesSelection/test/SimplePrepareRendererResource.h index 4c7aca67b..122e42ce5 100644 --- a/Cesium3DTilesSelection/test/SimplePrepareRendererResource.h +++ b/Cesium3DTilesSelection/test/SimplePrepareRendererResource.h @@ -1,8 +1,8 @@ #pragma once -#include "Cesium3DTilesSelection/IPrepareRendererResources.h" -#include "Cesium3DTilesSelection/Tile.h" -#include "CesiumRasterOverlays/RasterOverlayTile.h" +#include +#include +#include #include #include diff --git a/Cesium3DTilesSelection/test/TestBoundingVolume.cpp b/Cesium3DTilesSelection/test/TestBoundingVolume.cpp index fc3681468..4049f57c4 100644 --- a/Cesium3DTilesSelection/test/TestBoundingVolume.cpp +++ b/Cesium3DTilesSelection/test/TestBoundingVolume.cpp @@ -1,7 +1,13 @@ #include +#include +#include #include +#include +#include +#include +#include +#include -#include #include using namespace Cesium3DTilesSelection; diff --git a/Cesium3DTilesSelection/test/TestCreditSystem.cpp b/Cesium3DTilesSelection/test/TestCreditSystem.cpp index 478d1b7f4..1c4506174 100644 --- a/Cesium3DTilesSelection/test/TestCreditSystem.cpp +++ b/Cesium3DTilesSelection/test/TestCreditSystem.cpp @@ -1,8 +1,10 @@ -#include "CesiumUtility/CreditSystem.h" +#include -#include #include +#include +#include + using namespace CesiumUtility; TEST_CASE("Test basic credit handling") { diff --git a/Cesium3DTilesSelection/test/TestImplicitOctreeLoader.cpp b/Cesium3DTilesSelection/test/TestImplicitOctreeLoader.cpp index 5f9536659..1a1df5f92 100644 --- a/Cesium3DTilesSelection/test/TestImplicitOctreeLoader.cpp +++ b/Cesium3DTilesSelection/test/TestImplicitOctreeLoader.cpp @@ -1,10 +1,16 @@ #include "ImplicitOctreeLoader.h" +#include #include #include +#include +#include +#include +#include #include #include -#include +#include +#include #include #include #include @@ -14,8 +20,21 @@ #include #include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include using namespace Cesium3DTilesContent; using namespace Cesium3DTilesSelection; diff --git a/Cesium3DTilesSelection/test/TestImplicitQuadtreeLoader.cpp b/Cesium3DTilesSelection/test/TestImplicitQuadtreeLoader.cpp index 514d094be..6879ade15 100644 --- a/Cesium3DTilesSelection/test/TestImplicitQuadtreeLoader.cpp +++ b/Cesium3DTilesSelection/test/TestImplicitQuadtreeLoader.cpp @@ -1,10 +1,18 @@ #include "ImplicitQuadtreeLoader.h" +#include #include #include +#include +#include +#include +#include #include #include +#include #include +#include +#include #include #include #include @@ -14,8 +22,21 @@ #include #include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include using namespace Cesium3DTilesContent; using namespace Cesium3DTilesSelection; diff --git a/Cesium3DTilesSelection/test/TestLayerJsonTerrainLoader.cpp b/Cesium3DTilesSelection/test/TestLayerJsonTerrainLoader.cpp index 4319d2f61..15520cc4e 100644 --- a/Cesium3DTilesSelection/test/TestLayerJsonTerrainLoader.cpp +++ b/Cesium3DTilesSelection/test/TestLayerJsonTerrainLoader.cpp @@ -3,19 +3,40 @@ #include "SimplePrepareRendererResource.h" #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include #include #include #include #include #include +#include #include #include #include +#include +#include #include +#include +#include +#include +#include +#include +#include using namespace Cesium3DTilesSelection; using namespace CesiumGeospatial; diff --git a/Cesium3DTilesSelection/test/TestTilesetContentManager.cpp b/Cesium3DTilesSelection/test/TestTilesetContentManager.cpp index 739823692..f38c6ba00 100644 --- a/Cesium3DTilesSelection/test/TestTilesetContentManager.cpp +++ b/Cesium3DTilesSelection/test/TestTilesetContentManager.cpp @@ -6,11 +6,32 @@ #include #include #include +#include +#include #include +#include +#include +#include +#include +#include #include +#include #include +#include +#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -18,14 +39,36 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include #include -#include - +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include #include using namespace Cesium3DTilesSelection; @@ -84,8 +127,8 @@ CesiumGltf::Model createGlobeGrid( glm::dvec3 max = min; std::vector positions; - indices.reserve(6 * (width - 1) * (height - 1)); - positions.reserve(width * height); + indices.reserve(static_cast(6 * (width - 1) * (height - 1))); + positions.reserve(static_cast(width * height)); for (uint32_t y = 0; y < height; ++y) { for (uint32_t x = 0; x < width; ++x) { double longitude = beginPoint.longitude + x * dimension; diff --git a/Cesium3DTilesSelection/test/TestTilesetHeightQueries.cpp b/Cesium3DTilesSelection/test/TestTilesetHeightQueries.cpp index c5eadd700..4c7a89b88 100644 --- a/Cesium3DTilesSelection/test/TestTilesetHeightQueries.cpp +++ b/Cesium3DTilesSelection/test/TestTilesetHeightQueries.cpp @@ -1,16 +1,23 @@ #include #include +#include #include +#include +#include +#include +#include #include #include #include +#include #include #include -#include #include #include +#include +#include using namespace Cesium3DTilesContent; using namespace Cesium3DTilesSelection; diff --git a/Cesium3DTilesSelection/test/TestTilesetJsonLoader.cpp b/Cesium3DTilesSelection/test/TestTilesetJsonLoader.cpp index e0d43a2a8..437576cb9 100644 --- a/Cesium3DTilesSelection/test/TestTilesetJsonLoader.cpp +++ b/Cesium3DTilesSelection/test/TestTilesetJsonLoader.cpp @@ -2,23 +2,47 @@ #include "ImplicitQuadtreeLoader.h" #include "SimplePrepareRendererResource.h" +#include "TilesetContentLoaderResult.h" #include "TilesetJsonLoader.h" +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include #include +#include #include #include +#include +#include +#include +#include #include +#include #include +#include #include +#include #include +#include +#include +#include using namespace CesiumAsync; using namespace Cesium3DTilesSelection; diff --git a/Cesium3DTilesSelection/test/TestTilesetSelectionAlgorithm.cpp b/Cesium3DTilesSelection/test/TestTilesetSelectionAlgorithm.cpp index 5fbaabb8d..21d692e4c 100644 --- a/Cesium3DTilesSelection/test/TestTilesetSelectionAlgorithm.cpp +++ b/Cesium3DTilesSelection/test/TestTilesetSelectionAlgorithm.cpp @@ -1,10 +1,25 @@ -#include "Cesium3DTilesContent/registerAllTileContentTypes.h" -#include "Cesium3DTilesSelection/Tileset.h" -#include "Cesium3DTilesSelection/ViewState.h" #include "SimplePrepareRendererResource.h" +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include #include #include #include @@ -12,14 +27,25 @@ #include #include -#include #include -#include +#include +#include +#include +#include #include +#include #include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include using namespace CesiumAsync; using namespace Cesium3DTilesSelection; diff --git a/Cesium3DTilesWriter/include/Cesium3DTilesWriter/SchemaWriter.h b/Cesium3DTilesWriter/include/Cesium3DTilesWriter/SchemaWriter.h index 6f274edd9..60e4bbeed 100644 --- a/Cesium3DTilesWriter/include/Cesium3DTilesWriter/SchemaWriter.h +++ b/Cesium3DTilesWriter/include/Cesium3DTilesWriter/SchemaWriter.h @@ -1,7 +1,6 @@ #pragma once -#include "Cesium3DTilesWriter/Library.h" - +#include #include // forward declarations diff --git a/Cesium3DTilesWriter/include/Cesium3DTilesWriter/SubtreeWriter.h b/Cesium3DTilesWriter/include/Cesium3DTilesWriter/SubtreeWriter.h index 76a5603ee..6b9147127 100644 --- a/Cesium3DTilesWriter/include/Cesium3DTilesWriter/SubtreeWriter.h +++ b/Cesium3DTilesWriter/include/Cesium3DTilesWriter/SubtreeWriter.h @@ -1,7 +1,6 @@ #pragma once -#include "Cesium3DTilesWriter/Library.h" - +#include #include // forward declarations diff --git a/Cesium3DTilesWriter/include/Cesium3DTilesWriter/TilesetWriter.h b/Cesium3DTilesWriter/include/Cesium3DTilesWriter/TilesetWriter.h index 2ce548e3a..21468551a 100644 --- a/Cesium3DTilesWriter/include/Cesium3DTilesWriter/TilesetWriter.h +++ b/Cesium3DTilesWriter/include/Cesium3DTilesWriter/TilesetWriter.h @@ -1,7 +1,6 @@ #pragma once -#include "Cesium3DTilesWriter/Library.h" - +#include #include // forward declarations diff --git a/Cesium3DTilesWriter/src/SchemaWriter.cpp b/Cesium3DTilesWriter/src/SchemaWriter.cpp index cfeceb768..72aed6ea6 100644 --- a/Cesium3DTilesWriter/src/SchemaWriter.cpp +++ b/Cesium3DTilesWriter/src/SchemaWriter.cpp @@ -1,12 +1,13 @@ -#include "Cesium3DTilesWriter/SchemaWriter.h" - #include "TilesetJsonWriter.h" #include "registerWriterExtensions.h" +#include #include #include #include +#include + namespace Cesium3DTilesWriter { SchemaWriter::SchemaWriter() { registerWriterExtensions(this->_context); } diff --git a/Cesium3DTilesWriter/src/SubtreeWriter.cpp b/Cesium3DTilesWriter/src/SubtreeWriter.cpp index 30e939ed0..5062ee2fe 100644 --- a/Cesium3DTilesWriter/src/SubtreeWriter.cpp +++ b/Cesium3DTilesWriter/src/SubtreeWriter.cpp @@ -1,12 +1,13 @@ -#include "Cesium3DTilesWriter/SubtreeWriter.h" - #include "TilesetJsonWriter.h" #include "registerWriterExtensions.h" +#include #include #include #include +#include + namespace Cesium3DTilesWriter { SubtreeWriter::SubtreeWriter() { registerWriterExtensions(this->_context); } diff --git a/Cesium3DTilesWriter/src/TilesetWriter.cpp b/Cesium3DTilesWriter/src/TilesetWriter.cpp index 9bb9b61e5..19894c845 100644 --- a/Cesium3DTilesWriter/src/TilesetWriter.cpp +++ b/Cesium3DTilesWriter/src/TilesetWriter.cpp @@ -1,12 +1,13 @@ -#include "Cesium3DTilesWriter/TilesetWriter.h" - #include "TilesetJsonWriter.h" #include "registerWriterExtensions.h" +#include #include #include #include +#include + namespace Cesium3DTilesWriter { TilesetWriter::TilesetWriter() { registerWriterExtensions(this->_context); } diff --git a/Cesium3DTilesWriter/test/TestTilesetWriter.cpp b/Cesium3DTilesWriter/test/TestTilesetWriter.cpp index c1e777f9a..3338f6b25 100644 --- a/Cesium3DTilesWriter/test/TestTilesetWriter.cpp +++ b/Cesium3DTilesWriter/test/TestTilesetWriter.cpp @@ -1,13 +1,15 @@ -#include "Cesium3DTilesWriter/TilesetWriter.h" - -#include #include +#include -#include #include #include +#include #include +#include +#include +#include +#include namespace { void check(const std::string& input, const std::string& expectedOutput) { diff --git a/CesiumAsync/include/CesiumAsync/AsyncSystem.h b/CesiumAsync/include/CesiumAsync/AsyncSystem.h index 23bc64fd3..0f731d0aa 100644 --- a/CesiumAsync/include/CesiumAsync/AsyncSystem.h +++ b/CesiumAsync/include/CesiumAsync/AsyncSystem.h @@ -1,14 +1,14 @@ #pragma once -#include "Future.h" #include "Impl/ContinuationFutureType.h" #include "Impl/RemoveFuture.h" #include "Impl/WithTracing.h" #include "Impl/cesium-async++.h" -#include "Library.h" -#include "Promise.h" -#include "ThreadPool.h" +#include +#include +#include +#include #include #include diff --git a/CesiumAsync/include/CesiumAsync/CacheItem.h b/CesiumAsync/include/CesiumAsync/CacheItem.h index ea49fe6cd..32ab12995 100644 --- a/CesiumAsync/include/CesiumAsync/CacheItem.h +++ b/CesiumAsync/include/CesiumAsync/CacheItem.h @@ -1,7 +1,7 @@ #pragma once -#include "HttpHeaders.h" -#include "Library.h" +#include +#include #include #include diff --git a/CesiumAsync/include/CesiumAsync/CachingAssetAccessor.h b/CesiumAsync/include/CesiumAsync/CachingAssetAccessor.h index 67aa99ac4..97dba170e 100644 --- a/CesiumAsync/include/CesiumAsync/CachingAssetAccessor.h +++ b/CesiumAsync/include/CesiumAsync/CachingAssetAccessor.h @@ -1,9 +1,9 @@ #pragma once -#include "IAssetAccessor.h" -#include "IAssetRequest.h" -#include "ICacheDatabase.h" -#include "ThreadPool.h" +#include +#include +#include +#include #include diff --git a/CesiumAsync/include/CesiumAsync/Future.h b/CesiumAsync/include/CesiumAsync/Future.h index ffe4ec63c..7dd3bc4e6 100644 --- a/CesiumAsync/include/CesiumAsync/Future.h +++ b/CesiumAsync/include/CesiumAsync/Future.h @@ -4,9 +4,9 @@ #include "Impl/CatchFunction.h" #include "Impl/ContinuationFutureType.h" #include "Impl/WithTracing.h" -#include "SharedFuture.h" -#include "ThreadPool.h" +#include +#include #include #include diff --git a/CesiumAsync/include/CesiumAsync/GunzipAssetAccessor.h b/CesiumAsync/include/CesiumAsync/GunzipAssetAccessor.h index ca11bb073..160eaef89 100644 --- a/CesiumAsync/include/CesiumAsync/GunzipAssetAccessor.h +++ b/CesiumAsync/include/CesiumAsync/GunzipAssetAccessor.h @@ -1,7 +1,7 @@ #pragma once -#include "IAssetAccessor.h" -#include "IAssetRequest.h" +#include +#include namespace CesiumAsync { class AsyncSystem; diff --git a/CesiumAsync/include/CesiumAsync/IAssetAccessor.h b/CesiumAsync/include/CesiumAsync/IAssetAccessor.h index f1567d8bd..6d5683c68 100644 --- a/CesiumAsync/include/CesiumAsync/IAssetAccessor.h +++ b/CesiumAsync/include/CesiumAsync/IAssetAccessor.h @@ -1,8 +1,8 @@ #pragma once -#include "Future.h" -#include "IAssetRequest.h" -#include "Library.h" +#include +#include +#include #include #include diff --git a/CesiumAsync/include/CesiumAsync/IAssetRequest.h b/CesiumAsync/include/CesiumAsync/IAssetRequest.h index 870aa1f43..61445f8c4 100644 --- a/CesiumAsync/include/CesiumAsync/IAssetRequest.h +++ b/CesiumAsync/include/CesiumAsync/IAssetRequest.h @@ -1,7 +1,7 @@ #pragma once -#include "HttpHeaders.h" -#include "Library.h" +#include +#include #include #include diff --git a/CesiumAsync/include/CesiumAsync/IAssetResponse.h b/CesiumAsync/include/CesiumAsync/IAssetResponse.h index 1260f87a6..04d5163fe 100644 --- a/CesiumAsync/include/CesiumAsync/IAssetResponse.h +++ b/CesiumAsync/include/CesiumAsync/IAssetResponse.h @@ -1,7 +1,7 @@ #pragma once -#include "HttpHeaders.h" -#include "Library.h" +#include +#include #include #include diff --git a/CesiumAsync/include/CesiumAsync/ICacheDatabase.h b/CesiumAsync/include/CesiumAsync/ICacheDatabase.h index f90cb549d..c3cd26db6 100644 --- a/CesiumAsync/include/CesiumAsync/ICacheDatabase.h +++ b/CesiumAsync/include/CesiumAsync/ICacheDatabase.h @@ -1,8 +1,8 @@ #pragma once -#include "CacheItem.h" -#include "IAssetRequest.h" -#include "Library.h" +#include +#include +#include #include #include diff --git a/CesiumAsync/include/CesiumAsync/ITaskProcessor.h b/CesiumAsync/include/CesiumAsync/ITaskProcessor.h index 916c3ab3c..7baf121e4 100644 --- a/CesiumAsync/include/CesiumAsync/ITaskProcessor.h +++ b/CesiumAsync/include/CesiumAsync/ITaskProcessor.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include #include diff --git a/CesiumAsync/include/CesiumAsync/Promise.h b/CesiumAsync/include/CesiumAsync/Promise.h index 69b846b0d..6734ec29b 100644 --- a/CesiumAsync/include/CesiumAsync/Promise.h +++ b/CesiumAsync/include/CesiumAsync/Promise.h @@ -5,6 +5,7 @@ #include #include +#include namespace CesiumAsync { @@ -37,7 +38,7 @@ template class Promise { * @param error The error that caused the task to fail. */ template void reject(TException error) const { - this->_pEvent->set_exception(std::make_exception_ptr(error)); + this->_pEvent->set_exception(std::make_exception_ptr(std::move(error))); } /** @@ -90,7 +91,7 @@ template <> class Promise { * @param error The error that caused the task to fail. */ template void reject(TException error) const { - this->_pEvent->set_exception(std::make_exception_ptr(error)); + this->_pEvent->set_exception(std::make_exception_ptr(std::move(error))); } /** diff --git a/CesiumAsync/include/CesiumAsync/SharedAssetDepot.h b/CesiumAsync/include/CesiumAsync/SharedAssetDepot.h index 793cc3018..4d5e2a7cd 100644 --- a/CesiumAsync/include/CesiumAsync/SharedAssetDepot.h +++ b/CesiumAsync/include/CesiumAsync/SharedAssetDepot.h @@ -47,7 +47,7 @@ class CESIUMASYNC_API SharedAssetDepot * * Default is 16MiB. */ - int64_t inactiveAssetSizeLimitBytes = 16 * 1024 * 1024; + int64_t inactiveAssetSizeLimitBytes = static_cast(16 * 1024 * 1024); /** * @brief Signature for the callback function that will be called to fetch and @@ -119,12 +119,12 @@ class CESIUMASYNC_API SharedAssetDepot */ int64_t getInactiveAssetTotalSizeBytes() const; -private: - struct LockHolder; - // Disable copy void operator=(const SharedAssetDepot& other) = delete; +private: + struct LockHolder; + /** * @brief Locks the shared asset depot for thread-safe access. It will remain * locked until the returned object is destroyed or the `unlock` method is diff --git a/CesiumAsync/include/CesiumAsync/SharedFuture.h b/CesiumAsync/include/CesiumAsync/SharedFuture.h index 530bfe9fa..e7b3cc36b 100644 --- a/CesiumAsync/include/CesiumAsync/SharedFuture.h +++ b/CesiumAsync/include/CesiumAsync/SharedFuture.h @@ -4,8 +4,8 @@ #include "Impl/CatchFunction.h" #include "Impl/ContinuationFutureType.h" #include "Impl/WithTracing.h" -#include "ThreadPool.h" +#include #include #include diff --git a/CesiumAsync/include/CesiumAsync/SqliteCache.h b/CesiumAsync/include/CesiumAsync/SqliteCache.h index 5b3116164..0182f4aa9 100644 --- a/CesiumAsync/include/CesiumAsync/SqliteCache.h +++ b/CesiumAsync/include/CesiumAsync/SqliteCache.h @@ -1,6 +1,6 @@ #pragma once -#include "ICacheDatabase.h" +#include #include diff --git a/CesiumAsync/include/CesiumAsync/SqliteHelper.h b/CesiumAsync/include/CesiumAsync/SqliteHelper.h index bfc40b69d..adbd91c35 100644 --- a/CesiumAsync/include/CesiumAsync/SqliteHelper.h +++ b/CesiumAsync/include/CesiumAsync/SqliteHelper.h @@ -1,6 +1,6 @@ #pragma once -#include "cesium-sqlite3.h" +#include #include #include diff --git a/CesiumAsync/include/CesiumAsync/ThreadPool.h b/CesiumAsync/include/CesiumAsync/ThreadPool.h index ecccbc025..3aac7cee4 100644 --- a/CesiumAsync/include/CesiumAsync/ThreadPool.h +++ b/CesiumAsync/include/CesiumAsync/ThreadPool.h @@ -2,7 +2,8 @@ #include "Impl/ImmediateScheduler.h" #include "Impl/cesium-async++.h" -#include "Library.h" + +#include #include diff --git a/CesiumAsync/src/AsyncSystem.cpp b/CesiumAsync/src/AsyncSystem.cpp index 551d200f5..632c64bcd 100644 --- a/CesiumAsync/src/AsyncSystem.cpp +++ b/CesiumAsync/src/AsyncSystem.cpp @@ -1,6 +1,11 @@ -#include "CesiumAsync/AsyncSystem.h" +#include "CesiumAsync/Impl/AsyncSystemSchedulers.h" -#include "CesiumAsync/ITaskProcessor.h" +#include +#include +#include + +#include +#include namespace CesiumAsync { AsyncSystem::AsyncSystem( diff --git a/CesiumAsync/src/CachingAssetAccessor.cpp b/CesiumAsync/src/CachingAssetAccessor.cpp index 3fb18197f..2efe97b9c 100644 --- a/CesiumAsync/src/CachingAssetAccessor.cpp +++ b/CesiumAsync/src/CachingAssetAccessor.cpp @@ -1,17 +1,29 @@ -#include "CesiumAsync/CachingAssetAccessor.h" - -#include "CesiumAsync/AsyncSystem.h" -#include "CesiumAsync/CacheItem.h" -#include "CesiumAsync/IAssetResponse.h" #include "InternalTimegm.h" #include "ResponseCacheControl.h" -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include -#include #include +#include +#include #include +#include +#include +#include +#include #include +#include +#include +#include namespace CesiumAsync { class CacheAssetResponse : public IAssetResponse { @@ -79,28 +91,32 @@ class CacheAssetRequest : public IAssetRequest { CacheAssetResponse _response; }; -static std::time_t convertHttpDateToTime(const std::string& httpDate); +namespace { + +std::time_t convertHttpDateToTime(const std::string& httpDate); -static bool shouldRevalidateCache(const CacheItem& cacheItem); +bool shouldRevalidateCache(const CacheItem& cacheItem); -static bool isCacheStale(const CacheItem& cacheItem) noexcept; +bool isCacheStale(const CacheItem& cacheItem) noexcept; -static bool shouldCacheRequest( +bool shouldCacheRequest( const IAssetRequest& request, const std::optional& cacheControl); -static std::string calculateCacheKey(const IAssetRequest& request); +std::string calculateCacheKey(const IAssetRequest& request); -static std::time_t calculateExpiryTime( +std::time_t calculateExpiryTime( const IAssetRequest& request, const std::optional& cacheControl); -static std::shared_ptr updateCacheItem( +std::shared_ptr updateCacheItem( std::string&& url, std::vector&& headers, CacheItem&& cacheItem, const IAssetRequest& request); +} // namespace + CachingAssetAccessor::CachingAssetAccessor( const std::shared_ptr& pLogger, const std::shared_ptr& pAssetAccessor, @@ -113,7 +129,7 @@ CachingAssetAccessor::CachingAssetAccessor( _pCacheDatabase(pCacheDatabase), _cacheThreadPool(1) {} -CachingAssetAccessor::~CachingAssetAccessor() noexcept {} +CachingAssetAccessor::~CachingAssetAccessor() noexcept = default; Future> CachingAssetAccessor::get( const AsyncSystem& asyncSystem, @@ -286,6 +302,8 @@ Future> CachingAssetAccessor::request( void CachingAssetAccessor::tick() noexcept { _pAssetAccessor->tick(); } +namespace { + bool shouldRevalidateCache(const CacheItem& cacheItem) { std::optional cacheControl = ResponseCacheControl::parseFromResponseHeaders( @@ -445,4 +463,7 @@ std::time_t convertHttpDateToTime(const std::string& httpDate) { ss >> std::get_time(&tm, "%a, %d %b %Y %H:%M:%S"); return internalTimegm(&tm); } + +} // namespace + } // namespace CesiumAsync diff --git a/CesiumAsync/src/GunzipAssetAccessor.cpp b/CesiumAsync/src/GunzipAssetAccessor.cpp index 3fbb0eda7..5bac154f4 100644 --- a/CesiumAsync/src/GunzipAssetAccessor.cpp +++ b/CesiumAsync/src/GunzipAssetAccessor.cpp @@ -1,8 +1,18 @@ -#include "CesiumAsync/GunzipAssetAccessor.h" - -#include "CesiumAsync/AsyncSystem.h" -#include "CesiumAsync/IAssetResponse.h" -#include "CesiumUtility/Gzip.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include namespace CesiumAsync { @@ -44,7 +54,7 @@ class GunzippedAssetRequest : public IAssetRequest { public: GunzippedAssetRequest(std::shared_ptr&& pOther) : _pAssetRequest(std::move(pOther)), - _AssetResponse(_pAssetRequest->response()){}; + _assetResponse(_pAssetRequest->response()){}; virtual const std::string& method() const noexcept override { return this->_pAssetRequest->method(); } @@ -58,12 +68,12 @@ class GunzippedAssetRequest : public IAssetRequest { } virtual const IAssetResponse* response() const noexcept override { - return &this->_AssetResponse; + return &this->_assetResponse; } private: std::shared_ptr _pAssetRequest; - GunzippedAssetResponse _AssetResponse; + GunzippedAssetResponse _assetResponse; }; Future> gunzipIfNeeded( @@ -87,7 +97,7 @@ GunzipAssetAccessor::GunzipAssetAccessor( const std::shared_ptr& pAssetAccessor) : _pAssetAccessor(pAssetAccessor) {} -GunzipAssetAccessor::~GunzipAssetAccessor() noexcept {} +GunzipAssetAccessor::~GunzipAssetAccessor() noexcept = default; Future> GunzipAssetAccessor::get( const AsyncSystem& asyncSystem, diff --git a/CesiumAsync/src/HttpHeaders.cpp b/CesiumAsync/src/HttpHeaders.cpp index 7c01e3082..687564ea4 100644 --- a/CesiumAsync/src/HttpHeaders.cpp +++ b/CesiumAsync/src/HttpHeaders.cpp @@ -1,6 +1,8 @@ -#include "CesiumAsync/HttpHeaders.h" +#include #include +#include +#include namespace CesiumAsync { struct NocaseCompare { diff --git a/CesiumAsync/src/InternalTimegm.cpp b/CesiumAsync/src/InternalTimegm.cpp index b86b6e361..e2324e2f8 100644 --- a/CesiumAsync/src/InternalTimegm.cpp +++ b/CesiumAsync/src/InternalTimegm.cpp @@ -6,39 +6,11 @@ #include "InternalTimegm.h" #include +#include namespace CesiumAsync { -static int32_t isLeap(int32_t year); - -static int32_t daysFrom0(int32_t year); - -static int32_t daysFrom1970(int32_t year); - -static int32_t daysFrom1jan(int32_t year, int32_t month, int32_t day); - -time_t internalTimegm(std::tm const* t) { - int year = t->tm_year + 1900; - int month = t->tm_mon; - if (month > 11) { - year += month / 12; - month %= 12; - } else if (month < 0) { - const int years_diff = (-month + 11) / 12; - year -= years_diff; - month += 12 * years_diff; - } - month++; - const int day = t->tm_mday; - const int day_of_year = daysFrom1jan(year, month, day); - const int days_since_epoch = daysFrom1970(year) + day_of_year; - - const time_t seconds_in_day = 3600 * 24; - const time_t result = seconds_in_day * days_since_epoch + 3600 * t->tm_hour + - 60 * t->tm_min + t->tm_sec; - - return result; -} +namespace { int32_t isLeap(int32_t year) { if (year % 400 == 0) return 1; @@ -66,5 +38,31 @@ int32_t daysFrom1jan(int32_t year, int32_t month, int32_t day) { return days[isLeap(year)][month - 1] + day - 1; } +} // namespace + +time_t internalTimegm(std::tm const* t) { + int year = t->tm_year + 1900; + int month = t->tm_mon; + if (month > 11) { + year += month / 12; + month %= 12; + } else if (month < 0) { + const int years_diff = (-month + 11) / 12; + year -= years_diff; + month += 12 * years_diff; + } + month++; + const int day = t->tm_mday; + const int day_of_year = daysFrom1jan(year, month, day); + const time_t days_since_epoch = + static_cast(daysFrom1970(year) + day_of_year); + + const time_t seconds_in_day = static_cast(3600 * 24); + const time_t result = + seconds_in_day * days_since_epoch + + static_cast(3600 * t->tm_hour + 60 * t->tm_min + t->tm_sec); + + return result; +} } // namespace CesiumAsync diff --git a/CesiumAsync/src/NetworkAssetDescriptor.cpp b/CesiumAsync/src/NetworkAssetDescriptor.cpp index e0e62edae..948de00a5 100644 --- a/CesiumAsync/src/NetworkAssetDescriptor.cpp +++ b/CesiumAsync/src/NetworkAssetDescriptor.cpp @@ -1,6 +1,20 @@ +#include +#include +#include #include #include +#include #include +#include + +#include + +#include +#include +#include +#include +#include +#include using namespace CesiumUtility; diff --git a/CesiumAsync/src/QueuedScheduler.cpp b/CesiumAsync/src/QueuedScheduler.cpp index 0c00e4244..95ba5f6c7 100644 --- a/CesiumAsync/src/QueuedScheduler.cpp +++ b/CesiumAsync/src/QueuedScheduler.cpp @@ -1,7 +1,12 @@ #include "CesiumAsync/Impl/QueuedScheduler.h" +#include + #include +#include +#include #include +#include namespace { diff --git a/CesiumAsync/src/ResponseCacheControl.cpp b/CesiumAsync/src/ResponseCacheControl.cpp index 50d1dca42..01c0e88fb 100644 --- a/CesiumAsync/src/ResponseCacheControl.cpp +++ b/CesiumAsync/src/ResponseCacheControl.cpp @@ -1,10 +1,33 @@ #include "ResponseCacheControl.h" +#include + +#include #include +#include #include +#include namespace CesiumAsync { -static std::string trimSpace(const std::string& str); +namespace { +std::string trimSpace(const std::string& str) { + if (str.empty()) { + return ""; + } + + size_t begin = 0; + while (str[begin] == ' ') { + ++begin; + } + + size_t end = str.size() - 1; + while (str[end] == ' ') { + --end; + } + + return str.substr(begin, end - begin + 1); +} +} // namespace ResponseCacheControl::ResponseCacheControl( bool mustRevalidate, @@ -105,22 +128,4 @@ ResponseCacheControl::parseFromResponseHeaders(const HttpHeaders& headers) { sharedMaxAge, staleWhileRevalidate); } - -std::string trimSpace(const std::string& str) { - if (str.empty()) { - return ""; - } - - size_t begin = 0; - while (str[begin] == ' ') { - ++begin; - } - - size_t end = str.size() - 1; - while (str[end] == ' ') { - --end; - } - - return str.substr(begin, end - begin + 1); -} } // namespace CesiumAsync diff --git a/CesiumAsync/src/ResponseCacheControl.h b/CesiumAsync/src/ResponseCacheControl.h index bad12963d..f31345f98 100644 --- a/CesiumAsync/src/ResponseCacheControl.h +++ b/CesiumAsync/src/ResponseCacheControl.h @@ -1,7 +1,8 @@ #pragma once -#include "CesiumAsync/HttpHeaders.h" -#include "CesiumAsync/Library.h" +#include +#include +#include #include #include @@ -91,7 +92,10 @@ class ResponseCacheControl { /** * @brief Value of Max-Age directive that appears in the Cache-Control header. */ - int maxAgeValue() const noexcept { return *_maxAge; } + int maxAgeValue() const noexcept { + CESIUM_ASSERT(_maxAge.has_value()); + return *_maxAge; + } /** * @brief Existence of S-Maxage directive that appears in the Cache-Control @@ -103,7 +107,10 @@ class ResponseCacheControl { * @brief Value of S-Maxage directive that appears in the Cache-Control * header. */ - int sharedMaxAgeValue() const noexcept { return *_sharedMaxAge; } + int sharedMaxAgeValue() const noexcept { + CESIUM_ASSERT(_sharedMaxAge.has_value()); + return *_sharedMaxAge; + } /** * @brief Existence of Stale-While-Revalidate directive that appears in the @@ -118,6 +125,7 @@ class ResponseCacheControl { * Cache-Control header. */ int staleWhileRevalidateValue() const noexcept { + CESIUM_ASSERT(_staleWhileRevalidate.has_value()); return *_staleWhileRevalidate; } diff --git a/CesiumAsync/src/SqliteCache.cpp b/CesiumAsync/src/SqliteCache.cpp index b5e858e64..a3f1679ad 100644 --- a/CesiumAsync/src/SqliteCache.cpp +++ b/CesiumAsync/src/SqliteCache.cpp @@ -1,17 +1,30 @@ -#include +#include +#include #include #include #include #include #include +#include +#include #include +#include #include #include #include +#include +#include +#include +#include +#include +#include +#include #include +#include #include +#include using namespace CesiumAsync; @@ -758,7 +771,7 @@ void SqliteCache::destroyDatabase() { uint64_t maxItems = _pImpl->_maxItems; _pImpl.reset(); _pImpl = std::make_unique(pLogger, databaseName, maxItems); - if (remove(_pImpl->_databaseName.c_str()) != 0) { + if (std::remove(_pImpl->_databaseName.c_str()) != 0) { SPDLOG_LOGGER_ERROR( this->_pImpl->_pLogger, "Unable to delete database file."); diff --git a/CesiumAsync/src/SqliteHelper.cpp b/CesiumAsync/src/SqliteHelper.cpp index fd48bda1a..a845e9c9e 100644 --- a/CesiumAsync/src/SqliteHelper.cpp +++ b/CesiumAsync/src/SqliteHelper.cpp @@ -1,8 +1,10 @@ #include +#include #include #include +#include namespace CesiumAsync { diff --git a/CesiumAsync/src/TaskScheduler.cpp b/CesiumAsync/src/TaskScheduler.cpp index 65daa2652..46912c46d 100644 --- a/CesiumAsync/src/TaskScheduler.cpp +++ b/CesiumAsync/src/TaskScheduler.cpp @@ -1,5 +1,12 @@ #include "CesiumAsync/Impl/TaskScheduler.h" +#include + +#include + +#include +#include + using namespace CesiumAsync::CesiumImpl; TaskScheduler::TaskScheduler( diff --git a/CesiumAsync/src/ThreadPool.cpp b/CesiumAsync/src/ThreadPool.cpp index 8510597e5..69d8302c6 100644 --- a/CesiumAsync/src/ThreadPool.cpp +++ b/CesiumAsync/src/ThreadPool.cpp @@ -1,4 +1,13 @@ -#include "CesiumAsync/ThreadPool.h" +#include "CesiumAsync/Impl/ImmediateScheduler.h" + +#include + +#include + +#include +#include +#include +#include using namespace CesiumAsync; diff --git a/CesiumAsync/test/ExamplesAsyncSystem.cpp b/CesiumAsync/test/ExamplesAsyncSystem.cpp index c0356df59..20026afe1 100644 --- a/CesiumAsync/test/ExamplesAsyncSystem.cpp +++ b/CesiumAsync/test/ExamplesAsyncSystem.cpp @@ -1,14 +1,30 @@ #include +#include #include +#include +#include #include +#include #include #include +#include +#include -#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include #include +#include +#include +#include using namespace CesiumNativeTests; diff --git a/CesiumAsync/test/MockAssetRequest.h b/CesiumAsync/test/MockAssetRequest.h index 50464a427..1a46a0da7 100644 --- a/CesiumAsync/test/MockAssetRequest.h +++ b/CesiumAsync/test/MockAssetRequest.h @@ -1,9 +1,10 @@ #pragma once -#include "CesiumAsync/HttpHeaders.h" -#include "CesiumAsync/IAssetRequest.h" -#include "CesiumAsync/IAssetResponse.h" +#include +#include +#include +#include #include class MockAssetRequest : public CesiumAsync::IAssetRequest { diff --git a/CesiumAsync/test/MockAssetResponse.h b/CesiumAsync/test/MockAssetResponse.h index bd61af846..169cff37d 100644 --- a/CesiumAsync/test/MockAssetResponse.h +++ b/CesiumAsync/test/MockAssetResponse.h @@ -1,6 +1,6 @@ #pragma once -#include "CesiumAsync/IAssetResponse.h" +#include #include #include diff --git a/CesiumAsync/test/TestAsyncSystem.cpp b/CesiumAsync/test/TestAsyncSystem.cpp index a253d1593..017e0b72d 100644 --- a/CesiumAsync/test/TestAsyncSystem.cpp +++ b/CesiumAsync/test/TestAsyncSystem.cpp @@ -1,11 +1,21 @@ -#include "CesiumAsync/AsyncSystem.h" +#include +#include +#include +#include -#include #include +#include -#include +#include +#include +#include +#include #include +#include #include +#include +#include +#include using namespace CesiumAsync; diff --git a/CesiumAsync/test/TestCacheAssetAccessor.cpp b/CesiumAsync/test/TestCacheAssetAccessor.cpp index e01c51d53..f0d7957db 100644 --- a/CesiumAsync/test/TestCacheAssetAccessor.cpp +++ b/CesiumAsync/test/TestCacheAssetAccessor.cpp @@ -1,19 +1,31 @@ -#include "CesiumAsync/AsyncSystem.h" -#include "CesiumAsync/CachingAssetAccessor.h" -#include "CesiumAsync/ICacheDatabase.h" -#include "CesiumAsync/ITaskProcessor.h" #include "MockAssetAccessor.h" #include "MockAssetRequest.h" #include "MockAssetResponse.h" #include "MockTaskProcessor.h" #include "ResponseCacheControl.h" -#include +#include +#include +#include +#include +#include +#include +#include +#include + #include +#include #include #include +#include +#include +#include #include +#include +#include +#include +#include using namespace CesiumAsync; diff --git a/CesiumAsync/test/TestDiskCache.cpp b/CesiumAsync/test/TestDiskCache.cpp index c579cc74f..43409389c 100644 --- a/CesiumAsync/test/TestDiskCache.cpp +++ b/CesiumAsync/test/TestDiskCache.cpp @@ -1,13 +1,22 @@ -#include "CesiumAsync/SqliteCache.h" #include "MockAssetRequest.h" #include "MockAssetResponse.h" #include "ResponseCacheControl.h" -#include +#include +#include +#include + #include #include #include +#include +#include +#include +#include +#include +#include +#include using namespace CesiumAsync; diff --git a/CesiumAsync/test/TestGunzipAssetAccessor.cpp b/CesiumAsync/test/TestGunzipAssetAccessor.cpp index 7227f9b17..e96ab0a8c 100644 --- a/CesiumAsync/test/TestGunzipAssetAccessor.cpp +++ b/CesiumAsync/test/TestGunzipAssetAccessor.cpp @@ -4,10 +4,16 @@ #include "MockTaskProcessor.h" #include +#include -#include #include +#include +#include +#include +#include +#include + using namespace CesiumAsync; namespace { diff --git a/CesiumAsync/test/TestInternalTimegm.cpp b/CesiumAsync/test/TestInternalTimegm.cpp index 674c9fa86..cd8910d80 100644 --- a/CesiumAsync/test/TestInternalTimegm.cpp +++ b/CesiumAsync/test/TestInternalTimegm.cpp @@ -1,9 +1,10 @@ #define _CRT_SECURE_NO_WARNINGS #include "InternalTimegm.h" -#include #include +#include + using namespace CesiumAsync; TEST_CASE("Test custom timegm() method") { diff --git a/CesiumAsync/test/TestResponseCacheControl.cpp b/CesiumAsync/test/TestResponseCacheControl.cpp index 1a421c7e2..7a8b1e6b0 100644 --- a/CesiumAsync/test/TestResponseCacheControl.cpp +++ b/CesiumAsync/test/TestResponseCacheControl.cpp @@ -1,8 +1,11 @@ #include "ResponseCacheControl.h" -#include +#include + #include +#include + using namespace CesiumAsync; TEST_CASE("Test parsing cache-control header") { diff --git a/CesiumAsync/test/TestSharedAssetDepot.cpp b/CesiumAsync/test/TestSharedAssetDepot.cpp index 2a5eccb0f..058a28d08 100644 --- a/CesiumAsync/test/TestSharedAssetDepot.cpp +++ b/CesiumAsync/test/TestSharedAssetDepot.cpp @@ -1,11 +1,17 @@ +#include +#include #include -#include #include +#include +#include #include -#include #include +#include +#include +#include + using namespace CesiumAsync; using namespace CesiumNativeTests; using namespace CesiumUtility; diff --git a/CesiumGeometry/include/CesiumGeometry/Availability.h b/CesiumGeometry/include/CesiumGeometry/Availability.h index 2db058519..b8f595d2c 100644 --- a/CesiumGeometry/include/CesiumGeometry/Availability.h +++ b/CesiumGeometry/include/CesiumGeometry/Availability.h @@ -1,6 +1,7 @@ #pragma once -#include "Library.h" +#include +#include #include #include @@ -182,6 +183,7 @@ class CESIUMGEOMETRY_API AvailabilityAccessor { * specified by the \ref SubtreeBufferView. */ const std::span& getBufferAccessor() const { + CESIUM_ASSERT(bufferAccessor.has_value()); return *bufferAccessor; } @@ -193,6 +195,7 @@ class CESIUMGEOMETRY_API AvailabilityAccessor { * @returns The byte at the given index of the buffer accessor. */ const std::byte& operator[](size_t i) const { + CESIUM_ASSERT(bufferAccessor.has_value()); return bufferAccessor.value()[i]; } diff --git a/CesiumGeometry/include/CesiumGeometry/Axis.h b/CesiumGeometry/include/CesiumGeometry/Axis.h index dd7cdd3c3..eba189dce 100644 --- a/CesiumGeometry/include/CesiumGeometry/Axis.h +++ b/CesiumGeometry/include/CesiumGeometry/Axis.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include namespace CesiumGeometry { diff --git a/CesiumGeometry/include/CesiumGeometry/AxisAlignedBox.h b/CesiumGeometry/include/CesiumGeometry/AxisAlignedBox.h index 54a1e1eb3..87bd159f9 100644 --- a/CesiumGeometry/include/CesiumGeometry/AxisAlignedBox.h +++ b/CesiumGeometry/include/CesiumGeometry/AxisAlignedBox.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include #include diff --git a/CesiumGeometry/include/CesiumGeometry/BoundingSphere.h b/CesiumGeometry/include/CesiumGeometry/BoundingSphere.h index 852f49694..546b8f96d 100644 --- a/CesiumGeometry/include/CesiumGeometry/BoundingSphere.h +++ b/CesiumGeometry/include/CesiumGeometry/BoundingSphere.h @@ -1,7 +1,7 @@ #pragma once -#include "CullingResult.h" -#include "Library.h" +#include +#include #include #include diff --git a/CesiumGeometry/include/CesiumGeometry/CullingResult.h b/CesiumGeometry/include/CesiumGeometry/CullingResult.h index 4def30310..a0409cde2 100644 --- a/CesiumGeometry/include/CesiumGeometry/CullingResult.h +++ b/CesiumGeometry/include/CesiumGeometry/CullingResult.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include namespace CesiumGeometry { diff --git a/CesiumGeometry/include/CesiumGeometry/CullingVolume.h b/CesiumGeometry/include/CesiumGeometry/CullingVolume.h index 7bf5717ca..de0be1382 100644 --- a/CesiumGeometry/include/CesiumGeometry/CullingVolume.h +++ b/CesiumGeometry/include/CesiumGeometry/CullingVolume.h @@ -1,6 +1,6 @@ #pragma once -#include "Plane.h" +#include namespace Cesium3DTilesSelection { diff --git a/CesiumGeometry/include/CesiumGeometry/IntersectionTests.h b/CesiumGeometry/include/CesiumGeometry/IntersectionTests.h index 635b7aade..f22c00e49 100644 --- a/CesiumGeometry/include/CesiumGeometry/IntersectionTests.h +++ b/CesiumGeometry/include/CesiumGeometry/IntersectionTests.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include #include #include diff --git a/CesiumGeometry/include/CesiumGeometry/OctreeAvailability.h b/CesiumGeometry/include/CesiumGeometry/OctreeAvailability.h index 7f2a17bca..f25367c3a 100644 --- a/CesiumGeometry/include/CesiumGeometry/OctreeAvailability.h +++ b/CesiumGeometry/include/CesiumGeometry/OctreeAvailability.h @@ -1,9 +1,9 @@ #pragma once -#include "Availability.h" -#include "Library.h" -#include "OctreeTileID.h" -#include "TileAvailabilityFlags.h" +#include +#include +#include +#include #include #include diff --git a/CesiumGeometry/include/CesiumGeometry/OctreeTileID.h b/CesiumGeometry/include/CesiumGeometry/OctreeTileID.h index 7d52cc984..142e9a7a4 100644 --- a/CesiumGeometry/include/CesiumGeometry/OctreeTileID.h +++ b/CesiumGeometry/include/CesiumGeometry/OctreeTileID.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include #include diff --git a/CesiumGeometry/include/CesiumGeometry/OctreeTilingScheme.h b/CesiumGeometry/include/CesiumGeometry/OctreeTilingScheme.h index 047498a28..7c98a2ab1 100644 --- a/CesiumGeometry/include/CesiumGeometry/OctreeTilingScheme.h +++ b/CesiumGeometry/include/CesiumGeometry/OctreeTilingScheme.h @@ -1,8 +1,8 @@ #pragma once -#include "CesiumGeometry/AxisAlignedBox.h" -#include "CesiumGeometry/Library.h" -#include "CesiumGeometry/OctreeTileID.h" +#include +#include +#include #include diff --git a/CesiumGeometry/include/CesiumGeometry/OrientedBoundingBox.h b/CesiumGeometry/include/CesiumGeometry/OrientedBoundingBox.h index 983d06ba4..de8a8ddae 100644 --- a/CesiumGeometry/include/CesiumGeometry/OrientedBoundingBox.h +++ b/CesiumGeometry/include/CesiumGeometry/OrientedBoundingBox.h @@ -1,9 +1,9 @@ #pragma once -#include "AxisAlignedBox.h" -#include "BoundingSphere.h" -#include "CullingResult.h" -#include "Library.h" +#include +#include +#include +#include #include #include diff --git a/CesiumGeometry/include/CesiumGeometry/Plane.h b/CesiumGeometry/include/CesiumGeometry/Plane.h index 0fef46c6e..3f1e18205 100644 --- a/CesiumGeometry/include/CesiumGeometry/Plane.h +++ b/CesiumGeometry/include/CesiumGeometry/Plane.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include #include diff --git a/CesiumGeometry/include/CesiumGeometry/QuadtreeAvailability.h b/CesiumGeometry/include/CesiumGeometry/QuadtreeAvailability.h index f47dfde35..b095f3eee 100644 --- a/CesiumGeometry/include/CesiumGeometry/QuadtreeAvailability.h +++ b/CesiumGeometry/include/CesiumGeometry/QuadtreeAvailability.h @@ -1,9 +1,9 @@ #pragma once -#include "Availability.h" -#include "Library.h" -#include "QuadtreeTileID.h" -#include "TileAvailabilityFlags.h" +#include +#include +#include +#include #include #include diff --git a/CesiumGeometry/include/CesiumGeometry/QuadtreeRectangleAvailability.h b/CesiumGeometry/include/CesiumGeometry/QuadtreeRectangleAvailability.h index 7713b56ab..103ae067a 100644 --- a/CesiumGeometry/include/CesiumGeometry/QuadtreeRectangleAvailability.h +++ b/CesiumGeometry/include/CesiumGeometry/QuadtreeRectangleAvailability.h @@ -1,9 +1,9 @@ #pragma once -#include "Library.h" -#include "QuadtreeTileRectangularRange.h" -#include "QuadtreeTilingScheme.h" -#include "Rectangle.h" +#include +#include +#include +#include #include diff --git a/CesiumGeometry/include/CesiumGeometry/QuadtreeTileID.h b/CesiumGeometry/include/CesiumGeometry/QuadtreeTileID.h index 9d1ebad2d..fa8117624 100644 --- a/CesiumGeometry/include/CesiumGeometry/QuadtreeTileID.h +++ b/CesiumGeometry/include/CesiumGeometry/QuadtreeTileID.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include #include #include diff --git a/CesiumGeometry/include/CesiumGeometry/QuadtreeTilingScheme.h b/CesiumGeometry/include/CesiumGeometry/QuadtreeTilingScheme.h index 545177ea0..d097c4144 100644 --- a/CesiumGeometry/include/CesiumGeometry/QuadtreeTilingScheme.h +++ b/CesiumGeometry/include/CesiumGeometry/QuadtreeTilingScheme.h @@ -1,8 +1,8 @@ #pragma once -#include "Library.h" -#include "QuadtreeTileID.h" -#include "Rectangle.h" +#include +#include +#include #include diff --git a/CesiumGeometry/include/CesiumGeometry/Ray.h b/CesiumGeometry/include/CesiumGeometry/Ray.h index 9bcadd6ed..1d5f82d21 100644 --- a/CesiumGeometry/include/CesiumGeometry/Ray.h +++ b/CesiumGeometry/include/CesiumGeometry/Ray.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include #include #include diff --git a/CesiumGeometry/include/CesiumGeometry/Rectangle.h b/CesiumGeometry/include/CesiumGeometry/Rectangle.h index 7c9ef80e5..46a47318d 100644 --- a/CesiumGeometry/include/CesiumGeometry/Rectangle.h +++ b/CesiumGeometry/include/CesiumGeometry/Rectangle.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include #include diff --git a/CesiumGeometry/include/CesiumGeometry/TileAvailabilityFlags.h b/CesiumGeometry/include/CesiumGeometry/TileAvailabilityFlags.h index 86b1de32f..c46f5fe9b 100644 --- a/CesiumGeometry/include/CesiumGeometry/TileAvailabilityFlags.h +++ b/CesiumGeometry/include/CesiumGeometry/TileAvailabilityFlags.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include #include diff --git a/CesiumGeometry/include/CesiumGeometry/Transforms.h b/CesiumGeometry/include/CesiumGeometry/Transforms.h index 8a7870bfb..9e1c6fee1 100644 --- a/CesiumGeometry/include/CesiumGeometry/Transforms.h +++ b/CesiumGeometry/include/CesiumGeometry/Transforms.h @@ -1,7 +1,7 @@ #pragma once -#include "Axis.h" -#include "Library.h" +#include +#include #include diff --git a/CesiumGeometry/src/Availability.cpp b/CesiumGeometry/src/Availability.cpp index a27c389c5..a1f056db9 100644 --- a/CesiumGeometry/src/Availability.cpp +++ b/CesiumGeometry/src/Availability.cpp @@ -1,5 +1,13 @@ -#include "CesiumGeometry/Availability.h" +#include + +#include +#include +#include +#include +#include +#include +#include namespace CesiumGeometry { @@ -57,10 +65,9 @@ void AvailabilityNode::setLoadedSubtree( AvailabilityAccessor::AvailabilityAccessor( const AvailabilityView& view, - const AvailabilitySubtree& subtree) noexcept { - this->pBufferView = std::get_if(&view); - this->pConstant = std::get_if(&view); - + const AvailabilitySubtree& subtree) noexcept + : pBufferView(std::get_if(&view)), + pConstant(std::get_if(&view)) { if (this->pBufferView) { if (this->pBufferView->buffer < subtree.buffers.size()) { const std::vector& buffer = diff --git a/CesiumGeometry/src/BoundingSphere.cpp b/CesiumGeometry/src/BoundingSphere.cpp index 49ec11bb1..c83faf49f 100644 --- a/CesiumGeometry/src/BoundingSphere.cpp +++ b/CesiumGeometry/src/BoundingSphere.cpp @@ -1,9 +1,11 @@ -#include "CesiumGeometry/BoundingSphere.h" - -#include "CesiumGeometry/Plane.h" +#include +#include +#include +#include +#include +#include #include -#include namespace CesiumGeometry { diff --git a/CesiumGeometry/src/CullingVolume.cpp b/CesiumGeometry/src/CullingVolume.cpp index b6d1c782a..d6e41b2f5 100644 --- a/CesiumGeometry/src/CullingVolume.cpp +++ b/CesiumGeometry/src/CullingVolume.cpp @@ -1,8 +1,9 @@ -#include "CesiumGeometry/CullingVolume.h" +#include +#include -#include +#include +#include #include -#include namespace Cesium3DTilesSelection { diff --git a/CesiumGeometry/src/IntersectionTests.cpp b/CesiumGeometry/src/IntersectionTests.cpp index ea7fe47f2..ed6549bef 100644 --- a/CesiumGeometry/src/IntersectionTests.cpp +++ b/CesiumGeometry/src/IntersectionTests.cpp @@ -1,19 +1,25 @@ -#include "CesiumGeometry/IntersectionTests.h" - -#include "CesiumGeometry/AxisAlignedBox.h" -#include "CesiumGeometry/BoundingSphere.h" -#include "CesiumGeometry/OrientedBoundingBox.h" -#include "CesiumGeometry/Plane.h" -#include "CesiumGeometry/Ray.h" - +#include +#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include #include -#include #include +#include +#include +#include #include +#include +#include using namespace CesiumUtility; diff --git a/CesiumGeometry/src/OctreeAvailability.cpp b/CesiumGeometry/src/OctreeAvailability.cpp index fdecf628d..33b62fab4 100644 --- a/CesiumGeometry/src/OctreeAvailability.cpp +++ b/CesiumGeometry/src/OctreeAvailability.cpp @@ -1,16 +1,26 @@ -#include "CesiumGeometry/OctreeAvailability.h" - -#include "CesiumUtility/Assert.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include namespace CesiumGeometry { +namespace { /** * @brief Inserts two 0 bits of spacing between a number's bits. * * @param i A 10-bit unsigned int. * @return A 32-bit unsigned int. */ -static uint32_t spread3(uint32_t i) { +uint32_t spread3(uint32_t i) { i = (i ^ (i << 16)) & 0x030000ff; i = (i ^ (i << 8)) & 0x0300f00f; i = (i ^ (i << 4)) & 0x030c30c3; @@ -28,9 +38,10 @@ static uint32_t spread3(uint32_t i) { * @param z An unsigned 10-bit number to put in places 2, 5, 8, etc. * @return The 32-bit unsigned morton index. */ -static uint32_t getMortonIndex(uint32_t x, uint32_t y, uint32_t z) { +uint32_t getMortonIndex(uint32_t x, uint32_t y, uint32_t z) { return spread3(z) << 2 | spread3(y) << 1 | spread3(x); } +} // namespace OctreeAvailability::OctreeAvailability( uint32_t subtreeLevels, diff --git a/CesiumGeometry/src/OctreeTilingScheme.cpp b/CesiumGeometry/src/OctreeTilingScheme.cpp index aee92d109..47ec6c040 100644 --- a/CesiumGeometry/src/OctreeTilingScheme.cpp +++ b/CesiumGeometry/src/OctreeTilingScheme.cpp @@ -1,4 +1,11 @@ -#include "CesiumGeometry/OctreeTilingScheme.h" +#include +#include +#include + +#include + +#include +#include namespace CesiumGeometry { diff --git a/CesiumGeometry/src/OrientedBoundingBox.cpp b/CesiumGeometry/src/OrientedBoundingBox.cpp index 6ee147b70..2e43b2f37 100644 --- a/CesiumGeometry/src/OrientedBoundingBox.cpp +++ b/CesiumGeometry/src/OrientedBoundingBox.cpp @@ -1,14 +1,15 @@ -#include "CesiumGeometry/OrientedBoundingBox.h" - -#include "CesiumGeometry/Plane.h" - -#include - -#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #include -#include - namespace CesiumGeometry { CullingResult OrientedBoundingBox::intersectPlane(const Plane& plane) const noexcept { diff --git a/CesiumGeometry/src/Plane.cpp b/CesiumGeometry/src/Plane.cpp index b7a479c02..31aabf88c 100644 --- a/CesiumGeometry/src/Plane.cpp +++ b/CesiumGeometry/src/Plane.cpp @@ -1,5 +1,4 @@ -#include "CesiumGeometry/Plane.h" - +#include #include #include diff --git a/CesiumGeometry/src/QuadtreeAvailability.cpp b/CesiumGeometry/src/QuadtreeAvailability.cpp index e5a357eeb..809360330 100644 --- a/CesiumGeometry/src/QuadtreeAvailability.cpp +++ b/CesiumGeometry/src/QuadtreeAvailability.cpp @@ -1,12 +1,23 @@ -#include "CesiumGeometry/QuadtreeAvailability.h" - -#include "CesiumUtility/Assert.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include namespace CesiumGeometry { +namespace { + // For reference: // https://graphics.stanford.edu/~seander/bithacks.html#Interleave64bitOps -static uint16_t getMortonIndexForBytes(uint8_t a, uint8_t b) { +uint16_t getMortonIndexForBytes(uint8_t a, uint8_t b) { return static_cast( (((a * 0x0101010101010101ULL & 0x8040201008040201ULL) * 0x0102040810204081ULL >> @@ -18,7 +29,7 @@ static uint16_t getMortonIndexForBytes(uint8_t a, uint8_t b) { 0xAAAA)); } -static uint32_t getMortonIndexForShorts(uint16_t a, uint16_t b) { +uint32_t getMortonIndexForShorts(uint16_t a, uint16_t b) { uint8_t* pFirstByteA = reinterpret_cast(&a); uint8_t* pFirstByteB = reinterpret_cast(&b); @@ -40,12 +51,14 @@ static uint32_t getMortonIndexForShorts(uint16_t a, uint16_t b) { * @param y The unsigned 16-bit integer to put in the even bit positions. * @return The 32-bit unsigned morton index. */ -static uint32_t getMortonIndex(uint32_t x, uint32_t y) { +uint32_t getMortonIndex(uint32_t x, uint32_t y) { return getMortonIndexForShorts( static_cast(x), static_cast(y)); } +} // namespace + QuadtreeAvailability::QuadtreeAvailability( uint32_t subtreeLevels, uint32_t maximumLevel) noexcept diff --git a/CesiumGeometry/src/QuadtreeRectangleAvailability.cpp b/CesiumGeometry/src/QuadtreeRectangleAvailability.cpp index 775757c8f..4e930f9dd 100644 --- a/CesiumGeometry/src/QuadtreeRectangleAvailability.cpp +++ b/CesiumGeometry/src/QuadtreeRectangleAvailability.cpp @@ -1,10 +1,18 @@ -#include "CesiumGeometry/QuadtreeRectangleAvailability.h" - -#include "CesiumGeometry/TileAvailabilityFlags.h" +#include +#include +#include +#include +#include +#include #include +#include #include +#include +#include +#include +#include namespace CesiumGeometry { @@ -13,9 +21,9 @@ QuadtreeRectangleAvailability::QuadtreeRectangleAvailability( uint32_t maximumLevel) noexcept : _tilingScheme(tilingScheme), _maximumLevel(maximumLevel), - _rootNodes( + _rootNodes(static_cast( this->_tilingScheme.getRootTilesX() * - this->_tilingScheme.getRootTilesY()) { + this->_tilingScheme.getRootTilesY())) { for (uint32_t j = 0; j < this->_tilingScheme.getRootTilesY(); ++j) { const uint32_t rowStart = j * this->_tilingScheme.getRootTilesX(); for (uint32_t i = 0; i < this->_tilingScheme.getRootTilesX(); ++i) { diff --git a/CesiumGeometry/src/QuadtreeTileID.cpp b/CesiumGeometry/src/QuadtreeTileID.cpp index 0058a37be..1445e7589 100644 --- a/CesiumGeometry/src/QuadtreeTileID.cpp +++ b/CesiumGeometry/src/QuadtreeTileID.cpp @@ -1,7 +1,11 @@ -#include "CesiumGeometry/QuadtreeTilingScheme.h" - +#include +#include #include +#include +#include +#include + namespace CesiumGeometry { uint32_t QuadtreeTileID::computeInvertedY( diff --git a/CesiumGeometry/src/QuadtreeTilingScheme.cpp b/CesiumGeometry/src/QuadtreeTilingScheme.cpp index e4a465ec1..d16a86ebc 100644 --- a/CesiumGeometry/src/QuadtreeTilingScheme.cpp +++ b/CesiumGeometry/src/QuadtreeTilingScheme.cpp @@ -1,4 +1,11 @@ -#include "CesiumGeometry/QuadtreeTilingScheme.h" +#include +#include +#include + +#include + +#include +#include namespace CesiumGeometry { diff --git a/CesiumGeometry/src/Ray.cpp b/CesiumGeometry/src/Ray.cpp index f3944c240..44c6e83df 100644 --- a/CesiumGeometry/src/Ray.cpp +++ b/CesiumGeometry/src/Ray.cpp @@ -1,10 +1,9 @@ -#include "CesiumGeometry/Ray.h" - +#include #include +#include +#include #include -#include -#include #include diff --git a/CesiumGeometry/src/Rectangle.cpp b/CesiumGeometry/src/Rectangle.cpp index 8d04bcce5..f3e89d1bb 100644 --- a/CesiumGeometry/src/Rectangle.cpp +++ b/CesiumGeometry/src/Rectangle.cpp @@ -1,8 +1,11 @@ -#include "CesiumGeometry/Rectangle.h" +#include #include +#include #include +#include + namespace CesiumGeometry { bool Rectangle::contains(const glm::dvec2& position) const noexcept { diff --git a/CesiumGeometry/src/Transforms.cpp b/CesiumGeometry/src/Transforms.cpp index 329eaa81e..3a92dd9e0 100644 --- a/CesiumGeometry/src/Transforms.cpp +++ b/CesiumGeometry/src/Transforms.cpp @@ -1,8 +1,9 @@ -#include "CesiumGeometry/Transforms.h" +#include +#include -#include +#include +#include #include -#include namespace CesiumGeometry { diff --git a/CesiumGeometry/src/clipTriangleAtAxisAlignedThreshold.cpp b/CesiumGeometry/src/clipTriangleAtAxisAlignedThreshold.cpp index 7605204c3..11cbe076f 100644 --- a/CesiumGeometry/src/clipTriangleAtAxisAlignedThreshold.cpp +++ b/CesiumGeometry/src/clipTriangleAtAxisAlignedThreshold.cpp @@ -1,4 +1,6 @@ -#include "CesiumGeometry/clipTriangleAtAxisAlignedThreshold.h" +#include + +#include namespace CesiumGeometry { void clipTriangleAtAxisAlignedThreshold( diff --git a/CesiumGeometry/test/TestAvailability.cpp b/CesiumGeometry/test/TestAvailability.cpp index d5a4931a8..514d95cfc 100644 --- a/CesiumGeometry/test/TestAvailability.cpp +++ b/CesiumGeometry/test/TestAvailability.cpp @@ -1,19 +1,18 @@ -#include "CesiumGeometry/Availability.h" -#include "CesiumGeometry/AxisAlignedBox.h" -#include "CesiumGeometry/OctreeAvailability.h" -#include "CesiumGeometry/OctreeTileID.h" -#include "CesiumGeometry/QuadtreeAvailability.h" -#include "CesiumGeometry/QuadtreeTileID.h" -#include "CesiumGeometry/Rectangle.h" -#include "CesiumGeometry/TileAvailabilityFlags.h" - -#include +#include +#include +#include +#include +#include +#include + #include -#include -#include +#include +#include +#include #include +#include #include using namespace CesiumGeometry; diff --git a/CesiumGeometry/test/TestAxisAlignedBox.cpp b/CesiumGeometry/test/TestAxisAlignedBox.cpp index 51d3d5b21..2f65d7aa0 100644 --- a/CesiumGeometry/test/TestAxisAlignedBox.cpp +++ b/CesiumGeometry/test/TestAxisAlignedBox.cpp @@ -1,6 +1,5 @@ -#include "CesiumGeometry/AxisAlignedBox.h" +#include -#include #include using namespace CesiumGeometry; diff --git a/CesiumGeometry/test/TestBoundingSphere.cpp b/CesiumGeometry/test/TestBoundingSphere.cpp index 6c99ac71e..80b3f1a0a 100644 --- a/CesiumGeometry/test/TestBoundingSphere.cpp +++ b/CesiumGeometry/test/TestBoundingSphere.cpp @@ -1,12 +1,18 @@ -#include "CesiumGeometry/BoundingSphere.h" -#include "CesiumGeometry/Plane.h" -#include "CesiumUtility/Math.h" +#include +#include +#include +#include #include #include -#include +#include +#include +#include +#include #include -#include + +#include +#include using namespace CesiumGeometry; using namespace CesiumUtility; diff --git a/CesiumGeometry/test/TestClipTriangleAtAxisAlignedThreshold.cpp b/CesiumGeometry/test/TestClipTriangleAtAxisAlignedThreshold.cpp index 93be53c45..ed22e9ace 100644 --- a/CesiumGeometry/test/TestClipTriangleAtAxisAlignedThreshold.cpp +++ b/CesiumGeometry/test/TestClipTriangleAtAxisAlignedThreshold.cpp @@ -1,7 +1,9 @@ -#include "CesiumGeometry/clipTriangleAtAxisAlignedThreshold.h" +#include -#include #include +#include + +#include using namespace CesiumGeometry; diff --git a/CesiumGeometry/test/TestIntersectionTests.cpp b/CesiumGeometry/test/TestIntersectionTests.cpp index 6139ea2cf..a89f0b537 100644 --- a/CesiumGeometry/test/TestIntersectionTests.cpp +++ b/CesiumGeometry/test/TestIntersectionTests.cpp @@ -1,17 +1,25 @@ -#include "CesiumGeometry/AxisAlignedBox.h" -#include "CesiumGeometry/IntersectionTests.h" -#include "CesiumGeometry/OrientedBoundingBox.h" -#include "CesiumGeometry/Plane.h" -#include "CesiumGeometry/Ray.h" -#include "CesiumGeospatial/Ellipsoid.h" -#include "CesiumUtility/Math.h" - -#include +#include +#include +#include +#include +#include +#include +#include + #include -#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include #include +#include using namespace CesiumGeometry; using namespace CesiumGeospatial; diff --git a/CesiumGeometry/test/TestOrientedBoundingBox.cpp b/CesiumGeometry/test/TestOrientedBoundingBox.cpp index 72cbedcd1..893585f66 100644 --- a/CesiumGeometry/test/TestOrientedBoundingBox.cpp +++ b/CesiumGeometry/test/TestOrientedBoundingBox.cpp @@ -1,18 +1,29 @@ -#include "CesiumGeometry/OrientedBoundingBox.h" - -#include +#include +#include +#include +#include +#include #include #include #include -#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include #include +#include +#include using namespace CesiumGeometry; -using namespace Cesium3DTilesSelection; using namespace CesiumUtility; TEST_CASE("OrientedBoundingBox::intersectPlane") { diff --git a/CesiumGeometry/test/TestPlane.cpp b/CesiumGeometry/test/TestPlane.cpp index 9c1e862af..c89326974 100644 --- a/CesiumGeometry/test/TestPlane.cpp +++ b/CesiumGeometry/test/TestPlane.cpp @@ -1,8 +1,7 @@ -#include "CesiumGeometry/Plane.h" - +#include +#include #include -#include #include #include diff --git a/CesiumGeometry/test/TestRectangle.cpp b/CesiumGeometry/test/TestRectangle.cpp index 37103e1db..2a2b093ea 100644 --- a/CesiumGeometry/test/TestRectangle.cpp +++ b/CesiumGeometry/test/TestRectangle.cpp @@ -1,9 +1,11 @@ -#include "CesiumGeometry/Rectangle.h" - +#include #include -#include #include +#include +#include + +#include using namespace CesiumGeometry; diff --git a/CesiumGeometry/test/TestTransforms.cpp b/CesiumGeometry/test/TestTransforms.cpp index 5ab5388d1..fd37a1445 100644 --- a/CesiumGeometry/test/TestTransforms.cpp +++ b/CesiumGeometry/test/TestTransforms.cpp @@ -1,11 +1,9 @@ -#include "CesiumGeometry/Axis.h" -#include "CesiumGeometry/Transforms.h" +#include +#include -#include - -#include #include -#include +#include +#include using namespace CesiumGeometry; diff --git a/CesiumGeospatial/include/CesiumGeospatial/BoundingRegion.h b/CesiumGeospatial/include/CesiumGeospatial/BoundingRegion.h index bf1f21af9..1c4ba8b17 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/BoundingRegion.h +++ b/CesiumGeospatial/include/CesiumGeospatial/BoundingRegion.h @@ -1,12 +1,10 @@ #pragma once -#include "Ellipsoid.h" -#include "GlobeRectangle.h" -#include "Library.h" - #include #include #include +#include +#include namespace CesiumGeometry { class Plane; diff --git a/CesiumGeospatial/include/CesiumGeospatial/BoundingRegionBuilder.h b/CesiumGeospatial/include/CesiumGeospatial/BoundingRegionBuilder.h index 4f6476f08..da4bf01ef 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/BoundingRegionBuilder.h +++ b/CesiumGeospatial/include/CesiumGeospatial/BoundingRegionBuilder.h @@ -1,8 +1,8 @@ #pragma once -#include "BoundingRegion.h" -#include "GlobeRectangle.h" -#include "Library.h" +#include +#include +#include namespace CesiumGeospatial { diff --git a/CesiumGeospatial/include/CesiumGeospatial/BoundingRegionWithLooseFittingHeights.h b/CesiumGeospatial/include/CesiumGeospatial/BoundingRegionWithLooseFittingHeights.h index bfe9cf1b4..5f878b25c 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/BoundingRegionWithLooseFittingHeights.h +++ b/CesiumGeospatial/include/CesiumGeospatial/BoundingRegionWithLooseFittingHeights.h @@ -1,7 +1,7 @@ #pragma once -#include "BoundingRegion.h" -#include "Library.h" +#include +#include namespace CesiumGeospatial { diff --git a/CesiumGeospatial/include/CesiumGeospatial/Cartographic.h b/CesiumGeospatial/include/CesiumGeospatial/Cartographic.h index 32cba0104..4c5d53a40 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/Cartographic.h +++ b/CesiumGeospatial/include/CesiumGeospatial/Cartographic.h @@ -1,7 +1,6 @@ #pragma once -#include "Library.h" - +#include #include namespace CesiumGeospatial { diff --git a/CesiumGeospatial/include/CesiumGeospatial/CartographicPolygon.h b/CesiumGeospatial/include/CesiumGeospatial/CartographicPolygon.h index e5112b443..9417162f9 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/CartographicPolygon.h +++ b/CesiumGeospatial/include/CesiumGeospatial/CartographicPolygon.h @@ -1,7 +1,7 @@ #pragma once -#include "GlobeRectangle.h" -#include "Library.h" +#include +#include #include diff --git a/CesiumGeospatial/include/CesiumGeospatial/EarthGravitationalModel1996Grid.h b/CesiumGeospatial/include/CesiumGeospatial/EarthGravitationalModel1996Grid.h index 31f310ac2..f8f97b822 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/EarthGravitationalModel1996Grid.h +++ b/CesiumGeospatial/include/CesiumGeospatial/EarthGravitationalModel1996Grid.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include #include #include diff --git a/CesiumGeospatial/include/CesiumGeospatial/Ellipsoid.h b/CesiumGeospatial/include/CesiumGeospatial/Ellipsoid.h index 71d7b6d6d..de0e7ee82 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/Ellipsoid.h +++ b/CesiumGeospatial/include/CesiumGeospatial/Ellipsoid.h @@ -1,8 +1,7 @@ #pragma once -#include "Cartographic.h" -#include "Library.h" - +#include +#include #include #include diff --git a/CesiumGeospatial/include/CesiumGeospatial/EllipsoidTangentPlane.h b/CesiumGeospatial/include/CesiumGeospatial/EllipsoidTangentPlane.h index c0a730b73..3b181e289 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/EllipsoidTangentPlane.h +++ b/CesiumGeospatial/include/CesiumGeospatial/EllipsoidTangentPlane.h @@ -1,9 +1,8 @@ #pragma once -#include "Ellipsoid.h" -#include "Library.h" - #include +#include +#include #include #include diff --git a/CesiumGeospatial/include/CesiumGeospatial/GeographicProjection.h b/CesiumGeospatial/include/CesiumGeospatial/GeographicProjection.h index de6522464..da1ad5a70 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/GeographicProjection.h +++ b/CesiumGeospatial/include/CesiumGeospatial/GeographicProjection.h @@ -1,9 +1,8 @@ #pragma once -#include "Ellipsoid.h" -#include "GlobeRectangle.h" -#include "Library.h" - +#include +#include +#include #include #include diff --git a/CesiumGeospatial/include/CesiumGeospatial/GlobeAnchor.h b/CesiumGeospatial/include/CesiumGeospatial/GlobeAnchor.h index 0a241e8a8..2b81ed8dd 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/GlobeAnchor.h +++ b/CesiumGeospatial/include/CesiumGeospatial/GlobeAnchor.h @@ -1,8 +1,7 @@ #pragma once -#include "Library.h" - #include +#include #include diff --git a/CesiumGeospatial/include/CesiumGeospatial/GlobeRectangle.h b/CesiumGeospatial/include/CesiumGeospatial/GlobeRectangle.h index 0705b848c..b4a6ccae6 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/GlobeRectangle.h +++ b/CesiumGeospatial/include/CesiumGeospatial/GlobeRectangle.h @@ -1,9 +1,8 @@ #pragma once -#include "Cartographic.h" -#include "Library.h" - #include +#include +#include #include #include diff --git a/CesiumGeospatial/include/CesiumGeospatial/GlobeTransforms.h b/CesiumGeospatial/include/CesiumGeospatial/GlobeTransforms.h index 134916a9c..d4f391f6d 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/GlobeTransforms.h +++ b/CesiumGeospatial/include/CesiumGeospatial/GlobeTransforms.h @@ -1,7 +1,7 @@ #pragma once -#include "Ellipsoid.h" -#include "Library.h" +#include +#include #include #include diff --git a/CesiumGeospatial/include/CesiumGeospatial/LocalHorizontalCoordinateSystem.h b/CesiumGeospatial/include/CesiumGeospatial/LocalHorizontalCoordinateSystem.h index cfb6466c0..91c2b311b 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/LocalHorizontalCoordinateSystem.h +++ b/CesiumGeospatial/include/CesiumGeospatial/LocalHorizontalCoordinateSystem.h @@ -1,7 +1,7 @@ #pragma once -#include "Ellipsoid.h" -#include "Library.h" +#include +#include #include #include diff --git a/CesiumGeospatial/include/CesiumGeospatial/Projection.h b/CesiumGeospatial/include/CesiumGeospatial/Projection.h index aac8f3cd7..8a3f2ebe0 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/Projection.h +++ b/CesiumGeospatial/include/CesiumGeospatial/Projection.h @@ -1,11 +1,11 @@ #pragma once -#include "BoundingRegion.h" -#include "CesiumGeometry/AxisAlignedBox.h" -#include "CesiumGeometry/Rectangle.h" -#include "Ellipsoid.h" -#include "GeographicProjection.h" -#include "WebMercatorProjection.h" +#include +#include +#include +#include +#include +#include #include diff --git a/CesiumGeospatial/include/CesiumGeospatial/S2CellBoundingVolume.h b/CesiumGeospatial/include/CesiumGeospatial/S2CellBoundingVolume.h index 54456bcc3..8f2179dee 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/S2CellBoundingVolume.h +++ b/CesiumGeospatial/include/CesiumGeospatial/S2CellBoundingVolume.h @@ -1,11 +1,10 @@ #pragma once -#include "BoundingRegion.h" -#include "Ellipsoid.h" -#include "S2CellID.h" - #include #include +#include +#include +#include #include diff --git a/CesiumGeospatial/include/CesiumGeospatial/S2CellID.h b/CesiumGeospatial/include/CesiumGeospatial/S2CellID.h index fe63b58b5..081660fb2 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/S2CellID.h +++ b/CesiumGeospatial/include/CesiumGeospatial/S2CellID.h @@ -1,8 +1,8 @@ #pragma once -#include "Cartographic.h" -#include "GlobeRectangle.h" -#include "Library.h" +#include +#include +#include #include #include diff --git a/CesiumGeospatial/include/CesiumGeospatial/SimplePlanarEllipsoidCurve.h b/CesiumGeospatial/include/CesiumGeospatial/SimplePlanarEllipsoidCurve.h index 685536f07..410a15632 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/SimplePlanarEllipsoidCurve.h +++ b/CesiumGeospatial/include/CesiumGeospatial/SimplePlanarEllipsoidCurve.h @@ -1,8 +1,7 @@ #pragma once -#include "Library.h" - #include +#include #include diff --git a/CesiumGeospatial/include/CesiumGeospatial/WebMercatorProjection.h b/CesiumGeospatial/include/CesiumGeospatial/WebMercatorProjection.h index 457ba50ad..87db56fb6 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/WebMercatorProjection.h +++ b/CesiumGeospatial/include/CesiumGeospatial/WebMercatorProjection.h @@ -1,8 +1,8 @@ #pragma once -#include "Ellipsoid.h" -#include "GlobeRectangle.h" -#include "Library.h" +#include +#include +#include #include #include diff --git a/CesiumGeospatial/include/CesiumGeospatial/calcQuadtreeMaxGeometricError.h b/CesiumGeospatial/include/CesiumGeospatial/calcQuadtreeMaxGeometricError.h index 1134b2678..c1355972d 100644 --- a/CesiumGeospatial/include/CesiumGeospatial/calcQuadtreeMaxGeometricError.h +++ b/CesiumGeospatial/include/CesiumGeospatial/calcQuadtreeMaxGeometricError.h @@ -1,8 +1,7 @@ #pragma once -#include "Ellipsoid.h" - #include +#include namespace CesiumGeospatial { /** diff --git a/CesiumGeospatial/src/BoundingRegion.cpp b/CesiumGeospatial/src/BoundingRegion.cpp index da09f943e..4ff02666a 100644 --- a/CesiumGeospatial/src/BoundingRegion.cpp +++ b/CesiumGeospatial/src/BoundingRegion.cpp @@ -1,12 +1,20 @@ -#include "CesiumGeospatial/BoundingRegion.h" - -#include "CesiumGeospatial/EllipsoidTangentPlane.h" - +#include #include #include #include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include + +#include #include using namespace CesiumUtility; @@ -228,7 +236,8 @@ BoundingRegion BoundingRegion::computeUnion( ellipsoid); } -static OrientedBoundingBox fromPlaneExtents( +namespace { +OrientedBoundingBox fromPlaneExtents( const glm::dvec3& planeOrigin, const glm::dvec3& planeXAxis, const glm::dvec3& planeYAxis, @@ -260,6 +269,7 @@ static OrientedBoundingBox fromPlaneExtents( planeOrigin + (halfAxes * centerOffset), scaledHalfAxes); } +} // namespace /*static*/ OrientedBoundingBox BoundingRegion::_computeBoundingBox( const GlobeRectangle& rectangle, diff --git a/CesiumGeospatial/src/BoundingRegionBuilder.cpp b/CesiumGeospatial/src/BoundingRegionBuilder.cpp index e58e652dc..0e28f828d 100644 --- a/CesiumGeospatial/src/BoundingRegionBuilder.cpp +++ b/CesiumGeospatial/src/BoundingRegionBuilder.cpp @@ -1,8 +1,11 @@ -#include "CesiumGeospatial/BoundingRegionBuilder.h" - +#include +#include #include +#include #include +#include + #include using namespace CesiumUtility; diff --git a/CesiumGeospatial/src/BoundingRegionWithLooseFittingHeights.cpp b/CesiumGeospatial/src/BoundingRegionWithLooseFittingHeights.cpp index 94c9d9d46..d22e2f7c7 100644 --- a/CesiumGeospatial/src/BoundingRegionWithLooseFittingHeights.cpp +++ b/CesiumGeospatial/src/BoundingRegionWithLooseFittingHeights.cpp @@ -1,4 +1,9 @@ -#include "CesiumGeospatial/BoundingRegionWithLooseFittingHeights.h" +#include +#include +#include +#include + +#include namespace CesiumGeospatial { diff --git a/CesiumGeospatial/src/CartographicPolygon.cpp b/CesiumGeospatial/src/CartographicPolygon.cpp index 46427ef78..0e963d0b1 100644 --- a/CesiumGeospatial/src/CartographicPolygon.cpp +++ b/CesiumGeospatial/src/CartographicPolygon.cpp @@ -1,17 +1,27 @@ -#include "CesiumGeospatial/CartographicPolygon.h" - #include - -#include +#include +#include +#include + +#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include using namespace CesiumGeometry; namespace CesiumGeospatial { -static std::vector +namespace { +std::vector triangulatePolygon(const std::vector& polygon) { std::vector indices; const size_t vertexCount = polygon.size(); @@ -51,7 +61,7 @@ triangulatePolygon(const std::vector& polygon) { return indices; } -static std::optional +std::optional computeBoundingRectangle(const std::vector& polygon) { const size_t vertexCount = polygon.size(); @@ -105,6 +115,7 @@ computeBoundingRectangle(const std::vector& polygon) { return CesiumGeospatial::GlobeRectangle(west, south, east, north); } +} // namespace CartographicPolygon::CartographicPolygon(const std::vector& polygon) : _vertices(polygon), @@ -128,9 +139,7 @@ CartographicPolygon::CartographicPolygon(const std::vector& polygon) rectangleCorners[0] - rectangleCorners[3]}; // Iterate through all polygons. - for (size_t i = 0; i < cartographicPolygons.size(); ++i) { - const CartographicPolygon& selection = cartographicPolygons[i]; - + for (const auto& selection : cartographicPolygons) { const std::optional& polygonBoundingRectangle = selection.getBoundingRectangle(); if (!polygonBoundingRectangle || @@ -220,9 +229,7 @@ CartographicPolygon::CartographicPolygon(const std::vector& polygon) rectangleCorners[0] - rectangleCorners[3]}; // Iterate through all polygons. - for (size_t i = 0; i < cartographicPolygons.size(); ++i) { - const CartographicPolygon& selection = cartographicPolygons[i]; - + for (const auto& selection : cartographicPolygons) { const std::optional& polygonBoundingRectangle = selection.getBoundingRectangle(); if (!polygonBoundingRectangle || diff --git a/CesiumGeospatial/src/EarthGravitationalModel1996Grid.cpp b/CesiumGeospatial/src/EarthGravitationalModel1996Grid.cpp index 300ed8021..7ac4fbf28 100644 --- a/CesiumGeospatial/src/EarthGravitationalModel1996Grid.cpp +++ b/CesiumGeospatial/src/EarthGravitationalModel1996Grid.cpp @@ -2,9 +2,11 @@ #include #include -#include -#include -#include +#include +#include +#include +#include +#include #include using namespace CesiumUtility; diff --git a/CesiumGeospatial/src/Ellipsoid.cpp b/CesiumGeospatial/src/Ellipsoid.cpp index 4b81a3b61..2e85977bf 100644 --- a/CesiumGeospatial/src/Ellipsoid.cpp +++ b/CesiumGeospatial/src/Ellipsoid.cpp @@ -1,10 +1,15 @@ -#include "CesiumGeospatial/Ellipsoid.h" - +#include +#include #include +#include +#include #include #include +#include +#include + using namespace CesiumUtility; namespace CesiumGeospatial { diff --git a/CesiumGeospatial/src/EllipsoidTangentPlane.cpp b/CesiumGeospatial/src/EllipsoidTangentPlane.cpp index 038c58e87..0adaf2ead 100644 --- a/CesiumGeospatial/src/EllipsoidTangentPlane.cpp +++ b/CesiumGeospatial/src/EllipsoidTangentPlane.cpp @@ -1,13 +1,16 @@ -#include "CesiumGeospatial/EllipsoidTangentPlane.h" - -#include "CesiumGeospatial/GlobeTransforms.h" - #include #include #include +#include +#include +#include -#include +#include +#include +#include +#include +#include #include using namespace CesiumGeometry; diff --git a/CesiumGeospatial/src/GeographicProjection.cpp b/CesiumGeospatial/src/GeographicProjection.cpp index 6eeb36175..7f5877f4a 100644 --- a/CesiumGeospatial/src/GeographicProjection.cpp +++ b/CesiumGeospatial/src/GeographicProjection.cpp @@ -1,8 +1,11 @@ -#include "CesiumGeospatial/GeographicProjection.h" - -#include "CesiumGeospatial/Cartographic.h" - -#include +#include +#include +#include +#include +#include + +#include +#include namespace CesiumGeospatial { diff --git a/CesiumGeospatial/src/GlobeAnchor.cpp b/CesiumGeospatial/src/GlobeAnchor.cpp index 2a90aaf48..15cc4e7a8 100644 --- a/CesiumGeospatial/src/GlobeAnchor.cpp +++ b/CesiumGeospatial/src/GlobeAnchor.cpp @@ -1,8 +1,12 @@ +#include #include #include +#include +#include +#include +#include #include -#include namespace { diff --git a/CesiumGeospatial/src/GlobeRectangle.cpp b/CesiumGeospatial/src/GlobeRectangle.cpp index 7579906b7..d96c9df3c 100644 --- a/CesiumGeospatial/src/GlobeRectangle.cpp +++ b/CesiumGeospatial/src/GlobeRectangle.cpp @@ -1,7 +1,12 @@ -#include "CesiumGeospatial/GlobeRectangle.h" - +#include +#include #include +#include + +#include +#include + using namespace CesiumUtility; namespace CesiumGeospatial { diff --git a/CesiumGeospatial/src/GlobeTransforms.cpp b/CesiumGeospatial/src/GlobeTransforms.cpp index d08ed5746..d85f3ab10 100644 --- a/CesiumGeospatial/src/GlobeTransforms.cpp +++ b/CesiumGeospatial/src/GlobeTransforms.cpp @@ -1,9 +1,10 @@ -#include "CesiumGeospatial/GlobeTransforms.h" - +#include +#include #include -#include -#include +#include +#include +#include using namespace CesiumUtility; diff --git a/CesiumGeospatial/src/HilbertOrder.cpp b/CesiumGeospatial/src/HilbertOrder.cpp index 319b68291..41aaecf37 100644 --- a/CesiumGeospatial/src/HilbertOrder.cpp +++ b/CesiumGeospatial/src/HilbertOrder.cpp @@ -1,6 +1,8 @@ #include "HilbertOrder.h" -#include "CesiumUtility/Assert.h" +#include + +#include using namespace CesiumGeospatial; diff --git a/CesiumGeospatial/src/LocalHorizontalCoordinateSystem.cpp b/CesiumGeospatial/src/LocalHorizontalCoordinateSystem.cpp index 446474fd2..3e6738d87 100644 --- a/CesiumGeospatial/src/LocalHorizontalCoordinateSystem.cpp +++ b/CesiumGeospatial/src/LocalHorizontalCoordinateSystem.cpp @@ -1,10 +1,13 @@ #include +#include #include #include #include +#include +#include +#include #include -#include using namespace CesiumGeospatial; diff --git a/CesiumGeospatial/src/Projection.cpp b/CesiumGeospatial/src/Projection.cpp index 9accf8f00..0095f9f79 100644 --- a/CesiumGeospatial/src/Projection.cpp +++ b/CesiumGeospatial/src/Projection.cpp @@ -1,7 +1,19 @@ -#include "CesiumGeospatial/Projection.h" - +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include #include -#include + +#include namespace CesiumGeospatial { @@ -212,23 +224,4 @@ const Ellipsoid& getProjectionEllipsoid(const Projection& projection) { return std::visit(Operation{}, projection); } - -double computeApproximateConversionFactorToMetersNearPosition( - const Projection& projection, - const glm::dvec2& position) { - struct Operation { - const glm::dvec2& position; - - double operator()(const GeographicProjection& /*geographic*/) noexcept { - return 1.0; - } - - double operator()(const WebMercatorProjection& webMercator) noexcept { - // TODO: is there a better estimate? - return glm::cos(webMercator.unproject(position).latitude); - } - }; - - return std::visit(Operation{position}, projection); -} } // namespace CesiumGeospatial diff --git a/CesiumGeospatial/src/S2CellBoundingVolume.cpp b/CesiumGeospatial/src/S2CellBoundingVolume.cpp index e2c028c87..34af21cd4 100644 --- a/CesiumGeospatial/src/S2CellBoundingVolume.cpp +++ b/CesiumGeospatial/src/S2CellBoundingVolume.cpp @@ -1,13 +1,22 @@ -#include "CesiumGeospatial/S2CellBoundingVolume.h" - +#include +#include +#include +#include +#include +#include #include -#include +#include +#include #include #include #include #include +#include +#include +#include +#include using namespace CesiumGeometry; using namespace CesiumGeospatial; @@ -157,9 +166,9 @@ CesiumGeometry::CullingResult S2CellBoundingVolume::intersectPlane( const CesiumGeometry::Plane& plane) const noexcept { size_t plusCount = 0; size_t negCount = 0; - for (size_t i = 0; i < this->_vertices.size(); ++i) { + for (const auto& vertex : this->_vertices) { double distanceToPlane = - glm::dot(plane.getNormal(), this->_vertices[i]) + plane.getDistance(); + glm::dot(plane.getNormal(), vertex) + plane.getDistance(); if (distanceToPlane < 0.0) { ++negCount; } else { diff --git a/CesiumGeospatial/src/S2CellID.cpp b/CesiumGeospatial/src/S2CellID.cpp index 43fc86e84..b1a282167 100644 --- a/CesiumGeospatial/src/S2CellID.cpp +++ b/CesiumGeospatial/src/S2CellID.cpp @@ -8,22 +8,34 @@ #endif // #include +#include #include #include +#include #include +#include // #include #ifdef _MSC_VER #pragma warning(pop) #endif -#include "CesiumGeospatial/S2CellID.h" #include "HilbertOrder.h" #include +#include +#include +#include #include +#include +#include #include +#include +#include +#include +#include +#include using namespace CesiumGeometry; using namespace CesiumGeospatial; @@ -127,7 +139,11 @@ GlobeRectangleFromLatLng(const R1Interval& lat_, const S1Interval& lng_) { return GlobeRectangle(lng_.lo(), lat_.lo(), lng_.hi(), lat_.hi()); } -R1Interval FullLat() { return R1Interval(-M_PI_2, M_PI_2); } +R1Interval FullLat() { + return R1Interval( + -CesiumUtility::Math::PiOverTwo, + CesiumUtility::Math::PiOverTwo); +} GlobeRectangle Expanded( const R1Interval& lat_, @@ -220,27 +236,43 @@ GlobeRectangle S2CellID::computeBoundingRectangle() const { S1Interval lng; switch (face_) { case 0: - lat = R1Interval(-M_PI_4, M_PI_4); - lng = S1Interval(-M_PI_4, M_PI_4); + lat = R1Interval( + -CesiumUtility::Math::PiOverFour, + CesiumUtility::Math::PiOverFour); + lng = S1Interval( + -CesiumUtility::Math::PiOverFour, + CesiumUtility::Math::PiOverFour); break; case 1: - lat = R1Interval(-M_PI_4, M_PI_4); - lng = S1Interval(M_PI_4, 3 * M_PI_4); + lat = R1Interval( + -CesiumUtility::Math::PiOverFour, + CesiumUtility::Math::PiOverFour); + lng = S1Interval( + CesiumUtility::Math::PiOverFour, + 3 * CesiumUtility::Math::PiOverFour); break; case 2: - lat = R1Interval(kPoleMinLat, M_PI_2); + lat = R1Interval(kPoleMinLat, CesiumUtility::Math::PiOverTwo); lng = S1Interval::Full(); break; case 3: - lat = R1Interval(-M_PI_4, M_PI_4); - lng = S1Interval(3 * M_PI_4, -3 * M_PI_4); + lat = R1Interval( + -CesiumUtility::Math::PiOverFour, + CesiumUtility::Math::PiOverFour); + lng = S1Interval( + 3 * CesiumUtility::Math::PiOverFour, + -3 * CesiumUtility::Math::PiOverFour); break; case 4: - lat = R1Interval(-M_PI_4, M_PI_4); - lng = S1Interval(-3 * M_PI_4, -M_PI_4); + lat = R1Interval( + -CesiumUtility::Math::PiOverFour, + CesiumUtility::Math::PiOverFour); + lng = S1Interval( + -3 * CesiumUtility::Math::PiOverFour, + -CesiumUtility::Math::PiOverFour); break; default: - lat = R1Interval(-M_PI_2, -kPoleMinLat); + lat = R1Interval(-CesiumUtility::Math::PiOverTwo, -kPoleMinLat); lng = S1Interval::Full(); break; } diff --git a/CesiumGeospatial/src/SimplePlanarEllipsoidCurve.cpp b/CesiumGeospatial/src/SimplePlanarEllipsoidCurve.cpp index dd3904b59..15a8f110c 100644 --- a/CesiumGeospatial/src/SimplePlanarEllipsoidCurve.cpp +++ b/CesiumGeospatial/src/SimplePlanarEllipsoidCurve.cpp @@ -1,10 +1,16 @@ +#include #include -#include #include -#include +#include +#include +#include +#include +#include #include +#include + namespace CesiumGeospatial { std::optional @@ -81,7 +87,13 @@ SimplePlanarEllipsoidCurve::SimplePlanarEllipsoidCurve( const glm::dvec3& scaledDestinationEcef, const glm::dvec3& originalSourceEcef, const glm::dvec3& originalDestinationEcef) - : _ellipsoid(ellipsoid), + : _sourceHeight( + glm::length(originalSourceEcef) - glm::length(scaledSourceEcef)), + _destinationHeight( + glm::length(originalDestinationEcef) - + glm::length(scaledDestinationEcef)), + _ellipsoid(ellipsoid), + _sourceDirection(glm::normalize(originalSourceEcef)), _sourceEcef(originalSourceEcef), _destinationEcef(originalDestinationEcef) { // Here we find the center of a circle that passes through both the source and @@ -94,15 +106,6 @@ SimplePlanarEllipsoidCurve::SimplePlanarEllipsoidCurve( this->_rotationAxis = glm::axis(flyQuat); this->_totalAngle = glm::angle(flyQuat); - - // Calculate difference between lengths instead of length between points - - // allows for negative source height - this->_sourceHeight = - glm::length(originalSourceEcef) - glm::length(scaledSourceEcef); - this->_destinationHeight = - glm::length(originalDestinationEcef) - glm::length(scaledDestinationEcef); - - this->_sourceDirection = glm::normalize(originalSourceEcef); } } // namespace CesiumGeospatial diff --git a/CesiumGeospatial/src/WebMercatorProjection.cpp b/CesiumGeospatial/src/WebMercatorProjection.cpp index a6dd80ca9..1ba904e3b 100644 --- a/CesiumGeospatial/src/WebMercatorProjection.cpp +++ b/CesiumGeospatial/src/WebMercatorProjection.cpp @@ -1,10 +1,13 @@ -#include "CesiumGeospatial/WebMercatorProjection.h" - -#include "CesiumGeospatial/Cartographic.h" - +#include +#include +#include +#include +#include #include #include +#include +#include #include namespace CesiumGeospatial { diff --git a/CesiumGeospatial/src/calcQuadtreeMaxGeometricError.cpp b/CesiumGeospatial/src/calcQuadtreeMaxGeometricError.cpp index 6d6a54ccc..7259726c3 100644 --- a/CesiumGeospatial/src/calcQuadtreeMaxGeometricError.cpp +++ b/CesiumGeospatial/src/calcQuadtreeMaxGeometricError.cpp @@ -1,5 +1,8 @@ +#include #include +#include + namespace CesiumGeospatial { double calcQuadtreeMaxGeometricError( const CesiumGeospatial::Ellipsoid& ellipsoid) noexcept { diff --git a/CesiumGeospatial/test/TestBoundingRegion.cpp b/CesiumGeospatial/test/TestBoundingRegion.cpp index 2aefbd3c1..533176606 100644 --- a/CesiumGeospatial/test/TestBoundingRegion.cpp +++ b/CesiumGeospatial/test/TestBoundingRegion.cpp @@ -1,12 +1,16 @@ -#include "CesiumGeospatial/BoundingRegion.h" -#include "CesiumGeospatial/Ellipsoid.h" -#include "CesiumGeospatial/GlobeRectangle.h" - +#include #include +#include +#include +#include #include -#include #include +#include +#include +#include + +#include using namespace CesiumUtility; using namespace CesiumGeometry; diff --git a/CesiumGeospatial/test/TestBoundingRegionBuilder.cpp b/CesiumGeospatial/test/TestBoundingRegionBuilder.cpp index 9cb92d3ee..b0a3cf021 100644 --- a/CesiumGeospatial/test/TestBoundingRegionBuilder.cpp +++ b/CesiumGeospatial/test/TestBoundingRegionBuilder.cpp @@ -1,8 +1,8 @@ -#include "CesiumGeospatial/BoundingRegionBuilder.h" - +#include +#include +#include #include -#include #include #include diff --git a/CesiumGeospatial/test/TestEarthGravitationalModel1996Grid.cpp b/CesiumGeospatial/test/TestEarthGravitationalModel1996Grid.cpp index 4b9e46154..0e6150d66 100644 --- a/CesiumGeospatial/test/TestEarthGravitationalModel1996Grid.cpp +++ b/CesiumGeospatial/test/TestEarthGravitationalModel1996Grid.cpp @@ -1,13 +1,14 @@ #include #include -#include #include #include -#include #include +#include #include +#include +#include using namespace CesiumGeospatial; using namespace CesiumUtility; diff --git a/CesiumGeospatial/test/TestGlobeAnchor.cpp b/CesiumGeospatial/test/TestGlobeAnchor.cpp index 6749ac642..7fe0dd1da 100644 --- a/CesiumGeospatial/test/TestGlobeAnchor.cpp +++ b/CesiumGeospatial/test/TestGlobeAnchor.cpp @@ -1,9 +1,15 @@ #include +#include #include #include +#include -#include #include +#include +#include +#include +#include +#include #include using namespace CesiumGeometry; diff --git a/CesiumGeospatial/test/TestGlobeRectangle.cpp b/CesiumGeospatial/test/TestGlobeRectangle.cpp index 00be75aec..c6c11a9f4 100644 --- a/CesiumGeospatial/test/TestGlobeRectangle.cpp +++ b/CesiumGeospatial/test/TestGlobeRectangle.cpp @@ -1,9 +1,12 @@ -#include "CesiumGeospatial/GlobeRectangle.h" -#include "CesiumUtility/Math.h" +#include +#include +#include -#include #include +#include +#include + using namespace CesiumGeospatial; using namespace CesiumUtility; diff --git a/CesiumGeospatial/test/TestLocalHorizontalCoordinateSystem.cpp b/CesiumGeospatial/test/TestLocalHorizontalCoordinateSystem.cpp index 2bdc337df..cee19b0fb 100644 --- a/CesiumGeospatial/test/TestLocalHorizontalCoordinateSystem.cpp +++ b/CesiumGeospatial/test/TestLocalHorizontalCoordinateSystem.cpp @@ -1,8 +1,9 @@ #include #include -#include #include +#include +#include using namespace CesiumGeospatial; using namespace CesiumUtility; diff --git a/CesiumGeospatial/test/TestProjection.cpp b/CesiumGeospatial/test/TestProjection.cpp index a9b1714a1..ecb2f80e9 100644 --- a/CesiumGeospatial/test/TestProjection.cpp +++ b/CesiumGeospatial/test/TestProjection.cpp @@ -1,10 +1,13 @@ -#include "CesiumGeospatial/GlobeRectangle.h" -#include "CesiumGeospatial/Projection.h" - +#include +#include +#include +#include +#include +#include #include -#include #include +#include #include using namespace CesiumGeometry; diff --git a/CesiumGeospatial/test/TestS2CellBoundingVolume.cpp b/CesiumGeospatial/test/TestS2CellBoundingVolume.cpp index 73f60701d..f790c421e 100644 --- a/CesiumGeospatial/test/TestS2CellBoundingVolume.cpp +++ b/CesiumGeospatial/test/TestS2CellBoundingVolume.cpp @@ -1,9 +1,15 @@ +#include +#include +#include #include #include +#include -#include #include -#include +#include +#include + +#include using namespace CesiumGeometry; using namespace CesiumGeospatial; diff --git a/CesiumGeospatial/test/TestS2CellID.cpp b/CesiumGeospatial/test/TestS2CellID.cpp index c18c5683f..34bf48a56 100644 --- a/CesiumGeospatial/test/TestS2CellID.cpp +++ b/CesiumGeospatial/test/TestS2CellID.cpp @@ -1,10 +1,14 @@ #include -#include +#include +#include #include #include -#include #include +#include + +#include +#include using namespace CesiumGeometry; using namespace CesiumGeospatial; diff --git a/CesiumGeospatial/test/TestSimplePlanarEllipsoidCurve.cpp b/CesiumGeospatial/test/TestSimplePlanarEllipsoidCurve.cpp index abb8dd4ab..1f4b77caf 100644 --- a/CesiumGeospatial/test/TestSimplePlanarEllipsoidCurve.cpp +++ b/CesiumGeospatial/test/TestSimplePlanarEllipsoidCurve.cpp @@ -1,9 +1,15 @@ +#include +#include #include +#include -#include #include +#include +#include #include +#include + using namespace CesiumGeospatial; using namespace CesiumUtility; diff --git a/CesiumGltf/include/CesiumGltf/Accessor.h b/CesiumGltf/include/CesiumGltf/Accessor.h index 161262181..10a80496e 100644 --- a/CesiumGltf/include/CesiumGltf/Accessor.h +++ b/CesiumGltf/include/CesiumGltf/Accessor.h @@ -1,7 +1,7 @@ #pragma once -#include "CesiumGltf/AccessorSpec.h" -#include "CesiumGltf/Library.h" +#include +#include #include diff --git a/CesiumGltf/include/CesiumGltf/AccessorUtility.h b/CesiumGltf/include/CesiumGltf/AccessorUtility.h index b2dfa40ae..88472cb12 100644 --- a/CesiumGltf/include/CesiumGltf/AccessorUtility.h +++ b/CesiumGltf/include/CesiumGltf/AccessorUtility.h @@ -1,7 +1,6 @@ #pragma once -#include "AccessorView.h" - +#include #include #include diff --git a/CesiumGltf/include/CesiumGltf/AccessorView.h b/CesiumGltf/include/CesiumGltf/AccessorView.h index b98a01b18..73480dfab 100644 --- a/CesiumGltf/include/CesiumGltf/AccessorView.h +++ b/CesiumGltf/include/CesiumGltf/AccessorView.h @@ -1,7 +1,7 @@ #pragma once -#include "CesiumGltf/Accessor.h" -#include "CesiumGltf/Model.h" +#include +#include #include #include diff --git a/CesiumGltf/include/CesiumGltf/AccessorWriter.h b/CesiumGltf/include/CesiumGltf/AccessorWriter.h index 6c55b43e6..4e59460d7 100644 --- a/CesiumGltf/include/CesiumGltf/AccessorWriter.h +++ b/CesiumGltf/include/CesiumGltf/AccessorWriter.h @@ -1,6 +1,6 @@ #pragma once -#include "CesiumGltf/AccessorView.h" +#include namespace CesiumGltf { diff --git a/CesiumGltf/include/CesiumGltf/Buffer.h b/CesiumGltf/include/CesiumGltf/Buffer.h index bf7b4e433..1b735be9f 100644 --- a/CesiumGltf/include/CesiumGltf/Buffer.h +++ b/CesiumGltf/include/CesiumGltf/Buffer.h @@ -1,8 +1,8 @@ #pragma once -#include "CesiumGltf/BufferCesium.h" -#include "CesiumGltf/BufferSpec.h" -#include "CesiumGltf/Library.h" +#include +#include +#include namespace CesiumGltf { /** @copydoc BufferSpec */ diff --git a/CesiumGltf/include/CesiumGltf/BufferCesium.h b/CesiumGltf/include/CesiumGltf/BufferCesium.h index 1aab061a1..f3582afab 100644 --- a/CesiumGltf/include/CesiumGltf/BufferCesium.h +++ b/CesiumGltf/include/CesiumGltf/BufferCesium.h @@ -1,6 +1,6 @@ #pragma once -#include "CesiumGltf/Library.h" +#include #include #include diff --git a/CesiumGltf/include/CesiumGltf/FeatureIdTextureView.h b/CesiumGltf/include/CesiumGltf/FeatureIdTextureView.h index 609cd6879..b7f193366 100644 --- a/CesiumGltf/include/CesiumGltf/FeatureIdTextureView.h +++ b/CesiumGltf/include/CesiumGltf/FeatureIdTextureView.h @@ -1,7 +1,7 @@ #pragma once -#include "CesiumGltf/FeatureIdTexture.h" -#include "CesiumGltf/TextureView.h" +#include +#include #include diff --git a/CesiumGltf/include/CesiumGltf/Image.h b/CesiumGltf/include/CesiumGltf/Image.h index 5a06d1299..3862ae0e1 100644 --- a/CesiumGltf/include/CesiumGltf/Image.h +++ b/CesiumGltf/include/CesiumGltf/Image.h @@ -1,9 +1,9 @@ #pragma once -#include "CesiumGltf/ImageAsset.h" -#include "CesiumGltf/ImageSpec.h" -#include "CesiumGltf/Library.h" -#include "CesiumUtility/IntrusivePointer.h" +#include +#include +#include +#include namespace CesiumGltf { /** @copydoc ImageSpec */ diff --git a/CesiumGltf/include/CesiumGltf/ImageAsset.h b/CesiumGltf/include/CesiumGltf/ImageAsset.h index afa666644..34d86dafd 100644 --- a/CesiumGltf/include/CesiumGltf/ImageAsset.h +++ b/CesiumGltf/include/CesiumGltf/ImageAsset.h @@ -1,8 +1,8 @@ #pragma once -#include "CesiumGltf/Ktx2TranscodeTargets.h" -#include "CesiumGltf/Library.h" -#include "CesiumUtility/SharedAsset.h" +#include +#include +#include #include #include diff --git a/CesiumGltf/include/CesiumGltf/KhrTextureTransform.h b/CesiumGltf/include/CesiumGltf/KhrTextureTransform.h index 4505b6d68..2ccd6c8dd 100644 --- a/CesiumGltf/include/CesiumGltf/KhrTextureTransform.h +++ b/CesiumGltf/include/CesiumGltf/KhrTextureTransform.h @@ -1,6 +1,6 @@ #pragma once -#include "CesiumGltf/ExtensionKhrTextureTransform.h" +#include #include diff --git a/CesiumGltf/include/CesiumGltf/Ktx2TranscodeTargets.h b/CesiumGltf/include/CesiumGltf/Ktx2TranscodeTargets.h index 103e491c4..666c8e060 100644 --- a/CesiumGltf/include/CesiumGltf/Ktx2TranscodeTargets.h +++ b/CesiumGltf/include/CesiumGltf/Ktx2TranscodeTargets.h @@ -1,6 +1,6 @@ #pragma once -#include "CesiumGltf/Library.h" +#include namespace CesiumGltf { diff --git a/CesiumGltf/include/CesiumGltf/MetadataConversions.h b/CesiumGltf/include/CesiumGltf/MetadataConversions.h index 8c5b5d747..35226cdc6 100644 --- a/CesiumGltf/include/CesiumGltf/MetadataConversions.h +++ b/CesiumGltf/include/CesiumGltf/MetadataConversions.h @@ -1,7 +1,6 @@ #pragma once -#include "PropertyTypeTraits.h" - +#include #include #include diff --git a/CesiumGltf/include/CesiumGltf/NamedObject.h b/CesiumGltf/include/CesiumGltf/NamedObject.h index fcb41a814..a3f5aefed 100644 --- a/CesiumGltf/include/CesiumGltf/NamedObject.h +++ b/CesiumGltf/include/CesiumGltf/NamedObject.h @@ -1,7 +1,6 @@ #pragma once -#include "CesiumGltf/Library.h" - +#include #include #include diff --git a/CesiumGltf/include/CesiumGltf/PropertyArrayView.h b/CesiumGltf/include/CesiumGltf/PropertyArrayView.h index fcfb8e703..4316cdddc 100644 --- a/CesiumGltf/include/CesiumGltf/PropertyArrayView.h +++ b/CesiumGltf/include/CesiumGltf/PropertyArrayView.h @@ -1,8 +1,7 @@ #pragma once -#include "CesiumGltf/PropertyType.h" -#include "getOffsetFromOffsetsBuffer.h" - +#include +#include #include #include diff --git a/CesiumGltf/include/CesiumGltf/PropertyAttributePropertyView.h b/CesiumGltf/include/CesiumGltf/PropertyAttributePropertyView.h index a30b38cfd..959aef96a 100644 --- a/CesiumGltf/include/CesiumGltf/PropertyAttributePropertyView.h +++ b/CesiumGltf/include/CesiumGltf/PropertyAttributePropertyView.h @@ -1,11 +1,10 @@ #pragma once -#include "CesiumGltf/AccessorView.h" -#include "CesiumGltf/PropertyAttributeProperty.h" -#include "CesiumGltf/PropertyTransformations.h" -#include "CesiumGltf/PropertyTypeTraits.h" -#include "CesiumGltf/PropertyView.h" - +#include +#include +#include +#include +#include #include #include diff --git a/CesiumGltf/include/CesiumGltf/PropertyAttributeView.h b/CesiumGltf/include/CesiumGltf/PropertyAttributeView.h index 478169b58..1727a7233 100644 --- a/CesiumGltf/include/CesiumGltf/PropertyAttributeView.h +++ b/CesiumGltf/include/CesiumGltf/PropertyAttributeView.h @@ -1,11 +1,11 @@ #pragma once -#include "CesiumGltf/Class.h" -#include "CesiumGltf/ClassProperty.h" -#include "CesiumGltf/ExtensionModelExtStructuralMetadata.h" -#include "CesiumGltf/PropertyAttribute.h" -#include "CesiumGltf/PropertyAttributePropertyView.h" -#include "Model.h" +#include +#include +#include +#include +#include +#include namespace CesiumGltf { /** diff --git a/CesiumGltf/include/CesiumGltf/PropertyTablePropertyView.h b/CesiumGltf/include/CesiumGltf/PropertyTablePropertyView.h index f37d0642d..350e9e55d 100644 --- a/CesiumGltf/include/CesiumGltf/PropertyTablePropertyView.h +++ b/CesiumGltf/include/CesiumGltf/PropertyTablePropertyView.h @@ -1,10 +1,9 @@ #pragma once -#include "CesiumGltf/PropertyArrayView.h" -#include "CesiumGltf/PropertyTransformations.h" -#include "CesiumGltf/PropertyTypeTraits.h" -#include "CesiumGltf/PropertyView.h" - +#include +#include +#include +#include #include #include diff --git a/CesiumGltf/include/CesiumGltf/PropertyTableView.h b/CesiumGltf/include/CesiumGltf/PropertyTableView.h index f5bfaac40..501c62106 100644 --- a/CesiumGltf/include/CesiumGltf/PropertyTableView.h +++ b/CesiumGltf/include/CesiumGltf/PropertyTableView.h @@ -1,9 +1,9 @@ #pragma once -#include "CesiumGltf/ExtensionModelExtStructuralMetadata.h" -#include "CesiumGltf/Model.h" -#include "CesiumGltf/PropertyTablePropertyView.h" -#include "CesiumGltf/PropertyType.h" +#include +#include +#include +#include #include diff --git a/CesiumGltf/include/CesiumGltf/PropertyTexturePropertyView.h b/CesiumGltf/include/CesiumGltf/PropertyTexturePropertyView.h index 52583abf2..e8242f8f8 100644 --- a/CesiumGltf/include/CesiumGltf/PropertyTexturePropertyView.h +++ b/CesiumGltf/include/CesiumGltf/PropertyTexturePropertyView.h @@ -1,14 +1,13 @@ #pragma once -#include "CesiumGltf/ImageAsset.h" -#include "CesiumGltf/KhrTextureTransform.h" -#include "CesiumGltf/PropertyTextureProperty.h" -#include "CesiumGltf/PropertyTransformations.h" -#include "CesiumGltf/PropertyTypeTraits.h" -#include "CesiumGltf/PropertyView.h" -#include "CesiumGltf/Sampler.h" -#include "CesiumGltf/TextureView.h" - +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/CesiumGltf/include/CesiumGltf/PropertyTextureView.h b/CesiumGltf/include/CesiumGltf/PropertyTextureView.h index d5d35c16e..eccba1fa2 100644 --- a/CesiumGltf/include/CesiumGltf/PropertyTextureView.h +++ b/CesiumGltf/include/CesiumGltf/PropertyTextureView.h @@ -1,12 +1,12 @@ #pragma once -#include "CesiumGltf/Class.h" -#include "CesiumGltf/ClassProperty.h" -#include "CesiumGltf/ExtensionModelExtStructuralMetadata.h" -#include "CesiumGltf/Model.h" -#include "CesiumGltf/PropertyTexture.h" -#include "CesiumGltf/PropertyTexturePropertyView.h" -#include "CesiumGltf/TextureView.h" +#include +#include +#include +#include +#include +#include +#include namespace CesiumGltf { /** diff --git a/CesiumGltf/include/CesiumGltf/PropertyTransformations.h b/CesiumGltf/include/CesiumGltf/PropertyTransformations.h index d097c8866..0ae06a7b3 100644 --- a/CesiumGltf/include/CesiumGltf/PropertyTransformations.h +++ b/CesiumGltf/include/CesiumGltf/PropertyTransformations.h @@ -1,7 +1,7 @@ #pragma once -#include "CesiumGltf/PropertyArrayView.h" -#include "CesiumGltf/PropertyTypeTraits.h" +#include +#include #include diff --git a/CesiumGltf/include/CesiumGltf/PropertyTypeTraits.h b/CesiumGltf/include/CesiumGltf/PropertyTypeTraits.h index df357f600..1ef45b870 100644 --- a/CesiumGltf/include/CesiumGltf/PropertyTypeTraits.h +++ b/CesiumGltf/include/CesiumGltf/PropertyTypeTraits.h @@ -1,7 +1,7 @@ #pragma once -#include "CesiumGltf/PropertyArrayView.h" -#include "CesiumGltf/PropertyType.h" +#include +#include #include diff --git a/CesiumGltf/include/CesiumGltf/PropertyView.h b/CesiumGltf/include/CesiumGltf/PropertyView.h index 8e017c870..f6cb49754 100644 --- a/CesiumGltf/include/CesiumGltf/PropertyView.h +++ b/CesiumGltf/include/CesiumGltf/PropertyView.h @@ -1,10 +1,10 @@ #pragma once -#include "CesiumGltf/ClassProperty.h" -#include "CesiumGltf/PropertyAttributeProperty.h" -#include "CesiumGltf/PropertyTableProperty.h" -#include "CesiumGltf/PropertyTextureProperty.h" -#include "CesiumGltf/PropertyTypeTraits.h" +#include +#include +#include +#include +#include #include #include diff --git a/CesiumGltf/include/CesiumGltf/getOffsetFromOffsetsBuffer.h b/CesiumGltf/include/CesiumGltf/getOffsetFromOffsetsBuffer.h index 6fcb96dc0..02d304b3f 100644 --- a/CesiumGltf/include/CesiumGltf/getOffsetFromOffsetsBuffer.h +++ b/CesiumGltf/include/CesiumGltf/getOffsetFromOffsetsBuffer.h @@ -1,7 +1,6 @@ #pragma once -#include "CesiumGltf/PropertyType.h" - +#include #include #include diff --git a/CesiumGltf/src/Accessor.cpp b/CesiumGltf/src/Accessor.cpp index 075df596c..202d53033 100644 --- a/CesiumGltf/src/Accessor.cpp +++ b/CesiumGltf/src/Accessor.cpp @@ -1,6 +1,9 @@ -#include "CesiumGltf/Accessor.h" +#include +#include +#include -#include "CesiumGltf/Model.h" +#include +#include namespace CesiumGltf { /*static*/ int8_t @@ -77,7 +80,8 @@ Accessor::computeByteStride(const CesiumGltf::Model& model) const noexcept { if (pBufferView->byteStride && pBufferView->byteStride.value() != 0) { return pBufferView->byteStride.value(); } - return computeNumberOfComponents(this->type) * - computeByteSizeOfComponent(this->componentType); + return static_cast( + computeNumberOfComponents(this->type) * + computeByteSizeOfComponent(this->componentType)); } } // namespace CesiumGltf diff --git a/CesiumGltf/src/AccessorUtility.cpp b/CesiumGltf/src/AccessorUtility.cpp index 26dd6d8a9..db5443b87 100644 --- a/CesiumGltf/src/AccessorUtility.cpp +++ b/CesiumGltf/src/AccessorUtility.cpp @@ -1,7 +1,13 @@ -#include "CesiumGltf/AccessorUtility.h" - -#include "CesiumGltf/ExtensionExtMeshGpuInstancing.h" -#include "CesiumGltf/Model.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include namespace CesiumGltf { PositionAccessorType diff --git a/CesiumGltf/src/FeatureIdTextureView.cpp b/CesiumGltf/src/FeatureIdTextureView.cpp index ab7719e47..e3598a142 100644 --- a/CesiumGltf/src/FeatureIdTextureView.cpp +++ b/CesiumGltf/src/FeatureIdTextureView.cpp @@ -1,8 +1,11 @@ -#include "CesiumGltf/FeatureIdTextureView.h" +#include +#include +#include +#include -#include "CesiumGltf/ExtensionKhrTextureTransform.h" -#include "CesiumGltf/Model.h" -#include "CesiumGltf/SamplerUtility.h" +#include +#include +#include namespace CesiumGltf { FeatureIdTextureView::FeatureIdTextureView() noexcept @@ -48,8 +51,8 @@ FeatureIdTextureView::FeatureIdTextureView( } // Only channel values 0-3 are supported. - for (size_t i = 0; i < channels.size(); i++) { - if (channels[i] < 0 || channels[i] > 3) { + for (int64_t channel : channels) { + if (channel < 0 || channel > 3) { this->_status = FeatureIdTextureViewStatus::ErrorInvalidChannels; return; } diff --git a/CesiumGltf/src/InstanceAttributeSemantics.cpp b/CesiumGltf/src/InstanceAttributeSemantics.cpp index 6bde1ea61..6eef54532 100644 --- a/CesiumGltf/src/InstanceAttributeSemantics.cpp +++ b/CesiumGltf/src/InstanceAttributeSemantics.cpp @@ -1,5 +1,8 @@ #include +#include +#include + namespace CesiumGltf { /** diff --git a/CesiumGltf/src/KhrTextureTransform.cpp b/CesiumGltf/src/KhrTextureTransform.cpp index dd1dad8cd..5a6af64ba 100644 --- a/CesiumGltf/src/KhrTextureTransform.cpp +++ b/CesiumGltf/src/KhrTextureTransform.cpp @@ -1,5 +1,10 @@ -#include "CesiumGltf/KhrTextureTransform.h" +#include +#include + +#include + +#include using namespace CesiumGltf; diff --git a/CesiumGltf/src/Ktx2TranscodeTargets.cpp b/CesiumGltf/src/Ktx2TranscodeTargets.cpp index 07f24d9ef..844ddadc0 100644 --- a/CesiumGltf/src/Ktx2TranscodeTargets.cpp +++ b/CesiumGltf/src/Ktx2TranscodeTargets.cpp @@ -1,7 +1,5 @@ -#include "CesiumGltf/Ktx2TranscodeTargets.h" - -#include +#include using namespace CesiumGltf; diff --git a/CesiumGltf/src/Model.cpp b/CesiumGltf/src/Model.cpp index 857e982fe..d65bdd6a3 100644 --- a/CesiumGltf/src/Model.cpp +++ b/CesiumGltf/src/Model.cpp @@ -1,27 +1,63 @@ -#include "CesiumGltf/Model.h" - -#include "CesiumGltf/AccessorView.h" -#include "CesiumGltf/ExtensionBufferViewExtMeshoptCompression.h" -#include "CesiumGltf/ExtensionCesiumPrimitiveOutline.h" -#include "CesiumGltf/ExtensionCesiumTileEdges.h" -#include "CesiumGltf/ExtensionExtMeshFeatures.h" -#include "CesiumGltf/ExtensionExtMeshGpuInstancing.h" -#include "CesiumGltf/ExtensionKhrDracoMeshCompression.h" -#include "CesiumGltf/ExtensionKhrTextureBasisu.h" -#include "CesiumGltf/ExtensionMeshPrimitiveExtStructuralMetadata.h" -#include "CesiumGltf/ExtensionModelExtStructuralMetadata.h" -#include "CesiumGltf/ExtensionTextureWebp.h" - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include - -#include +#include + +#include +#include +#include +#include +#include +#include #include -#include #include #include -#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include using namespace CesiumUtility; diff --git a/CesiumGltf/src/PropertyAttributePropertyView.cpp b/CesiumGltf/src/PropertyAttributePropertyView.cpp index 378486cda..8e70f58ad 100644 --- a/CesiumGltf/src/PropertyAttributePropertyView.cpp +++ b/CesiumGltf/src/PropertyAttributePropertyView.cpp @@ -1,4 +1,5 @@ -#include "CesiumGltf/PropertyAttributePropertyView.h" +#include +#include namespace CesiumGltf { // Re-initialize consts here to avoid "undefined reference" errors with GCC / diff --git a/CesiumGltf/src/PropertyAttributeView.cpp b/CesiumGltf/src/PropertyAttributeView.cpp index 34d9a441b..7b5e720f8 100644 --- a/CesiumGltf/src/PropertyAttributeView.cpp +++ b/CesiumGltf/src/PropertyAttributeView.cpp @@ -1,4 +1,12 @@ -#include "CesiumGltf/PropertyAttributeView.h" +#include +#include +#include +#include +#include +#include +#include + +#include namespace CesiumGltf { PropertyType getAccessorTypeAsPropertyType(const Accessor& accessor) { diff --git a/CesiumGltf/src/PropertyTablePropertyView.cpp b/CesiumGltf/src/PropertyTablePropertyView.cpp index 8d2dabf53..e1cd8f6fe 100644 --- a/CesiumGltf/src/PropertyTablePropertyView.cpp +++ b/CesiumGltf/src/PropertyTablePropertyView.cpp @@ -1,4 +1,8 @@ -#include "CesiumGltf/PropertyTablePropertyView.h" +#include +#include +#include + +#include namespace CesiumGltf { // Re-initialize consts here to avoid "undefined reference" errors with GCC / diff --git a/CesiumGltf/src/PropertyTableView.cpp b/CesiumGltf/src/PropertyTableView.cpp index 361e318ed..f7bea44ea 100644 --- a/CesiumGltf/src/PropertyTableView.cpp +++ b/CesiumGltf/src/PropertyTableView.cpp @@ -1,8 +1,31 @@ -#include "CesiumGltf/PropertyTableView.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include namespace CesiumGltf { + +namespace { template -static PropertyViewStatusType checkOffsetsBuffer( +PropertyViewStatusType checkOffsetsBuffer( const std::span& offsetBuffer, size_t valueBufferSize, size_t instanceCount, @@ -46,7 +69,7 @@ static PropertyViewStatusType checkOffsetsBuffer( } template -static PropertyViewStatusType checkStringAndArrayOffsetsBuffers( +PropertyViewStatusType checkStringAndArrayOffsetsBuffers( const std::span& arrayOffsets, const std::span& stringOffsets, size_t valueBufferSize, @@ -103,6 +126,7 @@ static PropertyViewStatusType checkStringAndArrayOffsetsBuffers( return PropertyTablePropertyViewStatus::ErrorInvalidStringOffsetType; } } +} // namespace PropertyTableView::PropertyTableView( const Model& model, diff --git a/CesiumGltf/src/PropertyTexturePropertyView.cpp b/CesiumGltf/src/PropertyTexturePropertyView.cpp index c9435dcca..3a749b715 100644 --- a/CesiumGltf/src/PropertyTexturePropertyView.cpp +++ b/CesiumGltf/src/PropertyTexturePropertyView.cpp @@ -1,4 +1,5 @@ -#include "CesiumGltf/PropertyTexturePropertyView.h" +#include +#include namespace CesiumGltf { diff --git a/CesiumGltf/src/PropertyTextureView.cpp b/CesiumGltf/src/PropertyTextureView.cpp index c9968f4b0..40d2bbd93 100644 --- a/CesiumGltf/src/PropertyTextureView.cpp +++ b/CesiumGltf/src/PropertyTextureView.cpp @@ -1,4 +1,18 @@ -#include "CesiumGltf/PropertyTextureView.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include namespace CesiumGltf { PropertyTextureView::PropertyTextureView( @@ -102,8 +116,8 @@ PropertyViewStatusType PropertyTextureView::checkChannels( } int64_t imageChannelCount = static_cast(image.channels); - for (size_t i = 0; i < channels.size(); i++) { - if (channels[i] < 0 || channels[i] >= imageChannelCount) { + for (int64_t channel : channels) { + if (channel < 0 || channel >= imageChannelCount) { return PropertyTexturePropertyViewStatus::ErrorInvalidChannels; } } diff --git a/CesiumGltf/src/PropertyType.cpp b/CesiumGltf/src/PropertyType.cpp index 177bdf3ed..7a3d85805 100644 --- a/CesiumGltf/src/PropertyType.cpp +++ b/CesiumGltf/src/PropertyType.cpp @@ -1,8 +1,12 @@ -#include "CesiumGltf/PropertyType.h" +#include +#include +#include +#include -#include "CesiumGltf/AccessorSpec.h" -#include "CesiumGltf/ClassProperty.h" -#include "CesiumGltf/PropertyTable.h" +#include + +#include +#include namespace CesiumGltf { std::string convertPropertyTypeToString(PropertyType type) { diff --git a/CesiumGltf/src/PropertyView.cpp b/CesiumGltf/src/PropertyView.cpp index 007210460..79c752b68 100644 --- a/CesiumGltf/src/PropertyView.cpp +++ b/CesiumGltf/src/PropertyView.cpp @@ -1,4 +1,4 @@ -#include "CesiumGltf/PropertyView.h" +#include using namespace CesiumGltf; diff --git a/CesiumGltf/src/SamplerUtility.cpp b/CesiumGltf/src/SamplerUtility.cpp index 55c2c54c8..baf744e0e 100644 --- a/CesiumGltf/src/SamplerUtility.cpp +++ b/CesiumGltf/src/SamplerUtility.cpp @@ -1,9 +1,12 @@ -#include "CesiumGltf/SamplerUtility.h" - -#include "CesiumGltf/Sampler.h" +#include +#include #include +#include +#include +#include + namespace CesiumGltf { double applySamplerWrapS(const double u, const int32_t wrapS) { if (wrapS == Sampler::WrapS::REPEAT) { diff --git a/CesiumGltf/src/TextureView.cpp b/CesiumGltf/src/TextureView.cpp index 39ad5630e..f38e5b689 100644 --- a/CesiumGltf/src/TextureView.cpp +++ b/CesiumGltf/src/TextureView.cpp @@ -1,9 +1,21 @@ -#include "CesiumGltf/TextureView.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "CesiumGltf/Model.h" -#include "CesiumGltf/SamplerUtility.h" +#include +#include -#include +#include +#include +#include +#include +#include namespace CesiumGltf { @@ -156,7 +168,8 @@ std::vector TextureView::sampleNearestPixel( static_cast(image.height) - 1); int64_t pixelIndex = - image.bytesPerChannel * image.channels * (y * image.width + x); + static_cast(image.bytesPerChannel * image.channels) * + (y * image.width + x); // TODO: Currently stb only outputs uint8 pixel types. If that // changes this should account for additional pixel byte sizes. diff --git a/CesiumGltf/src/VertexAttributeSemantics.cpp b/CesiumGltf/src/VertexAttributeSemantics.cpp index e8a1661a3..f11b0880b 100644 --- a/CesiumGltf/src/VertexAttributeSemantics.cpp +++ b/CesiumGltf/src/VertexAttributeSemantics.cpp @@ -1,5 +1,8 @@ #include +#include +#include + namespace CesiumGltf { /** diff --git a/CesiumGltf/test/TestAccessorUtility.cpp b/CesiumGltf/test/TestAccessorUtility.cpp index 3f0c8d58c..9fd7d1055 100644 --- a/CesiumGltf/test/TestAccessorUtility.cpp +++ b/CesiumGltf/test/TestAccessorUtility.cpp @@ -1,10 +1,23 @@ -#include "CesiumGltf/AccessorUtility.h" -#include "CesiumGltf/ExtensionExtMeshGpuInstancing.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include #include +#include +#include +#include +#include #include +#include +#include using namespace CesiumGltf; diff --git a/CesiumGltf/test/TestAccessorView.cpp b/CesiumGltf/test/TestAccessorView.cpp index 1f756fa85..b70405a29 100644 --- a/CesiumGltf/test/TestAccessorView.cpp +++ b/CesiumGltf/test/TestAccessorView.cpp @@ -1,9 +1,15 @@ -#include "CesiumGltf/AccessorView.h" -#include "CesiumGltf/Model.h" +#include +#include +#include +#include +#include -#include #include -#include +#include + +#include +#include +#include using namespace CesiumGltf; diff --git a/CesiumGltf/test/TestFeatureIdTextureView.cpp b/CesiumGltf/test/TestFeatureIdTextureView.cpp index 6e5295cf3..cf806ca60 100644 --- a/CesiumGltf/test/TestFeatureIdTextureView.cpp +++ b/CesiumGltf/test/TestFeatureIdTextureView.cpp @@ -1,16 +1,25 @@ -#include "CesiumGltf/ExtensionExtMeshFeatures.h" -#include "CesiumGltf/FeatureIdTextureView.h" -#include "CesiumGltf/KhrTextureTransform.h" -#include "CesiumGltf/Model.h" -#include "CesiumUtility/Math.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include #include #include #include +#include #include -#include +#include #include using namespace CesiumGltf; diff --git a/CesiumGltf/test/TestJsonValue.cpp b/CesiumGltf/test/TestJsonValue.cpp index 1964a3765..f78fae0b1 100644 --- a/CesiumGltf/test/TestJsonValue.cpp +++ b/CesiumGltf/test/TestJsonValue.cpp @@ -1,6 +1,5 @@ #include -#include #include #include diff --git a/CesiumGltf/test/TestKhrTextureTransform.cpp b/CesiumGltf/test/TestKhrTextureTransform.cpp index 8d88382ee..69e18ff3d 100644 --- a/CesiumGltf/test/TestKhrTextureTransform.cpp +++ b/CesiumGltf/test/TestKhrTextureTransform.cpp @@ -1,7 +1,7 @@ -#include "CesiumGltf/KhrTextureTransform.h" -#include "CesiumUtility/Math.h" +#include +#include +#include -#include #include using namespace CesiumGltf; diff --git a/CesiumGltf/test/TestMetadataConversions.cpp b/CesiumGltf/test/TestMetadataConversions.cpp index 8d0c56296..cac43385a 100644 --- a/CesiumGltf/test/TestMetadataConversions.cpp +++ b/CesiumGltf/test/TestMetadataConversions.cpp @@ -1,7 +1,38 @@ -#include "CesiumGltf/MetadataConversions.h" +#include +#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include #ifdef _MSC_VER // Some tests intentionally use a double value that overflows a float. diff --git a/CesiumGltf/test/TestModel.cpp b/CesiumGltf/test/TestModel.cpp index 17f576065..524f3db4a 100644 --- a/CesiumGltf/test/TestModel.cpp +++ b/CesiumGltf/test/TestModel.cpp @@ -1,6 +1,8 @@ -#include "CesiumGltf/AccessorView.h" -#include "CesiumGltf/Model.h" - +#include +#include +#include +#include +#include #include #include #include @@ -10,18 +12,29 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include #include -#include +#include +#include +#include #include -#include -#include +#include #include #include #include -#include #include #include diff --git a/CesiumGltf/test/TestPropertyAttributePropertyView.cpp b/CesiumGltf/test/TestPropertyAttributePropertyView.cpp index 990a62dce..a2de0740b 100644 --- a/CesiumGltf/test/TestPropertyAttributePropertyView.cpp +++ b/CesiumGltf/test/TestPropertyAttributePropertyView.cpp @@ -1,17 +1,39 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif -#include "CesiumGltf/PropertyAttributePropertyView.h" - +#include #include -#include #include #include -#include #include using namespace CesiumGltf; diff --git a/CesiumGltf/test/TestPropertyAttributeView.cpp b/CesiumGltf/test/TestPropertyAttributeView.cpp index 1f94e588d..3b8897e57 100644 --- a/CesiumGltf/test/TestPropertyAttributeView.cpp +++ b/CesiumGltf/test/TestPropertyAttributeView.cpp @@ -1,12 +1,38 @@ -#include "CesiumGltf/PropertyAttributeView.h" - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include #include using namespace CesiumGltf; diff --git a/CesiumGltf/test/TestPropertyTablePropertyView.cpp b/CesiumGltf/test/TestPropertyTablePropertyView.cpp index d7b29538d..0979638c8 100644 --- a/CesiumGltf/test/TestPropertyTablePropertyView.cpp +++ b/CesiumGltf/test/TestPropertyTablePropertyView.cpp @@ -1,9 +1,36 @@ +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif -#include "CesiumGltf/PropertyTablePropertyView.h" +#include #include #include diff --git a/CesiumGltf/test/TestPropertyTableView.cpp b/CesiumGltf/test/TestPropertyTableView.cpp index 121f86f82..90c35e714 100644 --- a/CesiumGltf/test/TestPropertyTableView.cpp +++ b/CesiumGltf/test/TestPropertyTableView.cpp @@ -1,10 +1,37 @@ -#include "CesiumGltf/PropertyTablePropertyView.h" -#include "CesiumGltf/PropertyTableView.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include #include - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #include +#include +#include +#include using namespace CesiumGltf; diff --git a/CesiumGltf/test/TestPropertyTexturePropertyView.cpp b/CesiumGltf/test/TestPropertyTexturePropertyView.cpp index 2474c8a9a..850661655 100644 --- a/CesiumGltf/test/TestPropertyTexturePropertyView.cpp +++ b/CesiumGltf/test/TestPropertyTexturePropertyView.cpp @@ -1,18 +1,42 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif -#include "CesiumGltf/KhrTextureTransform.h" -#include "CesiumGltf/PropertyTexturePropertyView.h" -#include "CesiumUtility/Math.h" +#include +#include +#include -#include #include #include #include -#include #include using namespace CesiumGltf; diff --git a/CesiumGltf/test/TestPropertyTextureView.cpp b/CesiumGltf/test/TestPropertyTextureView.cpp index fa24ea0be..cd9cf2274 100644 --- a/CesiumGltf/test/TestPropertyTextureView.cpp +++ b/CesiumGltf/test/TestPropertyTextureView.cpp @@ -1,11 +1,31 @@ -#include "CesiumGltf/PropertyTextureView.h" -#include "CesiumUtility/Math.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include #include +#include +#include +#include +#include #include -#include +#include +#include +#include #include using namespace CesiumGltf; diff --git a/CesiumGltf/test/TestPropertyType.cpp b/CesiumGltf/test/TestPropertyType.cpp index 412e06eb4..3cc3fa4b7 100644 --- a/CesiumGltf/test/TestPropertyType.cpp +++ b/CesiumGltf/test/TestPropertyType.cpp @@ -1,11 +1,12 @@ -#include "CesiumGltf/AccessorSpec.h" -#include "CesiumGltf/ClassProperty.h" -#include "CesiumGltf/PropertyTableProperty.h" -#include "CesiumGltf/PropertyType.h" +#include +#include +#include +#include -#include #include +#include + using namespace CesiumGltf; TEST_CASE("Test convertStringToPropertyType") { diff --git a/CesiumGltf/test/TestPropertyTypeTraits.cpp b/CesiumGltf/test/TestPropertyTypeTraits.cpp index c8ec79d31..b61f5567a 100644 --- a/CesiumGltf/test/TestPropertyTypeTraits.cpp +++ b/CesiumGltf/test/TestPropertyTypeTraits.cpp @@ -1,7 +1,38 @@ -#include "CesiumGltf/PropertyTypeTraits.h" +#include +#include +#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include using namespace CesiumGltf; diff --git a/CesiumGltf/test/TestPropertyView.cpp b/CesiumGltf/test/TestPropertyView.cpp index 07152b95d..da065b4dd 100644 --- a/CesiumGltf/test/TestPropertyView.cpp +++ b/CesiumGltf/test/TestPropertyView.cpp @@ -1,7 +1,27 @@ -#include "CesiumGltf/PropertyView.h" +#include +#include +#include +#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include using namespace CesiumGltf; using namespace CesiumUtility; diff --git a/CesiumGltfContent/CMakeLists.txt b/CesiumGltfContent/CMakeLists.txt index 52755cf69..e60c25912 100644 --- a/CesiumGltfContent/CMakeLists.txt +++ b/CesiumGltfContent/CMakeLists.txt @@ -32,6 +32,8 @@ set_target_properties(CesiumGltfContent PUBLIC_HEADER "${CESIUM_GLTF_CONTENT_PUBLIC_HEADERS}" ) +target_compile_definitions(CesiumGltfContent PRIVATE GLM_ENABLE_EXPERIMENTAL) + target_sources( CesiumGltfContent PRIVATE diff --git a/CesiumGltfContent/include/CesiumGltfContent/GltfUtilities.h b/CesiumGltfContent/include/CesiumGltfContent/GltfUtilities.h index f6cce9ac0..d3c86bb03 100644 --- a/CesiumGltfContent/include/CesiumGltfContent/GltfUtilities.h +++ b/CesiumGltfContent/include/CesiumGltfContent/GltfUtilities.h @@ -1,10 +1,9 @@ #pragma once -#include "Library.h" - #include #include #include +#include #include diff --git a/CesiumGltfContent/include/CesiumGltfContent/ImageManipulation.h b/CesiumGltfContent/include/CesiumGltfContent/ImageManipulation.h index 57c2a0b72..ce11cfc61 100644 --- a/CesiumGltfContent/include/CesiumGltfContent/ImageManipulation.h +++ b/CesiumGltfContent/include/CesiumGltfContent/ImageManipulation.h @@ -1,9 +1,10 @@ #pragma once -#include "Library.h" +#include #include #include +#include // Forward declarations namespace CesiumGltf { diff --git a/CesiumGltfContent/src/GltfUtilities.cpp b/CesiumGltfContent/src/GltfUtilities.cpp index a7454b25a..fb4aef5fa 100644 --- a/CesiumGltfContent/src/GltfUtilities.cpp +++ b/CesiumGltfContent/src/GltfUtilities.cpp @@ -2,14 +2,21 @@ #include #include #include +#include #include +#include +#include +#include +#include #include +#include +#include +#include #include #include #include #include #include -#include #include #include #include @@ -17,16 +24,39 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include #include using namespace CesiumGltf; @@ -425,7 +455,7 @@ void findClosestRayHit( // Need at least 3 positions to form a triangle if (positionView.size() < 3) { - warnings.push_back("Skipping mesh with less than 3 vertex positions"); + warnings.emplace_back("Skipping mesh with less than 3 vertex positions"); return; } @@ -562,7 +592,7 @@ void findClosestIndexedRayHit( // Need at least 3 vertices to form a triangle if (indicesView.size() < 3) { - warnings.push_back("Skipping indexed mesh with less than 3 indices"); + warnings.emplace_back("Skipping indexed mesh with less than 3 indices"); return; } @@ -720,7 +750,7 @@ void findClosestIndexedRayHit( } if (foundInvalidIndex) - warnings.push_back( + warnings.emplace_back( "Found one or more invalid index values for indexed mesh"); tMinOut = tClosest; @@ -788,8 +818,8 @@ std::vector getIndexMap(const std::vector& usedIndices) { indexMap.reserve(usedIndices.size()); int32_t nextIndex = 0; - for (size_t i = 0; i < usedIndices.size(); ++i) { - if (usedIndices[i]) { + for (bool usedIndex : usedIndices) { + if (usedIndex) { indexMap.push_back(nextIndex); ++nextIndex; } else { @@ -1305,7 +1335,7 @@ std::optional intersectRayScenePrimitive( &warnings](const auto& positionView) { // Bail on invalid view if (positionView.status() != AccessorViewStatus::Valid) { - warnings.push_back( + warnings.emplace_back( "Skipping mesh with an invalid position component type"); return; } @@ -1316,7 +1346,7 @@ std::optional intersectRayScenePrimitive( Model::getSafe(&model.accessors, primitive.indices); if (!indexAccessor) { - warnings.push_back( + warnings.emplace_back( "Skipping mesh with an invalid index accessor id"); return; } @@ -1325,7 +1355,7 @@ std::optional intersectRayScenePrimitive( // From the glTF spec... // "Indices MUST be non-negative integer numbers." if (indexAccessor->componentType == Accessor::ComponentType::FLOAT) { - warnings.push_back( + warnings.emplace_back( "Skipping mesh with an invalid index component type"); return; } @@ -1341,7 +1371,7 @@ std::optional intersectRayScenePrimitive( &warnings](const auto& indexView) { // Bail on invalid view if (indexView.status() != AccessorViewStatus::Valid) { - warnings.push_back( + warnings.emplace_back( "Could not create accessor view for mesh indices"); return; } @@ -1427,7 +1457,7 @@ GltfUtilities::IntersectResult GltfUtilities::intersectRayGltfModel( // Skip primitives that can't access positions auto positionAccessorIt = primitive.attributes.find("POSITION"); if (positionAccessorIt == primitive.attributes.end()) { - result.warnings.push_back( + result.warnings.emplace_back( "Skipping mesh without a position attribute"); return; } @@ -1435,7 +1465,7 @@ GltfUtilities::IntersectResult GltfUtilities::intersectRayGltfModel( const Accessor* pPositionAccessor = Model::getSafe(&model.accessors, positionAccessorID); if (!pPositionAccessor) { - result.warnings.push_back( + result.warnings.emplace_back( "Skipping mesh with an invalid position accessor id"); return; } @@ -1443,7 +1473,7 @@ GltfUtilities::IntersectResult GltfUtilities::intersectRayGltfModel( // From the glTF spec, the POSITION accessor must use VEC3 // But we should still protect against malformed gltfs if (pPositionAccessor->type != AccessorSpec::Type::VEC3) { - result.warnings.push_back( + result.warnings.emplace_back( "Skipping mesh with a non-vec3 position accessor"); return; } diff --git a/CesiumGltfContent/src/ImageManipulation.cpp b/CesiumGltfContent/src/ImageManipulation.cpp index e1b368a7a..372eab44f 100644 --- a/CesiumGltfContent/src/ImageManipulation.cpp +++ b/CesiumGltfContent/src/ImageManipulation.cpp @@ -2,7 +2,9 @@ #include #include +#include #include +#include #define STB_IMAGE_WRITE_STATIC #define STB_IMAGE_WRITE_IMPLEMENTATION diff --git a/CesiumGltfContent/src/SkirtMeshMetadata.cpp b/CesiumGltfContent/src/SkirtMeshMetadata.cpp index f230dbbc8..e530f31b9 100644 --- a/CesiumGltfContent/src/SkirtMeshMetadata.cpp +++ b/CesiumGltfContent/src/SkirtMeshMetadata.cpp @@ -1,8 +1,8 @@ #include #include +#include #include -#include using namespace CesiumUtility; diff --git a/CesiumGltfContent/test/TestGltfUtilities.cpp b/CesiumGltfContent/test/TestGltfUtilities.cpp index 89e117b3c..86cdc50fc 100644 --- a/CesiumGltfContent/test/TestGltfUtilities.cpp +++ b/CesiumGltfContent/test/TestGltfUtilities.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -5,10 +6,15 @@ #include #include -#include #include +#include +#include +#include #include +#include +#include + using namespace CesiumGltf; using namespace CesiumGltfContent; using namespace CesiumUtility; diff --git a/CesiumGltfContent/test/TestImageManipulation.cpp b/CesiumGltfContent/test/TestImageManipulation.cpp index 6757bece9..6fb97af04 100644 --- a/CesiumGltfContent/test/TestImageManipulation.cpp +++ b/CesiumGltfContent/test/TestImageManipulation.cpp @@ -1,10 +1,11 @@ #include #include -#include #include #include +#include +#include using namespace CesiumGltf; using namespace CesiumGltfContent; diff --git a/CesiumGltfContent/test/TestIntersectRayGltf.cpp b/CesiumGltfContent/test/TestIntersectRayGltf.cpp index 69b3f56ca..550c2db81 100644 --- a/CesiumGltfContent/test/TestIntersectRayGltf.cpp +++ b/CesiumGltfContent/test/TestIntersectRayGltf.cpp @@ -1,17 +1,22 @@ -#include "CesiumGeometry/IntersectionTests.h" -#include "CesiumGeometry/Ray.h" -#include "CesiumGltfContent/GltfUtilities.h" -#include "CesiumGltfReader/GltfReader.h" - +#include +#include +#include +#include +#include +#include +#include #include #include -#include #include -#include +#include +#include +#include +#include +#include #include -#include +#include using namespace CesiumUtility; using namespace CesiumGltf; diff --git a/CesiumGltfReader/include/CesiumGltfReader/GltfReader.h b/CesiumGltfReader/include/CesiumGltfReader/GltfReader.h index 9a6eb8f23..6ce9f5728 100644 --- a/CesiumGltfReader/include/CesiumGltfReader/GltfReader.h +++ b/CesiumGltfReader/include/CesiumGltfReader/GltfReader.h @@ -1,8 +1,5 @@ #pragma once -#include "CesiumGltfReader/ImageDecoder.h" -#include "CesiumGltfReader/Library.h" - #include #include #include @@ -11,6 +8,8 @@ #include #include #include +#include +#include #include #include diff --git a/CesiumGltfReader/include/CesiumGltfReader/ImageDecoder.h b/CesiumGltfReader/include/CesiumGltfReader/ImageDecoder.h index d07ec06b1..c565124cb 100644 --- a/CesiumGltfReader/include/CesiumGltfReader/ImageDecoder.h +++ b/CesiumGltfReader/include/CesiumGltfReader/ImageDecoder.h @@ -1,8 +1,7 @@ #pragma once -#include "CesiumGltf/ImageAsset.h" -#include "CesiumGltfReader/Library.h" - +#include +#include #include #include diff --git a/CesiumGltfReader/src/GltfReader.cpp b/CesiumGltfReader/src/GltfReader.cpp index ca1fe0548..fa3064186 100644 --- a/CesiumGltfReader/src/GltfReader.cpp +++ b/CesiumGltfReader/src/GltfReader.cpp @@ -1,5 +1,3 @@ -#include "CesiumGltfReader/GltfReader.h" - #include "ModelJsonHandler.h" #include "applyKhrTextureTransform.h" #include "decodeDataUrls.h" @@ -8,27 +6,48 @@ #include "dequantizeMeshData.h" #include "registerReaderExtensions.h" +#include +#include +#include +#include #include #include +#include +#include +#include #include #include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include +#include +#include #include #include +#include -#include -#include -#include +#include #include #include -#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include using namespace CesiumAsync; using namespace CesiumGltf; @@ -232,6 +251,10 @@ GltfReaderResult readBinaryGltf( } void postprocess(GltfReaderResult& readGltf, const GltfReaderOptions& options) { + if (!readGltf.model) { + return; + } + Model& model = readGltf.model.value(); auto extFeatureMetadataIter = std::find( @@ -506,6 +529,10 @@ void CesiumGltfReader::GltfReader::postprocessGltf( constexpr std::string_view dataPrefix = "data:"; constexpr size_t dataPrefixLength = dataPrefix.size(); + // We already checked pResult->model at the top of the method, but clang-tidy + // doesn't understand this. + // NOLINTBEGIN(bugprone-unchecked-optional-access) + for (Buffer& buffer : pResult->model->buffers) { if (buffer.uri && buffer.uri->substr(0, dataPrefixLength) != dataPrefix) { resolvedBuffers.push_back( @@ -593,6 +620,7 @@ void CesiumGltfReader::GltfReader::postprocessGltf( ExtensionModelExtStructuralMetadata* pStructuralMetadata = pResult->model->getExtension(); + // NOLINTEND(bugprone-unchecked-optional-access) if (options.resolveExternalStructuralMetadata && pStructuralMetadata && pStructuralMetadata->schemaUri.has_value()) { diff --git a/CesiumGltfReader/src/GltfSharedAssetSystem.cpp b/CesiumGltfReader/src/GltfSharedAssetSystem.cpp index 494a41c58..54250e06a 100644 --- a/CesiumGltfReader/src/GltfSharedAssetSystem.cpp +++ b/CesiumGltfReader/src/GltfSharedAssetSystem.cpp @@ -1,5 +1,16 @@ +#include +#include +#include +#include #include #include +#include +#include +#include +#include + +#include +#include using namespace CesiumAsync; using namespace CesiumGltf; diff --git a/CesiumGltfReader/src/ImageDecoder.cpp b/CesiumGltfReader/src/ImageDecoder.cpp index 4192fb70d..9d653dcaf 100644 --- a/CesiumGltfReader/src/ImageDecoder.cpp +++ b/CesiumGltfReader/src/ImageDecoder.cpp @@ -1,29 +1,20 @@ -#include "CesiumGltfReader/ImageDecoder.h" - -#include "ModelJsonHandler.h" -#include "applyKhrTextureTransform.h" -#include "decodeDataUrls.h" -#include "decodeDraco.h" -#include "decodeMeshOpt.h" -#include "dequantizeMeshData.h" -#include "registerReaderExtensions.h" - -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include -#include #include -#include #include #include +#include +#include +#include +#include +#include #include +#include #define STBI_FAILURE_USERMSG @@ -52,7 +43,10 @@ bool isKtx(const std::span& data) { const uint8_t ktxMagic[ktxMagicByteLength] = {0xAB, 0x4B, 0x54, 0x58, 0x20, 0x32, 0x30, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A}; - return memcmp(data.data(), ktxMagic, ktxMagicByteLength) == 0; + return memcmp( + data.data(), + reinterpret_cast(ktxMagic), + ktxMagicByteLength) == 0; } bool isWebP(const std::span& data) { @@ -275,7 +269,7 @@ ImageReaderResult ImageDecoder::readImage( &image.height)) { image.channels = 4; image.bytesPerChannel = 1; - uint8_t* pImage = NULL; + uint8_t* pImage = nullptr; const auto bufferSize = image.width * image.height * image.channels; image.pixelData.resize(static_cast(bufferSize)); pImage = WebPDecodeRGBAInto( @@ -298,7 +292,7 @@ ImageReaderResult ImageDecoder::readImage( if (!tjDecompressHeader3( tjInstance, reinterpret_cast(data.data()), - static_cast(data.size()), + static_cast(data.size()), // NOLINT &image.width, &image.height, &inSubsamp, @@ -312,7 +306,7 @@ ImageReaderResult ImageDecoder::readImage( if (tjDecompress2( tjInstance, reinterpret_cast(data.data()), - static_cast(data.size()), + static_cast(data.size()), // NOLINT reinterpret_cast(image.pixelData.data()), image.width, 0, diff --git a/CesiumGltfReader/src/NamedObjectJsonHandler.cpp b/CesiumGltfReader/src/NamedObjectJsonHandler.cpp index 33e440667..8a24f6204 100644 --- a/CesiumGltfReader/src/NamedObjectJsonHandler.cpp +++ b/CesiumGltfReader/src/NamedObjectJsonHandler.cpp @@ -2,8 +2,11 @@ #include #include +#include +#include #include +#include namespace CesiumGltfReader { NamedObjectJsonHandler::NamedObjectJsonHandler( diff --git a/CesiumGltfReader/src/NetworkImageAssetDescriptor.cpp b/CesiumGltfReader/src/NetworkImageAssetDescriptor.cpp index 2284bff7c..ffd18c9df 100644 --- a/CesiumGltfReader/src/NetworkImageAssetDescriptor.cpp +++ b/CesiumGltfReader/src/NetworkImageAssetDescriptor.cpp @@ -1,6 +1,18 @@ +#include +#include +#include +#include +#include #include #include #include +#include + +#include +#include +#include +#include +#include using namespace CesiumAsync; using namespace CesiumGltf; diff --git a/CesiumGltfReader/src/NetworkSchemaAssetDescriptor.cpp b/CesiumGltfReader/src/NetworkSchemaAssetDescriptor.cpp index 19b14afe2..07a6fa7f4 100644 --- a/CesiumGltfReader/src/NetworkSchemaAssetDescriptor.cpp +++ b/CesiumGltfReader/src/NetworkSchemaAssetDescriptor.cpp @@ -1,7 +1,17 @@ +#include +#include +#include #include #include #include -#include +#include +#include + +#include +#include +#include +#include +#include using namespace CesiumAsync; using namespace CesiumGltf; diff --git a/CesiumGltfReader/src/applyKhrTextureTransform.cpp b/CesiumGltfReader/src/applyKhrTextureTransform.cpp index 055ab86f5..912fd961b 100644 --- a/CesiumGltfReader/src/applyKhrTextureTransform.cpp +++ b/CesiumGltfReader/src/applyKhrTextureTransform.cpp @@ -1,9 +1,26 @@ #include "applyKhrTextureTransform.h" +#include #include +#include +#include #include #include -#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include using namespace CesiumGltf; @@ -29,7 +46,6 @@ bool transformBufferView( return true; } -} // namespace template void processTextureInfo( @@ -98,20 +114,23 @@ void processTextureInfo( maybeTextureInfo->extensions.erase( ExtensionKhrTextureTransform::ExtensionName); } +} // namespace void applyKhrTextureTransform(Model& model) { for (Mesh& mesh : model.meshes) { for (MeshPrimitive& primitive : mesh.primitives) { Material* material = Model::getSafe(&model.materials, primitive.material); if (material) { - processTextureInfo( - model, - primitive, - material->pbrMetallicRoughness->baseColorTexture); - processTextureInfo( - model, - primitive, - material->pbrMetallicRoughness->metallicRoughnessTexture); + if (material->pbrMetallicRoughness) { + processTextureInfo( + model, + primitive, + material->pbrMetallicRoughness->baseColorTexture); + processTextureInfo( + model, + primitive, + material->pbrMetallicRoughness->metallicRoughnessTexture); + } processTextureInfo(model, primitive, material->normalTexture); processTextureInfo(model, primitive, material->occlusionTexture); processTextureInfo(model, primitive, material->emissiveTexture); diff --git a/CesiumGltfReader/src/decodeDataUrls.cpp b/CesiumGltfReader/src/decodeDataUrls.cpp index e992a52d0..95ce9b706 100644 --- a/CesiumGltfReader/src/decodeDataUrls.cpp +++ b/CesiumGltfReader/src/decodeDataUrls.cpp @@ -1,13 +1,23 @@ #include "decodeDataUrls.h" +#include +#include #include #include #include #include +#include #include #include +#include +#include +#include +#include +#include +#include +#include namespace CesiumGltfReader { diff --git a/CesiumGltfReader/src/decodeDraco.cpp b/CesiumGltfReader/src/decodeDraco.cpp index e63922146..e99662585 100644 --- a/CesiumGltfReader/src/decodeDraco.cpp +++ b/CesiumGltfReader/src/decodeDraco.cpp @@ -1,13 +1,28 @@ #include "decodeDraco.h" -#include "CesiumGltfReader/GltfReader.h" - +#include +#include +#include #include +#include +#include #include +#include +#include #include +#include +#include +#include +#include + #include +#include +#include +#include +#include #include +#include #ifdef _MSC_VER #pragma warning(push) @@ -29,6 +44,7 @@ std::unique_ptr decodeBufferViewToDracoMesh( CesiumGltf::MeshPrimitive& /* primitive */, const CesiumGltf::ExtensionKhrDracoMeshCompression& draco) { CESIUM_TRACE("CesiumGltfReader::decodeBufferViewToDracoMesh"); + CESIUM_ASSERT(readGltf.model.has_value()); CesiumGltf::Model& model = readGltf.model.value(); CesiumGltf::BufferView* pBufferView = @@ -99,6 +115,7 @@ void copyDecodedIndices( const CesiumGltf::MeshPrimitive& primitive, draco::Mesh* pMesh) { CESIUM_TRACE("CesiumGltfReader::copyDecodedIndices"); + CESIUM_ASSERT(readGltf.model.has_value()); CesiumGltf::Model& model = readGltf.model.value(); if (primitive.indices < 0) { @@ -112,10 +129,10 @@ void copyDecodedIndices( return; } - if (pIndicesAccessor->count != pMesh->num_faces() * 3) { + if (pIndicesAccessor->count != static_cast(pMesh->num_faces() * 3)) { readGltf.warnings.emplace_back( "indices accessor doesn't match with decoded Draco indices"); - pIndicesAccessor->count = pMesh->num_faces() * 3; + pIndicesAccessor->count = static_cast(pMesh->num_faces() * 3); } draco::PointIndex::ValueType numPoint = pMesh->num_points(); @@ -206,6 +223,7 @@ void copyDecodedAttribute( const draco::Mesh* pMesh, const draco::PointAttribute* pAttribute) { CESIUM_TRACE("CesiumGltfReader::copyDecodedAttribute"); + CESIUM_ASSERT(readGltf.model.has_value()); CesiumGltf::Model& model = readGltf.model.value(); if (pAccessor->count != pMesh->num_points()) { @@ -222,8 +240,8 @@ void copyDecodedAttribute( CesiumGltf::Buffer& buffer = model.buffers.emplace_back(); const int8_t numberOfComponents = pAccessor->computeNumberOfComponents(); - const int64_t stride = - numberOfComponents * pAccessor->computeByteSizeOfComponent(); + const int64_t stride = static_cast( + numberOfComponents * pAccessor->computeByteSizeOfComponent()); const int64_t sizeBytes = pAccessor->count * stride; buffer.cesium.data.resize(static_cast(sizeBytes)); @@ -274,6 +292,7 @@ void decodePrimitive( CesiumGltf::MeshPrimitive& primitive, CesiumGltf::ExtensionKhrDracoMeshCompression& draco) { CESIUM_TRACE("CesiumGltfReader::decodePrimitive"); + CESIUM_ASSERT(readGltf.model.has_value()); CesiumGltf::Model& model = readGltf.model.value(); std::unique_ptr pMesh = diff --git a/CesiumGltfReader/src/decodeMeshOpt.cpp b/CesiumGltfReader/src/decodeMeshOpt.cpp index fd74674b3..c4669ec16 100644 --- a/CesiumGltfReader/src/decodeMeshOpt.cpp +++ b/CesiumGltfReader/src/decodeMeshOpt.cpp @@ -1,8 +1,16 @@ #include "decodeMeshOpt.h" +#include +#include #include #include +#include +#include +#include +#include +#include + #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-conversion" diff --git a/CesiumGltfReader/src/dequantizeMeshData.cpp b/CesiumGltfReader/src/dequantizeMeshData.cpp index 6e992cc69..db14fd88e 100644 --- a/CesiumGltfReader/src/dequantizeMeshData.cpp +++ b/CesiumGltfReader/src/dequantizeMeshData.cpp @@ -1,6 +1,19 @@ #include "dequantizeMeshData.h" -#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include using namespace CesiumGltf; @@ -159,7 +172,7 @@ void dequantizeAccessor(Model& model, Accessor& accessor) { void dequantizeMeshData(Model& model) { for (Mesh& mesh : model.meshes) { for (MeshPrimitive& primitive : mesh.primitives) { - for (std::pair attribute : + for (const std::pair& attribute : primitive.attributes) { Accessor* pAccessor = Model::getSafe(&model.accessors, attribute.second); @@ -171,7 +184,8 @@ void dequantizeMeshData(Model& model) { } const std::string& attributeName = attribute.first; if (attributeName == "POSITION" || attributeName == "NORMAL" || - attributeName == "TANGENT" || attributeName.find("TEXCOORD") == 0) { + attributeName == "TANGENT" || + attributeName.starts_with("TEXCOORD")) { dequantizeAccessor(model, *pAccessor); } } diff --git a/CesiumGltfReader/test/TestExtensionModelExtStructuralMetadata.cpp b/CesiumGltfReader/test/TestExtensionModelExtStructuralMetadata.cpp index 70b9425e6..67d57c98f 100644 --- a/CesiumGltfReader/test/TestExtensionModelExtStructuralMetadata.cpp +++ b/CesiumGltfReader/test/TestExtensionModelExtStructuralMetadata.cpp @@ -1,15 +1,23 @@ -#include "CesiumGltfReader/GltfReader.h" - +#include #include +#include #include #include #include #include #include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include + using namespace CesiumGltf; using namespace CesiumUtility; using namespace CesiumNativeTests; diff --git a/CesiumGltfReader/test/TestGltfReader.cpp b/CesiumGltfReader/test/TestGltfReader.cpp index 40c0b3425..23d3facb6 100644 --- a/CesiumGltfReader/test/TestGltfReader.cpp +++ b/CesiumGltfReader/test/TestGltfReader.cpp @@ -1,27 +1,46 @@ -#include "CesiumGltfReader/GltfReader.h" - #include +#include #include +#include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include #include #include #include +#include #include #include -#include #include -#include -#include - +#include +#include +#include +#include + +#include +#include +#include #include -#include #include +#include +#include #include #include +#include +#include +#include using namespace CesiumAsync; using namespace CesiumGltf; @@ -727,7 +746,8 @@ TEST_CASE("GltfReader::loadGltf") { const CesiumGltf::Image& image = result.model->images[0]; CHECK(image.pAsset->width == 2048); CHECK(image.pAsset->height == 2048); - CHECK(image.pAsset->pixelData.size() == 2048 * 2048 * 4); + CHECK( + image.pAsset->pixelData.size() == static_cast(2048 * 2048 * 4)); CHECK(!result.model->buffers.empty()); for (const CesiumGltf::Buffer& buffer : result.model->buffers) { diff --git a/CesiumGltfReader/test/TestImageDecoder.cpp b/CesiumGltfReader/test/TestImageDecoder.cpp index 140f8b822..52f1a44fb 100644 --- a/CesiumGltfReader/test/TestImageDecoder.cpp +++ b/CesiumGltfReader/test/TestImageDecoder.cpp @@ -1,10 +1,12 @@ +#include #include #include -#include #include +#include #include +#include using namespace CesiumGltf; using namespace CesiumGltfReader; diff --git a/CesiumGltfWriter/include/CesiumGltfWriter/GltfWriter.h b/CesiumGltfWriter/include/CesiumGltfWriter/GltfWriter.h index e2ca35e04..2115a6939 100644 --- a/CesiumGltfWriter/include/CesiumGltfWriter/GltfWriter.h +++ b/CesiumGltfWriter/include/CesiumGltfWriter/GltfWriter.h @@ -1,7 +1,6 @@ #pragma once -#include "CesiumGltfWriter/Library.h" - +#include #include #include diff --git a/CesiumGltfWriter/include/CesiumGltfWriter/SchemaWriter.h b/CesiumGltfWriter/include/CesiumGltfWriter/SchemaWriter.h index 9a66a3ccb..ec01bed2f 100644 --- a/CesiumGltfWriter/include/CesiumGltfWriter/SchemaWriter.h +++ b/CesiumGltfWriter/include/CesiumGltfWriter/SchemaWriter.h @@ -1,7 +1,6 @@ #pragma once -#include "CesiumGltfWriter/Library.h" - +#include #include // forward declarations diff --git a/CesiumGltfWriter/src/GltfWriter.cpp b/CesiumGltfWriter/src/GltfWriter.cpp index 75966f0c8..52305b83f 100644 --- a/CesiumGltfWriter/src/GltfWriter.cpp +++ b/CesiumGltfWriter/src/GltfWriter.cpp @@ -1,13 +1,20 @@ -#include "CesiumGltfWriter/GltfWriter.h" - #include "ModelJsonWriter.h" #include "registerWriterExtensions.h" +#include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include + namespace CesiumGltfWriter { namespace { diff --git a/CesiumGltfWriter/src/SchemaWriter.cpp b/CesiumGltfWriter/src/SchemaWriter.cpp index 4790de601..66c4a020c 100644 --- a/CesiumGltfWriter/src/SchemaWriter.cpp +++ b/CesiumGltfWriter/src/SchemaWriter.cpp @@ -1,12 +1,13 @@ -#include "CesiumGltfWriter/SchemaWriter.h" - #include "ModelJsonWriter.h" #include "registerWriterExtensions.h" +#include #include #include #include +#include + namespace CesiumGltfWriter { SchemaWriter::SchemaWriter() { registerWriterExtensions(this->_context); } diff --git a/CesiumGltfWriter/test/TestGltfWriter.cpp b/CesiumGltfWriter/test/TestGltfWriter.cpp index 519d15446..716984ec4 100644 --- a/CesiumGltfWriter/test/TestGltfWriter.cpp +++ b/CesiumGltfWriter/test/TestGltfWriter.cpp @@ -1,13 +1,20 @@ -#include "CesiumGltfWriter/GltfWriter.h" - -#include +#include #include +#include +#include +#include -#include #include #include +#include #include +#include +#include +#include +#include +#include +#include namespace { void check(const std::string& input, const std::string& expectedOutput) { diff --git a/CesiumIonClient/include/CesiumIonClient/Connection.h b/CesiumIonClient/include/CesiumIonClient/Connection.h index 14ff5f3b8..250a9a139 100644 --- a/CesiumIonClient/include/CesiumIonClient/Connection.h +++ b/CesiumIonClient/include/CesiumIonClient/Connection.h @@ -1,16 +1,15 @@ #pragma once -#include "ApplicationData.h" -#include "Assets.h" -#include "Defaults.h" -#include "Profile.h" -#include "Response.h" -#include "Token.h" -#include "TokenList.h" - #include #include #include +#include +#include +#include +#include +#include +#include +#include #include diff --git a/CesiumIonClient/include/CesiumIonClient/Defaults.h b/CesiumIonClient/include/CesiumIonClient/Defaults.h index eec76493d..2268e6e33 100644 --- a/CesiumIonClient/include/CesiumIonClient/Defaults.h +++ b/CesiumIonClient/include/CesiumIonClient/Defaults.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + namespace CesiumIonClient { /** diff --git a/CesiumIonClient/include/CesiumIonClient/TokenList.h b/CesiumIonClient/include/CesiumIonClient/TokenList.h index 32da35148..29cd13b47 100644 --- a/CesiumIonClient/include/CesiumIonClient/TokenList.h +++ b/CesiumIonClient/include/CesiumIonClient/TokenList.h @@ -1,6 +1,6 @@ #pragma once -#include "Token.h" +#include namespace CesiumIonClient { diff --git a/CesiumIonClient/src/Connection.cpp b/CesiumIonClient/src/Connection.cpp index 661c522d3..6e1f9aaad 100644 --- a/CesiumIonClient/src/Connection.cpp +++ b/CesiumIonClient/src/Connection.cpp @@ -1,11 +1,19 @@ -#include "CesiumIonClient/Connection.h" - #include "fillWithRandomBytes.h" -#include "parseLinkHeader.h" +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include #include #include @@ -13,11 +21,26 @@ #include #include #include +#include #include #include #include - +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include #ifdef _MSC_VER #pragma warning(push) @@ -1020,12 +1043,12 @@ Future> Connection::modifyToken( /*static*/ std::optional Connection::getIdFromToken(const std::string& token) { - size_t startPos = token.find("."); + size_t startPos = token.find('.'); if (startPos == std::string::npos || startPos == token.size() - 1) { return std::nullopt; } - size_t endPos = token.find(".", startPos + 1); + size_t endPos = token.find('.', startPos + 1); if (endPos == std::string::npos) { return std::nullopt; } diff --git a/CesiumIonClient/src/Response.cpp b/CesiumIonClient/src/Response.cpp index 9db8bfeff..d3c82e9ee 100644 --- a/CesiumIonClient/src/Response.cpp +++ b/CesiumIonClient/src/Response.cpp @@ -1,22 +1,28 @@ -#include "CesiumIonClient/Response.h" - -#include "CesiumIonClient/ApplicationData.h" -#include "CesiumIonClient/Assets.h" -#include "CesiumIonClient/Defaults.h" -#include "CesiumIonClient/Profile.h" -#include "CesiumIonClient/TokenList.h" #include "parseLinkHeader.h" +#include #include #include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include + using namespace CesiumAsync; using namespace CesiumUtility; namespace CesiumIonClient { -template Response::Response() {} +template Response::Response() = default; template Response::Response( diff --git a/CesiumIonClient/src/fillWithRandomBytes.cpp b/CesiumIonClient/src/fillWithRandomBytes.cpp index 983d28578..05bd7820f 100644 --- a/CesiumIonClient/src/fillWithRandomBytes.cpp +++ b/CesiumIonClient/src/fillWithRandomBytes.cpp @@ -2,6 +2,8 @@ #include +#include +#include #include namespace CesiumIonClient { diff --git a/CesiumIonClient/src/parseLinkHeader.cpp b/CesiumIonClient/src/parseLinkHeader.cpp index 126211e14..f276ba738 100644 --- a/CesiumIonClient/src/parseLinkHeader.cpp +++ b/CesiumIonClient/src/parseLinkHeader.cpp @@ -2,6 +2,9 @@ #include #include +#include +#include +#include // This implementation is loosely based on the JavaScript implementation found // here: diff --git a/CesiumIonClient/test/TestConnection.cpp b/CesiumIonClient/test/TestConnection.cpp index dd31df952..f5f3c57d2 100644 --- a/CesiumIonClient/test/TestConnection.cpp +++ b/CesiumIonClient/test/TestConnection.cpp @@ -1,14 +1,25 @@ #include +#include #include +#include #include +#include #include +#include +#include #include #include #include -#include #include +#include +#include +#include +#include +#include +#include + using namespace CesiumAsync; using namespace CesiumIonClient; using namespace CesiumNativeTests; diff --git a/CesiumIonClient/test/TestFillWithRandomBytes.cpp b/CesiumIonClient/test/TestFillWithRandomBytes.cpp index 28f289634..8053564fa 100644 --- a/CesiumIonClient/test/TestFillWithRandomBytes.cpp +++ b/CesiumIonClient/test/TestFillWithRandomBytes.cpp @@ -1,8 +1,12 @@ #include "../src/fillWithRandomBytes.h" -#include #include +#include +#include +#include +#include + using namespace CesiumIonClient; TEST_CASE("fillWithRandomBytes") { diff --git a/CesiumIonClient/test/TestParseLinkHeader.cpp b/CesiumIonClient/test/TestParseLinkHeader.cpp index ba6baf440..c3c99360c 100644 --- a/CesiumIonClient/test/TestParseLinkHeader.cpp +++ b/CesiumIonClient/test/TestParseLinkHeader.cpp @@ -1,8 +1,9 @@ #include "../src/parseLinkHeader.h" -#include #include +#include + using namespace CesiumIonClient; TEST_CASE("parseLinkHeader") { diff --git a/CesiumJsonReader/include/CesiumJsonReader/ArrayJsonHandler.h b/CesiumJsonReader/include/CesiumJsonReader/ArrayJsonHandler.h index ff0037456..eca9bc749 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/ArrayJsonHandler.h +++ b/CesiumJsonReader/include/CesiumJsonReader/ArrayJsonHandler.h @@ -1,11 +1,11 @@ #pragma once -#include "CesiumUtility/Assert.h" -#include "DoubleJsonHandler.h" -#include "IntegerJsonHandler.h" -#include "JsonHandler.h" -#include "Library.h" -#include "StringJsonHandler.h" +#include +#include +#include +#include +#include +#include #include #include diff --git a/CesiumJsonReader/include/CesiumJsonReader/BoolJsonHandler.h b/CesiumJsonReader/include/CesiumJsonReader/BoolJsonHandler.h index 7188cb4c7..08be779a5 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/BoolJsonHandler.h +++ b/CesiumJsonReader/include/CesiumJsonReader/BoolJsonHandler.h @@ -1,7 +1,7 @@ #pragma once -#include "JsonHandler.h" -#include "Library.h" +#include +#include namespace CesiumJsonReader { /** diff --git a/CesiumJsonReader/include/CesiumJsonReader/DictionaryJsonHandler.h b/CesiumJsonReader/include/CesiumJsonReader/DictionaryJsonHandler.h index 33b767442..22a724c85 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/DictionaryJsonHandler.h +++ b/CesiumJsonReader/include/CesiumJsonReader/DictionaryJsonHandler.h @@ -1,9 +1,9 @@ #pragma once -#include "CesiumUtility/Assert.h" -#include "IntegerJsonHandler.h" -#include "Library.h" -#include "ObjectJsonHandler.h" +#include +#include +#include +#include #include #include diff --git a/CesiumJsonReader/include/CesiumJsonReader/DoubleJsonHandler.h b/CesiumJsonReader/include/CesiumJsonReader/DoubleJsonHandler.h index c4b5d264b..e38b52b41 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/DoubleJsonHandler.h +++ b/CesiumJsonReader/include/CesiumJsonReader/DoubleJsonHandler.h @@ -1,7 +1,7 @@ #pragma once -#include "JsonHandler.h" -#include "Library.h" +#include +#include namespace CesiumJsonReader { /** diff --git a/CesiumJsonReader/include/CesiumJsonReader/ExtensibleObjectJsonHandler.h b/CesiumJsonReader/include/CesiumJsonReader/ExtensibleObjectJsonHandler.h index be514c778..556eb47e3 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/ExtensibleObjectJsonHandler.h +++ b/CesiumJsonReader/include/CesiumJsonReader/ExtensibleObjectJsonHandler.h @@ -1,11 +1,10 @@ #pragma once -#include "DictionaryJsonHandler.h" -#include "ExtensionsJsonHandler.h" -#include "JsonObjectJsonHandler.h" -#include "JsonReaderOptions.h" -#include "ObjectJsonHandler.h" - +#include +#include +#include +#include +#include #include #include diff --git a/CesiumJsonReader/include/CesiumJsonReader/ExtensionsJsonHandler.h b/CesiumJsonReader/include/CesiumJsonReader/ExtensionsJsonHandler.h index 2a9391e13..5353625af 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/ExtensionsJsonHandler.h +++ b/CesiumJsonReader/include/CesiumJsonReader/ExtensionsJsonHandler.h @@ -1,9 +1,8 @@ #pragma once -#include "IExtensionJsonHandler.h" -#include "JsonReaderOptions.h" -#include "ObjectJsonHandler.h" - +#include +#include +#include #include #include diff --git a/CesiumJsonReader/include/CesiumJsonReader/IExtensionJsonHandler.h b/CesiumJsonReader/include/CesiumJsonReader/IExtensionJsonHandler.h index f01e4ff41..ce3bd12bd 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/IExtensionJsonHandler.h +++ b/CesiumJsonReader/include/CesiumJsonReader/IExtensionJsonHandler.h @@ -1,7 +1,6 @@ #pragma once -#include "IJsonHandler.h" - +#include #include #include diff --git a/CesiumJsonReader/include/CesiumJsonReader/IJsonHandler.h b/CesiumJsonReader/include/CesiumJsonReader/IJsonHandler.h index bd03fe388..0e8e1a635 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/IJsonHandler.h +++ b/CesiumJsonReader/include/CesiumJsonReader/IJsonHandler.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include #include #include @@ -17,7 +17,7 @@ namespace CesiumJsonReader { */ class CESIUMJSONREADER_API IJsonHandler { public: - virtual ~IJsonHandler(){}; + virtual ~IJsonHandler() = default; /** * @brief Called when the JSON parser encounters a `null`. * @returns A \ref IJsonHandler that will handle the next `read...` call. diff --git a/CesiumJsonReader/include/CesiumJsonReader/IgnoreValueJsonHandler.h b/CesiumJsonReader/include/CesiumJsonReader/IgnoreValueJsonHandler.h index 47f25d81d..88f4624f0 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/IgnoreValueJsonHandler.h +++ b/CesiumJsonReader/include/CesiumJsonReader/IgnoreValueJsonHandler.h @@ -1,7 +1,7 @@ #pragma once -#include "IJsonHandler.h" -#include "Library.h" +#include +#include #include diff --git a/CesiumJsonReader/include/CesiumJsonReader/IntegerJsonHandler.h b/CesiumJsonReader/include/CesiumJsonReader/IntegerJsonHandler.h index 27b146c2d..08a5599e7 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/IntegerJsonHandler.h +++ b/CesiumJsonReader/include/CesiumJsonReader/IntegerJsonHandler.h @@ -1,8 +1,8 @@ #pragma once -#include "CesiumUtility/Assert.h" -#include "JsonHandler.h" -#include "Library.h" +#include +#include +#include #include @@ -69,7 +69,7 @@ class CESIUMJSONREADER_API IntegerJsonHandler : public JsonHandler { virtual void reportWarning( const std::string& warning, std::vector&& context) override { - context.push_back("(expecting an integer)"); + context.emplace_back("(expecting an integer)"); this->parent()->reportWarning(warning, std::move(context)); } diff --git a/CesiumJsonReader/include/CesiumJsonReader/JsonHandler.h b/CesiumJsonReader/include/CesiumJsonReader/JsonHandler.h index b8863f516..2c392a2fb 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/JsonHandler.h +++ b/CesiumJsonReader/include/CesiumJsonReader/JsonHandler.h @@ -1,8 +1,8 @@ #pragma once -#include "IJsonHandler.h" -#include "IgnoreValueJsonHandler.h" -#include "Library.h" +#include +#include +#include #include #include diff --git a/CesiumJsonReader/include/CesiumJsonReader/JsonObjectJsonHandler.h b/CesiumJsonReader/include/CesiumJsonReader/JsonObjectJsonHandler.h index 1856aabc3..b83775cfb 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/JsonObjectJsonHandler.h +++ b/CesiumJsonReader/include/CesiumJsonReader/JsonObjectJsonHandler.h @@ -1,8 +1,7 @@ #pragma once -#include "JsonHandler.h" -#include "Library.h" - +#include +#include #include namespace CesiumJsonReader { diff --git a/CesiumJsonReader/include/CesiumJsonReader/JsonReader.h b/CesiumJsonReader/include/CesiumJsonReader/JsonReader.h index c3569edb1..35dd22252 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/JsonReader.h +++ b/CesiumJsonReader/include/CesiumJsonReader/JsonReader.h @@ -1,7 +1,7 @@ #pragma once -#include "JsonHandler.h" -#include "Library.h" +#include +#include #include diff --git a/CesiumJsonReader/include/CesiumJsonReader/JsonReaderOptions.h b/CesiumJsonReader/include/CesiumJsonReader/JsonReaderOptions.h index bc6f2dcb0..1f6f012de 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/JsonReaderOptions.h +++ b/CesiumJsonReader/include/CesiumJsonReader/JsonReaderOptions.h @@ -1,7 +1,7 @@ #pragma once -#include "IExtensionJsonHandler.h" -#include "Library.h" +#include +#include #include #include diff --git a/CesiumJsonReader/include/CesiumJsonReader/ObjectJsonHandler.h b/CesiumJsonReader/include/CesiumJsonReader/ObjectJsonHandler.h index 0bcc37d35..045baeef2 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/ObjectJsonHandler.h +++ b/CesiumJsonReader/include/CesiumJsonReader/ObjectJsonHandler.h @@ -1,8 +1,7 @@ #pragma once -#include "JsonHandler.h" -#include "Library.h" - +#include +#include #include #include diff --git a/CesiumJsonReader/include/CesiumJsonReader/StringJsonHandler.h b/CesiumJsonReader/include/CesiumJsonReader/StringJsonHandler.h index 5353f8b74..d2c8cc998 100644 --- a/CesiumJsonReader/include/CesiumJsonReader/StringJsonHandler.h +++ b/CesiumJsonReader/include/CesiumJsonReader/StringJsonHandler.h @@ -1,7 +1,7 @@ #pragma once -#include "JsonHandler.h" -#include "Library.h" +#include +#include #include diff --git a/CesiumJsonReader/src/BoolJsonHandler.cpp b/CesiumJsonReader/src/BoolJsonHandler.cpp index 070170c1b..1c290662f 100644 --- a/CesiumJsonReader/src/BoolJsonHandler.cpp +++ b/CesiumJsonReader/src/BoolJsonHandler.cpp @@ -1,7 +1,7 @@ -#include "CesiumJsonReader/BoolJsonHandler.h" - -#include "CesiumJsonReader/JsonHandler.h" -#include "CesiumUtility/Assert.h" +#include +#include +#include +#include namespace CesiumJsonReader { BoolJsonHandler::BoolJsonHandler() noexcept : JsonHandler() {} diff --git a/CesiumJsonReader/src/DoubleJsonHandler.cpp b/CesiumJsonReader/src/DoubleJsonHandler.cpp index 822dfbef8..9fedc50cd 100644 --- a/CesiumJsonReader/src/DoubleJsonHandler.cpp +++ b/CesiumJsonReader/src/DoubleJsonHandler.cpp @@ -1,6 +1,9 @@ -#include "CesiumJsonReader/DoubleJsonHandler.h" +#include +#include +#include +#include -#include "CesiumUtility/Assert.h" +#include namespace CesiumJsonReader { DoubleJsonHandler::DoubleJsonHandler() noexcept : JsonHandler() {} diff --git a/CesiumJsonReader/src/ExtensibleObjectJsonHandler.cpp b/CesiumJsonReader/src/ExtensibleObjectJsonHandler.cpp index 246e19119..2b6881a78 100644 --- a/CesiumJsonReader/src/ExtensibleObjectJsonHandler.cpp +++ b/CesiumJsonReader/src/ExtensibleObjectJsonHandler.cpp @@ -1,9 +1,12 @@ -#include "CesiumJsonReader/ExtensibleObjectJsonHandler.h" +#include +#include +#include +#include +#include +#include -#include "CesiumJsonReader/ExtensionsJsonHandler.h" -#include "CesiumJsonReader/JsonHandler.h" -#include "CesiumJsonReader/JsonReaderOptions.h" -#include "CesiumJsonReader/ObjectJsonHandler.h" +#include +#include namespace CesiumJsonReader { ExtensibleObjectJsonHandler::ExtensibleObjectJsonHandler( diff --git a/CesiumJsonReader/src/ExtensionsJsonHandler.cpp b/CesiumJsonReader/src/ExtensionsJsonHandler.cpp index 18535961a..ff7b84d2c 100644 --- a/CesiumJsonReader/src/ExtensionsJsonHandler.cpp +++ b/CesiumJsonReader/src/ExtensionsJsonHandler.cpp @@ -1,6 +1,11 @@ -#include "CesiumJsonReader/ExtensionsJsonHandler.h" +#include +#include +#include +#include +#include -#include "CesiumJsonReader/JsonReaderOptions.h" +#include +#include namespace CesiumJsonReader { void ExtensionsJsonHandler::reset( diff --git a/CesiumJsonReader/src/IgnoreValueJsonHandler.cpp b/CesiumJsonReader/src/IgnoreValueJsonHandler.cpp index 874253fb6..4d1164d73 100644 --- a/CesiumJsonReader/src/IgnoreValueJsonHandler.cpp +++ b/CesiumJsonReader/src/IgnoreValueJsonHandler.cpp @@ -1,6 +1,11 @@ -#include "CesiumJsonReader/IgnoreValueJsonHandler.h" +#include +#include +#include #include +#include +#include +#include namespace CesiumJsonReader { void IgnoreValueJsonHandler::reset(IJsonHandler* pParent) noexcept { @@ -69,7 +74,7 @@ IJsonHandler* IgnoreValueJsonHandler::readArrayEnd() { void IgnoreValueJsonHandler::reportWarning( const std::string& warning, std::vector&& context) { - context.push_back("Ignoring a value"); + context.emplace_back("Ignoring a value"); this->parent()->reportWarning(warning, std::move(context)); } diff --git a/CesiumJsonReader/src/JsonHandler.cpp b/CesiumJsonReader/src/JsonHandler.cpp index d08077f76..4f1aea7e6 100644 --- a/CesiumJsonReader/src/JsonHandler.cpp +++ b/CesiumJsonReader/src/JsonHandler.cpp @@ -1,7 +1,13 @@ -#include "CesiumJsonReader/JsonHandler.h" +#include +#include + +#include +#include +#include +#include namespace CesiumJsonReader { -JsonHandler::JsonHandler() noexcept {} +JsonHandler::JsonHandler() noexcept = default; IJsonHandler* JsonHandler::readNull() { this->reportWarning("A null value is not allowed and has been ignored."); diff --git a/CesiumJsonReader/src/JsonObjectJsonHandler.cpp b/CesiumJsonReader/src/JsonObjectJsonHandler.cpp index 37122d77a..5d2b14229 100644 --- a/CesiumJsonReader/src/JsonObjectJsonHandler.cpp +++ b/CesiumJsonReader/src/JsonObjectJsonHandler.cpp @@ -1,6 +1,12 @@ -#include "CesiumJsonReader/JsonObjectJsonHandler.h" +#include +#include +#include +#include #include +#include +#include +#include namespace CesiumJsonReader { namespace { diff --git a/CesiumJsonReader/src/JsonReader.cpp b/CesiumJsonReader/src/JsonReader.cpp index 29183f219..c416ba3f7 100644 --- a/CesiumJsonReader/src/JsonReader.cpp +++ b/CesiumJsonReader/src/JsonReader.cpp @@ -1,9 +1,19 @@ -#include "CesiumJsonReader/JsonReader.h" - +#include +#include +#include #include +#include +#include #include +#include +#include +#include +#include +#include +#include + namespace CesiumJsonReader { namespace { diff --git a/CesiumJsonReader/src/JsonReaderOptions.cpp b/CesiumJsonReader/src/JsonReaderOptions.cpp index b925ea84d..93b58dc78 100644 --- a/CesiumJsonReader/src/JsonReaderOptions.cpp +++ b/CesiumJsonReader/src/JsonReaderOptions.cpp @@ -1,8 +1,14 @@ -#include "CesiumJsonReader/JsonReaderOptions.h" +#include +#include +#include +#include +#include +#include -#include "CesiumJsonReader/IExtensionJsonHandler.h" -#include "CesiumJsonReader/JsonObjectJsonHandler.h" -#include "CesiumJsonReader/JsonReader.h" +#include +#include +#include +#include namespace CesiumJsonReader { class AnyExtensionJsonHandler : public JsonObjectJsonHandler, diff --git a/CesiumJsonReader/src/ObjectJsonHandler.cpp b/CesiumJsonReader/src/ObjectJsonHandler.cpp index 143b93525..35ed080f5 100644 --- a/CesiumJsonReader/src/ObjectJsonHandler.cpp +++ b/CesiumJsonReader/src/ObjectJsonHandler.cpp @@ -1,4 +1,9 @@ -#include "CesiumJsonReader/ObjectJsonHandler.h" +#include +#include + +#include +#include +#include namespace CesiumJsonReader { IJsonHandler* ObjectJsonHandler::readObjectStart() { diff --git a/CesiumJsonReader/src/SharedAssetJsonHandler.cpp b/CesiumJsonReader/src/SharedAssetJsonHandler.cpp index b8a36902a..44be8470e 100644 --- a/CesiumJsonReader/src/SharedAssetJsonHandler.cpp +++ b/CesiumJsonReader/src/SharedAssetJsonHandler.cpp @@ -1,9 +1,11 @@ -#include "CesiumJsonReader/SharedAssetJsonHandler.h" +#include +#include +#include +#include +#include -#include "CesiumJsonReader/ExtensibleObjectJsonHandler.h" -#include "CesiumJsonReader/ExtensionsJsonHandler.h" -#include "CesiumJsonReader/JsonHandler.h" -#include "CesiumJsonReader/JsonReaderOptions.h" +#include +#include namespace CesiumJsonReader { SharedAssetJsonHandler::SharedAssetJsonHandler( diff --git a/CesiumJsonReader/src/StringJsonHandler.cpp b/CesiumJsonReader/src/StringJsonHandler.cpp index 35ad2a3dc..797ff3a63 100644 --- a/CesiumJsonReader/src/StringJsonHandler.cpp +++ b/CesiumJsonReader/src/StringJsonHandler.cpp @@ -1,6 +1,9 @@ -#include "CesiumJsonReader/StringJsonHandler.h" +#include +#include +#include -#include "CesiumJsonReader/JsonHandler.h" +#include +#include namespace CesiumJsonReader { StringJsonHandler::StringJsonHandler() noexcept : JsonHandler() {} diff --git a/CesiumJsonWriter/include/CesiumJsonWriter/ExtensionWriterContext.h b/CesiumJsonWriter/include/CesiumJsonWriter/ExtensionWriterContext.h index 431795618..66e9c2a7c 100644 --- a/CesiumJsonWriter/include/CesiumJsonWriter/ExtensionWriterContext.h +++ b/CesiumJsonWriter/include/CesiumJsonWriter/ExtensionWriterContext.h @@ -1,7 +1,7 @@ #pragma once -#include "CesiumJsonWriter/JsonWriter.h" -#include "CesiumJsonWriter/Library.h" +#include +#include #include #include diff --git a/CesiumJsonWriter/include/CesiumJsonWriter/JsonWriter.h b/CesiumJsonWriter/include/CesiumJsonWriter/JsonWriter.h index b9b1b07a0..979ef8c5a 100644 --- a/CesiumJsonWriter/include/CesiumJsonWriter/JsonWriter.h +++ b/CesiumJsonWriter/include/CesiumJsonWriter/JsonWriter.h @@ -18,7 +18,7 @@ namespace CesiumJsonWriter { class JsonWriter { public: JsonWriter(); - virtual ~JsonWriter() {} + virtual ~JsonWriter() = default; /** * @brief Writes a `null` value to the output. @@ -234,8 +234,9 @@ class JsonWriter { * @param insideArray The callback to run, after \ref StartArray but before * \ref EndArray. */ - virtual void - KeyArray(std::string_view keyName, std::function insideArray); + virtual void KeyArray( + std::string_view keyName, + const std::function& insideArray); /** * @brief Writes an object to the output with the given key and calls the * provided callback to write values inside of the object. This is a @@ -246,8 +247,9 @@ class JsonWriter { * @param insideObject The callback to run, after \ref StartObject but before * \ref EndObject. */ - virtual void - KeyObject(std::string_view keyName, std::function insideObject); + virtual void KeyObject( + std::string_view keyName, + const std::function& insideObject); /** * @brief Obtains the written output as a string. diff --git a/CesiumJsonWriter/include/CesiumJsonWriter/PrettyJsonWriter.h b/CesiumJsonWriter/include/CesiumJsonWriter/PrettyJsonWriter.h index 0361ebf15..97be5ff22 100644 --- a/CesiumJsonWriter/include/CesiumJsonWriter/PrettyJsonWriter.h +++ b/CesiumJsonWriter/include/CesiumJsonWriter/PrettyJsonWriter.h @@ -1,6 +1,6 @@ #pragma once -#include "JsonWriter.h" +#include #include #include @@ -23,7 +23,7 @@ class PrettyJsonWriter : public JsonWriter { public: PrettyJsonWriter() noexcept; - ~PrettyJsonWriter() {} + ~PrettyJsonWriter() = default; bool Null() override; bool Bool(bool b) override; @@ -58,11 +58,12 @@ class PrettyJsonWriter : public JsonWriter { void KeyPrimitive(std::string_view keyName, double value) override; void KeyPrimitive(std::string_view keyName, std::nullptr_t value) override; - void KeyArray(std::string_view keyName, std::function insideArray) - override; + void KeyArray( + std::string_view keyName, + const std::function& insideArray) override; void KeyObject( std::string_view keyName, - std::function insideObject) override; + const std::function& insideObject) override; std::string toString() override; std::string_view toStringView() override; diff --git a/CesiumJsonWriter/include/CesiumJsonWriter/writeJsonExtensions.h b/CesiumJsonWriter/include/CesiumJsonWriter/writeJsonExtensions.h index 25d332649..0d9e609e2 100644 --- a/CesiumJsonWriter/include/CesiumJsonWriter/writeJsonExtensions.h +++ b/CesiumJsonWriter/include/CesiumJsonWriter/writeJsonExtensions.h @@ -1,7 +1,7 @@ #pragma once -#include "CesiumJsonWriter/ExtensionWriterContext.h" -#include "CesiumJsonWriter/JsonWriter.h" +#include +#include #include diff --git a/CesiumJsonWriter/src/ExtensionWriterContext.cpp b/CesiumJsonWriter/src/ExtensionWriterContext.cpp index f985a39c0..d69d300ff 100644 --- a/CesiumJsonWriter/src/ExtensionWriterContext.cpp +++ b/CesiumJsonWriter/src/ExtensionWriterContext.cpp @@ -1,10 +1,12 @@ -#include "CesiumJsonWriter/ExtensionWriterContext.h" - -#include "CesiumJsonWriter/JsonObjectWriter.h" -#include "CesiumJsonWriter/JsonWriter.h" - +#include +#include +#include #include +#include +#include +#include + namespace CesiumJsonWriter { namespace { void objWriter( diff --git a/CesiumJsonWriter/src/JsonObjectWriter.cpp b/CesiumJsonWriter/src/JsonObjectWriter.cpp index cb03b4da7..06360f68a 100644 --- a/CesiumJsonWriter/src/JsonObjectWriter.cpp +++ b/CesiumJsonWriter/src/JsonObjectWriter.cpp @@ -1,11 +1,7 @@ -#include "CesiumJsonWriter/JsonObjectWriter.h" - -#include "CesiumJsonWriter/JsonWriter.h" - +#include +#include #include -#include -#include #include namespace CesiumJsonWriter { diff --git a/CesiumJsonWriter/src/JsonWriter.cpp b/CesiumJsonWriter/src/JsonWriter.cpp index e5dad1689..3b7f44861 100644 --- a/CesiumJsonWriter/src/JsonWriter.cpp +++ b/CesiumJsonWriter/src/JsonWriter.cpp @@ -1,9 +1,16 @@ -#include "CesiumJsonWriter/JsonWriter.h" +#include + +#include +#include #include -#include +#include +#include +#include +#include #include #include +#include namespace CesiumJsonWriter { JsonWriter::JsonWriter() @@ -114,7 +121,7 @@ void JsonWriter::KeyPrimitive(std::string_view keyName, std::nullptr_t value) { // Array / Objects void JsonWriter::KeyArray( std::string_view keyName, - std::function insideArray) { + const std::function& insideArray) { Key(keyName); _compact->StartArray(); insideArray(); @@ -123,7 +130,7 @@ void JsonWriter::KeyArray( void JsonWriter::KeyObject( std::string_view keyName, - std::function insideObject) { + const std::function& insideObject) { Key(keyName); _compact->StartObject(); insideObject(); diff --git a/CesiumJsonWriter/src/PrettyJsonWriter.cpp b/CesiumJsonWriter/src/PrettyJsonWriter.cpp index 048e1f23c..71bd74cc3 100644 --- a/CesiumJsonWriter/src/PrettyJsonWriter.cpp +++ b/CesiumJsonWriter/src/PrettyJsonWriter.cpp @@ -1,9 +1,17 @@ -#include "CesiumJsonWriter/PrettyJsonWriter.h" +#include + +#include +#include #include -#include +#include +#include +#include +#include #include #include +#include +#include namespace CesiumJsonWriter { PrettyJsonWriter::PrettyJsonWriter() noexcept { @@ -132,7 +140,7 @@ void PrettyJsonWriter::KeyPrimitive( // Array / Objects void PrettyJsonWriter::KeyArray( std::string_view keyName, - std::function insideArray) { + const std::function& insideArray) { Key(keyName); pretty->StartArray(); insideArray(); @@ -141,7 +149,7 @@ void PrettyJsonWriter::KeyArray( void PrettyJsonWriter::KeyObject( std::string_view keyName, - std::function insideObject) { + const std::function& insideObject) { Key(keyName); pretty->StartObject(); insideObject(); diff --git a/CesiumNativeTests/include/CesiumNativeTests/SimpleAssetAccessor.h b/CesiumNativeTests/include/CesiumNativeTests/SimpleAssetAccessor.h index f82eaa4c5..b427aefc8 100644 --- a/CesiumNativeTests/include/CesiumNativeTests/SimpleAssetAccessor.h +++ b/CesiumNativeTests/include/CesiumNativeTests/SimpleAssetAccessor.h @@ -1,11 +1,10 @@ #pragma once -#include "SimpleAssetRequest.h" -#include "SimpleAssetResponse.h" - #include #include #include +#include +#include #include #include diff --git a/CesiumNativeTests/src/FileAccessor.cpp b/CesiumNativeTests/src/FileAccessor.cpp index d3a5e97f0..78a781ec4 100644 --- a/CesiumNativeTests/src/FileAccessor.cpp +++ b/CesiumNativeTests/src/FileAccessor.cpp @@ -1,10 +1,23 @@ #include +#include +#include +#include #include #include +#include #include +#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include namespace CesiumNativeTests { diff --git a/CesiumNativeTests/src/OwnedTempFile.cpp b/CesiumNativeTests/src/OwnedTempFile.cpp index b7c1cf9f8..cd9875dec 100644 --- a/CesiumNativeTests/src/OwnedTempFile.cpp +++ b/CesiumNativeTests/src/OwnedTempFile.cpp @@ -1,17 +1,22 @@ #include -#include #include +#include +#include #include +#include #include +#include +#include constexpr size_t randFilenameLen = 8; constexpr size_t randFilenameNumChars = 63; static const char randFilenameChars[randFilenameNumChars] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; -static std::string getTempFilename() { +namespace { +std::string getTempFilename() { std::string str = "CesiumTest_"; str.reserve(str.length() + randFilenameLen); @@ -26,6 +31,7 @@ static std::string getTempFilename() { auto path = std::filesystem::temp_directory_path() / str; return path.string(); } +} // namespace OwnedTempFile::OwnedTempFile() : _filePath(getTempFilename()) {} diff --git a/CesiumNativeTests/src/readFile.cpp b/CesiumNativeTests/src/readFile.cpp index b83e9f8fb..a8ca863ef 100644 --- a/CesiumNativeTests/src/readFile.cpp +++ b/CesiumNativeTests/src/readFile.cpp @@ -1,9 +1,12 @@ #include -#include #include +#include +#include #include +#include +#include std::vector readFile(const std::filesystem::path& fileName) { std::ifstream file(fileName, std::ios::binary | std::ios::ate); diff --git a/CesiumNativeTests/src/test-main.cpp b/CesiumNativeTests/src/test-main.cpp index 902c24ba6..0788fbf48 100644 --- a/CesiumNativeTests/src/test-main.cpp +++ b/CesiumNativeTests/src/test-main.cpp @@ -1,4 +1,3 @@ -#include -#include +#include int main(int argc, char* argv[]) { return Catch::Session().run(argc, argv); } diff --git a/CesiumQuantizedMeshTerrain/include/CesiumQuantizedMeshTerrain/Layer.h b/CesiumQuantizedMeshTerrain/include/CesiumQuantizedMeshTerrain/Layer.h index f588b3e77..750256b00 100644 --- a/CesiumQuantizedMeshTerrain/include/CesiumQuantizedMeshTerrain/Layer.h +++ b/CesiumQuantizedMeshTerrain/include/CesiumQuantizedMeshTerrain/Layer.h @@ -1,11 +1,10 @@ #pragma once -#include "Library.h" - #include #include #include #include +#include #include diff --git a/CesiumQuantizedMeshTerrain/include/CesiumQuantizedMeshTerrain/LayerWriter.h b/CesiumQuantizedMeshTerrain/include/CesiumQuantizedMeshTerrain/LayerWriter.h index d7594177d..349f1f5e6 100644 --- a/CesiumQuantizedMeshTerrain/include/CesiumQuantizedMeshTerrain/LayerWriter.h +++ b/CesiumQuantizedMeshTerrain/include/CesiumQuantizedMeshTerrain/LayerWriter.h @@ -1,8 +1,7 @@ #pragma once -#include "CesiumQuantizedMeshTerrain/Library.h" - #include +#include #include diff --git a/CesiumQuantizedMeshTerrain/include/CesiumQuantizedMeshTerrain/QuantizedMeshLoader.h b/CesiumQuantizedMeshTerrain/include/CesiumQuantizedMeshTerrain/QuantizedMeshLoader.h index 823234ccc..cf355efb5 100644 --- a/CesiumQuantizedMeshTerrain/include/CesiumQuantizedMeshTerrain/QuantizedMeshLoader.h +++ b/CesiumQuantizedMeshTerrain/include/CesiumQuantizedMeshTerrain/QuantizedMeshLoader.h @@ -1,12 +1,11 @@ #pragma once -#include "Library.h" - #include #include #include #include #include +#include #include #include diff --git a/CesiumQuantizedMeshTerrain/src/Layer.cpp b/CesiumQuantizedMeshTerrain/src/Layer.cpp index 2bc09ed62..2b5cecb00 100644 --- a/CesiumQuantizedMeshTerrain/src/Layer.cpp +++ b/CesiumQuantizedMeshTerrain/src/Layer.cpp @@ -1,6 +1,15 @@ +#include +#include +#include +#include +#include +#include +#include #include +#include #include +#include using namespace CesiumGeometry; using namespace CesiumGeospatial; diff --git a/CesiumQuantizedMeshTerrain/src/LayerWriter.cpp b/CesiumQuantizedMeshTerrain/src/LayerWriter.cpp index f79fbd644..a5a1db319 100644 --- a/CesiumQuantizedMeshTerrain/src/LayerWriter.cpp +++ b/CesiumQuantizedMeshTerrain/src/LayerWriter.cpp @@ -1,12 +1,13 @@ -#include "CesiumQuantizedMeshTerrain/LayerWriter.h" - #include "LayerJsonWriter.h" #include "registerWriterExtensions.h" #include #include +#include #include +#include + namespace CesiumQuantizedMeshTerrain { LayerWriter::LayerWriter() { registerWriterExtensions(this->_context); } diff --git a/CesiumQuantizedMeshTerrain/src/QuantizedMeshLoader.cpp b/CesiumQuantizedMeshTerrain/src/QuantizedMeshLoader.cpp index c2c38d34a..0e190232e 100644 --- a/CesiumQuantizedMeshTerrain/src/QuantizedMeshLoader.cpp +++ b/CesiumQuantizedMeshTerrain/src/QuantizedMeshLoader.cpp @@ -1,30 +1,56 @@ -#include +#include #include +#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include -#include #include #include -#include +#include #include -#include -#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include #include +#include +#include +#include using namespace CesiumGeometry; using namespace CesiumGeospatial; using namespace CesiumGltfContent; -using namespace CesiumQuantizedMeshTerrain; using namespace CesiumUtility; +namespace CesiumQuantizedMeshTerrain { + struct QuantizedMeshHeader { // The center of the tile in Earth-centered Fixed coordinates. double CenterX; @@ -111,6 +137,8 @@ struct QuantizedMeshView { constexpr size_t headerLength = 92; constexpr size_t extensionHeaderLength = 5; +namespace { + int32_t zigZagDecode(int32_t value) noexcept { return (value >> 1) ^ (-(value & 1)); } @@ -135,7 +163,7 @@ void decodeIndices( } template -static T readValue( +T readValue( const std::span& data, size_t offset, T defaultValue) noexcept { @@ -145,10 +173,7 @@ static T readValue( return defaultValue; } -static QuantizedMeshMetadataResult -processMetadata(const QuadtreeTileID& tileID, std::span json); - -static std::optional parseQuantizedMesh( +std::optional parseQuantizedMesh( const std::span& data, bool enableWaterMask) { if (data.size() < headerLength) { @@ -244,7 +269,8 @@ static std::optional parseQuantizedMesh( // read the west edge indices meshView.westEdgeIndicesCount = readValue(data, readIndex, 0); readIndex += sizeof(uint32_t); - edgeByteSizes = meshView.westEdgeIndicesCount * indexSizeBytes; + edgeByteSizes = + static_cast(meshView.westEdgeIndicesCount * indexSizeBytes); if (readIndex + edgeByteSizes > data.size()) { return std::nullopt; } @@ -256,7 +282,8 @@ static std::optional parseQuantizedMesh( // read the south edge meshView.southEdgeIndicesCount = readValue(data, readIndex, 0); readIndex += sizeof(uint32_t); - edgeByteSizes = meshView.southEdgeIndicesCount * indexSizeBytes; + edgeByteSizes = + static_cast(meshView.southEdgeIndicesCount * indexSizeBytes); if (readIndex + edgeByteSizes > data.size()) { return std::nullopt; } @@ -268,7 +295,8 @@ static std::optional parseQuantizedMesh( // read the east edge meshView.eastEdgeIndicesCount = readValue(data, readIndex, 0); readIndex += sizeof(uint32_t); - edgeByteSizes = meshView.eastEdgeIndicesCount * indexSizeBytes; + edgeByteSizes = + static_cast(meshView.eastEdgeIndicesCount * indexSizeBytes); if (readIndex + edgeByteSizes > data.size()) { return std::nullopt; } @@ -280,7 +308,8 @@ static std::optional parseQuantizedMesh( // read the north edge meshView.northEdgeIndicesCount = readValue(data, readIndex, 0); readIndex += sizeof(uint32_t); - edgeByteSizes = meshView.northEdgeIndicesCount * indexSizeBytes; + edgeByteSizes = + static_cast(meshView.northEdgeIndicesCount * indexSizeBytes); if (readIndex + edgeByteSizes > data.size()) { return std::nullopt; } @@ -304,12 +333,13 @@ static std::optional parseQuantizedMesh( if (extensionID == 1) { // Oct-encoded per-vertex normals - if (readIndex + vertexCount * 2 > data.size()) { + if (readIndex + static_cast(vertexCount * 2) > data.size()) { break; } - meshView.octEncodedNormalBuffer = - std::span(data.data() + readIndex, vertexCount * 2); + meshView.octEncodedNormalBuffer = std::span( + data.data() + readIndex, + static_cast(vertexCount * 2)); } else if (enableWaterMask && extensionID == 2) { // Water Mask if (extensionLength == 1) { @@ -351,7 +381,7 @@ static std::optional parseQuantizedMesh( return meshView; } -static double calculateSkirtHeight( +double calculateSkirtHeight( const CesiumGeospatial::Ellipsoid& ellipsoid, const CesiumGeospatial::GlobeRectangle& rectangle) noexcept { const double levelMaximumGeometricError = @@ -360,7 +390,7 @@ static double calculateSkirtHeight( } template -static void addSkirt( +void addSkirt( const CesiumGeospatial::Ellipsoid& ellipsoid, const glm::dvec3& center, const CesiumGeospatial::GlobeRectangle& rectangle, @@ -384,7 +414,7 @@ static void addSkirt( const double north = rectangle.getNorth(); size_t newEdgeIndex = currentVertexCount; - size_t positionIdx = currentVertexCount * 3; + size_t positionIdx = static_cast(currentVertexCount * 3); size_t indexIdx = currentIndicesCount; for (size_t i = 0; i < edgeIndices.size(); ++i) { E edgeIdx = edgeIndices[i]; @@ -431,7 +461,7 @@ static void addSkirt( } template -static void addSkirts( +void addSkirts( const CesiumGeospatial::Ellipsoid& ellipsoid, const glm::dvec3& center, const CesiumGeospatial::GlobeRectangle& rectangle, @@ -619,7 +649,7 @@ static void decodeNormals( } template -static std::vector generateNormals( +std::vector generateNormals( const std::span& positions, const std::span& indices, size_t currentNumOfIndex) { @@ -669,6 +699,30 @@ static std::vector generateNormals( return normalsBuffer; } +QuantizedMeshMetadataResult processMetadata( + const QuadtreeTileID& tileID, + std::span metadataString) { + rapidjson::Document metadata; + metadata.Parse( + reinterpret_cast(metadataString.data()), + metadataString.size()); + + QuantizedMeshMetadataResult result; + + if (metadata.HasParseError()) { + result.errors.emplaceError(fmt::format( + "Error when parsing metadata, error code {} at byte offset {}", + metadata.GetParseError(), + metadata.GetErrorOffset())); + return result; + } + + return QuantizedMeshLoader::loadAvailabilityRectangles( + metadata, + tileID.level + 1); +} +} // namespace + /*static*/ QuantizedMeshLoadResult QuantizedMeshLoader::load( const QuadtreeTileID& tileID, const BoundingRegion& tileBoundingVolume, @@ -700,10 +754,11 @@ static std::vector generateNormals( // decode position without skirt, but preallocate position buffer to include // skirt as well std::vector outputPositionsBuffer( - (vertexCount + skirtVertexCount) * 3 * sizeof(float)); + static_cast((vertexCount + skirtVertexCount) * 3) * + sizeof(float)); std::span outputPositions( reinterpret_cast(outputPositionsBuffer.data()), - (vertexCount + skirtVertexCount) * 3); + static_cast((vertexCount + skirtVertexCount) * 3)); size_t positionOutputIndex = 0; const glm::dvec3 center( @@ -1190,29 +1245,6 @@ struct TileRange { uint32_t maximumY; }; -static QuantizedMeshMetadataResult processMetadata( - const QuadtreeTileID& tileID, - std::span metadataString) { - rapidjson::Document metadata; - metadata.Parse( - reinterpret_cast(metadataString.data()), - metadataString.size()); - - QuantizedMeshMetadataResult result; - - if (metadata.HasParseError()) { - result.errors.emplaceError(fmt::format( - "Error when parsing metadata, error code {} at byte offset {}", - metadata.GetParseError(), - metadata.GetErrorOffset())); - return result; - } - - return QuantizedMeshLoader::loadAvailabilityRectangles( - metadata, - tileID.level + 1); -} - /*static*/ QuantizedMeshMetadataResult QuantizedMeshLoader::loadMetadata( const std::span& data, const QuadtreeTileID& tileID) { @@ -1222,3 +1254,5 @@ static QuantizedMeshMetadataResult processMetadata( } return processMetadata(tileID, meshView->metadataJsonBuffer); } + +} // namespace CesiumQuantizedMeshTerrain \ No newline at end of file diff --git a/CesiumQuantizedMeshTerrain/test/TestLayer.cpp b/CesiumQuantizedMeshTerrain/test/TestLayer.cpp index 721c7de1c..f020edc8d 100644 --- a/CesiumQuantizedMeshTerrain/test/TestLayer.cpp +++ b/CesiumQuantizedMeshTerrain/test/TestLayer.cpp @@ -1,9 +1,17 @@ +#include +#include +#include +#include +#include +#include #include #include -#include #include +#include +#include + using namespace CesiumGeometry; using namespace CesiumGeospatial; using namespace CesiumQuantizedMeshTerrain; diff --git a/CesiumQuantizedMeshTerrain/test/TestLayerWriter.cpp b/CesiumQuantizedMeshTerrain/test/TestLayerWriter.cpp index bdffe1647..13ffce70d 100644 --- a/CesiumQuantizedMeshTerrain/test/TestLayerWriter.cpp +++ b/CesiumQuantizedMeshTerrain/test/TestLayerWriter.cpp @@ -1,10 +1,12 @@ +#include #include #include #include -#include #include +#include + using namespace CesiumJsonReader; using namespace CesiumQuantizedMeshTerrain; diff --git a/CesiumQuantizedMeshTerrain/test/TestQuantizedMeshContent.cpp b/CesiumQuantizedMeshTerrain/test/TestQuantizedMeshContent.cpp index 65b357d4c..47c1544ce 100644 --- a/CesiumQuantizedMeshTerrain/test/TestQuantizedMeshContent.cpp +++ b/CesiumQuantizedMeshTerrain/test/TestQuantizedMeshContent.cpp @@ -1,16 +1,37 @@ #include +#include #include #include +#include +#include #include -#include +#include #include +#include +#include +#include +#include +#include #include #include -#include #include -#include - +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include #include using namespace Cesium3DTilesContent; @@ -397,7 +418,7 @@ void checkGridMesh( int32_t v = 0; std::vector uvs; - uvs.reserve(verticesWidth * verticesHeight); + uvs.reserve(static_cast(verticesWidth * verticesHeight)); uint32_t positionIdx = 0; uint32_t idx = 0; for (uint32_t y = 0; y < verticesHeight; ++y) { @@ -469,8 +490,10 @@ void checkGridMesh( size_t eastIndicesCount = quantizedMesh.vertexData.eastIndices.size(); size_t northIndicesCount = quantizedMesh.vertexData.northIndices.size(); - size_t gridVerticesCount = verticesWidth * verticesHeight; - size_t gridIndicesCount = (verticesHeight - 1) * (verticesWidth - 1) * 6; + size_t gridVerticesCount = + static_cast(verticesWidth * verticesHeight); + size_t gridIndicesCount = + static_cast((verticesHeight - 1) * (verticesWidth - 1) * 6); size_t totalSkirtVertices = westIndicesCount + southIndicesCount + eastIndicesCount + northIndicesCount; size_t totalSkirtIndices = (totalSkirtVertices - 4) * 6; @@ -571,7 +594,8 @@ static void checkGeneratedGridNormal( uint32_t verticesWidth, uint32_t verticesHeight) { uint32_t totalGridIndices = (verticesWidth - 1) * (verticesHeight - 1) * 6; - std::vector expectedNormals(verticesWidth * verticesHeight); + std::vector expectedNormals( + static_cast(verticesWidth * verticesHeight)); for (uint32_t i = 0; i < totalGridIndices; i += 3) { I id0 = indices[i]; I id1 = indices[i + 1]; @@ -617,7 +641,8 @@ static void checkGeneratedGridNormal( size_t eastIndicesCount = quantizedMesh.vertexData.eastIndices.size(); size_t northIndicesCount = quantizedMesh.vertexData.northIndices.size(); - size_t gridVerticesCount = verticesWidth * verticesHeight; + size_t gridVerticesCount = + static_cast(verticesWidth * verticesHeight); size_t totalSkirtVertices = westIndicesCount + southIndicesCount + eastIndicesCount + northIndicesCount; @@ -1004,7 +1029,8 @@ TEST_CASE("Test converting quantized mesh to gltf with skirt") { glm::vec3 normal = glm::normalize(glm::vec3(0.2, 1.4, 0.3)); uint8_t x = 0, y = 0; octEncode(normal, x, y); - std::vector octNormals(verticesWidth * verticesHeight * 2); + std::vector octNormals( + static_cast(verticesWidth * verticesHeight * 2)); for (size_t i = 0; i < octNormals.size(); i += 2) { octNormals[i] = std::byte(x); octNormals[i + 1] = std::byte(y); @@ -1046,7 +1072,8 @@ TEST_CASE("Test converting quantized mesh to gltf with skirt") { REQUIRE( static_cast(normals.size()) == - (verticesWidth * verticesHeight + totalSkirtVerticesCount)); + (static_cast(verticesWidth * verticesHeight) + + totalSkirtVerticesCount)); for (int64_t i = 0; i < normals.size(); ++i) { REQUIRE(Math::equalsEpsilon(normals[i].x, normal.x, Math::Epsilon2)); REQUIRE(Math::equalsEpsilon(normals[i].y, normal.y, Math::Epsilon2)); @@ -1091,7 +1118,8 @@ TEST_CASE("Test converting ill-formed quantized mesh") { glm::vec3 normal = glm::normalize(glm::vec3(0.2, 1.4, 0.3)); uint8_t x = 0, y = 0; octEncode(normal, x, y); - std::vector octNormals(verticesWidth * verticesHeight * 2); + std::vector octNormals( + static_cast(verticesWidth * verticesHeight * 2)); for (size_t i = 0; i < octNormals.size(); i += 2) { octNormals[i] = std::byte(x); octNormals[i + 1] = std::byte(y); diff --git a/CesiumRasterOverlays/include/CesiumRasterOverlays/BingMapsRasterOverlay.h b/CesiumRasterOverlays/include/CesiumRasterOverlays/BingMapsRasterOverlay.h index e97e8c808..632ced760 100644 --- a/CesiumRasterOverlays/include/CesiumRasterOverlays/BingMapsRasterOverlay.h +++ b/CesiumRasterOverlays/include/CesiumRasterOverlays/BingMapsRasterOverlay.h @@ -1,10 +1,9 @@ #pragma once -#include "Library.h" -#include "RasterOverlay.h" - #include #include +#include +#include #include #include diff --git a/CesiumRasterOverlays/include/CesiumRasterOverlays/DebugColorizeTilesRasterOverlay.h b/CesiumRasterOverlays/include/CesiumRasterOverlays/DebugColorizeTilesRasterOverlay.h index c99b245e5..0d1c91188 100644 --- a/CesiumRasterOverlays/include/CesiumRasterOverlays/DebugColorizeTilesRasterOverlay.h +++ b/CesiumRasterOverlays/include/CesiumRasterOverlays/DebugColorizeTilesRasterOverlay.h @@ -1,7 +1,7 @@ #pragma once -#include "CesiumGeospatial/Ellipsoid.h" -#include "RasterOverlay.h" +#include +#include namespace CesiumRasterOverlays { diff --git a/CesiumRasterOverlays/include/CesiumRasterOverlays/IPrepareRasterOverlayRendererResources.h b/CesiumRasterOverlays/include/CesiumRasterOverlays/IPrepareRasterOverlayRendererResources.h index 43fb643e2..a5fc46624 100644 --- a/CesiumRasterOverlays/include/CesiumRasterOverlays/IPrepareRasterOverlayRendererResources.h +++ b/CesiumRasterOverlays/include/CesiumRasterOverlays/IPrepareRasterOverlayRendererResources.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include #include diff --git a/CesiumRasterOverlays/include/CesiumRasterOverlays/IonRasterOverlay.h b/CesiumRasterOverlays/include/CesiumRasterOverlays/IonRasterOverlay.h index 6b968182d..858b9314c 100644 --- a/CesiumRasterOverlays/include/CesiumRasterOverlays/IonRasterOverlay.h +++ b/CesiumRasterOverlays/include/CesiumRasterOverlays/IonRasterOverlay.h @@ -1,10 +1,9 @@ #pragma once -#include "Library.h" -#include "RasterOverlay.h" - #include #include +#include +#include #include #include diff --git a/CesiumRasterOverlays/include/CesiumRasterOverlays/QuadtreeRasterOverlayTileProvider.h b/CesiumRasterOverlays/include/CesiumRasterOverlays/QuadtreeRasterOverlayTileProvider.h index 4551b4217..2ea16c2f0 100644 --- a/CesiumRasterOverlays/include/CesiumRasterOverlays/QuadtreeRasterOverlayTileProvider.h +++ b/CesiumRasterOverlays/include/CesiumRasterOverlays/QuadtreeRasterOverlayTileProvider.h @@ -1,14 +1,13 @@ #pragma once -#include "IPrepareRasterOverlayRendererResources.h" -#include "Library.h" -#include "RasterOverlayTileProvider.h" - #include #include #include #include #include +#include +#include +#include #include #include #include diff --git a/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterOverlay.h b/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterOverlay.h index bdad340ce..de3143b2a 100644 --- a/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterOverlay.h +++ b/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterOverlay.h @@ -1,12 +1,11 @@ #pragma once -#include "Library.h" -#include "RasterOverlayLoadFailureDetails.h" - #include #include #include #include +#include +#include #include #include @@ -14,6 +13,7 @@ #include #include +#include #include #include #include @@ -50,7 +50,7 @@ struct CESIUMRASTEROVERLAYS_API RasterOverlayOptions { * in memory in case they're needed again soon. This property controls the * maximum size of that cache. */ - int64_t subTileCacheBytes = 16 * 1024 * 1024; + int64_t subTileCacheBytes = static_cast(16 * 1024 * 1024); /** * @brief The maximum pixel size of raster overlay textures, in either diff --git a/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterOverlayDetails.h b/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterOverlayDetails.h index 75fded234..a48bfb897 100644 --- a/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterOverlayDetails.h +++ b/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterOverlayDetails.h @@ -1,10 +1,9 @@ #pragma once -#include "Library.h" - #include #include #include +#include #include diff --git a/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterOverlayTileProvider.h b/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterOverlayTileProvider.h index cac05ee52..202b6b9cc 100644 --- a/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterOverlayTileProvider.h +++ b/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterOverlayTileProvider.h @@ -1,10 +1,9 @@ #pragma once -#include "Library.h" - #include #include #include +#include #include #include #include diff --git a/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterOverlayUtilities.h b/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterOverlayUtilities.h index 0d0366416..5b837ab76 100644 --- a/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterOverlayUtilities.h +++ b/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterOverlayUtilities.h @@ -1,11 +1,10 @@ #pragma once -#include "Library.h" -#include "RasterOverlayDetails.h" - #include #include #include +#include +#include #include diff --git a/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterizedPolygonsOverlay.h b/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterizedPolygonsOverlay.h index e355a26fb..dfe2add0a 100644 --- a/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterizedPolygonsOverlay.h +++ b/CesiumRasterOverlays/include/CesiumRasterOverlays/RasterizedPolygonsOverlay.h @@ -1,13 +1,12 @@ #pragma once -#include "Library.h" -#include "RasterOverlay.h" -#include "RasterOverlayTileProvider.h" - #include #include #include #include +#include +#include +#include #include diff --git a/CesiumRasterOverlays/include/CesiumRasterOverlays/TileMapServiceRasterOverlay.h b/CesiumRasterOverlays/include/CesiumRasterOverlays/TileMapServiceRasterOverlay.h index f7d9da48a..3f82c373e 100644 --- a/CesiumRasterOverlays/include/CesiumRasterOverlays/TileMapServiceRasterOverlay.h +++ b/CesiumRasterOverlays/include/CesiumRasterOverlays/TileMapServiceRasterOverlay.h @@ -1,13 +1,12 @@ #pragma once -#include "Library.h" -#include "RasterOverlay.h" - #include #include #include #include #include +#include +#include #include #include diff --git a/CesiumRasterOverlays/include/CesiumRasterOverlays/WebMapServiceRasterOverlay.h b/CesiumRasterOverlays/include/CesiumRasterOverlays/WebMapServiceRasterOverlay.h index 8a01d1860..6feaa0ba2 100644 --- a/CesiumRasterOverlays/include/CesiumRasterOverlays/WebMapServiceRasterOverlay.h +++ b/CesiumRasterOverlays/include/CesiumRasterOverlays/WebMapServiceRasterOverlay.h @@ -1,13 +1,12 @@ #pragma once -#include "Library.h" -#include "RasterOverlay.h" - #include #include #include #include #include +#include +#include #include diff --git a/CesiumRasterOverlays/include/CesiumRasterOverlays/WebMapTileServiceRasterOverlay.h b/CesiumRasterOverlays/include/CesiumRasterOverlays/WebMapTileServiceRasterOverlay.h index caeb2cae2..bf41427c8 100644 --- a/CesiumRasterOverlays/include/CesiumRasterOverlays/WebMapTileServiceRasterOverlay.h +++ b/CesiumRasterOverlays/include/CesiumRasterOverlays/WebMapTileServiceRasterOverlay.h @@ -1,13 +1,12 @@ #pragma once -#include "Library.h" -#include "RasterOverlay.h" - #include #include #include #include #include +#include +#include #include #include diff --git a/CesiumRasterOverlays/src/BingMapsRasterOverlay.cpp b/CesiumRasterOverlays/src/BingMapsRasterOverlay.cpp index 3531ebdeb..417cee679 100644 --- a/CesiumRasterOverlays/src/BingMapsRasterOverlay.cpp +++ b/CesiumRasterOverlays/src/BingMapsRasterOverlay.cpp @@ -1,23 +1,34 @@ +#include #include #include +#include +#include #include #include #include #include #include +#include #include #include #include #include +#include #include -#include -#include #include +#include +#include #include #include +#include +#include +#include +#include #include +#include +#include #include #include #include @@ -143,7 +154,7 @@ class BingMapsTileProvider final : public QuadtreeRasterOverlayTileProvider { }); } - virtual ~BingMapsTileProvider() {} + virtual ~BingMapsTileProvider() = default; protected: virtual CesiumAsync::Future loadQuadtreeTileImage( @@ -171,7 +182,10 @@ class BingMapsTileProvider final : public QuadtreeRasterOverlayTileProvider { options.rectangle = this->getTilingScheme().tileToRectangle(tileID); std::vector& tileCredits = options.credits = this->getOwner().getCredits(); - tileCredits.push_back(*this->getCredit()); + const std::optional& thisCredit = this->getCredit(); + if (thisCredit.has_value()) { + tileCredits.push_back(*thisCredit); + } const CesiumGeospatial::GlobeRectangle tileRectangle = CesiumGeospatial::unprojectRectangleSimple( @@ -236,7 +250,7 @@ BingMapsRasterOverlay::BingMapsRasterOverlay( _mapStyle(mapStyle), _culture(culture) {} -BingMapsRasterOverlay::~BingMapsRasterOverlay() {} +BingMapsRasterOverlay::~BingMapsRasterOverlay() = default; namespace { diff --git a/CesiumRasterOverlays/src/DebugColorizeTilesRasterOverlay.cpp b/CesiumRasterOverlays/src/DebugColorizeTilesRasterOverlay.cpp index d5b8d09de..fc8ea22a1 100644 --- a/CesiumRasterOverlays/src/DebugColorizeTilesRasterOverlay.cpp +++ b/CesiumRasterOverlays/src/DebugColorizeTilesRasterOverlay.cpp @@ -1,9 +1,27 @@ +#include +#include +#include +#include #include +#include #include +#include #include #include +#include +#include #include +#include + +#include +#include +#include +#include +#include +#include +#include + using namespace CesiumRasterOverlays; using namespace CesiumGeospatial; using namespace CesiumGltf; diff --git a/CesiumRasterOverlays/src/IonRasterOverlay.cpp b/CesiumRasterOverlays/src/IonRasterOverlay.cpp index 914849cd8..e6fbc664c 100644 --- a/CesiumRasterOverlays/src/IonRasterOverlay.cpp +++ b/CesiumRasterOverlays/src/IonRasterOverlay.cpp @@ -1,15 +1,30 @@ +#include #include #include #include #include +#include #include #include #include #include +#include +#include #include -#include #include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + using namespace CesiumAsync; using namespace CesiumUtility; @@ -26,7 +41,7 @@ IonRasterOverlay::IonRasterOverlay( _ionAccessToken(ionAccessToken), _ionAssetEndpointUrl(ionAssetEndpointUrl) {} -IonRasterOverlay::~IonRasterOverlay() {} +IonRasterOverlay::~IonRasterOverlay() = default; std::unordered_map IonRasterOverlay::endpointCache; @@ -75,7 +90,7 @@ IonRasterOverlay::createTileProvider( pCreditSystem, pPrepareRendererResources, pLogger, - pOwner); + std::move(pOwner)); } Future diff --git a/CesiumRasterOverlays/src/QuadtreeRasterOverlayTileProvider.cpp b/CesiumRasterOverlays/src/QuadtreeRasterOverlayTileProvider.cpp index b7b19ae13..fdfb1c143 100644 --- a/CesiumRasterOverlays/src/QuadtreeRasterOverlayTileProvider.cpp +++ b/CesiumRasterOverlays/src/QuadtreeRasterOverlayTileProvider.cpp @@ -1,10 +1,36 @@ +#include +#include +#include +#include +#include #include +#include +#include #include #include #include #include +#include +#include +#include #include -#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace CesiumAsync; using namespace CesiumGeometry; @@ -654,18 +680,18 @@ QuadtreeRasterOverlayTileProvider::combineImages( target.pixelData.resize(size_t( target.width * target.height * target.channels * target.bytesPerChannel)); - for (auto it = images.begin(); it != images.end(); ++it) { - if (!it->pValue) { + for (const auto& image : images) { + if (!image.pValue) { continue; } - const LoadedRasterOverlayImage& loaded = *it->pValue->pLoaded; + const LoadedRasterOverlayImage& loaded = *image.pValue->pLoaded; if (!loaded.pImage) { continue; } // Tiles with a subset inherently have no more detail available (otherwise // we wouldn't need the subset). - if (!it->pValue->subset) { + if (!image.pValue->subset) { result.moreDetailAvailable |= loaded.moreDetailAvailable; } @@ -674,15 +700,15 @@ QuadtreeRasterOverlayTileProvider::combineImages( result.rectangle, *loaded.pImage, loaded.rectangle, - it->pValue->subset); + image.pValue->subset); } size_t combinedCreditsCount = 0; - for (auto it = images.begin(); it != images.end(); ++it) { - if (!it->pValue) { + for (const auto& image : images) { + if (!image.pValue) { continue; } - const LoadedRasterOverlayImage& loaded = *it->pValue->pLoaded; + const LoadedRasterOverlayImage& loaded = *image.pValue->pLoaded; if (!loaded.pImage) { continue; } @@ -691,11 +717,11 @@ QuadtreeRasterOverlayTileProvider::combineImages( } result.credits.reserve(combinedCreditsCount); - for (auto it = images.begin(); it != images.end(); ++it) { - if (!it->pValue) { + for (const auto& image : images) { + if (!image.pValue) { continue; } - const LoadedRasterOverlayImage& loaded = *it->pValue->pLoaded; + const LoadedRasterOverlayImage& loaded = *image.pValue->pLoaded; if (!loaded.pImage) { continue; } diff --git a/CesiumRasterOverlays/src/RasterOverlay.cpp b/CesiumRasterOverlays/src/RasterOverlay.cpp index 0f369b63b..dcd58c32f 100644 --- a/CesiumRasterOverlays/src/RasterOverlay.cpp +++ b/CesiumRasterOverlays/src/RasterOverlay.cpp @@ -1,9 +1,17 @@ +#include +#include +#include +#include +#include #include #include #include #include +#include -#include +#include +#include +#include using namespace CesiumAsync; using namespace CesiumRasterOverlays; diff --git a/CesiumRasterOverlays/src/RasterOverlayDetails.cpp b/CesiumRasterOverlays/src/RasterOverlayDetails.cpp index fee7954b6..74bec0561 100644 --- a/CesiumRasterOverlays/src/RasterOverlayDetails.cpp +++ b/CesiumRasterOverlays/src/RasterOverlayDetails.cpp @@ -1,8 +1,16 @@ +#include +#include +#include +#include #include #include #include +#include +#include #include +#include +#include namespace CesiumRasterOverlays { RasterOverlayDetails::RasterOverlayDetails() diff --git a/CesiumRasterOverlays/src/RasterOverlayTile.cpp b/CesiumRasterOverlays/src/RasterOverlayTile.cpp index 2b9c19207..b1f7aa5cd 100644 --- a/CesiumRasterOverlays/src/RasterOverlayTile.cpp +++ b/CesiumRasterOverlays/src/RasterOverlayTile.cpp @@ -1,10 +1,9 @@ -#include -#include #include #include #include #include -#include + +#include using namespace CesiumAsync; diff --git a/CesiumRasterOverlays/src/RasterOverlayTileProvider.cpp b/CesiumRasterOverlays/src/RasterOverlayTileProvider.cpp index 74aca0a88..68c274fc0 100644 --- a/CesiumRasterOverlays/src/RasterOverlayTileProvider.cpp +++ b/CesiumRasterOverlays/src/RasterOverlayTileProvider.cpp @@ -1,14 +1,36 @@ +#include +#include +#include +#include #include +#include +#include +#include #include #include #include #include #include +#include +#include +#include #include -#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + using namespace CesiumAsync; using namespace CesiumGeometry; using namespace CesiumGeospatial; @@ -32,12 +54,10 @@ RasterOverlayTileProvider::RasterOverlayTileProvider( _projection(CesiumGeospatial::GeographicProjection(ellipsoid)), _coverageRectangle(CesiumGeospatial::GeographicProjection:: computeMaximumProjectedRectangle(ellipsoid)), - _pPlaceholder(), + _pPlaceholder(new RasterOverlayTile(*this)), _tileDataBytes(0), _totalTilesCurrentlyLoading(0), - _throttledTilesCurrentlyLoading(0) { - this->_pPlaceholder = new RasterOverlayTile(*this); -} + _throttledTilesCurrentlyLoading(0) {} RasterOverlayTileProvider::RasterOverlayTileProvider( const CesiumUtility::IntrusivePointer& pOwner, diff --git a/CesiumRasterOverlays/src/RasterOverlayUtilities.cpp b/CesiumRasterOverlays/src/RasterOverlayUtilities.cpp index 3590e4ac7..29f969e63 100644 --- a/CesiumRasterOverlays/src/RasterOverlayUtilities.cpp +++ b/CesiumRasterOverlays/src/RasterOverlayUtilities.cpp @@ -1,17 +1,46 @@ +#include +#include #include #include +#include #include +#include +#include +#include +#include #include +#include #include +#include +#include +#include #include +#include #include #include +#include #include #include +#include #include +#include +#include +#include +#include +#include + #include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include using namespace CesiumGltf; using namespace CesiumGltfContent; @@ -812,7 +841,7 @@ bool upsamplePrimitiveForRasterOverlays( std::to_string(textureCoordinateIndex); for (std::pair& attribute : primitive.attributes) { - if (attribute.first.find(textureCoordinateAttributeBaseName) == 0) { + if (attribute.first.starts_with(textureCoordinateAttributeBaseName)) { if (uvAccessorIndex == -1) { if (attribute.first == textureCoordinateName) { uvAccessorIndex = attribute.second; @@ -1079,8 +1108,8 @@ bool upsamplePrimitiveForRasterOverlays( Accessor& accessor = model.accessors[static_cast(attribute.accessorIndex)]; accessor.count = numberOfVertices; - accessor.min = std::move(attribute.minimums); - accessor.max = std::move(attribute.maximums); + accessor.min = attribute.minimums; + accessor.max = attribute.maximums; } // Add an accessor for the indices diff --git a/CesiumRasterOverlays/src/RasterizedPolygonsOverlay.cpp b/CesiumRasterOverlays/src/RasterizedPolygonsOverlay.cpp index 8b8868ba9..941b4c5dc 100644 --- a/CesiumRasterOverlays/src/RasterizedPolygonsOverlay.cpp +++ b/CesiumRasterOverlays/src/RasterizedPolygonsOverlay.cpp @@ -1,15 +1,29 @@ #include #include +#include +#include #include +#include +#include +#include +#include #include #include #include +#include #include +#include +#include +#include #include +#include +#include #include +#include #include +#include using namespace CesiumGeometry; using namespace CesiumGeospatial; @@ -233,7 +247,7 @@ RasterizedPolygonsOverlay::RasterizedPolygonsOverlay( _ellipsoid(ellipsoid), _projection(projection) {} -RasterizedPolygonsOverlay::~RasterizedPolygonsOverlay() {} +RasterizedPolygonsOverlay::~RasterizedPolygonsOverlay() = default; CesiumAsync::Future RasterizedPolygonsOverlay::createTileProvider( diff --git a/CesiumRasterOverlays/src/TileMapServiceRasterOverlay.cpp b/CesiumRasterOverlays/src/TileMapServiceRasterOverlay.cpp index ccea970e6..c7f569ca1 100644 --- a/CesiumRasterOverlays/src/TileMapServiceRasterOverlay.cpp +++ b/CesiumRasterOverlays/src/TileMapServiceRasterOverlay.cpp @@ -1,18 +1,40 @@ +#include #include #include +#include +#include +#include +#include +#include #include +#include #include +#include #include +#include #include #include +#include #include #include +#include +#include #include +#include +#include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include using namespace CesiumAsync; using namespace CesiumUtility; @@ -24,6 +46,41 @@ struct TileMapServiceTileset { std::string url; uint32_t level; }; + +std::optional getAttributeString( + const tinyxml2::XMLElement* pElement, + const char* attributeName) { + if (!pElement) { + return std::nullopt; + } + + const char* pAttrValue = pElement->Attribute(attributeName); + if (!pAttrValue) { + return std::nullopt; + } + + return std::string(pAttrValue); +} + +std::optional getAttributeUint32( + const tinyxml2::XMLElement* pElement, + const char* attributeName) { + std::optional s = getAttributeString(pElement, attributeName); + if (s) { + return std::stoul(s.value()); + } + return std::nullopt; +} + +std::optional getAttributeDouble( + const tinyxml2::XMLElement* pElement, + const char* attributeName) { + std::optional s = getAttributeString(pElement, attributeName); + if (s) { + return std::stod(s.value()); + } + return std::nullopt; +} } // namespace class TileMapServiceTileProvider final @@ -67,7 +124,7 @@ class TileMapServiceTileProvider final _fileExtension(fileExtension), _tileSets(tileSets) {} - virtual ~TileMapServiceTileProvider() {} + virtual ~TileMapServiceTileProvider() = default; protected: virtual CesiumAsync::Future loadQuadtreeTileImage( @@ -121,42 +178,7 @@ TileMapServiceRasterOverlay::TileMapServiceRasterOverlay( _headers(headers), _options(tmsOptions) {} -TileMapServiceRasterOverlay::~TileMapServiceRasterOverlay() {} - -static std::optional getAttributeString( - const tinyxml2::XMLElement* pElement, - const char* attributeName) { - if (!pElement) { - return std::nullopt; - } - - const char* pAttrValue = pElement->Attribute(attributeName); - if (!pAttrValue) { - return std::nullopt; - } - - return std::string(pAttrValue); -} - -static std::optional getAttributeUint32( - const tinyxml2::XMLElement* pElement, - const char* attributeName) { - std::optional s = getAttributeString(pElement, attributeName); - if (s) { - return std::stoul(s.value()); - } - return std::nullopt; -} - -static std::optional getAttributeDouble( - const tinyxml2::XMLElement* pElement, - const char* attributeName) { - std::optional s = getAttributeString(pElement, attributeName); - if (s) { - return std::stod(s.value()); - } - return std::nullopt; -} +TileMapServiceRasterOverlay::~TileMapServiceRasterOverlay() = default; namespace { @@ -371,7 +393,7 @@ TileMapServiceRasterOverlay::createTileProvider( // standard, which is 'global-mercator' and 'global-geodetic' // profiles. In the gdal2Tiles case, X and Y are always in // geodetic degrees. - isRectangleInDegrees = projectionName.find("global-") != 0; + isRectangleInDegrees = !projectionName.starts_with("global-"); } else if ( projectionName == "geodetic" || projectionName == "global-geodetic") { diff --git a/CesiumRasterOverlays/src/WebMapServiceRasterOverlay.cpp b/CesiumRasterOverlays/src/WebMapServiceRasterOverlay.cpp index def3de2b3..f610cd3ec 100644 --- a/CesiumRasterOverlays/src/WebMapServiceRasterOverlay.cpp +++ b/CesiumRasterOverlays/src/WebMapServiceRasterOverlay.cpp @@ -1,19 +1,42 @@ +#include #include #include +#include +#include +#include +#include +#include #include #include -#include +#include #include +#include #include #include +#include #include #include +#include +#include #include +#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include using namespace CesiumAsync; using namespace CesiumGeometry; @@ -22,6 +45,106 @@ using namespace CesiumUtility; namespace CesiumRasterOverlays { +namespace { +bool validateCapabilities( + tinyxml2::XMLElement* pRoot, + const WebMapServiceRasterOverlayOptions& options, + std::string& error) { + tinyxml2::XMLElement* pService = pRoot->FirstChildElement("Service"); + if (!pService) { + error = "Web map service XML document does not have a Service " + "element. "; + return false; + } + + tinyxml2::XMLElement* pServiceName = pService->FirstChildElement("Name"); + if (!pServiceName) { + error = "Invalid web map service XML document (Service > Name is " + "missing) "; + return false; + } + + tinyxml2::XMLElement* pOptionalServiceMaxWidth = + pService->FirstChildElement("MaxWidth"); + if (pOptionalServiceMaxWidth) { + const std::string maxWidthText = pOptionalServiceMaxWidth->GetText(); + try { + const int maxWidth = std::stoi(maxWidthText); + const int optionalTileWidth = static_cast(options.tileWidth); + if (optionalTileWidth > maxWidth) { + error = fmt::format( + "configured tile width ({}) exceeds " + "Service >> " + "MaxWidth defined in WMS document ({}).", + optionalTileWidth, + maxWidth); + return false; + } + } catch (std::invalid_argument&) { + error = "Invalid web map service XML document"; + return false; + } + } + + tinyxml2::XMLElement* pOptionalServiceMaxHeight = + pService->FirstChildElement("MaxHeight"); + if (pOptionalServiceMaxHeight) { + const std::string maxHeightText = pOptionalServiceMaxHeight->GetText(); + try { + const int maxHeight = std::stoi(maxHeightText); + const int optionalTileHeight = static_cast(options.tileHeight); + if (optionalTileHeight > maxHeight) { + error = fmt::format( + "configured tile height ({}) exceeds " + "Service >> " + "MaxHeight defined in WMS document ({}).", + optionalTileHeight, + maxHeight); + return false; + } + } catch (std::invalid_argument&) { + error = "Invalid web map service XML document"; + return false; + } + } + + std::vector configLayers{}; + std::stringstream sstream(options.layers); + std::string layer; + const char delimiter = ','; + while (std::getline(sstream, layer, delimiter)) { + if (layer.size() > 0) { + configLayers.push_back(layer); + } + } + + tinyxml2::XMLElement* pOptionalServiceLayerLimit = + pService->FirstChildElement("LayerLimit"); + if (pOptionalServiceLayerLimit) { + try { + const int layerLimit = std::stoi(pOptionalServiceLayerLimit->GetText()); + const int numLayers = static_cast(configLayers.size()); + if (numLayers > layerLimit) { + char buffer[512]; + std::snprintf( + buffer, + 512, + "the number of configured layers (%d) exceeds WMS LayerLimit %d", + numLayers, + layerLimit); + error = buffer; + return false; + } + } catch (std::invalid_argument const&) { + error = "Invalid web map service XML document"; + return false; + } + } + + return true; +} +} // namespace + class WebMapServiceTileProvider final : public QuadtreeRasterOverlayTileProvider { public: @@ -65,7 +188,7 @@ class WebMapServiceTileProvider final _layers(layers), _format(format) {} - virtual ~WebMapServiceTileProvider() {} + virtual ~WebMapServiceTileProvider() = default; protected: virtual CesiumAsync::Future loadQuadtreeTileImage( @@ -139,105 +262,7 @@ WebMapServiceRasterOverlay::WebMapServiceRasterOverlay( _headers(headers), _options(wmsOptions) {} -WebMapServiceRasterOverlay::~WebMapServiceRasterOverlay() {} - -static bool validateCapabilities( - tinyxml2::XMLElement* pRoot, - const WebMapServiceRasterOverlayOptions& options, - std::string& error) { - tinyxml2::XMLElement* pService = pRoot->FirstChildElement("Service"); - if (!pService) { - error = "Web map service XML document does not have a Service " - "element. "; - return false; - } - - tinyxml2::XMLElement* pServiceName = pService->FirstChildElement("Name"); - if (!pServiceName) { - error = "Invalid web map service XML document (Service > Name is " - "missing) "; - return false; - } - - tinyxml2::XMLElement* pOptionalServiceMaxWidth = - pService->FirstChildElement("MaxWidth"); - if (pOptionalServiceMaxWidth) { - const std::string maxWidthText = pOptionalServiceMaxWidth->GetText(); - try { - const int maxWidth = std::stoi(maxWidthText); - const int optionalTileWidth = static_cast(options.tileWidth); - if (optionalTileWidth > maxWidth) { - error = fmt::format( - "configured tile width ({}) exceeds " - "Service >> " - "MaxWidth defined in WMS document ({}).", - optionalTileWidth, - maxWidth); - return false; - } - } catch (std::invalid_argument&) { - error = "Invalid web map service XML document"; - return false; - } - } - - tinyxml2::XMLElement* pOptionalServiceMaxHeight = - pService->FirstChildElement("MaxHeight"); - if (pOptionalServiceMaxHeight) { - const std::string maxHeightText = pOptionalServiceMaxHeight->GetText(); - try { - const int maxHeight = std::stoi(maxHeightText); - const int optionalTileHeight = static_cast(options.tileHeight); - if (optionalTileHeight > maxHeight) { - error = fmt::format( - "configured tile height ({}) exceeds " - "Service >> " - "MaxHeight defined in WMS document ({}).", - optionalTileHeight, - maxHeight); - return false; - } - } catch (std::invalid_argument&) { - error = "Invalid web map service XML document"; - return false; - } - } - - std::vector configLayers{}; - std::stringstream sstream(options.layers); - std::string layer; - const char delimiter = ','; - while (std::getline(sstream, layer, delimiter)) { - if (layer.size() > 0) { - configLayers.push_back(layer); - } - } - - tinyxml2::XMLElement* pOptionalServiceLayerLimit = - pService->FirstChildElement("LayerLimit"); - if (pOptionalServiceLayerLimit) { - try { - const int layerLimit = std::stoi(pOptionalServiceLayerLimit->GetText()); - const int numLayers = static_cast(configLayers.size()); - if (numLayers > layerLimit) { - char buffer[512]; - std::snprintf( - buffer, - 512, - "the number of configured layers (%d) exceeds WMS LayerLimit %d", - numLayers, - layerLimit); - error = buffer; - return false; - } - } catch (std::invalid_argument const&) { - error = "Invalid web map service XML document"; - return false; - } - } - - return true; -} +WebMapServiceRasterOverlay::~WebMapServiceRasterOverlay() = default; Future WebMapServiceRasterOverlay::createTileProvider( @@ -287,8 +312,7 @@ WebMapServiceRasterOverlay::createTileProvider( pLogger, options = this->_options, url = this->_baseUrl, - headers = - this->_headers](const std::shared_ptr& pRequest) + headers = this->_headers](std::shared_ptr&& pRequest) -> CreateTileProviderResult { const IAssetResponse* pResponse = pRequest->response(); if (!pResponse) { diff --git a/CesiumRasterOverlays/src/WebMapTileServiceRasterOverlay.cpp b/CesiumRasterOverlays/src/WebMapTileServiceRasterOverlay.cpp index 175f63461..bff293511 100644 --- a/CesiumRasterOverlays/src/WebMapTileServiceRasterOverlay.cpp +++ b/CesiumRasterOverlays/src/WebMapTileServiceRasterOverlay.cpp @@ -1,16 +1,35 @@ +#include #include -#include +#include +#include +#include +#include #include #include +#include +#include #include +#include #include #include +#include #include #include +#include #include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include #include +#include using namespace CesiumAsync; using namespace CesiumUtility; @@ -42,8 +61,8 @@ class WebMapTileServiceTileProvider final std::string layer, std::string style, std::string _tileMatrixSetID, - const std::optional> tileMatrixLabels, - const std::optional> dimensions, + const std::optional>& tileMatrixLabels, + const std::optional>& dimensions, const std::vector& subdomains) : QuadtreeRasterOverlayTileProvider( pOwner, @@ -63,14 +82,14 @@ class WebMapTileServiceTileProvider final _headers(headers), _useKVP(useKVP), _format(format), - _layer(layer), - _style(style), - _tileMatrixSetID(_tileMatrixSetID), + _layer(std::move(layer)), + _style(std::move(style)), + _tileMatrixSetID(std::move(_tileMatrixSetID)), _labels(tileMatrixLabels), _staticDimensions(dimensions), _subdomains(subdomains) {} - virtual ~WebMapTileServiceTileProvider() {} + virtual ~WebMapTileServiceTileProvider() = default; protected: virtual CesiumAsync::Future loadQuadtreeTileImage( @@ -179,7 +198,7 @@ WebMapTileServiceRasterOverlay::WebMapTileServiceRasterOverlay( _headers(headers), _options(wmtsOptions) {} -WebMapTileServiceRasterOverlay::~WebMapTileServiceRasterOverlay() {} +WebMapTileServiceRasterOverlay::~WebMapTileServiceRasterOverlay() = default; Future WebMapTileServiceRasterOverlay::createTileProvider( diff --git a/CesiumRasterOverlays/test/TestAddRasterOverlayToGltf.cpp b/CesiumRasterOverlays/test/TestAddRasterOverlayToGltf.cpp index b3804d64d..e864f2f62 100644 --- a/CesiumRasterOverlays/test/TestAddRasterOverlayToGltf.cpp +++ b/CesiumRasterOverlays/test/TestAddRasterOverlayToGltf.cpp @@ -1,17 +1,29 @@ -#include +#include #include #include #include #include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include #include +#include +#include #include #include #include +#include #include #include #include @@ -19,12 +31,24 @@ #include #include -#include #include -#include - -#include -#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace CesiumAsync; using namespace CesiumGeometry; diff --git a/CesiumRasterOverlays/test/TestQuadtreeRasterOverlayTileProvider.cpp b/CesiumRasterOverlays/test/TestQuadtreeRasterOverlayTileProvider.cpp index 1fa69efad..fdda74726 100644 --- a/CesiumRasterOverlays/test/TestQuadtreeRasterOverlayTileProvider.cpp +++ b/CesiumRasterOverlays/test/TestQuadtreeRasterOverlayTileProvider.cpp @@ -1,12 +1,37 @@ -#include "CesiumRasterOverlays/QuadtreeRasterOverlayTileProvider.h" -#include "CesiumRasterOverlays/RasterOverlay.h" -#include "CesiumRasterOverlays/RasterOverlayTile.h" - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include -#include #include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace CesiumAsync; using namespace CesiumGeometry; @@ -70,7 +95,7 @@ class TestTileProvider : public QuadtreeRasterOverlayTileProvider { result.pImage->bytesPerChannel = 1; result.pImage->channels = 4; result.pImage->pixelData.resize( - this->getWidth() * this->getHeight() * 4, + static_cast(this->getWidth() * this->getHeight() * 4), std::byte(tileID.level)); } diff --git a/CesiumRasterOverlays/test/TestTileMapServiceRasterOverlay.cpp b/CesiumRasterOverlays/test/TestTileMapServiceRasterOverlay.cpp index 45c47977c..1dcc10f7f 100644 --- a/CesiumRasterOverlays/test/TestTileMapServiceRasterOverlay.cpp +++ b/CesiumRasterOverlays/test/TestTileMapServiceRasterOverlay.cpp @@ -1,16 +1,30 @@ +#include +#include #include +#include +#include #include #include #include #include #include #include +#include +#include #include -#include #include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include using namespace CesiumGltf; using namespace CesiumNativeTests; diff --git a/CesiumRasterOverlays/test/TestUpsampleGltfForRasterOverlay.cpp b/CesiumRasterOverlays/test/TestUpsampleGltfForRasterOverlay.cpp index f38495597..164b201b6 100644 --- a/CesiumRasterOverlays/test/TestUpsampleGltfForRasterOverlay.cpp +++ b/CesiumRasterOverlays/test/TestUpsampleGltfForRasterOverlay.cpp @@ -1,15 +1,27 @@ +#include #include #include +#include #include #include +#include +#include +#include +#include +#include #include #include #include -#include #include +#include +#include +#include +#include +#include #include +#include #include #include diff --git a/CesiumUtility/include/CesiumUtility/AttributeCompression.h b/CesiumUtility/include/CesiumUtility/AttributeCompression.h index 1c468b855..d7d84aac0 100644 --- a/CesiumUtility/include/CesiumUtility/AttributeCompression.h +++ b/CesiumUtility/include/CesiumUtility/AttributeCompression.h @@ -1,7 +1,7 @@ #pragma once -#include "Library.h" -#include "Math.h" +#include +#include #include diff --git a/CesiumUtility/include/CesiumUtility/CreditSystem.h b/CesiumUtility/include/CesiumUtility/CreditSystem.h index 138a33c0d..9f0e13df7 100644 --- a/CesiumUtility/include/CesiumUtility/CreditSystem.h +++ b/CesiumUtility/include/CesiumUtility/CreditSystem.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include #include #include @@ -26,7 +26,7 @@ struct CESIUMUTILITY_API Credit { private: size_t id; - Credit(size_t id_) noexcept { id = id_; } + Credit(size_t id_) noexcept : id(id_) {} friend class CreditSystem; }; diff --git a/CesiumUtility/include/CesiumUtility/DoublyLinkedList.h b/CesiumUtility/include/CesiumUtility/DoublyLinkedList.h index c0e8c50ff..290ebdbef 100644 --- a/CesiumUtility/include/CesiumUtility/DoublyLinkedList.h +++ b/CesiumUtility/include/CesiumUtility/DoublyLinkedList.h @@ -31,7 +31,7 @@ template class DoublyLinkedListPointers final { * @brief Assignment operator. */ DoublyLinkedListPointers& - operator=(const DoublyLinkedListPointers& /*rhs*/) noexcept { + operator=(const DoublyLinkedListPointers& /*rhs*/) noexcept { // NOLINT return *this; } diff --git a/CesiumUtility/include/CesiumUtility/ErrorList.h b/CesiumUtility/include/CesiumUtility/ErrorList.h index 12a21e738..774358028 100644 --- a/CesiumUtility/include/CesiumUtility/ErrorList.h +++ b/CesiumUtility/include/CesiumUtility/ErrorList.h @@ -1,7 +1,8 @@ #pragma once -#include "Library.h" -#include "joinToString.h" +#include +#include // NOLINT +#include #include diff --git a/CesiumUtility/include/CesiumUtility/ExtensibleObject.h b/CesiumUtility/include/CesiumUtility/ExtensibleObject.h index c307181f5..55bb7f35e 100644 --- a/CesiumUtility/include/CesiumUtility/ExtensibleObject.h +++ b/CesiumUtility/include/CesiumUtility/ExtensibleObject.h @@ -1,7 +1,7 @@ #pragma once -#include "JsonValue.h" -#include "Library.h" +#include +#include #include #include diff --git a/CesiumUtility/include/CesiumUtility/IDepotOwningAsset.h b/CesiumUtility/include/CesiumUtility/IDepotOwningAsset.h index b5a43c82e..44cd59ef3 100644 --- a/CesiumUtility/include/CesiumUtility/IDepotOwningAsset.h +++ b/CesiumUtility/include/CesiumUtility/IDepotOwningAsset.h @@ -14,7 +14,7 @@ namespace CesiumUtility { */ template class IDepotOwningAsset { public: - virtual ~IDepotOwningAsset() {} + virtual ~IDepotOwningAsset() = default; /** * @brief Marks the given asset as a candidate for deletion. diff --git a/CesiumUtility/include/CesiumUtility/IntrusivePointer.h b/CesiumUtility/include/CesiumUtility/IntrusivePointer.h index fc5114cb8..5255e66c2 100644 --- a/CesiumUtility/include/CesiumUtility/IntrusivePointer.h +++ b/CesiumUtility/include/CesiumUtility/IntrusivePointer.h @@ -92,8 +92,9 @@ template class IntrusivePointer final { /** * @brief Assignment operator. */ + // NOLINTNEXTLINE(bugprone-unhandled-self-assignment) IntrusivePointer& operator=(const IntrusivePointer& rhs) noexcept { - if (this->_p != rhs._p) { + if (*this != rhs) { // addReference the new pointer before releaseReference'ing the old. T* pOld = this->_p; this->_p = rhs._p; @@ -113,7 +114,7 @@ template class IntrusivePointer final { */ template IntrusivePointer& operator=(const IntrusivePointer& rhs) noexcept { - if (this->_p != rhs._p) { + if (*this != rhs) { // addReference the new pointer before releaseReference'ing the old. T* pOld = this->_p; this->_p = rhs._p; @@ -197,6 +198,14 @@ template class IntrusivePointer final { return !(*this == rhs); } + /** + * @brief Returns `true` if two pointers are *not* equal. + */ + template + bool operator!=(const IntrusivePointer& rhs) const noexcept { + return !(*this == rhs); + } + /** * @brief Returns `true` if the contents of this pointer is equal to the given * pointer. diff --git a/CesiumUtility/include/CesiumUtility/JsonValue.h b/CesiumUtility/include/CesiumUtility/JsonValue.h index 3adca37a8..ae03c35fd 100644 --- a/CesiumUtility/include/CesiumUtility/JsonValue.h +++ b/CesiumUtility/include/CesiumUtility/JsonValue.h @@ -1,6 +1,6 @@ #pragma once -#include "Library.h" +#include #include #include diff --git a/CesiumUtility/include/CesiumUtility/Math.h b/CesiumUtility/include/CesiumUtility/Math.h index ded8212d9..372247cf8 100644 --- a/CesiumUtility/include/CesiumUtility/Math.h +++ b/CesiumUtility/include/CesiumUtility/Math.h @@ -1,9 +1,11 @@ #pragma once -#include "Library.h" +#include #include +#include + namespace CesiumUtility { /** @@ -75,20 +77,25 @@ class CESIUMUTILITY_API Math final { static constexpr double Epsilon21 = 1e-21; /** - * @brief pi + * @brief Pi */ - static constexpr double OnePi = 3.14159265358979323846; + static constexpr double OnePi = std::numbers::pi; /** - * @brief two times pi + * @brief Two times pi */ static constexpr double TwoPi = OnePi * 2.0; /** - * @brief pi divded by two + * @brief Pi divided by two */ static constexpr double PiOverTwo = OnePi / 2.0; + /** + * @brief Pi divided by four + */ + static constexpr double PiOverFour = OnePi / 4.0; + /** * @brief Converts a relative to an absolute epsilon, for the epsilon-equality * check between two values. diff --git a/CesiumUtility/include/CesiumUtility/ReferenceCounted.h b/CesiumUtility/include/CesiumUtility/ReferenceCounted.h index b25bb4260..08f4ade0b 100644 --- a/CesiumUtility/include/CesiumUtility/ReferenceCounted.h +++ b/CesiumUtility/include/CesiumUtility/ReferenceCounted.h @@ -53,7 +53,6 @@ class ReferenceCounted #endif { public: - ReferenceCounted() noexcept {} ~ReferenceCounted() noexcept { CESIUM_ASSERT(this->_referenceCount == 0); } /** @@ -99,6 +98,9 @@ class ReferenceCounted } private: + ReferenceCounted() noexcept = default; + friend T; + using ThreadSafeCounter = std::atomic; using NonThreadSafeCounter = std::int32_t; using CounterType = diff --git a/CesiumUtility/include/CesiumUtility/joinToString.h b/CesiumUtility/include/CesiumUtility/joinToString.h index d92a53fef..b1bee76ec 100644 --- a/CesiumUtility/include/CesiumUtility/joinToString.h +++ b/CesiumUtility/include/CesiumUtility/joinToString.h @@ -41,7 +41,8 @@ joinToString(TIterator begin, TIterator end, const std::string& separator) { * @return The joined string. */ template -std::string joinToString(TCollection collection, const std::string& separator) { +std::string +joinToString(const TCollection& collection, const std::string& separator) { return joinToString(collection.cbegin(), collection.cend(), separator); } } // namespace CesiumUtility diff --git a/CesiumUtility/src/Assert.cpp b/CesiumUtility/src/Assert.cpp index 07effd58b..29c208ad1 100644 --- a/CesiumUtility/src/Assert.cpp +++ b/CesiumUtility/src/Assert.cpp @@ -1,4 +1,3 @@ -#include "CesiumUtility/Assert.h" #if defined CESIUM_FORCE_ASSERTIONS && defined NDEBUG diff --git a/CesiumUtility/src/CreditSystem.cpp b/CesiumUtility/src/CreditSystem.cpp index b33fe85dc..7fb928510 100644 --- a/CesiumUtility/src/CreditSystem.cpp +++ b/CesiumUtility/src/CreditSystem.cpp @@ -1,6 +1,11 @@ #include #include +#include +#include +#include +#include +#include namespace CesiumUtility { diff --git a/CesiumUtility/src/ErrorList.cpp b/CesiumUtility/src/ErrorList.cpp index b1f3a1257..7646dd510 100644 --- a/CesiumUtility/src/ErrorList.cpp +++ b/CesiumUtility/src/ErrorList.cpp @@ -1,5 +1,8 @@ #include +#include +#include + namespace CesiumUtility { /*static*/ ErrorList ErrorList::error(std::string errorMessage) { diff --git a/CesiumUtility/src/ExtensibleObject.cpp b/CesiumUtility/src/ExtensibleObject.cpp index a7b29f0b3..3a304b281 100644 --- a/CesiumUtility/src/ExtensibleObject.cpp +++ b/CesiumUtility/src/ExtensibleObject.cpp @@ -1,4 +1,9 @@ -#include "CesiumUtility/ExtensibleObject.h" +#include +#include + +#include +#include +#include namespace CesiumUtility { JsonValue* ExtensibleObject::getGenericExtension( diff --git a/CesiumUtility/src/Gzip.cpp b/CesiumUtility/src/Gzip.cpp index 6845ea00d..ee953a7ad 100644 --- a/CesiumUtility/src/Gzip.cpp +++ b/CesiumUtility/src/Gzip.cpp @@ -1,10 +1,13 @@ -#include "CesiumUtility/Gzip.h" - -#include "CesiumUtility/Assert.h" +#include +#include +#include #include +#include #include +#include +#include namespace CesiumUtility { diff --git a/CesiumUtility/src/Hash.cpp b/CesiumUtility/src/Hash.cpp index 927614105..11e8df1de 100644 --- a/CesiumUtility/src/Hash.cpp +++ b/CesiumUtility/src/Hash.cpp @@ -1,5 +1,7 @@ #include +#include + namespace CesiumUtility { // This function is adapted from Boost v1.86.0, `hash_mix_impl<64>` function. diff --git a/CesiumUtility/src/JsonHelpers.cpp b/CesiumUtility/src/JsonHelpers.cpp index f59fe9521..f61b0d89d 100644 --- a/CesiumUtility/src/JsonHelpers.cpp +++ b/CesiumUtility/src/JsonHelpers.cpp @@ -1,7 +1,13 @@ -#include "CesiumUtility/JsonHelpers.h" +#include -#include +#include #include +#include + +#include +#include +#include +#include namespace CesiumUtility { diff --git a/CesiumUtility/src/JsonValue.cpp b/CesiumUtility/src/JsonValue.cpp index 2323e632c..d4e3745ad 100644 --- a/CesiumUtility/src/JsonValue.cpp +++ b/CesiumUtility/src/JsonValue.cpp @@ -1,6 +1,9 @@ -#include "CesiumUtility/JsonValue.h" +#include #include +#include +#include +#include namespace CesiumUtility { diff --git a/CesiumUtility/src/StringHelpers.cpp b/CesiumUtility/src/StringHelpers.cpp index 8362e082a..dc3a79579 100644 --- a/CesiumUtility/src/StringHelpers.cpp +++ b/CesiumUtility/src/StringHelpers.cpp @@ -1,5 +1,7 @@ #include +#include + namespace CesiumUtility { /*static*/ std::string StringHelpers::toStringUtf8(const std::u8string& s) { diff --git a/CesiumUtility/src/Tracing.cpp b/CesiumUtility/src/Tracing.cpp index e749bb220..44ed53fba 100644 --- a/CesiumUtility/src/Tracing.cpp +++ b/CesiumUtility/src/Tracing.cpp @@ -1,11 +1,7 @@ #ifndef CESIUM_OVERRIDE_TRACING -#include "CesiumUtility/Tracing.h" - -#include - -#include +#include #if CESIUM_TRACING_ENABLED diff --git a/CesiumUtility/src/Uri.cpp b/CesiumUtility/src/Uri.cpp index 5e1622d0a..f311ab759 100644 --- a/CesiumUtility/src/Uri.cpp +++ b/CesiumUtility/src/Uri.cpp @@ -1,19 +1,22 @@ -#include "CesiumUtility/Uri.h" - +#include #include #include +#include #include #include #include -#include +#include #include +#include #include namespace CesiumUtility { -const char* HTTPS_PREFIX = "https:"; -const char* HTTP_PREFIX = "http:"; + +namespace { +const char* const HTTPS_PREFIX = "https:"; +const char* const HTTP_PREFIX = "http:"; std::string cesiumConformUrl(const std::string& url, bool useHttps) { // Prepend protocol to protocol-relative URIs. @@ -22,6 +25,7 @@ std::string cesiumConformUrl(const std::string& url, bool useHttps) { } return url; } +} // namespace std::string Uri::resolve( const std::string& base, @@ -340,9 +344,9 @@ std::string Uri::getPath(const std::string& uri) { UriPathSegmentA* pCurrent = parsedUri.pathHead; while (pCurrent != nullptr) { - parts.emplace_back(std::string( + parts.emplace_back( pCurrent->text.first, - size_t(pCurrent->text.afterLast - pCurrent->text.first))); + size_t(pCurrent->text.afterLast - pCurrent->text.first)); pCurrent = pCurrent->next; } diff --git a/CesiumUtility/test/TestAttributeCompression.cpp b/CesiumUtility/test/TestAttributeCompression.cpp index 1203fa29c..88728b88e 100644 --- a/CesiumUtility/test/TestAttributeCompression.cpp +++ b/CesiumUtility/test/TestAttributeCompression.cpp @@ -1,8 +1,14 @@ -#include "CesiumUtility/AttributeCompression.h" -#include "CesiumUtility/Math.h" +#include +#include -#include #include +#include +#include +#include + +#include +#include +#include using namespace CesiumUtility; diff --git a/CesiumUtility/test/TestDoublyLinkedList.cpp b/CesiumUtility/test/TestDoublyLinkedList.cpp index 8e399e518..5fd0ef899 100644 --- a/CesiumUtility/test/TestDoublyLinkedList.cpp +++ b/CesiumUtility/test/TestDoublyLinkedList.cpp @@ -1,8 +1,11 @@ -#include "CesiumUtility/DoublyLinkedList.h" +#include -#include #include +#include +#include +#include + using namespace CesiumUtility; namespace { diff --git a/CesiumUtility/test/TestGetQueryValue.cpp b/CesiumUtility/test/TestGetQueryValue.cpp index d9e1c8239..cc05ff97a 100644 --- a/CesiumUtility/test/TestGetQueryValue.cpp +++ b/CesiumUtility/test/TestGetQueryValue.cpp @@ -1,8 +1,9 @@ -#include "CesiumUtility/Uri.h" +#include -#include #include +#include + using namespace CesiumUtility; TEST_CASE("Uri::getQueryValue") { diff --git a/CesiumUtility/test/TestGzip.cpp b/CesiumUtility/test/TestGzip.cpp index 05cfa16d8..802803c5d 100644 --- a/CesiumUtility/test/TestGzip.cpp +++ b/CesiumUtility/test/TestGzip.cpp @@ -1,10 +1,11 @@ #include #include -#include #include +#include #include +#include using namespace CesiumUtility; diff --git a/CesiumUtility/test/TestIntrusivePointer.cpp b/CesiumUtility/test/TestIntrusivePointer.cpp index 251d098b2..32c4d82f9 100644 --- a/CesiumUtility/test/TestIntrusivePointer.cpp +++ b/CesiumUtility/test/TestIntrusivePointer.cpp @@ -1,8 +1,9 @@ -#include "CesiumUtility/IntrusivePointer.h" +#include -#include #include +#include + using namespace CesiumUtility; namespace { diff --git a/CesiumUtility/test/TestJoinToString.cpp b/CesiumUtility/test/TestJoinToString.cpp index 98637f310..4430a8dae 100644 --- a/CesiumUtility/test/TestJoinToString.cpp +++ b/CesiumUtility/test/TestJoinToString.cpp @@ -1,8 +1,10 @@ #include -#include #include +#include +#include + using namespace CesiumUtility; TEST_CASE("joinToString") { diff --git a/CesiumUtility/test/TestMath.cpp b/CesiumUtility/test/TestMath.cpp index 4834d35ec..532d2cd4b 100644 --- a/CesiumUtility/test/TestMath.cpp +++ b/CesiumUtility/test/TestMath.cpp @@ -1,9 +1,10 @@ -#include "CesiumNativeTests/RandomVector.h" -#include "CesiumUtility/Math.h" +#include +#include -#include #include -#include +#include +#include +#include using namespace CesiumUtility; diff --git a/CesiumUtility/test/TestScopeGuard.cpp b/CesiumUtility/test/TestScopeGuard.cpp index 2bb31d6c3..db137f87e 100644 --- a/CesiumUtility/test/TestScopeGuard.cpp +++ b/CesiumUtility/test/TestScopeGuard.cpp @@ -1,8 +1,9 @@ #include -#include #include +#include + namespace { struct ExitFunctor { void operator()() { ++(*check); } diff --git a/CesiumUtility/test/TestSpanHelper.cpp b/CesiumUtility/test/TestSpanHelper.cpp index fc534dc7a..d6095cd20 100644 --- a/CesiumUtility/test/TestSpanHelper.cpp +++ b/CesiumUtility/test/TestSpanHelper.cpp @@ -1,8 +1,10 @@ -#include "CesiumUtility/SpanHelper.h" +#include -#include #include +#include +#include +#include #include TEST_CASE("reintepretCastSpan") { diff --git a/CesiumUtility/test/TestUri.cpp b/CesiumUtility/test/TestUri.cpp index fc1f3fa3b..8d853c0a0 100644 --- a/CesiumUtility/test/TestUri.cpp +++ b/CesiumUtility/test/TestUri.cpp @@ -1,6 +1,5 @@ #include -#include #include using namespace CesiumUtility; diff --git a/cmake/macros/setup_clang_tidy.cmake b/cmake/macros/setup_clang_tidy.cmake index 3e8164670..a065a4bf3 100644 --- a/cmake/macros/setup_clang_tidy.cmake +++ b/cmake/macros/setup_clang_tidy.cmake @@ -81,14 +81,17 @@ function(setup_clang_tidy) "Clang" RESULT_TOOL_PATH CLANG_TIDY_RUNNER_PATH) + list(APPEND CLANG_TIDY_RUNNER_PARAMS -extra-arg=-Wno-unknown-warning-option) + list(APPEND CLANG_TIDY_RUNNER_PARAMS -j${CESIUM_CLANG_TIDY_USE_THREADS}) + list(APPEND CLANG_TIDY_RUNNER_PARAMS -clang-tidy-binary ${CLANG_TIDY_PATH}) + list(APPEND CLANG_TIDY_RUNNER_PARAMS -p ${_PROJECT_BUILD_DIRECTORY}) # path that contains a compile_commands.json + list(APPEND CLANG_TIDY_RUNNER_PARAMS "\".*(src\/|include\/).*\"") if(CLANG_TIDY_RUNNER_PATH) add_custom_target( - clang-tidy COMMAND ${CLANG_TIDY_RUNNER_PATH} -clang-tidy-binary ${CLANG_TIDY_PATH} -p - ${_PROJECT_BUILD_DIRECTORY} # path that contains a compile_commands.json + clang-tidy COMMAND ${CLANG_TIDY_RUNNER_PATH} ${CLANG_TIDY_RUNNER_PARAMS} ) add_custom_target( - clang-tidy-fix COMMAND ${CLANG_TIDY_RUNNER_PATH} -fix -clang-tidy-binary ${CLANG_TIDY_PATH} -p - ${_PROJECT_BUILD_DIRECTORY} # path that contains a compile_commands.json + clang-tidy-fix COMMAND ${CLANG_TIDY_RUNNER_PATH} -fix ${CLANG_TIDY_RUNNER_PARAMS} ) else() # run-clang-tidy was not found, so call clang-tidy directly. diff --git a/package.json b/package.json index 2eccab43e..2c44738ed 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "check-format": "check-clang-format", "generate-gltf": "cd tools/generate-classes && npm run generate-gltf && cd ../.. && npm run format", "generate-3d-tiles": "cd tools/generate-classes && npm run generate-3d-tiles && cd ../.. && npm run format", - "generate-quantized-mesh-terrain": "cd tools/generate-classes && npm run generate-quantized-mesh-terrain && cd ../.. && npm run format" + "generate-quantized-mesh-terrain": "cd tools/generate-classes && npm run generate-quantized-mesh-terrain && cd ../.. && npm run format", + "conform-includes": "node tools/conform-includes.js" }, "repository": { "type": "git", diff --git a/tools/conform-includes.js b/tools/conform-includes.js new file mode 100644 index 000000000..1aa858be9 --- /dev/null +++ b/tools/conform-includes.js @@ -0,0 +1,100 @@ +/** + * Attempts to conform all `#include` directives to match the style guide. + * Including header files from the same directory as the current file will + * be formatted as #include "file.h" + * Including header files from other directories will be formatted as + * #include + * + * This script should be run in the root directory of the project, + * like `node tools/conform-includes.js`. + */ + +const fs = require("fs"); +const path = require("path"); + +const dirs = fs.readdirSync(".").filter(d => d.startsWith("Cesium")); +console.log(dirs); + +const libs = {}; +dirs.forEach(d => { + const lib = { + name: d, + files: [], + headerFiles: [], + privateHeaders: [] + }; + + const srcDir = path.join(d, "src"); + if (fs.existsSync(srcDir)) { + const srcFiles = fs.readdirSync(srcDir).filter(t => t.endsWith(".cpp") || t.endsWith(".h")); + lib.files = lib.files.concat(srcFiles.map(f => path.join(srcDir, f))); + lib.privateHeaders = lib.privateHeaders.concat(srcFiles.filter(f => f.endsWith(".h"))); + } + + const includeDir = path.join(d, "include", d); + if (fs.existsSync(includeDir)) { + const includeFiles = fs.readdirSync(includeDir).filter(t => t.endsWith(".cpp") || t.endsWith(".h")); + lib.files = lib.files.concat(includeFiles.map(f => path.join(includeDir, f))); + lib.headerFiles = lib.headerFiles.concat(includeFiles); + } + + const generatedIncludeDir = path.join(d, "generated", "include", d); + if (fs.existsSync(generatedIncludeDir)) { + const generatedIncludeFiles = fs.readdirSync(generatedIncludeDir).filter(t => t.endsWith(".h")); + // We don't want to actually process generated files, but we do want to know they're there. + lib.headerFiles = lib.headerFiles.concat(generatedIncludeFiles); + } + + const testDir = path.join(d, "test"); + if (fs.existsSync(testDir)) { + const testFiles = fs.readdirSync(testDir).filter(t => t.endsWith(".cpp") || t.endsWith(".h")); + lib.files = lib.files.concat(testFiles.map(f => path.join(testDir, f))); + } + + libs[d] = lib; +}); + +const includeRegex = /#include\s*(\<(.+?)\>|\"(.+?)\")/g; +function conformFile(file, libName) { + const fileContents = fs.readFileSync(file, "utf-8"); + const newContents = fileContents.replace(includeRegex, (str, _, a, b) => { + const filePath = a || b; + const pathParts = path.parse(filePath); + const pathLib = pathParts.dir; + const pathFile = pathParts.base; + // No directory part of the path name, or it's the current lib anyways + if (!pathLib.trim() || pathLib == libName) { + // Points to a known header file of this lib + if (libs[libName].headerFiles.indexOf(pathFile) != -1) { + return `#include <${libName}/${pathFile}>`; + } + + // Private include in the source directory + if (libs[libName].privateHeaders.indexOf(pathFile) != -1) { + return `#include "${pathFile}"`; + } + + if (pathLib == libName) { + console.error(`${filePath} is supposed to be in lib ${libName} but wasn't found?`); + return str; + } + + // It's an include we don't know how to deal with, just ignore it + return str; + } + + if (libs[pathLib] && libs[pathLib].headerFiles.indexOf(pathFile) != -1) { + return `#include <${pathLib}/${pathFile}>`; + } + + return str; + }); + fs.writeFileSync(file, newContents); +} + +Object.keys(libs).forEach(libName => { + libs[libName].files.forEach(f => { + console.log(`conforming ${f}`); + conformFile(f, libName); + }); +}); \ No newline at end of file