summaryrefslogtreecommitdiff
path: root/indra/llprimitive
diff options
context:
space:
mode:
authorAnsariel <ansariel.hiller@phoenixviewer.com>2024-06-01 15:49:26 +0200
committerAnsariel <ansariel.hiller@phoenixviewer.com>2024-06-01 15:49:26 +0200
commitb42f9d836b4c0f7fbd4bdae1734021e2a09fdbe8 (patch)
treed73404c2fbacce379a57e2d03a6cd54558590859 /indra/llprimitive
parentcb3bd8865aa0f9fb8a247ea595cf1973057ba91f (diff)
Re-enable a lot of compiler warnings for MSVC and address the C4267 "possible loss of precision" warnings
Diffstat (limited to 'indra/llprimitive')
-rw-r--r--indra/llprimitive/lldaeloader.cpp40
-rw-r--r--indra/llprimitive/llgltfloader.cpp2
-rw-r--r--indra/llprimitive/llgltfmaterial.cpp2
-rw-r--r--indra/llprimitive/llgltfmaterial_templates.h4
-rw-r--r--indra/llprimitive/llmediaentry.cpp4
-rw-r--r--indra/llprimitive/llmodel.cpp38
-rw-r--r--indra/llprimitive/llmodel.h4
-rw-r--r--indra/llprimitive/llprimtexturelist.cpp24
-rw-r--r--indra/llprimitive/tests/llprimitive_test.cpp2
9 files changed, 60 insertions, 60 deletions
diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp
index de5a2fe1fa..9bc6c7092f 100644
--- a/indra/llprimitive/lldaeloader.cpp
+++ b/indra/llprimitive/lldaeloader.cpp
@@ -258,7 +258,7 @@ LLModel::EModelStatus load_face_from_dom_triangles(
// Don't share verts within the same tri, degenerate
//
- U32 indx_size = indices.size();
+ U32 indx_size = static_cast<U32>(indices.size());
U32 verts_new_tri = indx_size % 3;
if ((verts_new_tri < 1 || indices[indx_size - 1] != shared_index)
&& (verts_new_tri < 2 || indices[indx_size - 2] != shared_index))
@@ -732,7 +732,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac
{ //for each vertex
if (j > 2)
{
- U32 size = verts.size();
+ auto size = verts.size();
LLVolumeFace::VertexData v0 = verts[size-3];
LLVolumeFace::VertexData v1 = verts[size-1];
@@ -1098,7 +1098,7 @@ bool LLDAELoader::OpenFile(const std::string& filename)
while (model_iter != mModelList.end())
{
LLModel* mdl = *model_iter;
- U32 material_count = mdl->mMaterialList.size();
+ U32 material_count = static_cast<U32>(mdl->mMaterialList.size());
LL_INFOS() << "Importing " << mdl->mLabel << " model with " << material_count << " material references" << LL_ENDL;
std::vector<std::string>::iterator mat_iter = mdl->mMaterialList.begin();
std::vector<std::string>::iterator end_iter = material_count > LIMIT_MATERIALS_OUTPUT
@@ -1287,11 +1287,11 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do
{
//Get the children at this level
daeTArray< daeSmartRef<daeElement> > children = pScene->getChildren();
- S32 childCount = children.getCount();
+ auto childCount = children.getCount();
//Process any children that are joints
//Not all children are joints, some could be ambient lights, cameras, geometry etc..
- for (S32 i = 0; i < childCount; ++i)
+ for (size_t i = 0; i < childCount; ++i)
{
domNode* pNode = daeSafeCast<domNode>(children[i]);
if (pNode)
@@ -1312,7 +1312,7 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do
if ( pSkeletonRootNode )
{
//Once we have the root node - start acccessing it's joint components
- const int jointCnt = mJointMap.size();
+ const int jointCnt = static_cast<int>(mJointMap.size());
JointMap :: const_iterator jointIt = mJointMap.begin();
//Loop over all the possible joints within the .dae - using the allowed joint list in the ctor.
@@ -1453,9 +1453,9 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do
if (t)
{
domListOfFloats& transform = t->getValue();
- S32 count = transform.getCount()/16;
+ auto count = transform.getCount()/16;
- for (S32 k = 0; k < count; ++k)
+ for (size_t k = 0; k < count; ++k)
{
LLMatrix4 mat;
@@ -1531,7 +1531,7 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do
//with the skeleton are not stored in the same order as they are in the exported joint buffer.
//This remaps the skeletal joints to be in the same order as the joints stored in the model.
std::vector<std::string> :: const_iterator jointIt = model->mSkinInfo.mJointNames.begin();
- const int jointCnt = model->mSkinInfo.mJointNames.size();
+ const int jointCnt = static_cast<int>(model->mSkinInfo.mJointNames.size());
for ( int i=0; i<jointCnt; ++i, ++jointIt )
{
std::string lookingForJoint = (*jointIt).c_str();
@@ -1550,7 +1550,7 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do
}
}
- U32 bind_count = model->mSkinInfo.mAlternateBindMatrix.size();
+ auto bind_count = model->mSkinInfo.mAlternateBindMatrix.size();
if (bind_count > 0 && bind_count != jointCnt)
{
LL_WARNS("Mesh") << "Model " << model->mLabel << " has invalid joint bind matrix list." << LL_ENDL;
@@ -1699,8 +1699,8 @@ void LLDAELoader::buildJointToNodeMappingFromScene( daeElement* pRoot )
if ( pScene )
{
daeTArray< daeSmartRef<daeElement> > children = pScene->getChildren();
- S32 childCount = children.getCount();
- for (S32 i = 0; i < childCount; ++i)
+ auto childCount = children.getCount();
+ for (size_t i = 0; i < childCount; ++i)
{
domNode* pNode = daeSafeCast<domNode>(children[i]);
processJointToNodeMapping( pNode );
@@ -1745,8 +1745,8 @@ void LLDAELoader::processJointToNodeMapping( domNode* pNode )
void LLDAELoader::processChildJoints( domNode* pParentNode )
{
daeTArray< daeSmartRef<daeElement> > childOfChild = pParentNode->getChildren();
- S32 childOfChildCount = childOfChild.getCount();
- for (S32 i = 0; i < childOfChildCount; ++i)
+ auto childOfChildCount = childOfChild.getCount();
+ for (size_t i = 0; i < childOfChildCount; ++i)
{
domNode* pChildNode = daeSafeCast<domNode>( childOfChild[i] );
if ( pChildNode )
@@ -1847,7 +1847,7 @@ bool LLDAELoader::verifyController( domController* pController )
{
sum += pVertexWeights->getVcount()->getValue()[i];
}
- result = verifyCount( sum * inputs.getCount(), (domInt) pVertexWeights->getV()->getValue().getCount() );
+ result = verifyCount( sum * static_cast<U32>(inputs.getCount()), (domInt) static_cast<int>(pVertexWeights->getV()->getValue().getCount()) );
}
}
@@ -1980,9 +1980,9 @@ void LLDAELoader::processJointNode( domNode* pNode, JointTransformMap& jointTran
//Gather and handle the incoming nodes children
daeTArray< daeSmartRef<daeElement> > childOfChild = pNode->getChildren();
- S32 childOfChildCount = childOfChild.getCount();
+ auto childOfChildCount = childOfChild.getCount();
- for (S32 i = 0; i < childOfChildCount; ++i)
+ for (size_t i = 0; i < childOfChildCount; ++i)
{
domNode* pChildNode = daeSafeCast<domNode>( childOfChild[i] );
if ( pChildNode )
@@ -2192,8 +2192,8 @@ void LLDAELoader::processElement( daeElement* element, bool& badElement, DAE* da
//process children
daeTArray< daeSmartRef<daeElement> > children = element->getChildren();
- int childCount = children.getCount();
- for (S32 i = 0; i < childCount; i++)
+ auto childCount = children.getCount();
+ for (size_t i = 0; i < childCount; i++)
{
processElement(children[i],badElement, dae);
}
@@ -2568,7 +2568,7 @@ bool LLDAELoader::loadModelsFromDomMesh(domMesh* mesh, std::vector<LLModel*>& mo
ret->remapVolumeFaces();
}
- volume_faces = remainder.size();
+ volume_faces = static_cast<U32>(remainder.size());
models_out.push_back(ret);
diff --git a/indra/llprimitive/llgltfloader.cpp b/indra/llprimitive/llgltfloader.cpp
index 810b648f17..776f81cc01 100644
--- a/indra/llprimitive/llgltfloader.cpp
+++ b/indra/llprimitive/llgltfloader.cpp
@@ -231,7 +231,7 @@ bool LLGLTFLoader::parseMaterials()
image.numChannels = in_image.component;
image.bytesPerChannel = in_image.bits >> 3; // Convert bits to bytes
image.pixelType = in_image.pixel_type; // Maps exactly, i.e. TINYGLTF_COMPONENT_TYPE_UNSIGNED_BYTE == GL_UNSIGNED_BYTE, etc
- image.size = in_image.image.size();
+ image.size = static_cast<U32>(in_image.image.size());
image.height = in_image.height;
image.width = in_image.width;
image.data = in_image.image.data();
diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp
index 12af568b7e..dd4ab82abc 100644
--- a/indra/llprimitive/llgltfmaterial.cpp
+++ b/indra/llprimitive/llgltfmaterial.cpp
@@ -180,7 +180,7 @@ bool LLGLTFMaterial::fromJSON(const std::string& json, std::string& warn_msg, st
tinygltf::Model model_in;
- if (gltf.LoadASCIIFromString(&model_in, &error_msg, &warn_msg, json.c_str(), json.length(), ""))
+ if (gltf.LoadASCIIFromString(&model_in, &error_msg, &warn_msg, json.c_str(), static_cast<unsigned int>(json.length()), ""))
{
setFromModel(model_in, 0);
diff --git a/indra/llprimitive/llgltfmaterial_templates.h b/indra/llprimitive/llgltfmaterial_templates.h
index 276cc71b19..4ec7f312af 100644
--- a/indra/llprimitive/llgltfmaterial_templates.h
+++ b/indra/llprimitive/llgltfmaterial_templates.h
@@ -87,12 +87,12 @@ void LLGLTFMaterial::setFromTexture(const tinygltf::Model& model, const T& textu
template<typename T>
void LLGLTFMaterial::allocateTextureImage(tinygltf::Model& model, T& texture_info, const std::string& uri)
{
- const S32 image_idx = model.images.size();
+ const S32 image_idx = static_cast<S32>(model.images.size());
model.images.emplace_back();
model.images[image_idx].uri = uri;
// The texture, not to be confused with the texture info
- const S32 texture_idx = model.textures.size();
+ const S32 texture_idx = static_cast<S32>(model.textures.size());
model.textures.emplace_back();
tinygltf::Texture& texture = model.textures[texture_idx];
texture.source = image_idx;
diff --git a/indra/llprimitive/llmediaentry.cpp b/indra/llprimitive/llmediaentry.cpp
index e626a989f6..b5b17c53aa 100644
--- a/indra/llprimitive/llmediaentry.cpp
+++ b/indra/llprimitive/llmediaentry.cpp
@@ -353,7 +353,7 @@ U32 LLMediaEntry::setWhiteList( const std::vector<std::string> &whitelist )
{
// *NOTE: This code is VERY similar to the setWhitelist below.
// IF YOU CHANGE THIS IMPLEMENTATION, BE SURE TO CHANGE THE OTHER!
- U32 size = 0;
+ size_t size = 0;
U32 count = 0;
// First count to make sure the size constraint is not violated
std::vector<std::string>::const_iterator iter = whitelist.begin();
@@ -394,7 +394,7 @@ U32 LLMediaEntry::setWhiteList( const LLSD &whitelist )
{
// *NOTE: This code is VERY similar to the setWhitelist above.
// IF YOU CHANGE THIS IMPLEMENTATION, BE SURE TO CHANGE THE OTHER!
- U32 size = 0;
+ size_t size = 0;
U32 count = 0;
// First check to make sure the size and count constraints are not violated
LLSD::array_const_iterator iter = whitelist.beginArray();
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp
index 37917c0c04..6a322bb9ec 100644
--- a/indra/llprimitive/llmodel.cpp
+++ b/indra/llprimitive/llmodel.cpp
@@ -918,7 +918,7 @@ LLSD LLModel::writeModel(
//copy ostr to binary buffer
std::string data = ostr.str();
const U8* buff = (U8*)data.data();
- U32 bytes = data.size();
+ U32 bytes = static_cast<U32>(data.size());
LLSD::Binary w(bytes);
for (U32 j = 0; j < bytes; ++j)
@@ -965,7 +965,7 @@ LLSD LLModel::writeModelToStream(std::ostream& ostr, LLSD& mdl, bool nowrite, bo
{ //write out skin block
skin = zip_llsd(mdl["skin"]);
- U32 size = skin.size();
+ U32 size = static_cast<U32>(skin.size());
if (size > 0)
{
header["skin"]["offset"] = (LLSD::Integer) cur_offset;
@@ -980,7 +980,7 @@ LLSD LLModel::writeModelToStream(std::ostream& ostr, LLSD& mdl, bool nowrite, bo
{ //write out convex decomposition
decomposition = zip_llsd(mdl["physics_convex"]);
- U32 size = decomposition.size();
+ U32 size = static_cast<U32>(decomposition.size());
if (size > 0)
{
header["physics_convex"]["offset"] = (LLSD::Integer) cur_offset;
@@ -1002,7 +1002,7 @@ LLSD LLModel::writeModelToStream(std::ostream& ostr, LLSD& mdl, bool nowrite, bo
{
out[i] = zip_llsd(mdl[model_names[i]]);
- U32 size = out[i].size();
+ U32 size = static_cast<U32>(out[i].size());
header[model_names[i]]["offset"] = (LLSD::Integer) cur_offset;
header[model_names[i]]["size"] = (LLSD::Integer) size;
@@ -1159,7 +1159,7 @@ void LLModel::updateHullCenters()
mCenterOfHullCenters += cur_center;
cur_center *= 1.f/mPhysics.mHull[i].size();
mHullCenter[i] = cur_center;
- mHullPoints += mPhysics.mHull[i].size();
+ mHullPoints += static_cast<U32>(mPhysics.mHull[i].size());
}
if (mHullPoints > 0)
@@ -1280,14 +1280,14 @@ bool LLModel::loadModel(std::istream& is)
bool LLModel::isMaterialListSubset( LLModel* ref )
{
- int refCnt = ref->mMaterialList.size();
- int modelCnt = mMaterialList.size();
+ auto refCnt = ref->mMaterialList.size();
+ auto modelCnt = mMaterialList.size();
- for (U32 src = 0; src < modelCnt; ++src)
+ for (size_t src = 0; src < modelCnt; ++src)
{
bool foundRef = false;
- for (U32 dst = 0; dst < refCnt; ++dst)
+ for (size_t dst = 0; dst < refCnt; ++dst)
{
//LL_INFOS()<<mMaterialList[src]<<" "<<ref->mMaterialList[dst]<<LL_ENDL;
foundRef = mMaterialList[src] == ref->mMaterialList[dst];
@@ -1630,15 +1630,15 @@ U32 LLMeshSkinInfo::sizeBytes() const
{
U32 res = sizeof(LLUUID); // mMeshID
- res += sizeof(std::vector<std::string>) + sizeof(std::string) * mJointNames.size();
+ res += sizeof(std::vector<std::string>) + sizeof(std::string) * static_cast<U32>(mJointNames.size());
for (U32 i = 0; i < mJointNames.size(); ++i)
{
- res += mJointNames[i].size(); // actual size, not capacity
+ res += static_cast<U32>(mJointNames[i].size()); // actual size, not capacity
}
- res += sizeof(std::vector<S32>) + sizeof(S32) * mJointNums.size();
- res += sizeof(std::vector<LLMatrix4>) + 16 * sizeof(float) * mInvBindMatrix.size();
- res += sizeof(std::vector<LLMatrix4>) + 16 * sizeof(float) * mAlternateBindMatrix.size();
+ res += sizeof(std::vector<S32>) + sizeof(S32) * static_cast<U32>(mJointNums.size());
+ res += sizeof(std::vector<LLMatrix4>) + 16 * sizeof(float) * static_cast<U32>(mInvBindMatrix.size());
+ res += sizeof(std::vector<LLMatrix4>) + 16 * sizeof(float) * static_cast<U32>(mAlternateBindMatrix.size());
res += 16 * sizeof(float); //mBindShapeMatrix
res += sizeof(float) + 3 * sizeof(bool);
@@ -1755,15 +1755,15 @@ U32 LLModel::Decomposition::sizeBytes() const
{
U32 res = sizeof(LLUUID); // mMeshID
- res += sizeof(LLModel::convex_hull_decomposition) + sizeof(std::vector<LLVector3>) * mHull.size();
+ res += sizeof(LLModel::convex_hull_decomposition) + sizeof(std::vector<LLVector3>) * static_cast<U32>(mHull.size());
for (U32 i = 0; i < mHull.size(); ++i)
{
- res += mHull[i].size() * sizeof(LLVector3);
+ res += static_cast<U32>(mHull[i].size()) * sizeof(LLVector3);
}
- res += sizeof(LLModel::hull) + sizeof(LLVector3) * mBaseHull.size();
+ res += sizeof(LLModel::hull) + sizeof(LLVector3) * static_cast<U32>(mBaseHull.size());
- res += sizeof(std::vector<LLModel::PhysicsMesh>) + sizeof(std::vector<LLModel::PhysicsMesh>) * mMesh.size();
+ res += sizeof(std::vector<LLModel::PhysicsMesh>) + sizeof(std::vector<LLModel::PhysicsMesh>) * static_cast<U32>(mMesh.size());
for (U32 i = 0; i < mMesh.size(); ++i)
{
res += mMesh[i].sizeBytes();
@@ -1814,7 +1814,7 @@ LLSD LLModel::Decomposition::asLLSD() const
for (U32 i = 0; i < mHull.size(); ++i)
{
- U32 size = mHull[i].size();
+ U32 size = static_cast<U32>(mHull[i].size());
total += size;
hulls[i] = (U8) (size);
diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h
index 20d643d642..b0cba2d655 100644
--- a/indra/llprimitive/llmodel.h
+++ b/indra/llprimitive/llmodel.h
@@ -122,8 +122,8 @@ public:
U32 sizeBytes() const
{
U32 res = sizeof(std::vector<LLVector3>) * 2;
- res += sizeof(LLVector3) * mPositions.size();
- res += sizeof(LLVector3) * mNormals.size();
+ res += sizeof(LLVector3) * static_cast<U32>(mPositions.size());
+ res += sizeof(LLVector3) * static_cast<U32>(mNormals.size());
return res;
}
};
diff --git a/indra/llprimitive/llprimtexturelist.cpp b/indra/llprimitive/llprimtexturelist.cpp
index ce4df843ea..68f3f5ffac 100644
--- a/indra/llprimitive/llprimtexturelist.cpp
+++ b/indra/llprimitive/llprimtexturelist.cpp
@@ -83,13 +83,13 @@ void LLPrimTextureList::clear()
void LLPrimTextureList::copy(const LLPrimTextureList& other_list)
{
// compare the sizes
- S32 this_size = mEntryList.size();
- S32 other_size = other_list.mEntryList.size();
+ auto this_size = mEntryList.size();
+ auto other_size = other_list.mEntryList.size();
if (this_size > other_size)
{
// remove the extra entries
- for (S32 index = this_size; index > other_size; --index)
+ for (size_t index = this_size; index > other_size; --index)
{
delete mEntryList[index-1];
}
@@ -97,18 +97,18 @@ void LLPrimTextureList::copy(const LLPrimTextureList& other_list)
this_size = other_size;
}
- S32 index = 0;
+ size_t index = 0;
// copy for the entries that already exist
for ( ; index < this_size; ++index)
{
delete mEntryList[index];
- mEntryList[index] = other_list.getTexture(index)->newCopy();
+ mEntryList[index] = other_list.getTexture(static_cast<U8>(index))->newCopy();
}
// add new entires if needed
for ( ; index < other_size; ++index)
{
- mEntryList.push_back( other_list.getTexture(index)->newCopy() );
+ mEntryList.push_back( other_list.getTexture(static_cast<U8>(index))->newCopy());
}
}
@@ -127,9 +127,9 @@ void LLPrimTextureList::take(LLPrimTextureList& other_list)
// returns TEM_CHANGE_TEXTURE if successful, otherwise TEM_CHANGE_NONE
S32 LLPrimTextureList::copyTexture(const U8 index, const LLTextureEntry& te)
{
- if (S32(index) >= mEntryList.size())
+ if (size_t(index) >= mEntryList.size())
{
- S32 current_size = mEntryList.size();
+ auto current_size = mEntryList.size();
LL_WARNS() << "ignore copy of index = " << S32(index) << " into texture entry list of size = " << current_size << LL_ENDL;
return TEM_CHANGE_NONE;
}
@@ -389,7 +389,7 @@ LLMaterialPtr LLPrimTextureList::getMaterialParams(const U8 index)
S32 LLPrimTextureList::size() const
{
- return mEntryList.size();
+ return static_cast<S32>(mEntryList.size());
}
// sets the size of the mEntryList container
@@ -400,12 +400,12 @@ void LLPrimTextureList::setSize(S32 new_size)
new_size = 0;
}
- S32 current_size = mEntryList.size();
+ auto current_size = mEntryList.size();
if (new_size > current_size)
{
mEntryList.resize(new_size);
- for (S32 index = current_size; index < new_size; ++index)
+ for (size_t index = current_size; index < new_size; ++index)
{
if (current_size > 0
&& mEntryList[current_size - 1])
@@ -423,7 +423,7 @@ void LLPrimTextureList::setSize(S32 new_size)
}
else if (new_size < current_size)
{
- for (S32 index = current_size-1; index >= new_size; --index)
+ for (size_t index = current_size-1; index >= new_size; --index)
{
delete mEntryList[index];
}
diff --git a/indra/llprimitive/tests/llprimitive_test.cpp b/indra/llprimitive/tests/llprimitive_test.cpp
index 60960067d0..0213a3e8b6 100644
--- a/indra/llprimitive/tests/llprimitive_test.cpp
+++ b/indra/llprimitive/tests/llprimitive_test.cpp
@@ -109,7 +109,7 @@ void LLPrimTextureList::take(LLPrimTextureList &other_list) { }
void LLPrimTextureList::setSize(S32 new_size) { mEntryList.resize(new_size); }
void LLPrimTextureList::setAllIDs(const LLUUID &id) { }
LLTextureEntry * LLPrimTextureList::getTexture(const U8 index) const { return nullptr; }
-S32 LLPrimTextureList::size() const { return mEntryList.size(); }
+S32 LLPrimTextureList::size() const { return static_cast<S32>(mEntryList.size()); }
class PRIMITIVE_TEST_SETUP
{