summaryrefslogtreecommitdiff
path: root/indra/newview/gltf
diff options
context:
space:
mode:
authorBrad Linden <brad@lindenlab.com>2024-06-11 15:39:48 -0700
committerBrad Linden <brad@lindenlab.com>2024-06-11 15:39:48 -0700
commita7b0f9391146b42dd5cd5f47f845de81bfdb6820 (patch)
tree4d0e499b14abe28434de8f9cc97a50fa92e0d6e0 /indra/newview/gltf
parent7c42711ca3a4e67b95473aa5129dce5ff19bea15 (diff)
Fixed signed/unsigned warnings after they got enabled in the maint-A merge
Diffstat (limited to 'indra/newview/gltf')
-rw-r--r--indra/newview/gltf/accessor.cpp5
-rw-r--r--indra/newview/gltf/animation.cpp11
-rw-r--r--indra/newview/gltf/primitive.cpp19
3 files changed, 19 insertions, 16 deletions
diff --git a/indra/newview/gltf/accessor.cpp b/indra/newview/gltf/accessor.cpp
index 9f1cb0c1cd..2ef9237f2d 100644
--- a/indra/newview/gltf/accessor.cpp
+++ b/indra/newview/gltf/accessor.cpp
@@ -108,7 +108,8 @@ void Buffer::erase(Asset& asset, S32 offset, S32 length)
mData.erase(mData.begin() + offset, mData.begin() + offset + length);
- mByteLength = mData.size();
+ llassert(mData.size() <= size_t(INT_MAX));
+ mByteLength = S32(mData.size());
for (BufferView& view : asset.mBufferViews)
{
@@ -141,7 +142,7 @@ bool Buffer::prep(Asset& asset)
}
mData.resize(mByteLength);
- if (!file.read((U8*)mData.data(), mData.size()))
+ if (!file.read((U8*)mData.data(), mByteLength))
{
LL_WARNS("GLTF") << "Failed to load buffer data from asset: " << id << LL_ENDL;
return false;
diff --git a/indra/newview/gltf/animation.cpp b/indra/newview/gltf/animation.cpp
index 45e9e1ddef..8f53c28539 100644
--- a/indra/newview/gltf/animation.cpp
+++ b/indra/newview/gltf/animation.cpp
@@ -189,16 +189,15 @@ void Animation::Sampler::getFrameInfo(Asset& asset, F32 time, U32& frameIndex, F
if (mFrameTimes.size() > 1)
{
+ llassert(mFrameTimes.size() <= size_t(U32_MAX));
+ frameIndex = U32(mFrameTimes.size()) - 2;
+ t = 1.f;
+
if (time > mMaxTime)
{
- frameIndex = mFrameTimes.size() - 2;
- t = 1.0f;
return;
}
- frameIndex = mFrameTimes.size() - 2;
- t = 1.f;
-
for (U32 i = 0; i < mFrameTimes.size() - 1; i++)
{
if (time >= mFrameTimes[i] && time < mFrameTimes[i + 1])
@@ -382,7 +381,7 @@ void Skin::uploadMatrixPalette(Asset& asset)
glGenBuffers(1, &mUBO);
}
- U32 joint_count = llmin(max_joints, mJoints.size());
+ size_t joint_count = llmin<size_t>(max_joints, mJoints.size());
std::vector<mat4> t_mp;
diff --git a/indra/newview/gltf/primitive.cpp b/indra/newview/gltf/primitive.cpp
index bc333aff69..197ffb68e8 100644
--- a/indra/newview/gltf/primitive.cpp
+++ b/indra/newview/gltf/primitive.cpp
@@ -55,7 +55,7 @@ struct MikktMesh
bool copy(const Primitive* prim)
{
bool indexed = !prim->mIndexArray.empty();
- U32 vert_count = indexed ? prim->mIndexArray.size() : prim->mPositions.size();
+ auto vert_count = indexed ? prim->mIndexArray.size() : prim->mPositions.size();
if (prim->mMode != Primitive::Mode::TRIANGLES)
{
@@ -85,7 +85,7 @@ struct MikktMesh
j.resize(vert_count);
}
- for (int i = 0; i < vert_count; ++i)
+ for (U32 i = 0; i < vert_count; ++i)
{
U32 idx = indexed ? prim->mIndexArray[i] : i;
@@ -110,8 +110,8 @@ struct MikktMesh
void genNormals()
{
- U32 tri_count = p.size() / 3;
- for (U32 i = 0; i < tri_count; ++i)
+ size_t tri_count = p.size() / 3;
+ for (size_t i = 0; i < tri_count; ++i)
{
LLVector3 v0 = p[i * 3];
LLVector3 v1 = p[i * 3 + 1];
@@ -166,7 +166,7 @@ struct MikktMesh
prim->mWeights.resize(vert_count);
prim->mJoints.resize(vert_count);
}
-
+
prim->mIndexArray.resize(remap.size());
for (int i = 0; i < remap.size(); ++i)
@@ -411,7 +411,10 @@ bool Primitive::prep(Asset& asset)
}
mVertexBuffer = new LLVertexBuffer(mask);
- mVertexBuffer->allocateBuffer(mPositions.size(), mIndexArray.size() * 2); // double the size of the index buffer for 32-bit indices
+ // we store these buffer sizes as S32 elsewhere
+ llassert(mPositions.size() <= size_t(S32_MAX));
+ llassert(mIndexArray.size() <= size_t(S32_MAX / 2));
+ mVertexBuffer->allocateBuffer(U32(mPositions.size()), U32(mIndexArray.size() * 2)); // double the size of the index buffer for 32-bit indices
mVertexBuffer->setBuffer();
mVertexBuffer->setPositionData(mPositions.data());
@@ -619,8 +622,8 @@ const LLVolumeTriangle* Primitive::lineSegmentIntersect(const LLVector4a& start,
face.mTangents = mTangents.data();
face.mIndices = nullptr; // unreferenced
- face.mNumIndices = mIndexArray.size();
- face.mNumVertices = mPositions.size();
+ face.mNumIndices = S32(mIndexArray.size());
+ face.mNumVertices = S32(mPositions.size());
LLOctreeTriangleRayIntersect intersect(start, dir, &face, &closest_t, intersection, tex_coord, normal, tangent_out);
intersect.traverse(mOctree);