From 0dc2e9197a03ff86dbc2b283879bef67275aa8cf Mon Sep 17 00:00:00 2001 From: kkulling Date: Wed, 13 Mar 2019 14:40:02 +0100 Subject: [PATCH 1/4] Fix compiler warnings. --- code/AssbinLoader.cpp | 2 +- code/FBXConverter.cpp | 2 +- code/SMDLoader.cpp | 4 ++-- test/unit/utSTLImportExport.cpp | 4 ++-- tools/assimp_view/SceneAnimator.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/code/AssbinLoader.cpp b/code/AssbinLoader.cpp index 7adb8db6f..acba8b3dd 100644 --- a/code/AssbinLoader.cpp +++ b/code/AssbinLoader.cpp @@ -708,7 +708,7 @@ void AssbinImporter::InternReadFile( const std::string& pFile, aiScene* pScene, unsigned char * uncompressedData = new unsigned char[ uncompressedSize ]; - int res = uncompress( uncompressedData, &uncompressedSize, compressedData, len ); + int res = uncompress( uncompressedData, &uncompressedSize, compressedData, (uLong) len ); if(res != Z_OK) { delete [] uncompressedData; diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index c556d3bba..a61ae4006 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -964,7 +964,7 @@ namespace Assimp { { if (indices[i] < 0) epcount++; } - unsigned int pcount = indices.size(); + unsigned int pcount = static_cast( indices.size() ); unsigned int scount = out_mesh->mNumFaces = pcount - epcount; aiFace* fac = out_mesh->mFaces = new aiFace[scount](); diff --git a/code/SMDLoader.cpp b/code/SMDLoader.cpp index 00d92e0b4..4288bf9c3 100644 --- a/code/SMDLoader.cpp +++ b/code/SMDLoader.cpp @@ -486,7 +486,7 @@ void SMDImporter::CreateOutputAnimations(const std::string &pFile, IOSystem* pIO if (bLoadAnimationList) { GetAnimationFileList(pFile, pIOHandler, animFileList); } - int animCount = animFileList.size() + 1; + int animCount = static_cast( animFileList.size() + 1u ); pScene->mNumAnimations = 1; pScene->mAnimations = new aiAnimation*[animCount]; memset(pScene->mAnimations, 0, sizeof(aiAnimation*)*animCount); @@ -510,7 +510,7 @@ void SMDImporter::CreateOutputAnimation(int index, const std::string &name) { anim->mName.Set(name.c_str()); } anim->mDuration = dLengthOfAnim; - anim->mNumChannels = asBones.size(); + anim->mNumChannels = static_cast( asBones.size() ); anim->mTicksPerSecond = 25.0; // FIXME: is this correct? aiNodeAnim** pp = anim->mChannels = new aiNodeAnim*[anim->mNumChannels]; diff --git a/test/unit/utSTLImportExport.cpp b/test/unit/utSTLImportExport.cpp index b5518de23..0f90aacf9 100644 --- a/test/unit/utSTLImportExport.cpp +++ b/test/unit/utSTLImportExport.cpp @@ -152,10 +152,10 @@ TEST_F(utSTLImporterExporter, test_export_pointclouds) { auto pMesh = scene.mMeshes[0]; - long numValidPoints = points.size(); + size_t numValidPoints = points.size(); pMesh->mVertices = new aiVector3D[numValidPoints]; - pMesh->mNumVertices = numValidPoints; + pMesh->mNumVertices = static_cast( numValidPoints ); int i = 0; for (XYZ &p : points) { diff --git a/tools/assimp_view/SceneAnimator.cpp b/tools/assimp_view/SceneAnimator.cpp index c2ebeacb3..86fe46a9c 100644 --- a/tools/assimp_view/SceneAnimator.cpp +++ b/tools/assimp_view/SceneAnimator.cpp @@ -90,7 +90,7 @@ void SceneAnimator::SetAnimIndex( size_t pAnimIndex) { delete mAnimEvaluator; mAnimEvaluator = nullptr; mNodesByName.clear(); - mCurrentAnimIndex = pAnimIndex; + mCurrentAnimIndex = static_cast( pAnimIndex ); // create the internal node tree. Do this even in case of invalid animation index // so that the transformation matrices are properly set up to mimic the current scene From 650fadebe9c0496c7c0bd1778e64ee496052b0f7 Mon Sep 17 00:00:00 2001 From: kkulling Date: Wed, 13 Mar 2019 16:58:18 +0100 Subject: [PATCH 2/4] Fix compiler warnings: var declarations hides other var. --- code/FindInstancesProcess.cpp | 20 ++++++++--------- code/MD3FileData.h | 10 ++++----- code/MD3Loader.cpp | 26 ++++++++++++---------- code/SortByPTypeProcess.cpp | 37 ++++++++++++++++--------------- code/StandardShapes.cpp | 40 +++++++++++++++++----------------- code/ValidateDataStructure.cpp | 13 ++++++----- 6 files changed, 75 insertions(+), 71 deletions(-) diff --git a/code/FindInstancesProcess.cpp b/code/FindInstancesProcess.cpp index 23f9d1581..be1138116 100644 --- a/code/FindInstancesProcess.cpp +++ b/code/FindInstancesProcess.cpp @@ -178,30 +178,30 @@ void FindInstancesProcess::Execute( aiScene* pScene) // use a constant epsilon for colors and UV coordinates static const float uvEpsilon = 10e-4f; { - unsigned int i, end = orig->GetNumUVChannels(); - for(i = 0; i < end; ++i) { - if (!orig->mTextureCoords[i]) { + unsigned int j, end = orig->GetNumUVChannels(); + for(j = 0; j < end; ++j) { + if (!orig->mTextureCoords[j]) { continue; } - if(!CompareArrays(orig->mTextureCoords[i],inst->mTextureCoords[i],orig->mNumVertices,uvEpsilon)) { + if(!CompareArrays(orig->mTextureCoords[j],inst->mTextureCoords[j],orig->mNumVertices,uvEpsilon)) { break; } } - if (i != end) { + if (j != end) { continue; } } { - unsigned int i, end = orig->GetNumColorChannels(); - for(i = 0; i < end; ++i) { - if (!orig->mColors[i]) { + unsigned int j, end = orig->GetNumColorChannels(); + for(j = 0; j < end; ++j) { + if (!orig->mColors[j]) { continue; } - if(!CompareArrays(orig->mColors[i],inst->mColors[i],orig->mNumVertices,uvEpsilon)) { + if(!CompareArrays(orig->mColors[j],inst->mColors[j],orig->mNumVertices,uvEpsilon)) { break; } } - if (i != end) { + if (j != end) { continue; } } diff --git a/code/MD3FileData.h b/code/MD3FileData.h index 0978e548d..2acd6631f 100644 --- a/code/MD3FileData.h +++ b/code/MD3FileData.h @@ -59,7 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -namespace Assimp { +namespace Assimp { namespace MD3 { // to make it easier for us, we test the magic word against both "endianesses" @@ -303,12 +303,12 @@ inline void Vec3NormalToLatLng( const aiVector3D& p_vIn, uint16_t& p_iOut ) b = int(57.2957795f * ( std::acos( p_vIn[2] ) ) * ( 255.0f / 360.0f )); b &= 0xff; - ((unsigned char*)&p_iOut)[0] = b; // longitude - ((unsigned char*)&p_iOut)[1] = a; // latitude + ((unsigned char*)&p_iOut)[0] = (unsigned char) b; // longitude + ((unsigned char*)&p_iOut)[1] = (unsigned char) a; // latitude } } -} -} +} // Namespace MD3 +} // Namespace Assimp #endif // !! AI_MD3FILEHELPER_H_INC diff --git a/code/MD3Loader.cpp b/code/MD3Loader.cpp index 0faffd5f9..13a5c6c94 100644 --- a/code/MD3Loader.cpp +++ b/code/MD3Loader.cpp @@ -258,10 +258,10 @@ bool Q3Shader::LoadSkin(SkinData& fill, const std::string& pFile,IOSystem* io) continue; fill.textures.push_back(SkinData::TextureEntry()); - SkinData::TextureEntry& s = fill.textures.back(); + SkinData::TextureEntry &entry = fill.textures.back(); - s.first = ss; - s.second = GetNextToken(buff); + entry.first = ss; + entry.second = GetNextToken(buff); } return true; } @@ -730,11 +730,13 @@ void MD3Importer::InternReadFile( const std::string& pFile, std::string::size_type s = mFile.find_last_of("/\\"); if (s == std::string::npos) { s = 0; + } else { + ++s; + } + filename = mFile.substr(s), path = mFile.substr(0, s); + for (std::string::iterator it = filename.begin(); it != filename.end(); ++it) { + *it = static_cast( tolower(*it) ); } - else ++s; - filename = mFile.substr(s), path = mFile.substr(0,s); - for( std::string::iterator it = filename .begin(); it != filename.end(); ++it) - *it = tolower( *it); // Load multi-part model file, if necessary if (configHandleMP) { @@ -905,15 +907,15 @@ void MD3Importer::InternReadFile( const std::string& pFile, // Now search the current shader for a record with this name ( // excluding texture file extension) if (!shaders.blocks.empty()) { - - std::string::size_type s = convertedPath.find_last_of('.'); - if (s == std::string::npos) - s = convertedPath.length(); + std::string::size_type sh = convertedPath.find_last_of('.'); + if (sh == std::string::npos) { + sh = convertedPath.length(); + } const std::string without_ext = convertedPath.substr(0,s); std::list< Q3Shader::ShaderDataBlock >::const_iterator dit = std::find(shaders.blocks.begin(),shaders.blocks.end(),without_ext); if (dit != shaders.blocks.end()) { - // Hurra, wir haben einen. Tolle Sache. + // We made it! shader = &*dit; ASSIMP_LOG_INFO("Found shader record for " +without_ext ); } else { diff --git a/code/SortByPTypeProcess.cpp b/code/SortByPTypeProcess.cpp index 87bbe5257..2e0cc5400 100644 --- a/code/SortByPTypeProcess.cpp +++ b/code/SortByPTypeProcess.cpp @@ -228,36 +228,37 @@ void SortByPTypeProcess::Execute( aiScene* pScene) { out->mNumVertices = (3 == real ? numPolyVerts : out->mNumFaces * (real+1)); - aiVector3D *vert(NULL), *nor(NULL), *tan(NULL), *bit(NULL); + aiVector3D *vert(nullptr), *nor(nullptr), *tan(nullptr), *bit(nullptr); aiVector3D *uv [AI_MAX_NUMBER_OF_TEXTURECOORDS]; aiColor4D *cols [AI_MAX_NUMBER_OF_COLOR_SETS]; - if (mesh->mVertices) + if (mesh->mVertices) { vert = out->mVertices = new aiVector3D[out->mNumVertices]; + } - if (mesh->mNormals) - nor = out->mNormals = new aiVector3D[out->mNumVertices]; + if (mesh->mNormals) { + nor = out->mNormals = new aiVector3D[out->mNumVertices]; + } - if (mesh->mTangents) - { + if (mesh->mTangents) { tan = out->mTangents = new aiVector3D[out->mNumVertices]; bit = out->mBitangents = new aiVector3D[out->mNumVertices]; } - for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i) - { - if (mesh->mTextureCoords[i]) - uv[i] = out->mTextureCoords[i] = new aiVector3D[out->mNumVertices]; - else uv[i] = NULL; + for (unsigned int j = 0; j < AI_MAX_NUMBER_OF_TEXTURECOORDS;++j) { + uv[j] = nullptr; + if (mesh->mTextureCoords[j]) { + uv[j] = out->mTextureCoords[j] = new aiVector3D[out->mNumVertices]; + } - out->mNumUVComponents[i] = mesh->mNumUVComponents[i]; + out->mNumUVComponents[j] = mesh->mNumUVComponents[j]; } - for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS;++i) - { - if (mesh->mColors[i]) - cols[i] = out->mColors[i] = new aiColor4D[out->mNumVertices]; - else cols[i] = NULL; + for (unsigned int j = 0; j < AI_MAX_NUMBER_OF_COLOR_SETS;++j) { + cols[j] = nullptr; + if (mesh->mColors[j]) { + cols[j] = out->mColors[j] = new aiColor4D[out->mNumVertices]; + } } typedef std::vector< aiVertexWeight > TempBoneInfo; @@ -323,7 +324,7 @@ void SortByPTypeProcess::Execute( aiScene* pScene) { in.mIndices[q] = outIdx++; } - in.mIndices = NULL; + in.mIndices = nullptr; ++outFaces; } ai_assert(outFaces == out->mFaces + out->mNumFaces); diff --git a/code/StandardShapes.cpp b/code/StandardShapes.cpp index f262b6bac..2e5100130 100644 --- a/code/StandardShapes.cpp +++ b/code/StandardShapes.cpp @@ -127,35 +127,35 @@ aiMesh* StandardShapes::MakeMesh(const std::vector& positions, // Determine which kinds of primitives the mesh consists of aiMesh* out = new aiMesh(); - switch (numIndices) - { - case 1: - out->mPrimitiveTypes = aiPrimitiveType_POINT; - break; - case 2: - out->mPrimitiveTypes = aiPrimitiveType_LINE; - break; - case 3: - out->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; - break; - default: - out->mPrimitiveTypes = aiPrimitiveType_POLYGON; - break; + switch (numIndices) { + case 1: + out->mPrimitiveTypes = aiPrimitiveType_POINT; + break; + case 2: + out->mPrimitiveTypes = aiPrimitiveType_LINE; + break; + case 3: + out->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; + break; + default: + out->mPrimitiveTypes = aiPrimitiveType_POLYGON; + break; }; out->mNumFaces = (unsigned int)positions.size() / numIndices; out->mFaces = new aiFace[out->mNumFaces]; - for (unsigned int i = 0, a = 0; i < out->mNumFaces;++i) - { + for (unsigned int i = 0, a = 0; i < out->mNumFaces;++i) { aiFace& f = out->mFaces[i]; f.mNumIndices = numIndices; f.mIndices = new unsigned int[numIndices]; - for (unsigned int i = 0; i < numIndices;++i,++a) - f.mIndices[i] = a; + for (unsigned int j = 0; i < numIndices; ++i, ++a) { + f.mIndices[j] = a; + } } out->mNumVertices = (unsigned int)positions.size(); out->mVertices = new aiVector3D[out->mNumVertices]; ::memcpy(out->mVertices,&positions[0],out->mNumVertices*sizeof(aiVector3D)); + return out; } @@ -466,8 +466,8 @@ void StandardShapes::MakeCone(ai_real height,ai_real radius1, // Need to flip face order? if ( SIZE_MAX != old ) { - for (size_t s = old; s < positions.size();s += 3) { - std::swap(positions[s],positions[s+1]); + for (size_t p = old; p < positions.size();p += 3) { + std::swap(positions[p],positions[p+1]); } } } diff --git a/code/ValidateDataStructure.cpp b/code/ValidateDataStructure.cpp index 405670bdd..5861e3419 100644 --- a/code/ValidateDataStructure.cpp +++ b/code/ValidateDataStructure.cpp @@ -577,15 +577,16 @@ void ValidateDSProcess::SearchForInvalidTextures(const aiMaterial* pMaterial, int iNumIndices = 0; int iIndex = -1; - for (unsigned int i = 0; i < pMaterial->mNumProperties;++i) - { - aiMaterialProperty* prop = pMaterial->mProperties[i]; - if (!::strcmp(prop->mKey.data,"$tex.file") && prop->mSemantic == type) { + for (unsigned int i = 0; i < pMaterial->mNumProperties;++i) { + aiMaterialProperty* prop = pMaterial->mProperties[ i ]; + ai_assert(nullptr != prop); + if ( !::strcmp(prop->mKey.data,"$tex.file") && prop->mSemantic == static_cast(type)) { iIndex = std::max(iIndex, (int) prop->mIndex); ++iNumIndices; - if (aiPTI_String != prop->mType) - ReportError("Material property %s is expected to be a string",prop->mKey.data); + if (aiPTI_String != prop->mType) { + ReportError("Material property %s is expected to be a string", prop->mKey.data); + } } } if (iIndex +1 != iNumIndices) { From 61ffe017e8b5c86fcc22db8bc2e4bbc3273b7b26 Mon Sep 17 00:00:00 2001 From: kimkulling Date: Thu, 14 Mar 2019 17:37:28 +0100 Subject: [PATCH 3/4] Fix some coverity findings. --- code/ImproveCacheLocality.cpp | 4 +++- tools/assimp_cmd/Info.cpp | 40 ++++++++++++++-------------------- tools/assimp_cmd/WriteDumb.cpp | 13 +++++------ 3 files changed, 25 insertions(+), 32 deletions(-) diff --git a/code/ImproveCacheLocality.cpp b/code/ImproveCacheLocality.cpp index be6452dda..ace9d95ff 100644 --- a/code/ImproveCacheLocality.cpp +++ b/code/ImproveCacheLocality.cpp @@ -112,7 +112,9 @@ void ImproveCacheLocalityProcess::Execute( aiScene* pScene) } } if (!DefaultLogger::isNullLogger()) { - ASSIMP_LOG_INFO_F("Cache relevant are ", numm, " meshes (", numf," faces). Average output ACMR is ", out / numf ); + if (numf > 0) { + ASSIMP_LOG_INFO_F("Cache relevant are ", numm, " meshes (", numf, " faces). Average output ACMR is ", out / numf); + } ASSIMP_LOG_DEBUG("ImproveCacheLocalityProcess finished. "); } } diff --git a/tools/assimp_cmd/Info.cpp b/tools/assimp_cmd/Info.cpp index cb7ac86cf..b504083d3 100644 --- a/tools/assimp_cmd/Info.cpp +++ b/tools/assimp_cmd/Info.cpp @@ -51,27 +51,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include const char* AICMD_MSG_INFO_HELP_E = -"assimp info [-r] [-v]\n" -"\tPrint basic structure of a 3D model\n" -"\t-r,--raw: No postprocessing, do a raw import\n" -"\t-v,--verbose: Print verbose info such as node transform data\n" -"\t-s, --silent: Print only minimal info\n"; + "assimp info [-r] [-v]\n" + "\tPrint basic structure of a 3D model\n" + "\t-r,--raw: No postprocessing, do a raw import\n" + "\t-v,--verbose: Print verbose info such as node transform data\n" + "\t-s, --silent: Print only minimal info\n"; -const std::string TREE_BRANCH_ASCII = "|-"; -const std::string TREE_BRANCH_UTF8 = "\xe2\x94\x9c\xe2\x95\xb4"; -const std::string TREE_STOP_ASCII = "'-"; -const std::string TREE_STOP_UTF8 = "\xe2\x94\x94\xe2\x95\xb4"; -const std::string TREE_CONTINUE_ASCII = "| "; -const std::string TREE_CONTINUE_UTF8 = "\xe2\x94\x82 "; +const char *TREE_BRANCH_ASCII = "|-"; +const char *TREE_BRANCH_UTF8 = "\xe2\x94\x9c\xe2\x95\xb4"; +const char *TREE_STOP_ASCII = "'-"; +const char *TREE_STOP_UTF8 = "\xe2\x94\x94\xe2\x95\xb4"; +const char *TREE_CONTINUE_ASCII = "| "; +const char *TREE_CONTINUE_UTF8 = "\xe2\x94\x82 "; -// note: by default this is outputing utf-8 text. +// note: by default this is using utf-8 text. // this is well supported on pretty much any linux terminal. // if this causes problems on some platform, // put an #ifdef to use the ascii version for that platform. -const std::string TREE_BRANCH = TREE_BRANCH_UTF8; -const std::string TREE_STOP = TREE_STOP_UTF8; -const std::string TREE_CONTINUE = TREE_CONTINUE_UTF8; - +const char *TREE_BRANCH = TREE_BRANCH_UTF8; +const char *TREE_STOP = TREE_STOP_UTF8; +const char *TREE_CONTINUE = TREE_CONTINUE_UTF8; // ----------------------------------------------------------------------------------- unsigned int CountNodes(const aiNode* root) @@ -280,14 +279,7 @@ void PrintHierarchy( // ----------------------------------------------------------------------------------- // Implementation of the assimp info utility to print basic file info -int Assimp_Info (const char* const* params, unsigned int num) -{ - if (num < 1) { - printf("assimp info: Invalid number of arguments. " - "See \'assimp info --help\'\n"); - return 1; - } - +int Assimp_Info (const char* const* params, unsigned int num) { // --help if (!strcmp( params[0],"-h")||!strcmp( params[0],"--help")||!strcmp( params[0],"-?") ) { printf("%s",AICMD_MSG_INFO_HELP_E); diff --git a/tools/assimp_cmd/WriteDumb.cpp b/tools/assimp_cmd/WriteDumb.cpp index 569749994..0d6f58c60 100644 --- a/tools/assimp_cmd/WriteDumb.cpp +++ b/tools/assimp_cmd/WriteDumb.cpp @@ -276,9 +276,12 @@ inline uint32_t WriteBounds(const T* in, unsigned int size) void ChangeInteger(uint32_t ofs,uint32_t n) { const uint32_t cur = ftell(out); - fseek(out,ofs,SEEK_SET); - fwrite(&n,4,1,out); - fseek(out,cur,SEEK_SET); + int retCode; + retCode = fseek(out, ofs, SEEK_SET); + ai_assert(0 == retCode); + fwrite(&n, 4, 1, out); + retCode = fseek(out, cur, SEEK_SET); + ai_assert(0 == retCode); } // ----------------------------------------------------------------------------------- @@ -1333,10 +1336,6 @@ int Assimp_Dump (const char* const* params, unsigned int num) { const char* fail = "assimp dump: Invalid number of arguments. " "See \'assimp dump --help\'\r\n"; - if (num < 1) { - printf("%s", fail); - return 1; - } // --help if (!strcmp( params[0], "-h") || !strcmp( params[0], "--help") || !strcmp( params[0], "-?") ) { From 64a7a46406a8d0814699cb26aaa5f4817cc4aa29 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 16 Mar 2019 16:08:03 +0100 Subject: [PATCH 4/4] Update MD3Loader.cpp Fix typo. --- code/MD3Loader.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/code/MD3Loader.cpp b/code/MD3Loader.cpp index 13a5c6c94..cd58931f8 100644 --- a/code/MD3Loader.cpp +++ b/code/MD3Loader.cpp @@ -718,9 +718,7 @@ void MD3Importer::ConvertPath(const char* texture_name, const char* header_name, // ------------------------------------------------------------------------------------------------ // Imports the given file into the given scene structure. -void MD3Importer::InternReadFile( const std::string& pFile, - aiScene* pScene, IOSystem* pIOHandler) -{ +void MD3Importer::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) { mFile = pFile; mScene = pScene; mIOHandler = pIOHandler; @@ -912,7 +910,7 @@ void MD3Importer::InternReadFile( const std::string& pFile, sh = convertedPath.length(); } - const std::string without_ext = convertedPath.substr(0,s); + const std::string without_ext = convertedPath.substr(0,sh); std::list< Q3Shader::ShaderDataBlock >::const_iterator dit = std::find(shaders.blocks.begin(),shaders.blocks.end(),without_ext); if (dit != shaders.blocks.end()) { // We made it! @@ -947,8 +945,7 @@ void MD3Importer::InternReadFile( const std::string& pFile, aiString szString; if (convertedPath.length()) { szString.Set(convertedPath); - } - else { + } else { ASSIMP_LOG_WARN("Texture file name has zero length. Using default name"); szString.Set("dummy_texture.bmp"); } @@ -957,8 +954,7 @@ void MD3Importer::InternReadFile( const std::string& pFile, // prevent transparency by default int no_alpha = aiTextureFlags_IgnoreAlpha; pcHelper->AddProperty(&no_alpha,1,AI_MATKEY_TEXFLAGS_DIFFUSE(0)); - } - else { + } else { Q3Shader::ConvertShaderToMaterial(pcHelper,*shader); } @@ -1028,7 +1024,7 @@ void MD3Importer::InternReadFile( const std::string& pFile, if (!shader || shader->cull == Q3Shader::CULL_CW) { std::swap(pcMesh->mFaces[i].mIndices[2],pcMesh->mFaces[i].mIndices[1]); } - pcTriangles++; + ++pcTriangles; } // Go to the next surface @@ -1044,8 +1040,9 @@ void MD3Importer::InternReadFile( const std::string& pFile, } } - if (!pScene->mNumMeshes) + if (!pScene->mNumMeshes) { throw DeadlyImportError( "MD3: File contains no valid mesh"); + } pScene->mNumMaterials = iNumMaterials; // Now we need to generate an empty node graph @@ -1059,7 +1056,6 @@ void MD3Importer::InternReadFile( const std::string& pFile, pScene->mRootNode->mChildren = new aiNode*[pcHeader->NUM_TAGS]; for (unsigned int i = 0; i < pcHeader->NUM_TAGS; ++i, ++pcTags) { - aiNode* nd = pScene->mRootNode->mChildren[i] = new aiNode(); nd->mName.Set((const char*)pcTags->NAME); nd->mParent = pScene->mRootNode; @@ -1087,8 +1083,12 @@ void MD3Importer::InternReadFile( const std::string& pFile, pScene->mRootNode->mMeshes[i] = i; // Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system - pScene->mRootNode->mTransformation = aiMatrix4x4(1.f,0.f,0.f,0.f, - 0.f,0.f,1.f,0.f,0.f,-1.f,0.f,0.f,0.f,0.f,0.f,1.f); + pScene->mRootNode->mTransformation = aiMatrix4x4( + 1.f,0.f,0.f,0.f, + 0.f,0.f,1.f,0.f, + 0.f,-1.f,0.f,0.f, + 0.f,0.f,0.f,1.f + ); } #endif // !! ASSIMP_BUILD_NO_MD3_IMPORTER