From 4a63f1759c7f9e520920ea3bcc130f8cdd17a5d6 Mon Sep 17 00:00:00 2001 From: Jared Mulconry Date: Sun, 20 Nov 2016 12:49:33 +1100 Subject: [PATCH] Fixed build warnings on MSVC14 x64 in the Ogre format sources. --- code/OgreBinarySerializer.cpp | 2 +- code/OgreMaterial.cpp | 6 ++-- code/OgreStructs.cpp | 54 +++++++++++++++++------------------ code/OgreXmlSerializer.cpp | 2 +- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/code/OgreBinarySerializer.cpp b/code/OgreBinarySerializer.cpp index ce17cea6a..7b45cf50f 100644 --- a/code/OgreBinarySerializer.cpp +++ b/code/OgreBinarySerializer.cpp @@ -483,7 +483,7 @@ void OgreBinarySerializer::ReadSubMesh(Mesh *mesh) NormalizeBoneWeights(submesh->vertexData); - submesh->index = mesh->subMeshes.size(); + submesh->index = static_cast(mesh->subMeshes.size()); mesh->subMeshes.push_back(submesh); } diff --git a/code/OgreMaterial.cpp b/code/OgreMaterial.cpp index a221ab274..bdcd0285a 100644 --- a/code/OgreMaterial.cpp +++ b/code/OgreMaterial.cpp @@ -77,7 +77,7 @@ void OgreImporter::ReadMaterials(const std::string &pFile, Assimp::IOSystem *pIO aiMaterial *material = ReadMaterial(pFile, pIOHandler, submesh->materialRef); if (material) { - submesh->materialIndex = materials.size(); + submesh->materialIndex = static_cast(materials.size()); materials.push_back(material); } } @@ -99,7 +99,7 @@ void OgreImporter::ReadMaterials(const std::string &pFile, Assimp::IOSystem *pIO aiMaterial *material = ReadMaterial(pFile, pIOHandler, submesh->materialRef); if (material) { - submesh->materialIndex = materials.size(); + submesh->materialIndex = static_cast(materials.size()); materials.push_back(material); } } @@ -110,7 +110,7 @@ void OgreImporter::ReadMaterials(const std::string &pFile, Assimp::IOSystem *pIO void OgreImporter::AssignMaterials(aiScene *pScene, std::vector &materials) { - pScene->mNumMaterials = materials.size(); + pScene->mNumMaterials = static_cast(materials.size()); if (pScene->mNumMaterials > 0) { pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials]; diff --git a/code/OgreStructs.cpp b/code/OgreStructs.cpp index e2e8c8103..d9cd547d6 100644 --- a/code/OgreStructs.cpp +++ b/code/OgreStructs.cpp @@ -274,12 +274,12 @@ AssimpVertexBoneWeightList IVertexData::AssimpBoneWeights(size_t vertices) AssimpVertexBoneWeightList weights; for(size_t vi=0; vi(vi)]; for (VertexBoneAssignmentList::const_iterator iter=vertexWeights.begin(), end=vertexWeights.end(); iter!=end; ++iter) { std::vector &boneWeights = weights[iter->boneIndex]; - boneWeights.push_back(aiVertexWeight(vi, iter->weight)); + boneWeights.push_back(aiVertexWeight(static_cast(vi), iter->weight)); } } return weights; @@ -319,7 +319,7 @@ uint32_t VertexData::VertexSize(uint16_t source) const for(const auto &element : vertexElements) { if (element.source == source) - size += element.Size(); + size += static_cast(element.Size()); } return size; } @@ -460,7 +460,7 @@ void Mesh::ConvertToAssimpScene(aiScene* dest) } // Setup - dest->mNumMeshes = NumSubMeshes(); + dest->mNumMeshes = static_cast(NumSubMeshes()); dest->mMeshes = new aiMesh*[dest->mNumMeshes]; // Create root node @@ -471,7 +471,7 @@ void Mesh::ConvertToAssimpScene(aiScene* dest) // Export meshes for(size_t i=0; imNumMeshes; ++i) { dest->mMeshes[i] = subMeshes[i]->ConvertToAssimpMesh(this); - dest->mRootNode->mMeshes[i] = i; + dest->mRootNode->mMeshes[i] = static_cast(i); } // Export skeleton @@ -481,7 +481,7 @@ void Mesh::ConvertToAssimpScene(aiScene* dest) if (!skeleton->bones.empty()) { BoneList rootBones = skeleton->RootBones(); - dest->mRootNode->mNumChildren = rootBones.size(); + dest->mRootNode->mNumChildren = static_cast(rootBones.size()); dest->mRootNode->mChildren = new aiNode*[dest->mRootNode->mNumChildren]; for(size_t i=0, len=rootBones.size(); ianimations.empty()) { - dest->mNumAnimations = skeleton->animations.size(); + dest->mNumAnimations = static_cast(skeleton->animations.size()); dest->mAnimations = new aiAnimation*[dest->mNumAnimations]; for(size_t i=0, len=skeleton->animations.size(); imNumFaces * 3; - dest->mNumVertices = uniqueVertexCount; + dest->mNumVertices = static_cast(uniqueVertexCount); dest->mVertices = new aiVector3D[dest->mNumVertices]; // Source streams @@ -604,7 +604,7 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) { if (uv1Element->type == VertexElement::VET_FLOAT2 || uv1Element->type == VertexElement::VET_FLOAT3) { - dest->mNumUVComponents[0] = uv1Element->ComponentCount(); + dest->mNumUVComponents[0] = static_cast(uv1Element->ComponentCount()); dest->mTextureCoords[0] = new aiVector3D[dest->mNumVertices]; } else @@ -617,7 +617,7 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) { if (uv2Element->type == VertexElement::VET_FLOAT2 || uv2Element->type == VertexElement::VET_FLOAT3) { - dest->mNumUVComponents[1] = uv2Element->ComponentCount(); + dest->mNumUVComponents[1] = static_cast(uv2Element->ComponentCount()); dest->mTextureCoords[1] = new aiVector3D[dest->mNumVertices]; } else @@ -665,11 +665,11 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) const size_t newIndex = pos + v; // Write face index - face.mIndices[v] = newIndex; + face.mIndices[v] = static_cast(newIndex); // Ogres vertex index to ref into the source buffers. const size_t ogreVertexIndex = ogreFace.mIndices[v]; - src->AddVertexMapping(ogreVertexIndex, newIndex); + src->AddVertexMapping(static_cast(ogreVertexIndex), static_cast(newIndex)); // Position positions->Seek((vWidthPosition * ogreVertexIndex) + positionsElement->offset, aiOrigin_SET); @@ -704,7 +704,7 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) AssimpVertexBoneWeightList weights = src->AssimpBoneWeights(dest->mNumVertices); std::set referencedBones = src->ReferencedBonesByWeights(); - dest->mNumBones = referencedBones.size(); + dest->mNumBones = static_cast(referencedBones.size()); dest->mBones = new aiBone*[dest->mNumBones]; size_t assimpBoneIndex = 0; @@ -758,7 +758,7 @@ SubMeshXml *MeshXml::GetSubMesh(uint16_t index) const void MeshXml::ConvertToAssimpScene(aiScene* dest) { // Setup - dest->mNumMeshes = NumSubMeshes(); + dest->mNumMeshes = static_cast(NumSubMeshes()); dest->mMeshes = new aiMesh*[dest->mNumMeshes]; // Create root node @@ -770,7 +770,7 @@ void MeshXml::ConvertToAssimpScene(aiScene* dest) for(size_t i=0; imNumMeshes; ++i) { dest->mMeshes[i] = subMeshes[i]->ConvertToAssimpMesh(this); - dest->mRootNode->mMeshes[i] = i; + dest->mRootNode->mMeshes[i] = static_cast(i); } // Export skeleton @@ -780,7 +780,7 @@ void MeshXml::ConvertToAssimpScene(aiScene* dest) if (!skeleton->bones.empty()) { BoneList rootBones = skeleton->RootBones(); - dest->mRootNode->mNumChildren = rootBones.size(); + dest->mRootNode->mNumChildren = static_cast(rootBones.size()); dest->mRootNode->mChildren = new aiNode*[dest->mRootNode->mNumChildren]; for(size_t i=0, len=rootBones.size(); ianimations.empty()) { - dest->mNumAnimations = skeleton->animations.size(); + dest->mNumAnimations = static_cast(skeleton->animations.size()); dest->mAnimations = new aiAnimation*[dest->mNumAnimations]; for(size_t i=0, len=skeleton->animations.size(); imNumFaces * 3; - dest->mNumVertices = uniqueVertexCount; + dest->mNumVertices = static_cast(uniqueVertexCount); dest->mVertices = new aiVector3D[dest->mNumVertices]; VertexDataXml *src = (!usesSharedVertexData ? vertexData : parent->sharedVertexData); @@ -875,11 +875,11 @@ aiMesh *SubMeshXml::ConvertToAssimpMesh(MeshXml *parent) const size_t newIndex = pos + v; // Write face index - face.mIndices[v] = newIndex; + face.mIndices[v] = static_cast(newIndex); // Ogres vertex index to ref into the source buffers. const size_t ogreVertexIndex = ogreFace.mIndices[v]; - src->AddVertexMapping(ogreVertexIndex, newIndex); + src->AddVertexMapping(static_cast(ogreVertexIndex), static_cast(newIndex)); // Position dest->mVertices[newIndex] = src->positions[ogreVertexIndex]; @@ -904,7 +904,7 @@ aiMesh *SubMeshXml::ConvertToAssimpMesh(MeshXml *parent) AssimpVertexBoneWeightList weights = src->AssimpBoneWeights(dest->mNumVertices); std::set referencedBones = src->ReferencedBonesByWeights(); - dest->mNumBones = referencedBones.size(); + dest->mNumBones = static_cast(referencedBones.size()); dest->mBones = new aiBone*[dest->mNumBones]; size_t assimpBoneIndex = 0; @@ -958,7 +958,7 @@ aiAnimation *Animation::ConvertToAssimpAnimation() // Tracks if (!tracks.empty()) { - anim->mNumChannels = tracks.size(); + anim->mNumChannels = static_cast(tracks.size()); anim->mChannels = new aiNodeAnim*[anim->mNumChannels]; for(size_t i=0, len=tracks.size(); imNumChildren = children.size(); + node->mNumChildren = static_cast(children.size()); node->mChildren = new aiNode*[node->mNumChildren]; for(size_t i=0, len=children.size(); imNumWeights = boneWeights.size(); + bone->mNumWeights = static_cast(boneWeights.size()); bone->mWeights = new aiVertexWeight[boneWeights.size()]; memcpy(bone->mWeights, &boneWeights[0], boneWeights.size() * sizeof(aiVertexWeight)); } @@ -1158,9 +1158,9 @@ aiNodeAnim *VertexAnimationTrack::ConvertToAssimpAnimationNode(Skeleton *skeleto nodeAnim->mPositionKeys = new aiVectorKey[numKeyframes]; nodeAnim->mRotationKeys = new aiQuatKey[numKeyframes]; nodeAnim->mScalingKeys = new aiVectorKey[numKeyframes]; - nodeAnim->mNumPositionKeys = numKeyframes; - nodeAnim->mNumRotationKeys = numKeyframes; - nodeAnim->mNumScalingKeys = numKeyframes; + nodeAnim->mNumPositionKeys = static_cast(numKeyframes); + nodeAnim->mNumRotationKeys = static_cast(numKeyframes); + nodeAnim->mNumScalingKeys = static_cast(numKeyframes); for(size_t kfi=0; kfiindex = mesh->subMeshes.size(); + submesh->index = static_cast(mesh->subMeshes.size()); mesh->subMeshes.push_back(submesh); }