From 4cbce374b684c751530ac9a0dbcfcc69c6252677 Mon Sep 17 00:00:00 2001 From: Andy Maloney Date: Sun, 24 May 2015 11:48:15 -0400 Subject: [PATCH] Code Cleanups - add initializers to classes - fix %i/%u for unsigned ints - remove unused vars - pass by reference --- code/ColladaExporter.cpp | 4 ---- code/ColladaLoader.cpp | 2 +- code/ColladaLoader.h | 2 +- code/ComputeUVMappingProcess.cpp | 2 +- code/FixNormalsStep.cpp | 2 +- code/ImproveCacheLocality.cpp | 6 +++--- code/RemoveVCProcess.cpp | 4 +++- code/SortByPTypeProcess.cpp | 10 +++++----- code/TextureTransform.cpp | 3 ++- code/ValidateDataStructure.cpp | 6 +++--- include/assimp/Exporter.hpp | 9 ++++++++- 11 files changed, 28 insertions(+), 22 deletions(-) diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index bcd4518e4..6c87c3de8 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -167,8 +167,6 @@ void ColladaExporter::WriteHeader() std::time_t date = std::time(NULL); std::strftime(date_str, date_nb_chars, "%Y-%m-%dT%H:%M:%S", std::localtime(&date)); - std::string scene_name = mScene->mRootNode->mName.C_Str(); - aiVector3D scaling; aiQuaternion rotation; aiVector3D position; @@ -622,8 +620,6 @@ void ColladaExporter::WriteMaterials() { materials.resize( mScene->mNumMaterials); - std::set material_names; - /// collect all materials from the scene size_t numTextures = 0; for( size_t a = 0; a < mScene->mNumMaterials; ++a ) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 833e428ac..3a981b538 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -919,7 +919,7 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars // ------------------------------------------------------------------------------------------------ // Constructs the animations for the given source anim -void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string pPrefix) +void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string &pPrefix) { std::string animName = pPrefix.empty() ? pSrcAnim->mName : pPrefix + "_" + pSrcAnim->mName; diff --git a/code/ColladaLoader.h b/code/ColladaLoader.h index 4ff0a667d..5e1098727 100644 --- a/code/ColladaLoader.h +++ b/code/ColladaLoader.h @@ -155,7 +155,7 @@ protected: * @param pSrcAnim the source animation to process * @param pPrefix Prefix to the name in case of nested animations */ - void StoreAnimations( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string pPrefix); + void StoreAnimations( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pPrefix); /** Constructs the animation for the given source anim */ void CreateAnimation( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pName); diff --git a/code/ComputeUVMappingProcess.cpp b/code/ComputeUVMappingProcess.cpp index 172268b66..3ed8f9a9e 100644 --- a/code/ComputeUVMappingProcess.cpp +++ b/code/ComputeUVMappingProcess.cpp @@ -412,7 +412,7 @@ void ComputeUVMappingProcess::Execute( aiScene* pScene) { if (!DefaultLogger::isNullLogger()) { - sprintf(buffer, "Found non-UV mapped texture (%s,%i). Mapping type: %s", + sprintf(buffer, "Found non-UV mapped texture (%s,%u). Mapping type: %s", TextureTypeToString((aiTextureType)prop->mSemantic),prop->mIndex, MappingTypeToString(mapping)); diff --git a/code/FixNormalsStep.cpp b/code/FixNormalsStep.cpp index d3d53ac15..608a145e0 100644 --- a/code/FixNormalsStep.cpp +++ b/code/FixNormalsStep.cpp @@ -158,7 +158,7 @@ bool FixInfacingNormalsProcess::ProcessMesh( aiMesh* pcMesh, unsigned int index) if (!DefaultLogger::isNullLogger()) { char buffer[128]; // should be sufficiently large - ::sprintf(buffer,"Mesh %i: Normals are facing inwards (or the mesh is planar)",index); + ::sprintf(buffer,"Mesh %u: Normals are facing inwards (or the mesh is planar)",index); DefaultLogger::get()->info(buffer); } diff --git a/code/ImproveCacheLocality.cpp b/code/ImproveCacheLocality.cpp index 81617cc49..0f2ecc13a 100644 --- a/code/ImproveCacheLocality.cpp +++ b/code/ImproveCacheLocality.cpp @@ -110,7 +110,7 @@ void ImproveCacheLocalityProcess::Execute( aiScene* pScene) } if (!DefaultLogger::isNullLogger()) { char szBuff[128]; // should be sufficiently large in every case - ::sprintf(szBuff,"Cache relevant are %i meshes (%i faces). Average output ACMR is %f", + ::sprintf(szBuff,"Cache relevant are %u meshes (%u faces). Average output ACMR is %f", numm,numf,out/numf); DefaultLogger::get()->info(szBuff); @@ -182,7 +182,7 @@ float ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int mesh // the JoinIdenticalVertices process has not been executed on this // mesh, otherwise this value would normally be at least minimally // smaller than 3.0 ... - sprintf(szBuff,"Mesh %i: Not suitable for vcache optimization",meshNum); + sprintf(szBuff,"Mesh %u: Not suitable for vcache optimization",meshNum); DefaultLogger::get()->warn(szBuff); return 0.f; } @@ -361,7 +361,7 @@ float ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int mesh if ( DefaultLogger::get()->getLogSeverity() == Logger::VERBOSE) { char szBuff[128]; // should be sufficiently large in every case - ::sprintf(szBuff,"Mesh %i | ACMR in: %f out: %f | ~%.1f%%",meshNum,fACMR,fACMR2, + ::sprintf(szBuff,"Mesh %u | ACMR in: %f out: %f | ~%.1f%%",meshNum,fACMR,fACMR2, ((fACMR - fACMR2) / fACMR) * 100.f); DefaultLogger::get()->debug(szBuff); } diff --git a/code/RemoveVCProcess.cpp b/code/RemoveVCProcess.cpp index 2b551bacf..9fe4e8de2 100644 --- a/code/RemoveVCProcess.cpp +++ b/code/RemoveVCProcess.cpp @@ -54,7 +54,9 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -RemoveVCProcess::RemoveVCProcess() +RemoveVCProcess::RemoveVCProcess() : + configDeleteFlags() + , mScene() {} // ------------------------------------------------------------------------------------------------ diff --git a/code/SortByPTypeProcess.cpp b/code/SortByPTypeProcess.cpp index 096b3fcf1..34bb830fd 100644 --- a/code/SortByPTypeProcess.cpp +++ b/code/SortByPTypeProcess.cpp @@ -397,11 +397,11 @@ void SortByPTypeProcess::Execute( aiScene* pScene) if (!DefaultLogger::isNullLogger()) { char buffer[1024]; - ::sprintf(buffer,"Points: %i%s, Lines: %i%s, Triangles: %i%s, Polygons: %i%s (Meshes, X = removed)", - aiNumMeshesPerPType[0], (configRemoveMeshes & aiPrimitiveType_POINT ? "X" : ""), - aiNumMeshesPerPType[1], (configRemoveMeshes & aiPrimitiveType_LINE ? "X" : ""), - aiNumMeshesPerPType[2], (configRemoveMeshes & aiPrimitiveType_TRIANGLE ? "X" : ""), - aiNumMeshesPerPType[3], (configRemoveMeshes & aiPrimitiveType_POLYGON ? "X" : "")); + ::sprintf(buffer,"Points: %u%s, Lines: %u%s, Triangles: %u%s, Polygons: %u%s (Meshes, X = removed)", + aiNumMeshesPerPType[0], ((configRemoveMeshes & aiPrimitiveType_POINT) ? "X" : ""), + aiNumMeshesPerPType[1], ((configRemoveMeshes & aiPrimitiveType_LINE) ? "X" : ""), + aiNumMeshesPerPType[2], ((configRemoveMeshes & aiPrimitiveType_TRIANGLE) ? "X" : ""), + aiNumMeshesPerPType[3], ((configRemoveMeshes & aiPrimitiveType_POLYGON) ? "X" : "")); DefaultLogger::get()->info(buffer); DefaultLogger::get()->debug("SortByPTypeProcess finished"); } diff --git a/code/TextureTransform.cpp b/code/TextureTransform.cpp index 98e1becb9..29257404d 100644 --- a/code/TextureTransform.cpp +++ b/code/TextureTransform.cpp @@ -54,7 +54,8 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -TextureTransformStep::TextureTransformStep() +TextureTransformStep::TextureTransformStep() : + configFlags() { // nothing to do here } diff --git a/code/ValidateDataStructure.cpp b/code/ValidateDataStructure.cpp index 98d16be5e..2a2e1a0d6 100644 --- a/code/ValidateDataStructure.cpp +++ b/code/ValidateDataStructure.cpp @@ -60,7 +60,8 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer -ValidateDSProcess::ValidateDSProcess() +ValidateDSProcess::ValidateDSProcess() : + mScene() {} // ------------------------------------------------------------------------------------------------ @@ -690,8 +691,7 @@ void ValidateDSProcess::Validate( const aiMaterial* pMaterial) if (aiPTI_String == prop->mType) { // FIX: strings are now stored in a less expensive way, but we can't use the // validation routine for 'normal' aiStrings - uint32_t len; - if (prop->mDataLength < 5 || prop->mDataLength < 4 + (len=*reinterpret_cast(prop->mData)) + 1) { + if (prop->mDataLength < 5 || prop->mDataLength < 4 + (*reinterpret_cast(prop->mData)) + 1) { ReportError("aiMaterial::mProperties[%i].mDataLength is " "too small to contain a string (%i, needed: %i)", i,prop->mDataLength,sizeof(aiString)); diff --git a/include/assimp/Exporter.hpp b/include/assimp/Exporter.hpp index fb890129e..4e5a1131a 100644 --- a/include/assimp/Exporter.hpp +++ b/include/assimp/Exporter.hpp @@ -109,7 +109,14 @@ public: mEnforcePP = pEnforcePP; } - ExportFormatEntry() : mExportFunction(), mEnforcePP() {} + ExportFormatEntry() : + mExportFunction() + , mEnforcePP() + { + mDescription.id = NULL; + mDescription.description = NULL; + mDescription.fileExtension = NULL; + } };