From cbfbf2a256a96008ee2c8dd61e69e98aa8b0559a Mon Sep 17 00:00:00 2001 From: Jared Mulconry Date: Sun, 27 Nov 2016 15:54:22 +1100 Subject: [PATCH] Fixed build warnings on MSVC14 x64 in the X3D format sources. --- code/X3DImporter.cpp | 12 ++++++------ code/X3DImporter_Geometry3D.cpp | 18 ++++++++++++------ code/X3DImporter_Postprocess.cpp | 24 ++++++++++++------------ code/X3DImporter_Rendering.cpp | 26 +++++++++++++------------- 4 files changed, 43 insertions(+), 37 deletions(-) diff --git a/code/X3DImporter.cpp b/code/X3DImporter.cpp index 0e4eae0..7c2425c 100644 --- a/code/X3DImporter.cpp +++ b/code/X3DImporter.cpp @@ -934,7 +934,7 @@ void X3DImporter::GeometryHelper_CoordIdxStr2FacesArr(const std::list& default: prim_type |= aiPrimitiveType_POLYGON; break; } - tface.mNumIndices = ts; + tface.mNumIndices = static_cast(ts); tface.mIndices = new unsigned int[ts]; memcpy(tface.mIndices, inds.data(), ts * sizeof(unsigned int)); pFaces.push_back(tface); @@ -1329,7 +1329,7 @@ aiMesh* X3DImporter::GeometryHelper_MakeMesh(const std::list& pCoordIdx size_t ts = faces.size(); // faces tmesh->mFaces = new aiFace[ts]; - tmesh->mNumFaces = ts; + tmesh->mNumFaces = static_cast(ts); for(size_t i = 0; i < ts; i++) tmesh->mFaces[i] = faces.at(i); // vertices @@ -1337,7 +1337,7 @@ aiMesh* X3DImporter::GeometryHelper_MakeMesh(const std::list& pCoordIdx ts = pVertices.size(); tmesh->mVertices = new aiVector3D[ts]; - tmesh->mNumVertices = ts; + tmesh->mNumVertices = static_cast(ts); for ( size_t i = 0; i < ts; i++ ) { tmesh->mVertices[ i ] = *vit++; @@ -1701,7 +1701,7 @@ void X3DImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSy { std::list::const_iterator it = mesh_list.begin(); - pScene->mNumMeshes = mesh_list.size(); + pScene->mNumMeshes = static_cast(mesh_list.size()); pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; for(size_t i = 0; i < pScene->mNumMeshes; i++) pScene->mMeshes[i] = *it++; } @@ -1710,7 +1710,7 @@ void X3DImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSy { std::list::const_iterator it = mat_list.begin(); - pScene->mNumMaterials = mat_list.size(); + pScene->mNumMaterials = static_cast(mat_list.size()); pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials]; for(size_t i = 0; i < pScene->mNumMaterials; i++) pScene->mMaterials[i] = *it++; } @@ -1719,7 +1719,7 @@ void X3DImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSy { std::list::const_iterator it = light_list.begin(); - pScene->mNumLights = light_list.size(); + pScene->mNumLights = static_cast(light_list.size()); pScene->mLights = new aiLight*[pScene->mNumLights]; for(size_t i = 0; i < pScene->mNumLights; i++) pScene->mLights[i] = *it++; } diff --git a/code/X3DImporter_Geometry3D.cpp b/code/X3DImporter_Geometry3D.cpp index 2525931..34e295d 100644 --- a/code/X3DImporter_Geometry3D.cpp +++ b/code/X3DImporter_Geometry3D.cpp @@ -347,8 +347,8 @@ void X3DImporter::ParseNode_Geometry3D_ElevationGrid() ((CX3DImporter_NodeElement_ElevationGrid*)ne)->NumIndices = 2;// will be holded as line set. for(size_t i = 0, i_e = (grid_alias.Vertices.size() - 1); i < i_e; i++) { - grid_alias.CoordIdx.push_back(i); - grid_alias.CoordIdx.push_back(i + 1); + grid_alias.CoordIdx.push_back(static_cast(i)); + grid_alias.CoordIdx.push_back(static_cast(i + 1)); grid_alias.CoordIdx.push_back(-1); } } @@ -758,7 +758,7 @@ void X3DImporter::ParseNode_Geometry3D_Extrusion() if(beginCap) { // add cap as polygon. vertices of cap are places at begin, so just add numbers from zero. - for(size_t i = 0, i_e = crossSection.size(); i < i_e; i++) ext_alias.CoordIndex.push_back(i); + for(size_t i = 0, i_e = crossSection.size(); i < i_e; i++) ext_alias.CoordIndex.push_back(static_cast(i)); // add delimiter ext_alias.CoordIndex.push_back(-1); @@ -769,7 +769,7 @@ void X3DImporter::ParseNode_Geometry3D_Extrusion() // add cap as polygon. vertices of cap are places at end, as for beginCap use just sequence of numbers but with offset. size_t beg = (pointset_arr.size() - 1) * crossSection.size(); - for(size_t i = beg, i_e = (beg + crossSection.size()); i < i_e; i++) ext_alias.CoordIndex.push_back(i); + for(size_t i = beg, i_e = (beg + crossSection.size()); i < i_e; i++) ext_alias.CoordIndex.push_back(static_cast(i)); // add delimiter ext_alias.CoordIndex.push_back(-1); @@ -795,14 +795,20 @@ void X3DImporter::ParseNode_Geometry3D_Extrusion() if(cri != cr_last) { MACRO_FACE_ADD_QUAD(ccw, ext_alias.CoordIndex, - spi * cr_sz + cri, right_col * cr_sz + cri, right_col * cr_sz + cri + 1, spi * cr_sz + cri + 1); + static_cast(spi * cr_sz + cri), + static_cast(right_col * cr_sz + cri), + static_cast(right_col * cr_sz + cri + 1), + static_cast(spi * cr_sz + cri + 1)); // add delimiter ext_alias.CoordIndex.push_back(-1); } else if(cross_closed)// if cross curve is closed then one more quad is needed: between first and last points of curve. { MACRO_FACE_ADD_QUAD(ccw, ext_alias.CoordIndex, - spi * cr_sz + cri, right_col * cr_sz + cri, right_col * cr_sz + 0, spi * cr_sz + 0); + static_cast(spi * cr_sz + cri), + static_cast(right_col * cr_sz + cri), + static_cast(right_col * cr_sz + 0), + static_cast(spi * cr_sz + 0)); // add delimiter ext_alias.CoordIndex.push_back(-1); } diff --git a/code/X3DImporter_Postprocess.cpp b/code/X3DImporter_Postprocess.cpp index 676816b..8a953b7 100644 --- a/code/X3DImporter_Postprocess.cpp +++ b/code/X3DImporter_Postprocess.cpp @@ -253,7 +253,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle tarr.reserve(tnemesh.Vertices.size()); for(std::list::iterator it = tnemesh.Vertices.begin(); it != tnemesh.Vertices.end(); it++) tarr.push_back(*it); - *pMesh = StandardShapes::MakeMesh(tarr, tnemesh.NumIndices);// create mesh from vertices using Assimp help. + *pMesh = StandardShapes::MakeMesh(tarr, static_cast(tnemesh.NumIndices));// create mesh from vertices using Assimp help. return;// mesh is build, nothing to do anymore. } @@ -272,7 +272,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle tarr.reserve(tnemesh.Vertices.size()); for(std::list::iterator it = tnemesh.Vertices.begin(); it != tnemesh.Vertices.end(); it++) tarr.push_back(*it); - *pMesh = StandardShapes::MakeMesh(tarr, tnemesh.NumIndices);// create mesh from vertices using Assimp help. + *pMesh = StandardShapes::MakeMesh(tarr, static_cast(tnemesh.NumIndices));// create mesh from vertices using Assimp help. return;// mesh is build, nothing to do anymore. } @@ -669,7 +669,7 @@ void X3DImporter::Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeEle { std::list::const_iterator it = SceneNode_Child.begin(); - pSceneNode.mNumChildren = SceneNode_Child.size(); + pSceneNode.mNumChildren = static_cast(SceneNode_Child.size()); pSceneNode.mChildren = new aiNode*[pSceneNode.mNumChildren]; for(size_t i = 0; i < pSceneNode.mNumChildren; i++) pSceneNode.mChildren[i] = *it++; } @@ -678,7 +678,7 @@ void X3DImporter::Postprocess_BuildNode(const CX3DImporter_NodeElement& pNodeEle { std::list::const_iterator it = SceneNode_Mesh.begin(); - pSceneNode.mNumMeshes = SceneNode_Mesh.size(); + pSceneNode.mNumMeshes = static_cast(SceneNode_Mesh.size()); pSceneNode.mMeshes = new unsigned int[pSceneNode.mNumMeshes]; for(size_t i = 0; i < pSceneNode.mNumMeshes; i++) pSceneNode.mMeshes[i] = *it++; } @@ -702,7 +702,7 @@ void X3DImporter::Postprocess_BuildShape(const CX3DImporter_NodeElement_Shape& p if(tmesh != nullptr) { // if mesh successfully built then add data about it to arrays - pNodeMeshInd.push_back(pSceneMeshList.size()); + pNodeMeshInd.push_back(static_cast(pSceneMeshList.size())); pSceneMeshList.push_back(tmesh); // keep mesh type. Need above for texture coordinate generation. mesh_type = (*it)->Type; @@ -714,7 +714,7 @@ void X3DImporter::Postprocess_BuildShape(const CX3DImporter_NodeElement_Shape& p if(tmat != nullptr) { // if material successfully built then add data about it to array - mat_ind = pSceneMaterialList.size(); + mat_ind = static_cast(pSceneMaterialList.size()); pSceneMaterialList.push_back(tmat); } } @@ -765,7 +765,7 @@ void X3DImporter::Postprocess_CollectMetadata(const CX3DImporter_NodeElement& pN } // copy collected metadata to output node. - pSceneNode.mMetaData = aiMetadata::Alloc( meta_list.size() ); + pSceneNode.mMetaData = aiMetadata::Alloc( static_cast(meta_list.size()) ); meta_idx = 0; for(std::list::const_iterator it = meta_list.begin(); it != meta_list.end(); it++, meta_idx++) { @@ -776,22 +776,22 @@ void X3DImporter::Postprocess_CollectMetadata(const CX3DImporter_NodeElement& pN if((*it)->Type == CX3DImporter_NodeElement::ENET_MetaBoolean) { if(((CX3DImporter_NodeElement_MetaBoolean*)cur_meta)->Value.size() > 0) - pSceneNode.mMetaData->Set(meta_idx, cur_meta->Name, *(((CX3DImporter_NodeElement_MetaBoolean*)cur_meta)->Value.begin())); + pSceneNode.mMetaData->Set(static_cast(meta_idx), cur_meta->Name, *(((CX3DImporter_NodeElement_MetaBoolean*)cur_meta)->Value.begin())); } else if((*it)->Type == CX3DImporter_NodeElement::ENET_MetaDouble) { if(((CX3DImporter_NodeElement_MetaDouble*)cur_meta)->Value.size() > 0) - pSceneNode.mMetaData->Set(meta_idx, cur_meta->Name, (float)*(((CX3DImporter_NodeElement_MetaDouble*)cur_meta)->Value.begin())); + pSceneNode.mMetaData->Set(static_cast(meta_idx), cur_meta->Name, (float)*(((CX3DImporter_NodeElement_MetaDouble*)cur_meta)->Value.begin())); } else if((*it)->Type == CX3DImporter_NodeElement::ENET_MetaFloat) { if(((CX3DImporter_NodeElement_MetaFloat*)cur_meta)->Value.size() > 0) - pSceneNode.mMetaData->Set(meta_idx, cur_meta->Name, *(((CX3DImporter_NodeElement_MetaFloat*)cur_meta)->Value.begin())); + pSceneNode.mMetaData->Set(static_cast(meta_idx), cur_meta->Name, *(((CX3DImporter_NodeElement_MetaFloat*)cur_meta)->Value.begin())); } else if((*it)->Type == CX3DImporter_NodeElement::ENET_MetaInteger) { if(((CX3DImporter_NodeElement_MetaInteger*)cur_meta)->Value.size() > 0) - pSceneNode.mMetaData->Set(meta_idx, cur_meta->Name, *(((CX3DImporter_NodeElement_MetaInteger*)cur_meta)->Value.begin())); + pSceneNode.mMetaData->Set(static_cast(meta_idx), cur_meta->Name, *(((CX3DImporter_NodeElement_MetaInteger*)cur_meta)->Value.begin())); } else if((*it)->Type == CX3DImporter_NodeElement::ENET_MetaString) { @@ -799,7 +799,7 @@ void X3DImporter::Postprocess_CollectMetadata(const CX3DImporter_NodeElement& pN { aiString tstr(((CX3DImporter_NodeElement_MetaString*)cur_meta)->Value.begin()->data()); - pSceneNode.mMetaData->Set(meta_idx, cur_meta->Name, tstr); + pSceneNode.mMetaData->Set(static_cast(meta_idx), cur_meta->Name, tstr); } } else diff --git a/code/X3DImporter_Rendering.cpp b/code/X3DImporter_Rendering.cpp index ce0d7b6..29dc287 100644 --- a/code/X3DImporter_Rendering.cpp +++ b/code/X3DImporter_Rendering.cpp @@ -524,7 +524,7 @@ void X3DImporter::ParseNode_Rendering_LineSet() { if(*vc_it < 2) throw DeadlyImportError("LineSet. vertexCount shall be greater than or equal to two."); - for(int32_t i = 0; i < *vc_it; i++) ne_alias.CoordIndex.push_back(coord_num++);// add vertices indices + for(int32_t i = 0; i < *vc_it; i++) ne_alias.CoordIndex.push_back(static_cast(coord_num++));// add vertices indices ne_alias.CoordIndex.push_back(-1);// add face delimiter. } @@ -678,17 +678,17 @@ void X3DImporter::ParseNode_Rendering_TriangleFanSet() { // 2 1 // 0 - ne_alias.CoordIndex.push_back(coord_num_first);// first vertex is a center and always is [0]. - ne_alias.CoordIndex.push_back(coord_num_prev++); - ne_alias.CoordIndex.push_back(coord_num_prev); + ne_alias.CoordIndex.push_back(static_cast(coord_num_first));// first vertex is a center and always is [0]. + ne_alias.CoordIndex.push_back(static_cast(coord_num_prev++)); + ne_alias.CoordIndex.push_back(static_cast(coord_num_prev)); } else { // 1 2 // 0 - ne_alias.CoordIndex.push_back(coord_num_first);// first vertex is a center and always is [0]. - ne_alias.CoordIndex.push_back(coord_num_prev + 1); - ne_alias.CoordIndex.push_back(coord_num_prev++); + ne_alias.CoordIndex.push_back(static_cast(coord_num_first));// first vertex is a center and always is [0]. + ne_alias.CoordIndex.push_back(static_cast(coord_num_prev + 1)); + ne_alias.CoordIndex.push_back(static_cast(coord_num_prev++)); }// if(ccw) else ne_alias.CoordIndex.push_back(-1);// add face delimiter. @@ -875,17 +875,17 @@ void X3DImporter::ParseNode_Rendering_TriangleStripSet() { // 0 2 // 1 - ne_alias.CoordIndex.push_back(coord_num0); - ne_alias.CoordIndex.push_back(coord_num1); - ne_alias.CoordIndex.push_back(coord_num2); + ne_alias.CoordIndex.push_back(static_cast(coord_num0)); + ne_alias.CoordIndex.push_back(static_cast(coord_num1)); + ne_alias.CoordIndex.push_back(static_cast(coord_num2)); } else { // 0 1 // 2 - ne_alias.CoordIndex.push_back(coord_num0); - ne_alias.CoordIndex.push_back(coord_num2); - ne_alias.CoordIndex.push_back(coord_num1); + ne_alias.CoordIndex.push_back(static_cast(coord_num0)); + ne_alias.CoordIndex.push_back(static_cast(coord_num2)); + ne_alias.CoordIndex.push_back(static_cast(coord_num1)); }// if(ccw) else ne_alias.CoordIndex.push_back(-1);// add face delimiter. -- 2.7.4