Skip to content

Commit

Permalink
Fix cast issues
Browse files Browse the repository at this point in the history
  • Loading branch information
azrogers committed Dec 18, 2024
1 parent 7ef48d5 commit 6aa10bb
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 18 deletions.
6 changes: 2 additions & 4 deletions Cesium3DTilesSelection/src/EllipsoidTilesetLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,9 @@ EllipsoidTilesetLoader::createGeometry(const Tile& tile) const {
static constexpr uint16_t resolution = 24;

std::vector<uint16_t> indices;
indices.reserve(
static_cast<size_type>(6 * (resolution - 1) * (resolution - 1)));
indices.reserve(static_cast<size_t>(6 * (resolution - 1) * (resolution - 1)));

std::vector<glm::vec3> vertices(
static_cast<size_type>(resolution * resolution));
std::vector<glm::vec3> vertices(static_cast<size_t>(resolution * resolution));
std::vector<glm::vec3> normals(vertices.size());

const Ellipsoid& ellipsoid = _projection.getEllipsoid();
Expand Down
4 changes: 2 additions & 2 deletions Cesium3DTilesSelection/test/TestTilesetContentManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ CesiumGltf::Model createGlobeGrid(
glm::dvec3 max = min;

std::vector<glm::dvec3> positions;
indices.reserve(static_cast<size_type>(6 * (width - 1) * (height - 1)));
positions.reserve(static_cast<size_type>(width * height));
indices.reserve(static_cast<size_t>(6 * (width - 1) * (height - 1)));
positions.reserve(static_cast<size_t>(width * height));
for (uint32_t y = 0; y < height; ++y) {
for (uint32_t x = 0; x < width; ++x) {
double longitude = beginPoint.longitude + x * dimension;
Expand Down
1 change: 0 additions & 1 deletion CesiumAsync/src/InternalTimegm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "InternalTimegm.h"

#include <cstddef>
#include <cstdint>
#include <ctime>

Expand Down
2 changes: 1 addition & 1 deletion CesiumGeometry/src/QuadtreeRectangleAvailability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ QuadtreeRectangleAvailability::QuadtreeRectangleAvailability(
uint32_t maximumLevel) noexcept
: _tilingScheme(tilingScheme),
_maximumLevel(maximumLevel),
_rootNodes(static_cast<size_type>(
_rootNodes(static_cast<size_t>(
this->_tilingScheme.getRootTilesX() *
this->_tilingScheme.getRootTilesY())) {
for (uint32_t j = 0; j < this->_tilingScheme.getRootTilesY(); ++j) {
Expand Down
1 change: 0 additions & 1 deletion CesiumGltf/src/Accessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include <CesiumGltf/BufferView.h>

#include <cstddef>
#include <cstdint>
#include <string>

Expand Down
3 changes: 2 additions & 1 deletion CesiumGltfReader/test/TestGltfReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,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() == static_cast<size_type>(2048 * 2048 * 4);
CHECK(
image.pAsset->pixelData.size() == static_cast<size_t>(2048 * 2048 * 4));

CHECK(!result.model->buffers.empty());
for (const CesiumGltf::Buffer& buffer : result.model->buffers) {
Expand Down
4 changes: 2 additions & 2 deletions CesiumQuantizedMeshTerrain/src/QuantizedMeshLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ static std::optional<QuantizedMeshView> parseQuantizedMesh(

meshView.octEncodedNormalBuffer = std::span<const std::byte>(
data.data() + readIndex,
static_cast<size_type>(vertexCount * 2));
static_cast<size_t>(vertexCount * 2));
} else if (enableWaterMask && extensionID == 2) {
// Water Mask
if (extensionLength == 1) {
Expand Down Expand Up @@ -735,7 +735,7 @@ static std::vector<std::byte> generateNormals(
sizeof(float));
std::span<float> outputPositions(
reinterpret_cast<float*>(outputPositionsBuffer.data()),
static_cast<size_type>((vertexCount + skirtVertexCount) * 3));
static_cast<size_t>((vertexCount + skirtVertexCount) * 3));
size_t positionOutputIndex = 0;

const glm::dvec3 center(
Expand Down
11 changes: 6 additions & 5 deletions CesiumQuantizedMeshTerrain/test/TestQuantizedMeshContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ void checkGridMesh(
int32_t v = 0;

std::vector<glm::dvec2> uvs;
uvs.reserve(static_cast<size_type>(verticesWidth * verticesHeight));
uvs.reserve(static_cast<size_t>(verticesWidth * verticesHeight));
uint32_t positionIdx = 0;
uint32_t idx = 0;
for (uint32_t y = 0; y < verticesHeight; ++y) {
Expand Down Expand Up @@ -596,7 +596,7 @@ static void checkGeneratedGridNormal(
uint32_t verticesHeight) {
uint32_t totalGridIndices = (verticesWidth - 1) * (verticesHeight - 1) * 6;
std::vector<glm::vec3> expectedNormals(
static_cast<size_type>(verticesWidth * verticesHeight));
static_cast<size_t>(verticesWidth * verticesHeight));
for (uint32_t i = 0; i < totalGridIndices; i += 3) {
I id0 = indices[i];
I id1 = indices[i + 1];
Expand Down Expand Up @@ -1031,7 +1031,7 @@ TEST_CASE("Test converting quantized mesh to gltf with skirt") {
uint8_t x = 0, y = 0;
octEncode(normal, x, y);
std::vector<std::byte> octNormals(
static_cast<size_type>(verticesWidth * verticesHeight * 2));
static_cast<size_t>(verticesWidth * verticesHeight * 2));
for (size_t i = 0; i < octNormals.size(); i += 2) {
octNormals[i] = std::byte(x);
octNormals[i + 1] = std::byte(y);
Expand Down Expand Up @@ -1073,7 +1073,8 @@ TEST_CASE("Test converting quantized mesh to gltf with skirt") {

REQUIRE(
static_cast<size_t>(normals.size()) ==
(static_cast<size_t>(verticesWidth * verticesHeight + totalSkirtVerticesCount));
(static_cast<size_t>(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));
Expand Down Expand Up @@ -1119,7 +1120,7 @@ TEST_CASE("Test converting ill-formed quantized mesh") {
uint8_t x = 0, y = 0;
octEncode(normal, x, y);
std::vector<std::byte> octNormals(
static_cast<size_type>(verticesWidth * verticesHeight * 2));
static_cast<size_t>(verticesWidth * verticesHeight * 2));
for (size_t i = 0; i < octNormals.size(); i += 2) {
octNormals[i] = std::byte(x);
octNormals[i + 1] = std::byte(y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class TestTileProvider : public QuadtreeRasterOverlayTileProvider {
result.pImage->bytesPerChannel = 1;
result.pImage->channels = 4;
result.pImage->pixelData.resize(
static_cast<size_type>(this->getWidth() * this->getHeight() * 4),
static_cast<size_t>(this->getWidth() * this->getHeight() * 4),
std::byte(tileID.level));
}

Expand Down

0 comments on commit 6aa10bb

Please sign in to comment.