Преглед изворни кода

Merge pull request #572 from asmaloney/fix/code_cleanup

Code Cleanups
Kim Kulling пре 10 година
родитељ
комит
4d05dd913c

+ 0 - 4
code/ColladaExporter.cpp

@@ -167,8 +167,6 @@ void ColladaExporter::WriteHeader()
 	std::time_t date = std::time(NULL);
 	std::time_t date = std::time(NULL);
 	std::strftime(date_str, date_nb_chars, "%Y-%m-%dT%H:%M:%S", std::localtime(&date));
 	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;
 	aiVector3D scaling;
 	aiQuaternion rotation;
 	aiQuaternion rotation;
 	aiVector3D position;
 	aiVector3D position;
@@ -622,8 +620,6 @@ void ColladaExporter::WriteMaterials()
 {
 {
   materials.resize( mScene->mNumMaterials);
   materials.resize( mScene->mNumMaterials);
 
 
-  std::set<std::string> material_names;
-
   /// collect all materials from the scene
   /// collect all materials from the scene
   size_t numTextures = 0;
   size_t numTextures = 0;
   for( size_t a = 0; a < mScene->mNumMaterials; ++a )
   for( size_t a = 0; a < mScene->mNumMaterials; ++a )

+ 1 - 1
code/ColladaLoader.cpp

@@ -919,7 +919,7 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 // Constructs the animations for the given source anim 
 // 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;
 	std::string animName = pPrefix.empty() ? pSrcAnim->mName : pPrefix + "_" + pSrcAnim->mName;
 
 

+ 1 - 1
code/ColladaLoader.h

@@ -155,7 +155,7 @@ protected:
 	 * @param pSrcAnim the source animation to process
 	 * @param pSrcAnim the source animation to process
 	 * @param pPrefix Prefix to the name in case of nested animations
 	 * @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 */
 	/** Constructs the animation for the given source anim */
 	void CreateAnimation( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pName);
 	void CreateAnimation( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pName);

+ 1 - 1
code/ComputeUVMappingProcess.cpp

@@ -412,7 +412,7 @@ void ComputeUVMappingProcess::Execute( aiScene* pScene)
 				{
 				{
 					if (!DefaultLogger::isNullLogger())
 					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,
 							TextureTypeToString((aiTextureType)prop->mSemantic),prop->mIndex,
 							MappingTypeToString(mapping));
 							MappingTypeToString(mapping));
 
 

+ 1 - 1
code/FixNormalsStep.cpp

@@ -158,7 +158,7 @@ bool FixInfacingNormalsProcess::ProcessMesh( aiMesh* pcMesh, unsigned int index)
 		if (!DefaultLogger::isNullLogger())
 		if (!DefaultLogger::isNullLogger())
 		{
 		{
 			char buffer[128]; // should be sufficiently large
 			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);
 			DefaultLogger::get()->info(buffer);
 		}
 		}
 
 

+ 3 - 3
code/ImproveCacheLocality.cpp

@@ -110,7 +110,7 @@ void ImproveCacheLocalityProcess::Execute( aiScene* pScene)
 	}
 	}
 	if (!DefaultLogger::isNullLogger()) {
 	if (!DefaultLogger::isNullLogger()) {
 		char szBuff[128]; // should be sufficiently large in every case
 		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);
 			numm,numf,out/numf);
 
 
 		DefaultLogger::get()->info(szBuff);
 		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
 			// the JoinIdenticalVertices process has not been executed on this
 			// mesh, otherwise this value would normally be at least minimally
 			// mesh, otherwise this value would normally be at least minimally
 			// smaller than 3.0 ...
 			// 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);
 			DefaultLogger::get()->warn(szBuff);
 			return 0.f;
 			return 0.f;
 		}
 		}
@@ -361,7 +361,7 @@ float ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int mesh
 		if ( DefaultLogger::get()->getLogSeverity() == Logger::VERBOSE) {
 		if ( DefaultLogger::get()->getLogSeverity() == Logger::VERBOSE) {
 			char szBuff[128]; // should be sufficiently large in every case
 			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);
 				((fACMR - fACMR2) / fACMR) * 100.f);
 			DefaultLogger::get()->debug(szBuff);
 			DefaultLogger::get()->debug(szBuff);
 		}
 		}

+ 3 - 1
code/RemoveVCProcess.cpp

@@ -54,7 +54,9 @@ using namespace Assimp;
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 // Constructor to be privately used by Importer
 // Constructor to be privately used by Importer
-RemoveVCProcess::RemoveVCProcess()
+RemoveVCProcess::RemoveVCProcess() :
+    configDeleteFlags()
+  , mScene()
 {}
 {}
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------

+ 5 - 5
code/SortByPTypeProcess.cpp

@@ -397,11 +397,11 @@ void SortByPTypeProcess::Execute( aiScene* pScene)
 	if (!DefaultLogger::isNullLogger())
 	if (!DefaultLogger::isNullLogger())
 	{
 	{
 		char buffer[1024];
 		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()->info(buffer);
 		DefaultLogger::get()->debug("SortByPTypeProcess finished");
 		DefaultLogger::get()->debug("SortByPTypeProcess finished");
 	}
 	}

+ 2 - 1
code/TextureTransform.cpp

@@ -54,7 +54,8 @@ using namespace Assimp;
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 // Constructor to be privately used by Importer
 // Constructor to be privately used by Importer
-TextureTransformStep::TextureTransformStep()
+TextureTransformStep::TextureTransformStep() :
+    configFlags()
 {
 {
 	// nothing to do here
 	// nothing to do here
 }
 }

+ 3 - 3
code/ValidateDataStructure.cpp

@@ -60,7 +60,8 @@ using namespace Assimp;
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 // Constructor to be privately used by Importer
 // 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)	{
 		if (aiPTI_String == prop->mType)	{
 			// FIX: strings are now stored in a less expensive way, but we can't use the
 			// FIX: strings are now stored in a less expensive way, but we can't use the
 			// validation routine for 'normal' aiStrings
 			// validation routine for 'normal' aiStrings
-			uint32_t len;
-			if (prop->mDataLength < 5 || prop->mDataLength < 4 + (len=*reinterpret_cast<uint32_t*>(prop->mData)) + 1)	{
+			if (prop->mDataLength < 5 || prop->mDataLength < 4 + (*reinterpret_cast<uint32_t*>(prop->mData)) + 1)	{
 				ReportError("aiMaterial::mProperties[%i].mDataLength is "
 				ReportError("aiMaterial::mProperties[%i].mDataLength is "
 					"too small to contain a string (%i, needed: %i)",
 					"too small to contain a string (%i, needed: %i)",
 					i,prop->mDataLength,sizeof(aiString));
 					i,prop->mDataLength,sizeof(aiString));

+ 8 - 1
include/assimp/Exporter.hpp

@@ -109,7 +109,14 @@ public:
 			mEnforcePP = pEnforcePP;
 			mEnforcePP = pEnforcePP;
 		}
 		}
 
 
-		ExportFormatEntry() : mExportFunction(), mEnforcePP() {}
+		ExportFormatEntry() :
+		    mExportFunction()
+		  , mEnforcePP()
+		{
+			mDescription.id = NULL;
+			mDescription.description = NULL;
+			mDescription.fileExtension = NULL;
+		}
 	};
 	};