Second time, first pass

This commit is contained in:
Ashley Rogers 2025-02-24 15:45:32 -05:00
parent 150a06c8c8
commit dca602777f
9 changed files with 40 additions and 25 deletions

View File

@ -40,10 +40,11 @@ target_sources(
${CESIUM_GLTF_PUBLIC_HEADERS}
)
target_include_directories(
CesiumGltf
SYSTEM PUBLIC
${CMAKE_CURRENT_LIST_DIR}/include/
cesium_target_include_directories(
TARGET
CesiumGltf
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/include
${CMAKE_CURRENT_LIST_DIR}/generated/include
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src

View File

@ -94,6 +94,7 @@ public:
this->_storage.data(),
reinterpret_cast<const std::byte*>(values.data()),
sizeInBytes);
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
this->_view = PropertyArrayView<ElementType>(this->_storage);
}
@ -200,7 +201,9 @@ public:
index += _bitOffset;
const int64_t byteIndex = index / 8;
const int64_t bitIndex = index % 8;
const int bitValue = static_cast<int>(_values[byteIndex] >> bitIndex) & 1;
const int bitValue =
static_cast<int>(_values[static_cast<size_t>(byteIndex)] >> bitIndex) &
1;
return bitValue == 1;
}
@ -255,10 +258,12 @@ public:
* @brief Obtains an `std::string_view` for the element at the given index.
*/
std::string_view operator[](int64_t index) const noexcept {
const size_t currentOffset =
getOffsetFromOffsetsBuffer(index, _stringOffsets, _stringOffsetType);
const size_t currentOffset = getOffsetFromOffsetsBuffer(
static_cast<size_t>(index),
_stringOffsets,
_stringOffsetType);
const size_t nextOffset = getOffsetFromOffsetsBuffer(
index + 1,
static_cast<size_t>(index + 1),
_stringOffsets,
_stringOffsetType);
return std::string_view(

View File

@ -534,12 +534,15 @@ private:
size_t count = static_cast<size_t>(this->arrayCount());
// Handle fixed-length arrays
if (count > 0) {
const size_t offsetBits = count * index;
const size_t nextOffsetBits = count * (index + 1);
const size_t offsetBits = count * static_cast<size_t>(index);
const size_t nextOffsetBits = count * static_cast<size_t>(index + 1);
const std::span<const std::byte> buffer(
_values.data() + offsetBits / 8,
(nextOffsetBits / 8 - offsetBits / 8 + 1));
return PropertyArrayView<bool>(buffer, offsetBits % 8, count);
return PropertyArrayView<bool>(
buffer,
offsetBits % 8,
static_cast<int64_t>(count));
}
// Handle variable-length arrays

View File

@ -137,9 +137,9 @@ ElementType assembleVecNValue(const std::span<uint8_t> bytes) noexcept {
CESIUM_ASSERT(
N == 2 && "Only vec2s can contain two-byte integer components.");
uint16_t x = static_cast<uint16_t>(bytes[0]) |
(static_cast<uint16_t>(bytes[1]) << 8);
static_cast<uint16_t>(static_cast<uint16_t>(bytes[1]) << 8);
uint16_t y = static_cast<uint16_t>(bytes[2]) |
(static_cast<uint16_t>(bytes[3]) << 8);
static_cast<uint16_t>(static_cast<uint16_t>(bytes[3]) << 8);
result[0] = *reinterpret_cast<int16_t*>(&x);
result[1] = *reinterpret_cast<int16_t*>(&y);

View File

@ -802,7 +802,7 @@ private:
}
const CesiumUtility::IntrusivePointer<ImageAsset>& pImage =
_pModel->images[imageIndex].pAsset;
_pModel->images[static_cast<size_t>(imageIndex)].pAsset;
const std::vector<int64_t>& channels = propertyTextureProperty.channels;
status = checkChannels(channels, *pImage);
@ -810,7 +810,8 @@ private:
return PropertyTexturePropertyView<T, Normalized>(status);
}
if (channels.size() * pImage->bytesPerChannel != elementSize) {
if (channels.size() * static_cast<size_t>(pImage->bytesPerChannel) !=
elementSize) {
return PropertyTexturePropertyViewStatus::ErrorChannelsAndTypeMismatch;
}

View File

@ -4,7 +4,6 @@
#include <cstdint>
#include <string>
#include <string_view>
namespace CesiumGltf {
/**

View File

@ -9,6 +9,7 @@
#include <CesiumGltf/PropertyTypeTraits.h>
#include <algorithm>
#include <cstddef>
#include <cstring>
#include <optional>
@ -326,7 +327,7 @@ getMatN(const CesiumUtility::JsonValue& jsonValue) {
const CesiumUtility::JsonValue::Array& array = jsonValue.getArray();
constexpr glm::length_t N = MatType::length();
if (array.size() != N * N) {
if (array.size() != static_cast<size_t>(N * N)) {
return std::nullopt;
}
@ -2970,7 +2971,7 @@ private:
std::vector<std::string> strings;
std::vector<uint64_t> stringOffsets;
const auto array = jsonValue.getArray();
const auto& array = jsonValue.getArray();
strings.reserve(array.size());
stringOffsets.reserve(array.size() + 1);
stringOffsets.push_back(static_cast<uint64_t>(0));

View File

@ -78,7 +78,7 @@ public:
*/
IDepotOwningAsset<T>* getDepot() { return this->_pDepot; }
protected:
private:
SharedAsset() = default;
~SharedAsset() { CESIUM_ASSERT(this->_referenceCount == 0); }
@ -93,7 +93,7 @@ protected:
* After a move construction, the content of the asset is moved to the new
* instance, but the asset depot still references the old instance.
*/
SharedAsset(SharedAsset&& rhs)
SharedAsset(SharedAsset&& rhs) noexcept
: ExtensibleObject(std::move(rhs)),
_referenceCount(0),
_pDepot(nullptr) {}
@ -102,8 +102,10 @@ protected:
* Assignment does not affect the asset's relationship with the depot, but is
* useful to assign the data in derived classes.
*/
SharedAsset& operator=(const SharedAsset& rhs) {
CesiumUtility::ExtensibleObject::operator=(rhs);
SharedAsset& operator=(const SharedAsset& rhs) noexcept {
if (&rhs != this) {
CesiumUtility::ExtensibleObject::operator=(rhs);
}
return *this;
}
@ -111,8 +113,10 @@ protected:
* Assignment does not affect the asset's relationship with the depot, but is
* useful to assign the data in derived classes.
*/
SharedAsset& operator=(SharedAsset&& rhs) {
CesiumUtility::ExtensibleObject::operator=(std::move(rhs));
SharedAsset& operator=(SharedAsset&& rhs) noexcept {
if (&rhs != this) {
CesiumUtility::ExtensibleObject::operator=(std::move(rhs));
}
return *this;
}
@ -149,6 +153,7 @@ private:
// To allow the depot to modify _pDepot.
template <typename TAssetType, typename TAssetKey>
friend class CesiumAsync::SharedAssetDepot;
friend T;
};
} // namespace CesiumUtility

View File

@ -2,7 +2,7 @@ function(configure_cesium_library targetName)
if (MSVC)
target_compile_options(${targetName} PRIVATE /W4 /WX /wd4201 /bigobj /w45038 /w44254 /w44242 /w44191 /w45220)
else()
target_compile_options(${targetName} PRIVATE -Werror -Wall -Wextra -Wconversion -Wpedantic -Wshadow -Wsign-conversion)
target_compile_options(${targetName} PRIVATE -Werror -Wall -Wextra -Wconversion -Wpedantic -Wshadow -Wsign-conversion -Wno-unknown-pragmas)
endif()
set_target_properties(${targetName} PROPERTIES