Skip to content

Commit

Permalink
Code Cleanups
Browse files Browse the repository at this point in the history
- add initializers to classes
- fix %i/%u for unsigned ints
- remove unused vars
- pass by reference
  • Loading branch information
asmaloney committed May 24, 2015
1 parent 8e24695 commit 4cbce37
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 22 deletions.
4 changes: 0 additions & 4 deletions code/ColladaExporter.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -622,8 +620,6 @@ void ColladaExporter::WriteMaterials()
{
materials.resize( mScene->mNumMaterials);

std::set<std::string> material_names;

/// collect all materials from the scene
size_t numTextures = 0;
for( size_t a = 0; a < mScene->mNumMaterials; ++a )
Expand Down
2 changes: 1 addition & 1 deletion code/ColladaLoader.cpp
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion code/ColladaLoader.h
Expand Up @@ -155,7 +155,7 @@ class ColladaLoader : public BaseImporter
* @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);
Expand Down
2 changes: 1 addition & 1 deletion code/ComputeUVMappingProcess.cpp
Expand Up @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion code/FixNormalsStep.cpp
Expand Up @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions code/ImproveCacheLocality.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion code/RemoveVCProcess.cpp
Expand Up @@ -54,7 +54,9 @@ using namespace Assimp;

// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
RemoveVCProcess::RemoveVCProcess()
RemoveVCProcess::RemoveVCProcess() :
configDeleteFlags()
, mScene()
{}

// ------------------------------------------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions code/SortByPTypeProcess.cpp
Expand Up @@ -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");
}
Expand Down
3 changes: 2 additions & 1 deletion code/TextureTransform.cpp
Expand Up @@ -54,7 +54,8 @@ using namespace Assimp;

// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
TextureTransformStep::TextureTransformStep()
TextureTransformStep::TextureTransformStep() :
configFlags()
{
// nothing to do here
}
Expand Down
6 changes: 3 additions & 3 deletions code/ValidateDataStructure.cpp
Expand Up @@ -60,7 +60,8 @@ using namespace Assimp;

// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
ValidateDSProcess::ValidateDSProcess()
ValidateDSProcess::ValidateDSProcess() :
mScene()
{}

// ------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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<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 "
"too small to contain a string (%i, needed: %i)",
i,prop->mDataLength,sizeof(aiString));
Expand Down
9 changes: 8 additions & 1 deletion include/assimp/Exporter.hpp
Expand Up @@ -109,7 +109,14 @@ class ASSIMP_API Exporter
mEnforcePP = pEnforcePP;
}

ExportFormatEntry() : mExportFunction(), mEnforcePP() {}
ExportFormatEntry() :
mExportFunction()
, mEnforcePP()
{
mDescription.id = NULL;
mDescription.description = NULL;
mDescription.fileExtension = NULL;
}
};


Expand Down

0 comments on commit 4cbce37

Please sign in to comment.