diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 81a43754e..5de48120c 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -58,6 +58,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "time.h" #include "math.h" +#include +#include #include #include "Defines.h" @@ -240,7 +242,7 @@ aiNode* ColladaLoader::BuildHierarchy( const ColladaParser& pParser, const Colla ResolveNodeInstances(pParser,pNode,instances); // add children. first the *real* ones - node->mNumChildren = pNode->mChildren.size()+instances.size(); + node->mNumChildren = static_cast(pNode->mChildren.size()+instances.size()); node->mChildren = new aiNode*[node->mNumChildren]; for( size_t a = 0; a < pNode->mChildren.size(); a++) @@ -506,7 +508,7 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll std::map::const_iterator matIt = mMaterialIndexByName.find( meshMaterial); unsigned int matIdx; if( matIt != mMaterialIndexByName.end()) - matIdx = matIt->second; + matIdx = static_cast(matIt->second); else matIdx = 0; @@ -553,11 +555,19 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll } // now place all mesh references we gathered in the target node - pTarget->mNumMeshes = newMeshRefs.size(); + pTarget->mNumMeshes = static_cast(newMeshRefs.size()); if( newMeshRefs.size()) { + struct UIntTypeConverter + { + unsigned int operator()(const size_t& v) const + { + return static_cast(v); + } + }; + pTarget->mMeshes = new unsigned int[pTarget->mNumMeshes]; - std::copy( newMeshRefs.begin(), newMeshRefs.end(), pTarget->mMeshes); + std::transform( newMeshRefs.begin(), newMeshRefs.end(), pTarget->mMeshes, UIntTypeConverter()); } } @@ -572,10 +582,10 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada:: // count the vertices addressed by its faces const size_t numVertices = std::accumulate( pSrcMesh->mFaceSize.begin() + pStartFace, - pSrcMesh->mFaceSize.begin() + pStartFace + pSubMesh.mNumFaces, 0); + pSrcMesh->mFaceSize.begin() + pStartFace + pSubMesh.mNumFaces, size_t(0)); // copy positions - dstMesh->mNumVertices = numVertices; + dstMesh->mNumVertices = static_cast(numVertices); dstMesh->mVertices = new aiVector3D[numVertices]; std::copy( pSrcMesh->mPositions.begin() + pStartVertex, pSrcMesh->mPositions.begin() + pStartVertex + numVertices, dstMesh->mVertices); @@ -634,16 +644,16 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada:: // create faces. Due to the fact that each face uses unique vertices, we can simply count up on each vertex size_t vertex = 0; - dstMesh->mNumFaces = pSubMesh.mNumFaces; + dstMesh->mNumFaces = static_cast(pSubMesh.mNumFaces); dstMesh->mFaces = new aiFace[dstMesh->mNumFaces]; for( size_t a = 0; a < dstMesh->mNumFaces; ++a) { size_t s = pSrcMesh->mFaceSize[ pStartFace + a]; aiFace& face = dstMesh->mFaces[a]; - face.mNumIndices = s; + face.mNumIndices = static_cast(s); face.mIndices = new unsigned int[s]; for( size_t b = 0; b < s; ++b) - face.mIndices[b] = vertex++; + face.mIndices[b] = static_cast(vertex++); } // create bones if given @@ -710,7 +720,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada:: if( weight > 0.0f) { aiVertexWeight w; - w.mVertexId = a - pStartVertex; + w.mVertexId = static_cast(a - pStartVertex); w.mWeight = weight; dstBones[jointIndex].push_back( w); } @@ -724,7 +734,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada:: numRemainingBones++; // create bone array and copy bone weights one by one - dstMesh->mNumBones = numRemainingBones; + dstMesh->mNumBones = static_cast(numRemainingBones); dstMesh->mBones = new aiBone*[numRemainingBones]; size_t boneCount = 0; for( size_t a = 0; a < numBones; ++a) @@ -748,7 +758,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada:: bone->mOffsetMatrix.c2 = ReadFloat( jointMatrixAcc, jointMatrices, a, 9); bone->mOffsetMatrix.c3 = ReadFloat( jointMatrixAcc, jointMatrices, a, 10); bone->mOffsetMatrix.c4 = ReadFloat( jointMatrixAcc, jointMatrices, a, 11); - bone->mNumWeights = dstBones[a].size(); + bone->mNumWeights = static_cast(dstBones[a].size()); bone->mWeights = new aiVertexWeight[bone->mNumWeights]; std::copy( dstBones[a].begin(), dstBones[a].end(), bone->mWeights); @@ -798,7 +808,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada:: // Stores all meshes in the given scene void ColladaLoader::StoreSceneMeshes( aiScene* pScene) { - pScene->mNumMeshes = mMeshes.size(); + pScene->mNumMeshes = static_cast(mMeshes.size()); if( mMeshes.size() > 0) { pScene->mMeshes = new aiMesh*[mMeshes.size()]; @@ -811,7 +821,7 @@ void ColladaLoader::StoreSceneMeshes( aiScene* pScene) // Stores all cameras in the given scene void ColladaLoader::StoreSceneCameras( aiScene* pScene) { - pScene->mNumCameras = mCameras.size(); + pScene->mNumCameras = static_cast(mCameras.size()); if( mCameras.size() > 0) { pScene->mCameras = new aiCamera*[mCameras.size()]; @@ -824,7 +834,7 @@ void ColladaLoader::StoreSceneCameras( aiScene* pScene) // Stores all lights in the given scene void ColladaLoader::StoreSceneLights( aiScene* pScene) { - pScene->mNumLights = mLights.size(); + pScene->mNumLights = static_cast(mLights.size()); if( mLights.size() > 0) { pScene->mLights = new aiLight*[mLights.size()]; @@ -837,7 +847,7 @@ void ColladaLoader::StoreSceneLights( aiScene* pScene) // Stores all textures in the given scene void ColladaLoader::StoreSceneTextures( aiScene* pScene) { - pScene->mNumTextures = mTextures.size(); + pScene->mNumTextures = static_cast(mTextures.size()); if( mTextures.size() > 0) { pScene->mTextures = new aiTexture*[mTextures.size()]; @@ -850,7 +860,7 @@ void ColladaLoader::StoreSceneTextures( aiScene* pScene) // Stores all materials in the given scene void ColladaLoader::StoreSceneMaterials( aiScene* pScene) { - pScene->mNumMaterials = newMats.size(); + pScene->mNumMaterials = static_cast(newMats.size()); if (newMats.size() > 0) { pScene->mMaterials = new aiMaterial*[newMats.size()]; @@ -891,7 +901,7 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars combinedAnim->mName = aiString( std::string( "combinedAnim_") + char( '0' + a)); combinedAnim->mDuration = templateAnim->mDuration; combinedAnim->mTicksPerSecond = templateAnim->mTicksPerSecond; - combinedAnim->mNumChannels = collectedAnimIndices.size() + 1; + combinedAnim->mNumChannels = static_cast(collectedAnimIndices.size() + 1); combinedAnim->mChannels = new aiNodeAnim*[combinedAnim->mNumChannels]; // add the template anim as first channel by moving its aiNodeAnim to the combined animation combinedAnim->mChannels[0] = templateAnim->mChannels[0]; @@ -923,7 +933,7 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars // now store all anims in the scene if( !mAnims.empty()) { - pScene->mNumAnimations = mAnims.size(); + pScene->mNumAnimations = static_cast(mAnims.size()); pScene->mAnimations = new aiAnimation*[mAnims.size()]; std::copy( mAnims.begin(), mAnims.end(), pScene->mAnimations); } @@ -1207,9 +1217,9 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars { aiNodeAnim* dstAnim = new aiNodeAnim; dstAnim->mNodeName = nodeName; - dstAnim->mNumPositionKeys = resultTrafos.size(); - dstAnim->mNumRotationKeys= resultTrafos.size(); - dstAnim->mNumScalingKeys = resultTrafos.size(); + dstAnim->mNumPositionKeys = static_cast(resultTrafos.size()); + dstAnim->mNumRotationKeys= static_cast(resultTrafos.size()); + dstAnim->mNumScalingKeys = static_cast(resultTrafos.size()); dstAnim->mPositionKeys = new aiVectorKey[resultTrafos.size()]; dstAnim->mRotationKeys = new aiQuatKey[resultTrafos.size()]; dstAnim->mScalingKeys = new aiVectorKey[resultTrafos.size()]; @@ -1237,7 +1247,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars { aiAnimation* anim = new aiAnimation; anim->mName.Set( pName); - anim->mNumChannels = anims.size(); + anim->mNumChannels = static_cast(anims.size()); anim->mChannels = new aiNodeAnim*[anims.size()]; std::copy( anims.begin(), anims.end(), anim->mChannels); anim->mDuration = 0.0f; @@ -1520,13 +1530,13 @@ aiString ColladaLoader::FindFilenameForEffectTexture( const ColladaParser& pPars // and copy texture data tex->mHeight = 0; - tex->mWidth = imIt->second.mImageData.size(); + tex->mWidth = static_cast(imIt->second.mImageData.size()); tex->pcData = (aiTexel*)new char[tex->mWidth]; memcpy(tex->pcData,&imIt->second.mImageData[0],tex->mWidth); // setup texture reference string result.data[0] = '*'; - result.length = 1 + ASSIMP_itoa10(result.data+1,MAXLEN-1,mTextures.size()); + result.length = 1 + ASSIMP_itoa10(result.data+1,static_cast(MAXLEN-1),static_cast(mTextures.size())); // and add this texture to the list mTextures.push_back(tex);