From 3d4bc98f6be51ebb8ac43af395e54bb6b608c9ae Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Tue, 11 Jun 2024 17:38:48 +0300 Subject: Trim remaining trailing whitespaces after #1695 --- indra/newview/gltf/accessor.h | 4 ++-- indra/newview/gltf/animation.h | 4 ++-- indra/newview/gltf/asset.cpp | 12 ++++++------ indra/newview/gltf/buffer_util.h | 2 +- indra/newview/gltf/primitive.cpp | 18 +++++++++--------- indra/newview/gltf/primitive.h | 6 +++--- 6 files changed, 23 insertions(+), 23 deletions(-) (limited to 'indra/newview/gltf') diff --git a/indra/newview/gltf/accessor.h b/indra/newview/gltf/accessor.h index 9b8265d8da..6e8871ef61 100644 --- a/indra/newview/gltf/accessor.h +++ b/indra/newview/gltf/accessor.h @@ -61,9 +61,9 @@ namespace LL std::string mName; const BufferView& operator=(const tinygltf::BufferView& src); - + }; - + class Accessor { public: diff --git a/indra/newview/gltf/animation.h b/indra/newview/gltf/animation.h index 869eae963a..66ccd14c5c 100644 --- a/indra/newview/gltf/animation.h +++ b/indra/newview/gltf/animation.h @@ -159,7 +159,7 @@ namespace LL // min/max time values for all samplers combined F32 mMinTime = 0.f; F32 mMaxTime = 0.f; - + // current time of the animation F32 mTime = 0.f; @@ -168,7 +168,7 @@ namespace LL std::vector mScaleChannels; const Animation& operator=(const tinygltf::Animation& src); - + void allocateGLResources(Asset& asset); void update(Asset& asset, float dt); diff --git a/indra/newview/gltf/asset.cpp b/indra/newview/gltf/asset.cpp index fbc3648fd2..973a460b73 100644 --- a/indra/newview/gltf/asset.cpp +++ b/indra/newview/gltf/asset.cpp @@ -71,7 +71,7 @@ void Node::updateTransforms(Asset& asset, const LLMatrix4a& parentMatrix) makeMatrixValid(); matMul(mMatrix, parentMatrix, mAssetMatrix); mAssetMatrixInv = inverse(mAssetMatrix); - + S32 my_index = this - &asset.mNodes[0]; for (auto& childIndex : mChildren) @@ -133,7 +133,7 @@ S32 Asset::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, { if (node.mMesh != INVALID_INDEX) { - + bool newHit = false; // transform start and end to this node's local space @@ -162,7 +162,7 @@ S32 Asset::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, if (newHit) { // shorten line segment on hit - node.mAssetMatrix.affineTransform(p, asset_end); + node.mAssetMatrix.affineTransform(p, asset_end); // transform results back to asset space if (intersection) @@ -229,7 +229,7 @@ void Node::makeMatrixValid() sc.set_scale(mScale); glh::matrix4f t; - //t = sc * rot * trans; + //t = sc * rot * trans; //t = trans * rot * sc; // best so far, still wrong on negative scale //t = sc * trans * rot; t = trans * sc * rot; @@ -538,7 +538,7 @@ const Asset& Asset::operator=(const tinygltf::Model& src) { mSkins[i] = src.skins[i]; } - + return *this; } @@ -616,7 +616,7 @@ void Skin::uploadMatrixPalette(Asset& asset, Node& node) for (U32 i = 0; i < mJoints.size(); ++i) { Node& joint = asset.mNodes[mJoints[i]]; - + //t_mp[i].set_value(joint.mRenderMatrix.getF32ptr()); //t_mp[i] = t_mp[i] * mInverseBindMatricesData[i]; diff --git a/indra/newview/gltf/buffer_util.h b/indra/newview/gltf/buffer_util.h index 4e6f5901e7..a448f7a484 100644 --- a/indra/newview/gltf/buffer_util.h +++ b/indra/newview/gltf/buffer_util.h @@ -31,7 +31,7 @@ // whenever we add support for more types #ifdef _MSC_VER -#define LL_FUNCSIG __FUNCSIG__ +#define LL_FUNCSIG __FUNCSIG__ #else #define LL_FUNCSIG __PRETTY_FUNCTION__ #endif diff --git a/indra/newview/gltf/primitive.cpp b/indra/newview/gltf/primitive.cpp index d536f6a4cd..f1f0cf48f6 100644 --- a/indra/newview/gltf/primitive.cpp +++ b/indra/newview/gltf/primitive.cpp @@ -9,7 +9,7 @@ * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; - * version 2.1 of the License only. + * version 2.1 of the License only. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -86,7 +86,7 @@ void Primitive::allocateGLResources(Asset& asset) } U32 mask = ATTRIBUTE_MASK; - + if (!mWeights.empty()) { mask |= LLVertexBuffer::MAP_WEIGHT4; @@ -124,7 +124,7 @@ void Primitive::allocateGLResources(Asset& asset) { mColors.resize(mPositions.size(), LLColor4U::white); } - + // bake material basecolor into color array if (mMaterial != INVALID_INDEX) { @@ -142,7 +142,7 @@ void Primitive::allocateGLResources(Asset& asset) { mNormals.resize(mPositions.size(), LLVector4a(0, 0, 1, 0)); } - + mVertexBuffer->setNormalData(mNormals.data()); if (mTangents.empty()) @@ -169,9 +169,9 @@ void Primitive::allocateGLResources(Asset& asset) mVertexBuffer->setWeight4Data(weight_data.data()); } - + createOctree(); - + mVertexBuffer->unbind(); } @@ -235,9 +235,9 @@ void Primitive::createOctree() const LLVector4a& v0 = mPositions[i0]; const LLVector4a& v1 = mPositions[i1]; const LLVector4a& v2 = mPositions[i2]; - + initOctreeTriangle(tri, scaler, i0, i1, i2, v0, v1, v2); - + //insert mOctree->insert(tri); } @@ -297,7 +297,7 @@ void Primitive::createOctree() { // nothing to do, no volume... maybe add some collision geometry around these primitive types? } - + else { LL_ERRS() << "Unsupported Primitive mode" << LL_ENDL; diff --git a/indra/newview/gltf/primitive.h b/indra/newview/gltf/primitive.h index 07e8e7deb2..09ab3d9ead 100644 --- a/indra/newview/gltf/primitive.h +++ b/indra/newview/gltf/primitive.h @@ -64,7 +64,7 @@ namespace LL // raycast acceleration structure LLPointer mOctree; std::vector mOctreeTriangles; - + S32 mMaterial = -1; U32 mMode = TINYGLTF_MODE_TRIANGLES; // default to triangles U32 mGLMode = LLRender::TRIANGLES; @@ -75,7 +75,7 @@ namespace LL // must be called before buffer is unmapped and after buffer is populated with good data void createOctree(); - //get the LLVolumeTriangle that intersects with the given line segment at the point + //get the LLVolumeTriangle that intersects with the given line segment at the point //closest to start. Moves end to the point of intersection. Returns nullptr if no intersection. //Line segment must be in the same coordinate frame as this Primitive const LLVolumeTriangle* lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, @@ -84,7 +84,7 @@ namespace LL LLVector4a* normal = NULL, // return the surface normal at the intersection point LLVector4a* tangent = NULL // return the surface tangent at the intersection point ); - + const Primitive& operator=(const tinygltf::Primitive& src); void allocateGLResources(Asset& asset); -- cgit v1.2.3 From a7b0f9391146b42dd5cd5f47f845de81bfdb6820 Mon Sep 17 00:00:00 2001 From: Brad Linden Date: Tue, 11 Jun 2024 15:39:48 -0700 Subject: Fixed signed/unsigned warnings after they got enabled in the maint-A merge --- indra/newview/gltf/accessor.cpp | 5 +++-- indra/newview/gltf/animation.cpp | 11 +++++------ indra/newview/gltf/primitive.cpp | 19 +++++++++++-------- 3 files changed, 19 insertions(+), 16 deletions(-) (limited to 'indra/newview/gltf') 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(max_joints, mJoints.size()); std::vector 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); -- cgit v1.2.3 From 8729c0d2c41d7acb2357a5ba9f3a713fe9bcc426 Mon Sep 17 00:00:00 2001 From: Brad Linden Date: Wed, 12 Jun 2024 11:41:20 -0700 Subject: Fixup more signed/unsigned warnings after merge. --- indra/newview/gltf/primitive.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'indra/newview/gltf') diff --git a/indra/newview/gltf/primitive.cpp b/indra/newview/gltf/primitive.cpp index dd37b5b4d0..2280c7004e 100644 --- a/indra/newview/gltf/primitive.cpp +++ b/indra/newview/gltf/primitive.cpp @@ -56,9 +56,9 @@ struct MikktMesh bool copy(const Primitive* prim) { bool indexed = !prim->mIndexArray.empty(); - auto vert_count = indexed ? prim->mIndexArray.size() : prim->mPositions.size(); + size_t vert_count = indexed ? prim->mIndexArray.size() : prim->mPositions.size(); - U32 triangle_count = 0; + size_t triangle_count = 0; if (prim->mMode == Primitive::Mode::TRIANGLE_STRIP || prim->mMode == Primitive::Mode::TRIANGLE_FAN) @@ -76,6 +76,7 @@ struct MikktMesh } vert_count = triangle_count * 3; + llassert(vert_count <= size_t(U32_MAX)); // triangle_count will also naturally be under the limit p.resize(vert_count); n.resize(vert_count); @@ -106,7 +107,7 @@ struct MikktMesh tc1.resize(vert_count); } - for (int tri_idx = 0; tri_idx < triangle_count; ++tri_idx) + for (U32 tri_idx = 0; tri_idx < U32(triangle_count); ++tri_idx) { U32 idx[3]; @@ -222,7 +223,7 @@ struct MikktMesh std::vector remap; remap.resize(p.size()); - U32 stream_count = mos.size(); + size_t stream_count = mos.size(); size_t vert_count = meshopt_generateVertexRemapMulti(&remap[0], nullptr, p.size(), p.size(), mos.data(), stream_count); -- cgit v1.2.3 From 8444cd9562a6a7b755fcb075864e205122354192 Mon Sep 17 00:00:00 2001 From: Brad Linden Date: Wed, 12 Jun 2024 13:51:21 -0700 Subject: Fix whitespace pre-commit hook failures --- indra/newview/gltf/buffer_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/gltf') diff --git a/indra/newview/gltf/buffer_util.h b/indra/newview/gltf/buffer_util.h index c1101818b7..40f9448aaf 100644 --- a/indra/newview/gltf/buffer_util.h +++ b/indra/newview/gltf/buffer_util.h @@ -845,7 +845,7 @@ namespace LL arr.resize(2); arr[0] = src.x; arr[1] = src.y; - + return true; } -- cgit v1.2.3