From 066349f36b0879208b67cc3c6b40c84d909a1b55 Mon Sep 17 00:00:00 2001 From: kimkulling Date: Thu, 19 Apr 2018 16:48:43 +0200 Subject: [PATCH 01/11] Add usage of log macros. --- code/3DSConverter.cpp | 18 ++++++------- code/3DSExporter.cpp | 2 +- code/3DSLoader.cpp | 40 ++++++++++++++-------------- code/ACLoader.cpp | 38 +++++++++++++------------- code/ASELoader.cpp | 16 +++++------ code/ASEParser.cpp | 26 +++++++++--------- code/B3DImporter.cpp | 2 +- code/BaseImporter.cpp | 50 +++++++++++++++++------------------ code/BaseProcess.cpp | 2 +- code/BlenderDNA.cpp | 9 +++---- code/BlenderDNA.h | 2 +- code/BlenderDNA.inl | 4 +-- code/BlenderLoader.cpp | 4 +-- code/BlenderModifier.h | 2 +- code/COBLoader.cpp | 8 +++--- code/ColladaLoader.cpp | 33 +++++++++++------------ code/ColladaParser.cpp | 32 +++++++++++----------- code/D3MFImporter.cpp | 2 +- code/D3MFOpcPackage.cpp | 2 +- code/DXFLoader.cpp | 14 ++++------ code/Importer.cpp | 23 ++++++++-------- code/SceneCombiner.cpp | 4 +-- code/UnrealLoader.cpp | 10 +++---- include/assimp/BlobIOSystem.h | 2 +- 24 files changed, 168 insertions(+), 177 deletions(-) diff --git a/code/3DSConverter.cpp b/code/3DSConverter.cpp index 081da1bcf..e07ca4c2d 100644 --- a/code/3DSConverter.cpp +++ b/code/3DSConverter.cpp @@ -120,7 +120,7 @@ void Discreet3DSImporter::ReplaceDefaultMaterial() else if ( (*a) >= mScene->mMaterials.size()) { (*a) = idx; - DefaultLogger::get()->warn("Material index overflow in 3DS file. Using default material"); + ASSIMP_LOG_WARN("Material index overflow in 3DS file. Using default material"); ++cnt; } } @@ -132,7 +132,7 @@ void Discreet3DSImporter::ReplaceDefaultMaterial() sMat.mDiffuse = aiColor3D(0.3f,0.3f,0.3f); mScene->mMaterials.push_back(sMat); - DefaultLogger::get()->info("3DS: Generating default material"); + ASSIMP_LOG_INFO("3DS: Generating default material"); } } @@ -147,12 +147,12 @@ void Discreet3DSImporter::CheckIndices(D3DS::Mesh& sMesh) { if ((*i).mIndices[a] >= sMesh.mPositions.size()) { - DefaultLogger::get()->warn("3DS: Vertex index overflow)"); + ASSIMP_LOG_WARN("3DS: Vertex index overflow)"); (*i).mIndices[a] = (uint32_t)sMesh.mPositions.size()-1; } if ( !sMesh.mTexCoords.empty() && (*i).mIndices[a] >= sMesh.mTexCoords.size()) { - DefaultLogger::get()->warn("3DS: Texture coordinate index overflow)"); + ASSIMP_LOG_WARN("3DS: Texture coordinate index overflow)"); (*i).mIndices[a] = (uint32_t)sMesh.mTexCoords.size()-1; } } @@ -497,7 +497,7 @@ void Discreet3DSImporter::AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut, pvCurrent->x *= -1.f; t2->x *= -1.f; } - DefaultLogger::get()->info("3DS: Flipping mesh X-Axis"); + ASSIMP_LOG_INFO("3DS: Flipping mesh X-Axis"); } // Handle pivot point @@ -573,11 +573,11 @@ void Discreet3DSImporter::AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut, pcIn->aTargetPositionKeys.size() > 1) { aiAnimation* anim = pcSOut->mAnimations[0]; - ai_assert(NULL != anim); + ai_assert(nullptr != anim); if (pcIn->aCameraRollKeys.size() > 1) { - DefaultLogger::get()->debug("3DS: Converting camera roll track ..."); + ASSIMP_LOG_DEBUG("3DS: Converting camera roll track ..."); // Camera roll keys - in fact they're just rotations // around the camera's z axis. The angles are given @@ -597,7 +597,7 @@ void Discreet3DSImporter::AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut, #if 0 if (pcIn->aTargetPositionKeys.size() > 1) { - DefaultLogger::get()->debug("3DS: Converting target track ..."); + ASSIMP_LOG_DEBUG("3DS: Converting target track ..."); // Camera or spot light - need to convert the separate // target position channel to our representation @@ -743,7 +743,7 @@ void Discreet3DSImporter::GenerateNodeGraph(aiScene* pcOut) // | | | | | // MESH_0 MESH_1 MESH_2 ... MESH_N CAMERA_0 .... // - DefaultLogger::get()->warn("No hierarchy information has been found in the file. "); + ASSIMP_LOG_WARN("No hierarchy information has been found in the file. "); pcOut->mRootNode->mNumChildren = pcOut->mNumMeshes + static_cast(mScene->mCameras.size() + mScene->mLights.size()); diff --git a/code/3DSExporter.cpp b/code/3DSExporter.cpp index fcd24d8aa..53976b16f 100644 --- a/code/3DSExporter.cpp +++ b/code/3DSExporter.cpp @@ -381,7 +381,7 @@ void Discreet3DSExporter::WriteTexture(const aiMaterial& mat, aiTextureType type // TODO: handle embedded textures properly if (path.data[0] == '*') { - DefaultLogger::get()->error("Ignoring embedded texture for export: " + std::string(path.C_Str())); + ASSIMP_LOG_ERROR("Ignoring embedded texture for export: " + std::string(path.C_Str())); return; } diff --git a/code/3DSLoader.cpp b/code/3DSLoader.cpp index bfe2bf6e5..3c95d8193 100644 --- a/code/3DSLoader.cpp +++ b/code/3DSLoader.cpp @@ -258,8 +258,9 @@ void Discreet3DSImporter::ReadChunk(Discreet3DS::Chunk* pcOut) if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSize()) throw DeadlyImportError("Chunk is too large"); - if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSizeToLimit()) - DefaultLogger::get()->error("3DS: Chunk overflow"); + if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSizeToLimit()) { + ASSIMP_LOG_ERROR("3DS: Chunk overflow"); + } } // ------------------------------------------------------------------------------------------------ @@ -320,7 +321,7 @@ void Discreet3DSImporter::ParseEditorChunk() // print the version number char buff[10]; ASSIMP_itoa10(buff,stream->GetI2()); - DefaultLogger::get()->info(std::string("3DS file format version: ") + buff); + ASSIMP_LOG_INFO_F(std::string("3DS file format version: "), buff); } break; }; @@ -361,7 +362,7 @@ void Discreet3DSImporter::ParseObjectChunk() if (is_qnan(mClrAmbient.r)) { // We failed to read the ambient base color. - DefaultLogger::get()->error("3DS: Failed to read ambient base color"); + ASSIMP_LOG_ERROR("3DS: Failed to read ambient base color"); mClrAmbient.r = mClrAmbient.g = mClrAmbient.b = 0.0f; } break; @@ -463,7 +464,7 @@ void Discreet3DSImporter::ParseChunk(const char* name, unsigned int num) if (len < 1e-5) { // There are some files with lookat == position. Don't know why or whether it's ok or not. - DefaultLogger::get()->error("3DS: Unable to read proper camera look-at vector"); + ASSIMP_LOG_ERROR("3DS: Unable to read proper camera look-at vector"); camera->mLookAt = aiVector3D(0.0,1.0,0.0); } @@ -629,9 +630,9 @@ void Discreet3DSImporter::SkipTCBInfo() if (!flags) { // Currently we can't do anything with these values. They occur // quite rare, so it wouldn't be worth the effort implementing - // them. 3DS ist not really suitable for complex animations, + // them. 3DS is not really suitable for complex animations, // so full support is not required. - DefaultLogger::get()->warn("3DS: Skipping TCB animation info"); + ASSIMP_LOG_WARN("3DS: Skipping TCB animation info"); } if (flags & Discreet3DS::KEY_USE_TENS) { @@ -732,7 +733,6 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent) // If object name is DUMMY, take this one instead if (mCurrentNode->mName == "$$$DUMMY") { - //DefaultLogger::get()->warn("3DS: Skipping dummy object name for non-dummy object"); mCurrentNode->mName = std::string(sz); break; } @@ -743,7 +743,7 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent) if ( Discreet3DS::CHUNK_TRACKINFO != parent) { - DefaultLogger::get()->warn("3DS: Skipping pivot subchunk for non usual object"); + ASSIMP_LOG_WARN("3DS: Skipping pivot subchunk for non usual object"); break; } @@ -805,7 +805,7 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent) { // roll keys are accepted for cameras only if (parent != Discreet3DS::CHUNK_TRACKCAMERA) { - DefaultLogger::get()->warn("3DS: Ignoring roll track for non-camera object"); + ASSIMP_LOG_WARN("3DS: Ignoring roll track for non-camera object"); break; } bool sortKeys = false; @@ -845,7 +845,7 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent) // CAMERA FOV KEYFRAME case Discreet3DS::CHUNK_TRACKFOV: { - DefaultLogger::get()->error("3DS: Skipping FOV animation track. " + ASSIMP_LOG_ERROR("3DS: Skipping FOV animation track. " "This is not supported"); } break; @@ -985,7 +985,7 @@ void Discreet3DSImporter::ParseFaceChunk() } } if (0xcdcdcdcd == idx) { - DefaultLogger::get()->error(std::string("3DS: Unknown material: ") + sz); + ASSIMP_LOG_ERROR_F( "3DS: Unknown material: ", sz); } // Now continue and read all material indices @@ -995,7 +995,7 @@ void Discreet3DSImporter::ParseFaceChunk() // check range if (fidx >= mMesh.mFaceMaterials.size()) { - DefaultLogger::get()->error("3DS: Invalid face index in face material list"); + ASSIMP_LOG_ERROR("3DS: Invalid face index in face material list"); } else mMesh.mFaceMaterials[fidx] = idx; }} @@ -1110,7 +1110,7 @@ void Discreet3DSImporter::ParseMaterialChunk() if (!cnt) { // This may not be, we use the default name instead - DefaultLogger::get()->error("3DS: Empty material name"); + ASSIMP_LOG_ERROR("3DS: Empty material name"); } else mScene->mMaterials.back().mName = std::string(sz,cnt); } @@ -1123,7 +1123,7 @@ void Discreet3DSImporter::ParseMaterialChunk() ParseColorChunk(pc); if (is_qnan(pc->r)) { // color chunk is invalid. Simply ignore it - DefaultLogger::get()->error("3DS: Unable to read DIFFUSE chunk"); + ASSIMP_LOG_ERROR("3DS: Unable to read DIFFUSE chunk"); pc->r = pc->g = pc->b = 1.0f; }} break; @@ -1135,7 +1135,7 @@ void Discreet3DSImporter::ParseMaterialChunk() ParseColorChunk(pc); if (is_qnan(pc->r)) { // color chunk is invalid. Simply ignore it - DefaultLogger::get()->error("3DS: Unable to read SPECULAR chunk"); + ASSIMP_LOG_ERROR("3DS: Unable to read SPECULAR chunk"); pc->r = pc->g = pc->b = 1.0f; }} break; @@ -1147,7 +1147,7 @@ void Discreet3DSImporter::ParseMaterialChunk() ParseColorChunk(pc); if (is_qnan(pc->r)) { // color chunk is invalid. Simply ignore it - DefaultLogger::get()->error("3DS: Unable to read AMBIENT chunk"); + ASSIMP_LOG_ERROR("3DS: Unable to read AMBIENT chunk"); pc->r = pc->g = pc->b = 0.0f; }} break; @@ -1159,7 +1159,7 @@ void Discreet3DSImporter::ParseMaterialChunk() ParseColorChunk(pc); if (is_qnan(pc->r)) { // color chunk is invalid. Simply ignore it - DefaultLogger::get()->error("3DS: Unable to read EMISSIVE chunk"); + ASSIMP_LOG_ERROR("3DS: Unable to read EMISSIVE chunk"); pc->r = pc->g = pc->b = 0.0f; }} break; @@ -1293,7 +1293,7 @@ void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut) pcOut->mScaleU = stream->GetF4(); if (0.0f == pcOut->mScaleU) { - DefaultLogger::get()->warn("Texture coordinate scaling in the x direction is zero. Assuming 1."); + ASSIMP_LOG_WARN("Texture coordinate scaling in the x direction is zero. Assuming 1."); pcOut->mScaleU = 1.0f; } break; @@ -1302,7 +1302,7 @@ void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut) pcOut->mScaleV = stream->GetF4(); if (0.0f == pcOut->mScaleV) { - DefaultLogger::get()->warn("Texture coordinate scaling in the y direction is zero. Assuming 1."); + ASSIMP_LOG_WARN("Texture coordinate scaling in the y direction is zero. Assuming 1."); pcOut->mScaleV = 1.0f; } break; diff --git a/code/ACLoader.cpp b/code/ACLoader.cpp index 3f8653d5d..7b8afbe9b 100644 --- a/code/ACLoader.cpp +++ b/code/ACLoader.cpp @@ -85,7 +85,7 @@ static const aiImporterDesc desc = { #define AI_AC_SKIP_TO_NEXT_TOKEN() \ if (!SkipSpaces(&buffer)) \ { \ - DefaultLogger::get()->error("AC3D: Unexpected EOF/EOL"); \ + ASSIMP_LOG_ERROR("AC3D: Unexpected EOF/EOL"); \ continue; \ } @@ -101,7 +101,7 @@ static const aiImporterDesc desc = { { \ if (IsLineEnd( *buffer )) \ { \ - DefaultLogger::get()->error("AC3D: Unexpected EOF/EOL in string"); \ + ASSIMP_LOG_ERROR("AC3D: Unexpected EOF/EOL in string"); \ out = "ERROR"; \ break; \ } \ @@ -120,7 +120,7 @@ static const aiImporterDesc desc = { { \ if (strncmp(buffer,name,name_length) || !IsSpace(buffer[name_length])) \ { \ - DefaultLogger::get()->error("AC3D: Unexpexted token. " name " was expected."); \ + ASSIMP_LOG_ERROR("AC3D: Unexpexted token. " name " was expected."); \ continue; \ } \ buffer += name_length+1; \ @@ -217,7 +217,7 @@ void AC3DImporter::LoadObjectSection(std::vector& objects) light->mName.length = ::ai_snprintf(light->mName.data, MAXLEN, "ACLight_%i",static_cast(mLights->size())-1); obj.name = std::string( light->mName.data ); - DefaultLogger::get()->debug("AC3D: Light source encountered"); + ASSIMP_LOG_DEBUG("AC3D: Light source encountered"); obj.type = Object::Light; } else if (!ASSIMP_strincmp(buffer,"group",5)) @@ -307,12 +307,12 @@ void AC3DImporter::LoadObjectSection(std::vector& objects) { if (!GetNextLine()) { - DefaultLogger::get()->error("AC3D: Unexpected EOF: not all vertices have been parsed yet"); + ASSIMP_LOG_ERROR("AC3D: Unexpected EOF: not all vertices have been parsed yet"); break; } else if (!IsNumeric(*buffer)) { - DefaultLogger::get()->error("AC3D: Unexpected token: not all vertices have been parsed yet"); + ASSIMP_LOG_ERROR("AC3D: Unexpected token: not all vertices have been parsed yet"); --buffer; // make sure the line is processed a second time break; } @@ -338,8 +338,8 @@ void AC3DImporter::LoadObjectSection(std::vector& objects) // example writes no surf chunks if (!Q3DWorkAround) { - DefaultLogger::get()->warn("AC3D: SURF token was expected"); - DefaultLogger::get()->debug("Continuing with Quick3D Workaround enabled"); + ASSIMP_LOG_WARN("AC3D: SURF token was expected"); + ASSIMP_LOG_DEBUG("Continuing with Quick3D Workaround enabled"); } --buffer; // make sure the line is processed a second time // break; --- see fix notes above @@ -384,7 +384,7 @@ void AC3DImporter::LoadObjectSection(std::vector& objects) { if(!GetNextLine()) { - DefaultLogger::get()->error("AC3D: Unexpected EOF: surface references are incomplete"); + ASSIMP_LOG_ERROR("AC3D: Unexpected EOF: surface references are incomplete"); break; } surf.entries.push_back(Surface::SurfaceEntry()); @@ -405,7 +405,7 @@ void AC3DImporter::LoadObjectSection(std::vector& objects) } } } - DefaultLogger::get()->error("AC3D: Unexpected EOF: \'kids\' line was expected"); + ASSIMP_LOG_ERROR("AC3D: Unexpected EOF: \'kids\' line was expected"); } // ------------------------------------------------------------------------------------------------ @@ -478,7 +478,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object, therefore: if no surfaces are defined return point data only */ - DefaultLogger::get()->info("AC3D: No surfaces defined in object definition, " + ASSIMP_LOG_INFO("AC3D: No surfaces defined in object definition, " "a point list is returned"); meshes.push_back(new aiMesh()); @@ -519,12 +519,12 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object, unsigned int idx = (*it).mat; if (idx >= needMat.size()) { - DefaultLogger::get()->error("AC3D: material index is out of range"); + ASSIMP_LOG_ERROR("AC3D: material index is out of range"); idx = 0; } if ((*it).entries.empty()) { - DefaultLogger::get()->warn("AC3D: surface her zero vertex references"); + ASSIMP_LOG_WARN("AC3D: surface her zero vertex references"); } // validate all vertex indices to make sure we won't crash here @@ -533,7 +533,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object, { if ((*it2).first >= object.vertices.size()) { - DefaultLogger::get()->warn("AC3D: Invalid vertex reference"); + ASSIMP_LOG_WARN("AC3D: Invalid vertex reference"); (*it2).first = 0; } } @@ -561,7 +561,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object, if ((*it).flags & 0xf) { - DefaultLogger::get()->warn("AC3D: The type flag of a surface is unknown"); + ASSIMP_LOG_WARN("AC3D: The type flag of a surface is unknown"); (*it).flags &= ~(0xf); } @@ -712,7 +712,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object, if (object.subDiv) { if (configEvalSubdivision) { std::unique_ptr div(Subdivider::Create(Subdivider::CATMULL_CLARKE)); - DefaultLogger::get()->info("AC3D: Evaluating subdivision surface: "+object.name); + ASSIMP_LOG_INFO("AC3D: Evaluating subdivision surface: "+object.name); std::vector cpy(meshes.size()-oldm,NULL); div->Subdivide(&meshes[oldm],cpy.size(),&cpy.front(),object.subDiv,true); @@ -721,7 +721,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object, // previous meshes are deleted vy Subdivide(). } else { - DefaultLogger::get()->info("AC3D: Letting the subdivision surface untouched due to my configuration: " + ASSIMP_LOG_INFO("AC3D: Letting the subdivision surface untouched due to my configuration: " +object.name); } } @@ -813,7 +813,7 @@ void AC3DImporter::InternReadFile( const std::string& pFile, unsigned int version = HexDigitToDecimal( buffer[4] ); char msg[3]; ASSIMP_itoa10(msg,3,version); - DefaultLogger::get()->info(std::string("AC3D file format version: ") + msg); + ASSIMP_LOG_INFO_F("AC3D file format version: ", msg); std::vector materials; materials.reserve(5); @@ -857,7 +857,7 @@ void AC3DImporter::InternReadFile( const std::string& pFile, } if (materials.empty()) { - DefaultLogger::get()->warn("AC3D: No material has been found"); + ASSIMP_LOG_WARN("AC3D: No material has been found"); materials.push_back(Material()); } diff --git a/code/ASELoader.cpp b/code/ASELoader.cpp index 32b0eae2d..1808f25e2 100644 --- a/code/ASELoader.cpp +++ b/code/ASELoader.cpp @@ -200,7 +200,7 @@ void ASEImporter::InternReadFile( const std::string& pFile, ConvertMeshes(*i,avOutMeshes); } if (tookNormals) { - DefaultLogger::get()->debug("ASE: Taking normals from the file. Use " + ASSIMP_LOG_DEBUG("ASE: Taking normals from the file. Use " "the AI_CONFIG_IMPORT_ASE_RECONSTRUCT_NORMALS setting if you " "experience problems"); } @@ -297,15 +297,15 @@ void ASEImporter::BuildAnimations(const std::vector& nodes) // TODO: Implement Bezier & TCB support if ((*i)->mAnim.mPositionType != ASE::Animation::TRACK) { - DefaultLogger::get()->warn("ASE: Position controller uses Bezier/TCB keys. " + ASSIMP_LOG_WARN("ASE: Position controller uses Bezier/TCB keys. " "This is not supported."); } if ((*i)->mAnim.mRotationType != ASE::Animation::TRACK) { - DefaultLogger::get()->warn("ASE: Rotation controller uses Bezier/TCB keys. " + ASSIMP_LOG_WARN("ASE: Rotation controller uses Bezier/TCB keys. " "This is not supported."); } if ((*i)->mAnim.mScalingType != ASE::Animation::TRACK) { - DefaultLogger::get()->warn("ASE: Position controller uses Bezier/TCB keys. " + ASSIMP_LOG_WARN("ASE: Position controller uses Bezier/TCB keys. " "This is not supported."); } @@ -624,7 +624,7 @@ void ASEImporter::AddNodes (const std::vector& nodes, node->mNumChildren++; // What we did is so great, it is at least worth a debug message - DefaultLogger::get()->debug("ASE: Generating separate target node ("+snode->mName+")"); + ASSIMP_LOG_DEBUG("ASE: Generating separate target node ("+snode->mName+")"); } } @@ -947,7 +947,7 @@ void ASEImporter::ConvertMeshes(ASE::Mesh& mesh, std::vector& avOutMesh // validate the material index of the mesh if (mesh.iMaterialIndex >= mParser->m_vMaterials.size()) { mesh.iMaterialIndex = (unsigned int)mParser->m_vMaterials.size()-1; - DefaultLogger::get()->warn("Material index is out of range"); + ASSIMP_LOG_WARN("Material index is out of range"); } // If the material the mesh is assigned to is consisting of submeshes, split it @@ -957,11 +957,11 @@ void ASEImporter::ConvertMeshes(ASE::Mesh& mesh, std::vector& avOutMesh std::vector* aiSplit = new std::vector[vSubMaterials.size()]; - // build a list of all faces per submaterial + // build a list of all faces per sub-material for (unsigned int i = 0; i < mesh.mFaces.size();++i) { // check range if (mesh.mFaces[i].iMaterial >= vSubMaterials.size()) { - DefaultLogger::get()->warn("Submaterial index is out of range"); + ASSIMP_LOG_WARN("Submaterial index is out of range"); // use the last material instead aiSplit[vSubMaterials.size()-1].push_back(i); diff --git a/code/ASEParser.cpp b/code/ASEParser.cpp index b953f8d96..298c6fe61 100644 --- a/code/ASEParser.cpp +++ b/code/ASEParser.cpp @@ -151,7 +151,7 @@ void Parser::LogWarning(const char* szWarn) #endif // output the warning to the logger ... - DefaultLogger::get()->warn(szTemp); + ASSIMP_LOG_WARN(szTemp); } // ------------------------------------------------------------------------------------------------ @@ -167,7 +167,7 @@ void Parser::LogInfo(const char* szWarn) #endif // output the information to the logger ... - DefaultLogger::get()->info(szTemp); + ASSIMP_LOG_INFO(szTemp); } // ------------------------------------------------------------------------------------------------ @@ -758,7 +758,7 @@ void Parser::ParseLV3MapBlock(Texture& map) SkipToNextToken(); if (temp != "Bitmap" && temp != "Normal Bump") { - DefaultLogger::get()->warn("ASE: Skipping unknown map type: " + temp); + ASSIMP_LOG_WARN_F("ASE: Skipping unknown map type: ", temp); parsePath = false; } continue; @@ -773,7 +773,7 @@ void Parser::ParseLV3MapBlock(Texture& map) { // Files with 'None' as map name are produced by // an Maja to ASE exporter which name I forgot .. - DefaultLogger::get()->warn("ASE: Skipping invalid map entry"); + ASSIMP_LOG_WARN("ASE: Skipping invalid map entry"); map.mMapName = ""; } @@ -1072,7 +1072,7 @@ void Parser::ParseLV2AnimationBlock(ASE::BaseNode& mesh) ( mesh.mType != BaseNode::Light || ((ASE::Light&)mesh).mLightType != ASE::Light::TARGET)) { - DefaultLogger::get()->error("ASE: Found target animation channel " + ASSIMP_LOG_ERROR("ASE: Found target animation channel " "but the node is neither a camera nor a spot light"); anim = NULL; } @@ -1098,7 +1098,7 @@ void Parser::ParseLV2AnimationBlock(ASE::BaseNode& mesh) if (!anim || anim == &mesh.mTargetAnim) { // Target animation channels may have no rotation channels - DefaultLogger::get()->error("ASE: Ignoring scaling channel in target animation"); + ASSIMP_LOG_ERROR("ASE: Ignoring scaling channel in target animation"); SkipSection(); } else ParseLV3ScaleAnimationBlock(*anim); @@ -1112,7 +1112,7 @@ void Parser::ParseLV2AnimationBlock(ASE::BaseNode& mesh) if (!anim || anim == &mesh.mTargetAnim) { // Target animation channels may have no rotation channels - DefaultLogger::get()->error("ASE: Ignoring rotation channel in target animation"); + ASSIMP_LOG_ERROR("ASE: Ignoring rotation channel in target animation"); SkipSection(); } else ParseLV3RotAnimationBlock(*anim); @@ -1295,12 +1295,14 @@ void Parser::ParseLV2NodeTransformBlock(ASE::BaseNode& mesh) { mode = 2; } - else DefaultLogger::get()->error("ASE: Ignoring target transform, " - "this is no spot light or target camera"); + else { + ASSIMP_LOG_ERROR("ASE: Ignoring target transform, " + "this is no spot light or target camera"); + } } else { - DefaultLogger::get()->error("ASE: Unknown node transformation: " + temp); + ASSIMP_LOG_ERROR("ASE: Unknown node transformation: " + temp); // mode = 0 } continue; @@ -1916,7 +1918,7 @@ void Parser::ParseLV3MeshNormalListBlock(ASE::Mesh& sMesh) else if (index == face.mIndices[2]) index = 2; else { - DefaultLogger::get()->error("ASE: Invalid vertex index in MESH_VERTEXNORMAL section"); + ASSIMP_LOG_ERROR("ASE: Invalid vertex index in MESH_VERTEXNORMAL section"); continue; } // We'll renormalize later @@ -1928,7 +1930,7 @@ void Parser::ParseLV3MeshNormalListBlock(ASE::Mesh& sMesh) ParseLV4MeshFloatTriple(&vNormal.x,faceIdx); if (faceIdx >= sMesh.mFaces.size()) { - DefaultLogger::get()->error("ASE: Invalid vertex index in MESH_FACENORMAL section"); + ASSIMP_LOG_ERROR("ASE: Invalid vertex index in MESH_FACENORMAL section"); continue; } diff --git a/code/B3DImporter.cpp b/code/B3DImporter.cpp index e4572f8eb..ce8bd5159 100644 --- a/code/B3DImporter.cpp +++ b/code/B3DImporter.cpp @@ -614,7 +614,7 @@ void B3DImporter::ReadBB3D( aiScene *scene ){ if (!DefaultLogger::isNullLogger()) { char dmp[128]; ai_snprintf(dmp, 128, "B3D file format version: %i",version); - DefaultLogger::get()->info(dmp); + ASSIMP_LOG_INFO(dmp); } while( ChunkSize() ){ diff --git a/code/BaseImporter.cpp b/code/BaseImporter.cpp index 4782e9e2d..fa9f70603 100644 --- a/code/BaseImporter.cpp +++ b/code/BaseImporter.cpp @@ -64,23 +64,24 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer BaseImporter::BaseImporter() -: m_progress() -{ +: m_progress() { // nothing to do here } // ------------------------------------------------------------------------------------------------ // Destructor, private as well -BaseImporter::~BaseImporter() -{ +BaseImporter::~BaseImporter() { // nothing to do here } // ------------------------------------------------------------------------------------------------ // Imports the given file and returns the imported data. -aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile, IOSystem* pIOHandler) -{ +aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile, IOSystem* pIOHandler) { m_progress = pImp->GetProgressHandler(); + if (nullptr == m_progress) { + return nullptr; + } + ai_assert(m_progress); // Gather configuration properties for this run @@ -100,8 +101,8 @@ aiScene* BaseImporter::ReadFile(const Importer* pImp, const std::string& pFile, } catch( const std::exception& err ) { // extract error description m_ErrorText = err.what(); - DefaultLogger::get()->error(m_ErrorText); - return NULL; + ASSIMP_LOG_ERROR(m_ErrorText); + return nullptr; } // return what we gathered from the import. @@ -195,7 +196,7 @@ void BaseImporter::GetExtensionList(std::set& extensions) { // We got a match, either we don't care where it is, or it happens to // be in the beginning of the file / line if (!tokensSol || r == buffer || r[-1] == '\r' || r[-1] == '\n') { - DefaultLogger::get()->debug(std::string("Found positive match for header keyword: ") + tokens[i]); + ASSIMP_LOG_DEBUG_F( "Found positive match for header keyword: ", tokens[i] ); return true; } } @@ -322,7 +323,7 @@ void BaseImporter::ConvertToUTF8(std::vector& data) // UTF 8 with BOM if((uint8_t)data[0] == 0xEF && (uint8_t)data[1] == 0xBB && (uint8_t)data[2] == 0xBF) { - DefaultLogger::get()->debug("Found UTF-8 BOM ..."); + ASSIMP_LOG_DEBUG("Found UTF-8 BOM ..."); std::copy(data.begin()+3,data.end(),data.begin()); data.resize(data.size()-3); @@ -341,7 +342,7 @@ void BaseImporter::ConvertToUTF8(std::vector& data) // UTF 32 LE with BOM if(*((uint32_t*)&data.front()) == 0x0000FFFE) { - DefaultLogger::get()->debug("Found UTF-32 BOM ..."); + ASSIMP_LOG_DEBUG("Found UTF-32 BOM ..."); std::vector output; int *ptr = (int*)&data[ 0 ]; @@ -361,7 +362,7 @@ void BaseImporter::ConvertToUTF8(std::vector& data) // UTF 16 LE with BOM if(*((uint16_t*)&data.front()) == 0xFEFF) { - DefaultLogger::get()->debug("Found UTF-16 BOM ..."); + ASSIMP_LOG_DEBUG("Found UTF-16 BOM ..."); std::vector output; utf8::utf16to8(data.begin(), data.end(), back_inserter(output)); @@ -386,16 +387,14 @@ void BaseImporter::ConvertUTF8toISO8859_1(std::string& data) data[j] = ((unsigned char) data[++i] + 0x40); } else { std::stringstream stream; - stream << "UTF8 code " << std::hex << data[i] << data[i + 1] << " can not be converted into ISA-8859-1."; - - DefaultLogger::get()->error(stream.str()); + ASSIMP_LOG_ERROR( stream.str() ); data[j++] = data[i++]; data[j] = data[i]; } } else { - DefaultLogger::get()->error("UTF8 code but only one character remaining"); + ASSIMP_LOG_ERROR("UTF8 code but only one character remaining"); data[j] = data[i]; } @@ -411,7 +410,7 @@ void BaseImporter::TextFileToBuffer(IOStream* stream, std::vector& data, TextFileMode mode) { - ai_assert(NULL != stream); + ai_assert(nullptr != stream); const size_t fileSize = stream->FileSize(); if (mode == FORBID_EMPTY) { @@ -472,14 +471,14 @@ struct Assimp::BatchData { , pImporter( nullptr ) , next_id(0xffff) , validate( validate ) { - ai_assert( NULL != pIO ); + ai_assert( nullptr != pIO ); pImporter = new Importer(); pImporter->SetIOHandler( pIO ); } ~BatchData() { - pImporter->SetIOHandler( NULL ); /* get pointer back into our possession */ + pImporter->SetIOHandler( nullptr ); /* get pointer back into our possession */ delete pImporter; } @@ -505,9 +504,8 @@ struct Assimp::BatchData { typedef std::list::iterator LoadReqIt; // ------------------------------------------------------------------------------------------------ -BatchLoader::BatchLoader(IOSystem* pIO, bool validate ) -{ - ai_assert(NULL != pIO); +BatchLoader::BatchLoader(IOSystem* pIO, bool validate ) { + ai_assert(nullptr != pIO); m_data = new BatchData( pIO, validate ); } @@ -573,7 +571,7 @@ aiScene* BatchLoader::GetImport( unsigned int which ) return sc; } } - return NULL; + return nullptr; } // ------------------------------------------------------------------------------------------------ @@ -596,13 +594,13 @@ void BatchLoader::LoadAll() if (!DefaultLogger::isNullLogger()) { - DefaultLogger::get()->info("%%% BEGIN EXTERNAL FILE %%%"); - DefaultLogger::get()->info("File: " + (*it).file); + ASSIMP_LOG_INFO("%%% BEGIN EXTERNAL FILE %%%"); + ASSIMP_LOG_INFO("File: ", (*it).file); } m_data->pImporter->ReadFile((*it).file,pp); (*it).scene = m_data->pImporter->GetOrphanedScene(); (*it).loaded = true; - DefaultLogger::get()->info("%%% END EXTERNAL FILE %%%"); + ASSIMP_LOG_INFO("%%% END EXTERNAL FILE %%%"); } } diff --git a/code/BaseProcess.cpp b/code/BaseProcess.cpp index 8508f59e4..ba968a819 100644 --- a/code/BaseProcess.cpp +++ b/code/BaseProcess.cpp @@ -85,7 +85,7 @@ void BaseProcess::ExecuteOnScene( Importer* pImp) // extract error description pImp->Pimpl()->mErrorString = err.what(); - DefaultLogger::get()->error(pImp->Pimpl()->mErrorString); + ASSIMP_LOG_ERROR(pImp->Pimpl()->mErrorString); // and kill the partially imported data delete pImp->Pimpl()->mScene; diff --git a/code/BlenderDNA.cpp b/code/BlenderDNA.cpp index 1d88f8fa6..0bca902c6 100644 --- a/code/BlenderDNA.cpp +++ b/code/BlenderDNA.cpp @@ -210,8 +210,7 @@ void DNAParser::Parse () s.size = offset; } - DefaultLogger::get()->debug((format(),"BlenderDNA: Got ",dna.structures.size(), - " structures with totally ",fields," fields")); + ASSIMP_LOG_DEBUG( "BlenderDNA: Got ", dna.structures.size()," structures with totally ",fields," fields"); #ifdef ASSIMP_BUILD_BLENDER_DEBUG dna.DumpToFile(); @@ -233,7 +232,7 @@ void DNA :: DumpToFile() std::ofstream f("dna.txt"); if (f.fail()) { - DefaultLogger::get()->error("Could not dump dna to dna.txt"); + ASSIMP_LOG_ERROR("Could not dump dna to dna.txt"); return; } f << "Field format: type name offset size" << "\n"; @@ -248,7 +247,7 @@ void DNA :: DumpToFile() } f << std::flush; - DefaultLogger::get()->info("BlenderDNA: Dumped dna to dna.txt"); + ASSIMP_LOG_INFO("BlenderDNA: Dumped dna to dna.txt"); } #endif @@ -367,7 +366,7 @@ void SectionParser :: Next() } #ifdef ASSIMP_BUILD_BLENDER_DEBUG - DefaultLogger::get()->debug(current.id); + ASSIMP_LOG_DEBUG(current.id); #endif } diff --git a/code/BlenderDNA.h b/code/BlenderDNA.h index 3a2455275..4a1e83b64 100644 --- a/code/BlenderDNA.h +++ b/code/BlenderDNA.h @@ -381,7 +381,7 @@ template <> struct Structure :: _defaultInitializer { template void operator ()(T& out, const char* reason = "") { - DefaultLogger::get()->warn(reason); + ASSIMP_LOG_WARN(reason); // ... and let the show go on _defaultInitializer<0 /*ErrorPolicy_Igno*/>()(out); diff --git a/code/BlenderDNA.inl b/code/BlenderDNA.inl index 163798a40..1f345b631 100644 --- a/code/BlenderDNA.inl +++ b/code/BlenderDNA.inl @@ -468,9 +468,7 @@ template <> bool Structure :: ResolvePointer(std::shar // this might happen if DNA::RegisterConverters hasn't been called so far // or if the target type is not contained in `our` DNA. out.reset(); - DefaultLogger::get()->warn((Formatter::format(), - "Failed to find a converter for the `",s.name,"` structure" - )); + ASSIMP_LOG_WARN( "Failed to find a converter for the `",s.name,"` structure" ); return false; } diff --git a/code/BlenderLoader.cpp b/code/BlenderLoader.cpp index d4d6473c5..71880e3ac 100644 --- a/code/BlenderLoader.cpp +++ b/code/BlenderLoader.cpp @@ -327,12 +327,12 @@ void BlenderImporter::ExtractScene(Scene& out, const FileDatabase& file) ss.Convert(out,file); #ifndef ASSIMP_BUILD_BLENDER_NO_STATS - DefaultLogger::get()->info((format(), + ASSIMP_LOG_INFO_F( "(Stats) Fields read: " ,file.stats().fields_read, ", pointers resolved: " ,file.stats().pointers_resolved, ", cache hits: " ,file.stats().cache_hits, ", cached objects: " ,file.stats().cached_objects - )); + ); #endif } diff --git a/code/BlenderModifier.h b/code/BlenderModifier.h index cd34659c9..1b0976b1e 100644 --- a/code/BlenderModifier.h +++ b/code/BlenderModifier.h @@ -86,7 +86,7 @@ public: const Scene& /*in*/, const Object& /*orig_object*/ ) { - DefaultLogger::get()->warn((Formatter::format("This modifier is not supported, skipping: "),orig_modifier.dna_type)); + ASSIMP_LOG_INFO_F("This modifier is not supported, skipping: "),orig_modifier.dna_type); return; } }; diff --git a/code/COBLoader.cpp b/code/COBLoader.cpp index 222088cbd..ae65f8f93 100644 --- a/code/COBLoader.cpp +++ b/code/COBLoader.cpp @@ -150,7 +150,7 @@ void COBImporter::InternReadFile( const std::string& pFile, ThrowException("Could not found magic id: `Caligari`"); } - DefaultLogger::get()->info("File format tag: "+std::string(head+9,6)); + ASSIMP_LOG_INFO_F("File format tag: ",std::string(head+9,6)); if (head[16]!='L') { ThrowException("File is big-endian, which is not supported"); } @@ -303,7 +303,7 @@ aiNode* COBImporter::BuildNodes(const Node& root,const Scene& scin,aiScene* fill } std::unique_ptr defmat; if(!min) { - DefaultLogger::get()->debug(format()<<"Could not resolve material index " + ASSIMP_LOG_DEBUG(format()<<"Could not resolve material index " <(-1)) { - DefaultLogger::get()->error(error); + ASSIMP_LOG_ERROR(error); // (HACK) - our current position in the stream is the beginning of the // head line of the next chunk. That's fine, but the caller is going @@ -935,7 +935,7 @@ void COBImporter::UnsupportedChunk_Binary( StreamReaderLE& reader, const ChunkIn // we can recover if the chunk size was specified. if(nfo.size != static_cast(-1)) { - DefaultLogger::get()->error(error); + ASSIMP_LOG_ERROR(error); reader.IncPtr(nfo.size); } else ThrowException(error); diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 4bb5f4521..a26df1898 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -294,7 +294,7 @@ void ColladaLoader::ResolveNodeInstances( const ColladaParser& pParser, const Co nd = FindNode(pParser.mRootNode, nodeInst.mNode); } if (!nd) - DefaultLogger::get()->error("Collada: Unable to resolve reference to instanced node " + nodeInst.mNode); + ASSIMP_LOG_ERROR_F("Collada: Unable to resolve reference to instanced node ", nodeInst.mNode); else { // attach this node to the list of children @@ -311,7 +311,7 @@ void ColladaLoader::ApplyVertexToEffectSemanticMapping(Collada::Sampler& sampler std::map::const_iterator it = table.mMap.find(sampler.mUVChannel); if (it != table.mMap.end()) { if (it->second.mType != Collada::IT_Texcoord) - DefaultLogger::get()->error("Collada: Unexpected effect input mapping"); + ASSIMP_LOG_ERROR("Collada: Unexpected effect input mapping"); sampler.mUVId = it->second.mSet; } @@ -327,7 +327,7 @@ void ColladaLoader::BuildLightsForNode( const ColladaParser& pParser, const Coll ColladaParser::LightLibrary::const_iterator srcLightIt = pParser.mLightLibrary.find( lid.mLight); if( srcLightIt == pParser.mLightLibrary.end()) { - DefaultLogger::get()->warn("Collada: Unable to find light for ID \"" + lid.mLight + "\". Skipping."); + ASSIMP_LOG_WARN_F("Collada: Unable to find light for ID \"" , lid.mLight , "\". Skipping."); continue; } const Collada::Light* srcLight = &srcLightIt->second; @@ -395,14 +395,14 @@ void ColladaLoader::BuildCamerasForNode( const ColladaParser& pParser, const Col ColladaParser::CameraLibrary::const_iterator srcCameraIt = pParser.mCameraLibrary.find( cid.mCamera); if( srcCameraIt == pParser.mCameraLibrary.end()) { - DefaultLogger::get()->warn("Collada: Unable to find camera for ID \"" + cid.mCamera + "\". Skipping."); + ASSIMP_LOG_WARN_F("Collada: Unable to find camera for ID \"" , cid.mCamera , "\". Skipping."); continue; } const Collada::Camera* srcCamera = &srcCameraIt->second; // orthographic cameras not yet supported in Assimp if (srcCamera->mOrtho) { - DefaultLogger::get()->warn("Collada: Orthographic cameras are not supported."); + ASSIMP_LOG_WARN("Collada: Orthographic cameras are not supported."); } // now fill our ai data structure @@ -472,7 +472,7 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll if( !srcMesh) { - DefaultLogger::get()->warn( format() << "Collada: Unable to find geometry for ID \"" << mid.mMeshOrController << "\". Skipping." ); + ASSIMP_LOG_WARN( "Collada: Unable to find geometry for ID \"", mid.mMeshOrController, "\". Skipping." ); continue; } } else @@ -501,7 +501,8 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll } else { - DefaultLogger::get()->warn( format() << "Collada: No material specified for subgroup <" << submesh.mMaterial << "> in geometry <" << mid.mMeshOrController << ">." ); + ASSIMP_LOG_WARN_F( "Collada: No material specified for subgroup <", submesh.mMaterial, "> in geometry <", + mid.mMeshOrController, ">." ); if( !mid.mMaterials.empty() ) meshMaterial = mid.mMaterials.begin()->second.mMatName; } @@ -874,7 +875,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada:: if( bnode) bone->mName.Set( FindNameForNode( bnode)); else - DefaultLogger::get()->warn( format() << "ColladaLoader::CreateMesh(): could not find corresponding node for joint \"" << bone->mName.data << "\"." ); + ASSIMP_LOG_WARN( "ColladaLoader::CreateMesh(): could not find corresponding node for joint \"", bone->mName.data, "\"." ); // and insert bone dstMesh->mBones[boneCount++] = bone; @@ -1175,7 +1176,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars else if( subElement == "Z") entry.mSubElement = 2; else - DefaultLogger::get()->warn( format() << "Unknown anim subelement <" << subElement << ">. Ignoring" ); + ASSIMP_LOG_WARN( "Unknown anim subelement <", subElement, ">. Ignoring" ); } else { // no subelement following, transformId is remaining string @@ -1406,7 +1407,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars anims.push_back( dstAnim); } else { - DefaultLogger::get()->warn( "Collada loader: found empty animation channel, ignored. Please check your exporter."); + ASSIMP_LOG_WARN( "Collada loader: found empty animation channel, ignored. Please check your exporter."); } if( !entries.empty() && entries.front().mTimeAccessor->mCount > 0 ) @@ -1561,7 +1562,7 @@ void ColladaLoader::AddTexture ( aiMaterial& mat, const ColladaParser& pParser, } } if (-1 == map) { - DefaultLogger::get()->warn("Collada: unable to determine UV channel for texture"); + ASSIMP_LOG_WARN("Collada: unable to determine UV channel for texture"); map = 0; } } @@ -1598,7 +1599,7 @@ void ColladaLoader::FillMaterials( const ColladaParser& pParser, aiScene* /*pSce break; default: - DefaultLogger::get()->warn("Collada: Unrecognized shading mode, using gouraud shading"); + ASSIMP_LOG_WARN("Collada: Unrecognized shading mode, using gouraud shading"); shadeMode = aiShadingMode_Gouraud; break; } @@ -1752,11 +1753,7 @@ aiString ColladaLoader::FindFilenameForEffectTexture( const ColladaParser& pPars ColladaParser::ImageLibrary::const_iterator imIt = pParser.mImageLibrary.find( name); if( imIt == pParser.mImageLibrary.end()) { - //missing texture should not stop the conversion - //throw DeadlyImportError( format() << - // "Collada: Unable to resolve effect texture entry \"" << pName << "\", ended up at ID \"" << name << "\"." ); - - DefaultLogger::get()->warn("Collada: Unable to resolve effect texture entry \"" + pName + "\", ended up at ID \"" + name + "\"."); + ASSIMP_LOG_WARN_F("Collada: Unable to resolve effect texture entry \"", pName, "\", ended up at ID \"", name, "\"."); //set default texture file name result.Set(name + ".jpg"); @@ -1775,7 +1772,7 @@ aiString ColladaLoader::FindFilenameForEffectTexture( const ColladaParser& pPars // setup format hint if (imIt->second.mEmbeddedFormat.length() > 3) { - DefaultLogger::get()->warn("Collada: texture format hint is too long, truncating to 3 characters"); + ASSIMP_LOG_WARN("Collada: texture format hint is too long, truncating to 3 characters"); } strncpy(tex->achFormatHint,imIt->second.mEmbeddedFormat.c_str(),3); diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index 31fbabe0e..20d6a39d5 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -152,22 +152,22 @@ void ColladaParser::ReadContents() if (!::strncmp(version,"1.5",3)) { mFormat = FV_1_5_n; - DefaultLogger::get()->debug("Collada schema version is 1.5.n"); + ASSIMP_LOG_DEBUG("Collada schema version is 1.5.n"); } else if (!::strncmp(version,"1.4",3)) { mFormat = FV_1_4_n; - DefaultLogger::get()->debug("Collada schema version is 1.4.n"); + ASSIMP_LOG_DEBUG("Collada schema version is 1.4.n"); } else if (!::strncmp(version,"1.3",3)) { mFormat = FV_1_3_n; - DefaultLogger::get()->debug("Collada schema version is 1.3.n"); + ASSIMP_LOG_DEBUG("Collada schema version is 1.3.n"); } } ReadStructure(); } else { - DefaultLogger::get()->debug( format() << "Ignoring global element <" << mReader->getNodeName() << ">." ); + ASSIMP_LOG_DEBUG_F( "Ignoring global element <", mReader->getNodeName(), ">." ); SkipElement(); } } else @@ -984,13 +984,13 @@ void ColladaParser::ReadImage( Collada::Image& pImage) // they're not skipped. int attrib = TestAttribute("array_index"); if (attrib != -1 && mReader->getAttributeValueAsInt(attrib) > 0) { - DefaultLogger::get()->warn("Collada: Ignoring texture array index"); + ASSIMP_LOG_WARN("Collada: Ignoring texture array index"); continue; } attrib = TestAttribute("mip_index"); if (attrib != -1 && mReader->getAttributeValueAsInt(attrib) > 0) { - DefaultLogger::get()->warn("Collada: Ignoring MIP map layer"); + ASSIMP_LOG_WARN("Collada: Ignoring MIP map layer"); continue; } @@ -1011,7 +1011,7 @@ void ColladaParser::ReadImage( Collada::Image& pImage) // embedded image. get format const int attrib = TestAttribute("format"); if (-1 == attrib) - DefaultLogger::get()->warn("Collada: Unknown image file format"); + ASSIMP_LOG_WARN("Collada: Unknown image file format"); else pImage.mEmbeddedFormat = mReader->getAttributeValue(attrib); const char* data = GetTextContent(); @@ -1590,7 +1590,7 @@ void ColladaParser::ReadSamplerProperties( Sampler& out ) out.mOp = aiTextureOp_Multiply; else { - DefaultLogger::get()->warn("Collada: Unsupported MAYA texture blend mode"); + ASSIMP_LOG_WARN("Collada: Unsupported MAYA texture blend mode"); } TestClosing( "blend_mode"); } @@ -2541,7 +2541,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si if( pInput.mIndex == 0) pMesh->mPositions.push_back( aiVector3D( obj[0], obj[1], obj[2])); else - DefaultLogger::get()->error("Collada: just one vertex position stream supported"); + ASSIMP_LOG_ERROR("Collada: just one vertex position stream supported"); break; case IT_Normal: // pad to current vertex count if necessary @@ -2552,7 +2552,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si if( pInput.mIndex == 0) pMesh->mNormals.push_back( aiVector3D( obj[0], obj[1], obj[2])); else - DefaultLogger::get()->error("Collada: just one vertex normal stream supported"); + ASSIMP_LOG_ERROR("Collada: just one vertex normal stream supported"); break; case IT_Tangent: // pad to current vertex count if necessary @@ -2563,7 +2563,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si if( pInput.mIndex == 0) pMesh->mTangents.push_back( aiVector3D( obj[0], obj[1], obj[2])); else - DefaultLogger::get()->error("Collada: just one vertex tangent stream supported"); + ASSIMP_LOG_ERROR("Collada: just one vertex tangent stream supported"); break; case IT_Bitangent: // pad to current vertex count if necessary @@ -2574,7 +2574,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si if( pInput.mIndex == 0) pMesh->mBitangents.push_back( aiVector3D( obj[0], obj[1], obj[2])); else - DefaultLogger::get()->error("Collada: just one vertex bitangent stream supported"); + ASSIMP_LOG_ERROR("Collada: just one vertex bitangent stream supported"); break; case IT_Texcoord: // up to 4 texture coord sets are fine, ignore the others @@ -2590,7 +2590,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si pMesh->mNumUVComponents[pInput.mIndex]=3; } else { - DefaultLogger::get()->error("Collada: too many texture coordinate sets. Skipping."); + ASSIMP_LOG_ERROR("Collada: too many texture coordinate sets. Skipping."); } break; case IT_Color: @@ -2610,7 +2610,7 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si pMesh->mColors[pInput.mIndex].push_back(result); } else { - DefaultLogger::get()->error("Collada: too many vertex color sets. Skipping."); + ASSIMP_LOG_ERROR("Collada: too many vertex color sets. Skipping."); } break; @@ -2739,7 +2739,7 @@ void ColladaParser::ReadSceneNode( Node* pNode) { const char* s = mReader->getAttributeValue(attrId); if (s[0] != '#') - DefaultLogger::get()->error("Collada: Unresolved reference format of camera"); + ASSIMP_LOG_ERROR("Collada: Unresolved reference format of camera"); else pNode->mPrimaryCamera = s+1; } @@ -2752,7 +2752,7 @@ void ColladaParser::ReadSceneNode( Node* pNode) { const char* s = mReader->getAttributeValue(attrID); if (s[0] != '#') - DefaultLogger::get()->error("Collada: Unresolved reference format of node"); + ASSIMP_LOG_ERROR("Collada: Unresolved reference format of node"); else { pNode->mNodeInstances.push_back(NodeInstance()); diff --git a/code/D3MFImporter.cpp b/code/D3MFImporter.cpp index 2732c73c4..0a3a140f3 100644 --- a/code/D3MFImporter.cpp +++ b/code/D3MFImporter.cpp @@ -396,7 +396,7 @@ private: return false; } } - DefaultLogger::get()->error("unexpected EOF, expected closing <" + closeTag + "> tag"); + ASSIMP_LOG_ERROR("unexpected EOF, expected closing <" + closeTag + "> tag"); return false; } diff --git a/code/D3MFOpcPackage.cpp b/code/D3MFOpcPackage.cpp index 3bf545813..8161a31e4 100644 --- a/code/D3MFOpcPackage.cpp +++ b/code/D3MFOpcPackage.cpp @@ -465,7 +465,7 @@ D3MFOpcPackage::D3MFOpcPackage(IOSystem* pIOHandler, const std::string& rFile) } } - DefaultLogger::get()->debug(rootFile); + ASSIMP_LOG_DEBUG(rootFile); mRootStream = mZipArchive->Open(rootFile.c_str()); ai_assert( mRootStream != nullptr ); diff --git a/code/DXFLoader.cpp b/code/DXFLoader.cpp index c8aee18dd..6c42d0fc2 100644 --- a/code/DXFLoader.cpp +++ b/code/DXFLoader.cpp @@ -212,7 +212,7 @@ void DXFImporter::InternReadFile( const std::string& pFile, ++reader; } if (!eof) { - DefaultLogger::get()->warn("DXF: EOF reached, but did not encounter DXF EOF marker"); + ASSIMP_LOG_WARN("DXF: EOF reached, but did not encounter DXF EOF marker"); } ConvertMeshes(pScene,output); @@ -229,7 +229,7 @@ void DXFImporter::InternReadFile( const std::string& pFile, void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output) { // the process of resolving all the INSERT statements can grow the - // polycount excessively, so log the original number. + // poly-count excessively, so log the original number. // XXX Option to import blocks as separate nodes? if (!DefaultLogger::isNullLogger()) { @@ -241,16 +241,14 @@ void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output) } } - DefaultLogger::get()->debug((Formatter::format("DXF: Unexpanded polycount is "), - icount,", vertex count is ",vcount - )); + ASSIMP_LOG_DEBUG("DXF: Unexpanded polycount is ", icount, ", vertex count is ", vcount); } if (! output.blocks.size() ) { throw DeadlyImportError("DXF: no data blocks loaded"); } - DXF::Block* entities = 0; + DXF::Block* entities( nullptr ); // index blocks by name DXF::BlockMap blocks_by_name; @@ -375,9 +373,7 @@ void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& bloc // first check if the referenced blocks exists ... const DXF::BlockMap::const_iterator it = blocks_by_name.find(insert.name); if (it == blocks_by_name.end()) { - DefaultLogger::get()->error((Formatter::format("DXF: Failed to resolve block reference: "), - insert.name,"; skipping" - )); + ASSIMP_LOG_ERROR("DXF: Failed to resolve block reference: ", insert.name,"; skipping" ); continue; } diff --git a/code/Importer.cpp b/code/Importer.cpp index 6f9b47562..1b3ccf2a1 100644 --- a/code/Importer.cpp +++ b/code/Importer.cpp @@ -368,11 +368,11 @@ bool Importer::IsDefaultProgressHandler() const bool _ValidateFlags(unsigned int pFlags) { if (pFlags & aiProcess_GenSmoothNormals && pFlags & aiProcess_GenNormals) { - DefaultLogger::get()->error("#aiProcess_GenSmoothNormals and #aiProcess_GenNormals are incompatible"); + ASSIMP_LOG_ERROR("#aiProcess_GenSmoothNormals and #aiProcess_GenNormals are incompatible"); return false; } if (pFlags & aiProcess_OptimizeGraph && pFlags & aiProcess_PreTransformVertices) { - DefaultLogger::get()->error("#aiProcess_OptimizeGraph and #aiProcess_PreTransformVertices are incompatible"); + ASSIMP_LOG_ERROR("#aiProcess_OptimizeGraph and #aiProcess_PreTransformVertices are incompatible"); return false; } return true; @@ -594,7 +594,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) if( !pimpl->mIOHandler->Exists( pFile)) { pimpl->mErrorString = "Unable to open file \"" + pFile + "\"."; - DefaultLogger::get()->error(pimpl->mErrorString); + ASSIMP_LOG_ERROR(pimpl->mErrorString); return NULL; } @@ -628,7 +628,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) // Put a proper error message if no suitable importer was found if( !imp) { pimpl->mErrorString = "No suitable reader found for the file format of file \"" + pFile + "\"."; - DefaultLogger::get()->error(pimpl->mErrorString); + ASSIMP_LOG_ERROR(pimpl->mErrorString); return NULL; } } @@ -716,7 +716,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) pimpl->mErrorString = std::string("std::exception: ") + e.what(); #endif - DefaultLogger::get()->error(pimpl->mErrorString); + ASSIMP_LOG_ERROR(pimpl->mErrorString); delete pimpl->mScene; pimpl->mScene = NULL; } #endif // ! ASSIMP_CATCH_GLOBAL_EXCEPTIONS @@ -762,7 +762,7 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) if (pimpl->bExtraVerbose) { #ifdef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS - DefaultLogger::get()->error("Verbose Import is not available due to build settings"); + ASSIMP_LOG_ERROR("Verbose Import is not available due to build settings"); #endif // no validation pFlags |= aiProcess_ValidateDataStructure; } @@ -800,18 +800,19 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) // If the extra verbose mode is active, execute the ValidateDataStructureStep again - after each step if (pimpl->bExtraVerbose) { - DefaultLogger::get()->debug("Verbose Import: revalidating data structures"); + DefaultLogger::get()->debug("Verbose Import: re-validating data structures"); ValidateDSProcess ds; ds.ExecuteOnScene (this); if( !pimpl->mScene) { - DefaultLogger::get()->error("Verbose Import: failed to revalidate data structures"); + ASSIMP_LOG_ERROR("Verbose Import: failed to re-validate data structures"); break; } } #endif // ! DEBUG } - pimpl->mProgressHandler->UpdatePostProcess( static_cast(pimpl->mPostProcessingSteps.size()), static_cast(pimpl->mPostProcessingSteps.size()) ); + pimpl->mProgressHandler->UpdatePostProcess( static_cast(pimpl->mPostProcessingSteps.size()), + static_cast(pimpl->mPostProcessingSteps.size()) ); // update private scene flags if( pimpl->mScene ) @@ -858,7 +859,7 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess if ( pimpl->bExtraVerbose ) { #ifdef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS - DefaultLogger::get()->error( "Verbose Import is not available due to build settings" ); + ASSIMP_LOG_ERROR( "Verbose Import is not available due to build settings" ); #endif // no validation } #else @@ -886,7 +887,7 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess ValidateDSProcess ds; ds.ExecuteOnScene( this ); if ( !pimpl->mScene ) { - DefaultLogger::get()->error( "Verbose Import: failed to revalidate data structures" ); + ASSIMP_LOG_ERROR( "Verbose Import: failed to revalidate data structures" ); } } diff --git a/code/SceneCombiner.cpp b/code/SceneCombiner.cpp index 589291131..2b6b1e19a 100644 --- a/code/SceneCombiner.cpp +++ b/code/SceneCombiner.cpp @@ -622,8 +622,8 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master, std::vectorerror(std::string("SceneCombiner: Failed to resolve attachment ") - + (*it).node->mName.data + " " + (*it).attachToNode->mName.data); + ASSIMP_LOG_ERROR_F( "SceneCombiner: Failed to resolve attachment ", (*it).node->mName.data, + " ", (*it).attachToNode->mName.data ); } } } diff --git a/code/UnrealLoader.cpp b/code/UnrealLoader.cpp index 5990ce1c5..64bfbb9e0 100644 --- a/code/UnrealLoader.cpp +++ b/code/UnrealLoader.cpp @@ -153,9 +153,9 @@ void UnrealImporter::InternReadFile( const std::string& pFile, a_path = extension+"_a.3d"; uc_path = extension+".uc"; - DefaultLogger::get()->debug("UNREAL: data file is " + d_path); - DefaultLogger::get()->debug("UNREAL: aniv file is " + a_path); - DefaultLogger::get()->debug("UNREAL: uc file is " + uc_path); + ASSIMP_LOG_DEBUG_F( "UNREAL: data file is ", d_path); + ASSIMP_LOG_DEBUG_F("UNREAL: aniv file is ", a_path); + ASSIMP_LOG_DEBUG_F("UNREAL: uc file is ", uc_path); // and open the files ... we can't live without them std::unique_ptr p(pIOHandler->Open(d_path)); @@ -179,7 +179,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile, tri.mVertex[i] = d_reader.GetI2(); if (tri.mVertex[i] >= numTris) { - DefaultLogger::get()->warn("UNREAL: vertex index out of range"); + ASSIMP_LOG_WARN("UNREAL: vertex index out of range"); tri.mVertex[i] = 0; } } @@ -324,7 +324,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile, } } else { - DefaultLogger::get()->error("Unable to open .uc file"); + ASSIMP_LOG_ERROR("Unable to open .uc file"); } std::vector materials; diff --git a/include/assimp/BlobIOSystem.h b/include/assimp/BlobIOSystem.h index 3c1691d5b..a0ed7209f 100644 --- a/include/assimp/BlobIOSystem.h +++ b/include/assimp/BlobIOSystem.h @@ -251,7 +251,7 @@ public: } } if (!master) { - DefaultLogger::get()->error("BlobIOSystem: no data written or master file was not closed properly."); + ASSIMP_LOG_ERROR("BlobIOSystem: no data written or master file was not closed properly."); return NULL; } From b6f29bf54f7577509ba1f6983064e267f556a8bf Mon Sep 17 00:00:00 2001 From: kimkulling Date: Thu, 19 Apr 2018 17:21:21 +0200 Subject: [PATCH 02/11] Add usage of log macros, next files. --- code/ColladaParser.cpp | 13 +++--- code/DXFHelper.h | 2 +- code/DXFLoader.cpp | 4 +- code/DeboneProcess.cpp | 4 +- code/DefaultIOSystem.cpp | 6 +-- code/FindInvalidDataProcess.cpp | 2 +- code/HMPLoader.cpp | 6 +-- code/Importer.cpp | 38 +++++++++--------- code/Importer/IFC/STEPFileReader.cpp | 2 +- code/ImproveCacheLocality.cpp | 2 +- code/JoinVerticesProcess.cpp | 2 +- code/LWOMaterial.cpp | 2 +- code/LWSLoader.cpp | 2 +- code/MD3Loader.cpp | 2 +- code/MD5Parser.cpp | 14 +++---- code/MDLLoader.cpp | 60 ++++++++++++++-------------- code/MDLMaterialLoader.cpp | 4 +- code/MS3DLoader.cpp | 4 +- code/NDOLoader.cpp | 2 +- code/NFFLoader.cpp | 8 ++-- code/ObjFileParser.cpp | 4 +- code/OgreMaterial.cpp | 6 +-- code/OgreStructs.cpp | 4 +- code/PlyParser.cpp | 4 +- code/Q3DLoader.cpp | 6 +-- code/RemoveVCProcess.cpp | 2 +- code/SIBImporter.cpp | 2 +- code/SMDLoader.cpp | 6 +-- code/SceneCombiner.cpp | 14 +++---- code/ScenePreprocessor.cpp | 12 +++--- code/SplitByBoneCountProcess.cpp | 6 +-- code/Subdivision.cpp | 4 +- code/TextureTransform.cpp | 2 +- code/ValidateDataStructure.cpp | 2 +- include/assimp/Profiler.h | 4 +- 35 files changed, 128 insertions(+), 129 deletions(-) diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index 20d6a39d5..fc283ff8c 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -2770,7 +2770,7 @@ void ColladaParser::ReadSceneNode( Node* pNode) // Reference to a light, name given in 'url' attribute int attrID = TestAttribute("url"); if (-1 == attrID) - DefaultLogger::get()->warn("Collada: Expected url attribute in element"); + ASSIMP_LOG_WARN("Collada: Expected url attribute in element"); else { const char* url = mReader->getAttributeValue( attrID); @@ -2786,7 +2786,7 @@ void ColladaParser::ReadSceneNode( Node* pNode) // Reference to a camera, name given in 'url' attribute int attrID = TestAttribute("url"); if (-1 == attrID) - DefaultLogger::get()->warn("Collada: Expected url attribute in element"); + ASSIMP_LOG_WARN("Collada: Expected url attribute in element"); else { const char* url = mReader->getAttributeValue( attrID); @@ -2873,7 +2873,7 @@ void ColladaParser::ReadMaterialVertexInputBinding( Collada::SemanticMappingTabl tbl.mMap[s] = vn; } else if( IsElement( "bind")) { - DefaultLogger::get()->warn("Collada: Found unsupported element"); + ASSIMP_LOG_WARN("Collada: Found unsupported element"); } } else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END) { @@ -2992,10 +2992,9 @@ void ColladaParser::ReportWarning(const char* msg,...) ai_assert(iLen > 0); va_end(args); - DefaultLogger::get()->warn("Validation warning: " + std::string(szBuffer,iLen)); + ASSIMP_LOG_WARN_F("Validation warning: ", std::string(szBuffer,iLen)); } - // ------------------------------------------------------------------------------------------------ // Skips all data until the end node of the current element void ColladaParser::SkipElement() @@ -3190,7 +3189,7 @@ aiMatrix4x4 ColladaParser::CalculateResultTransform( const std::vectorwarn( format() << "Vertex input type is empty." ); + ASSIMP_LOG_WARN("Vertex input type is empty." ); return IT_Invalid; } @@ -3209,7 +3208,7 @@ Collada::InputType ColladaParser::GetTypeForSemantic( const std::string& semanti else if( semantic == "TANGENT" || semantic == "TEXTANGENT") return IT_Tangent; - DefaultLogger::get()->warn( format() << "Unknown vertex input type \"" << semantic << "\". Ignoring." ); + ASSIMP_LOG_WARN_F( "Unknown vertex input type \"", semantic, "\". Ignoring." ); return IT_Invalid; } diff --git a/code/DXFHelper.h b/code/DXFHelper.h index 49ca2814d..00e66a0db 100644 --- a/code/DXFHelper.h +++ b/code/DXFHelper.h @@ -146,7 +146,7 @@ public: for(;splitter->length() && splitter->at(0) != '}'; splitter++, cnt++); splitter++; - DefaultLogger::get()->debug((Formatter::format("DXF: skipped over control group ("),cnt," lines)")); + ASSIMP_LOG_DEBUG((Formatter::format("DXF: skipped over control group ("),cnt," lines)")); } } catch(std::logic_error&) { ai_assert(!splitter); diff --git a/code/DXFLoader.cpp b/code/DXFLoader.cpp index 6c42d0fc2..89cc1d654 100644 --- a/code/DXFLoader.cpp +++ b/code/DXFLoader.cpp @@ -485,7 +485,7 @@ void DXFImporter::ParseBlocks(DXF::LineReader& reader, DXF::FileData& output) ++reader; } - DefaultLogger::get()->debug((Formatter::format("DXF: got "), + ASSIMP_LOG_DEBUG((Formatter::format("DXF: got "), output.blocks.size()," entries in BLOCKS" )); } @@ -567,7 +567,7 @@ void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output) ++reader; } - DefaultLogger::get()->debug((Formatter::format("DXF: got "), + ASSIMP_LOG_DEBUG((Formatter::format("DXF: got "), block.lines.size()," polylines and ", block.insertions.size() ," inserted blocks in ENTITIES" )); } diff --git a/code/DeboneProcess.cpp b/code/DeboneProcess.cpp index 33692b6a3..5a742dcf4 100644 --- a/code/DeboneProcess.cpp +++ b/code/DeboneProcess.cpp @@ -209,7 +209,7 @@ bool DeboneProcess::ConsiderMesh(const aiMesh* pMesh) if(vertexBones[vid]!=cUnowned) { if(vertexBones[vid]==i) //double entry { - DefaultLogger::get()->warn("Encountered double entry in bone weights"); + ASSIMP_LOG_WARN("Encountered double entry in bone weights"); } else //TODO: track attraction in order to break tie { @@ -281,7 +281,7 @@ void DeboneProcess::SplitMesh( const aiMesh* pMesh, std::vector< std::pair< aiMe if(vertexBones[vid]!=cUnowned) { if(vertexBones[vid]==i) //double entry { - //DefaultLogger::get()->warn("Encountered double entry in bone weights"); + ASSIMP_LOG_WARN("Encountered double entry in bone weights"); } else //TODO: track attraction in order to break tie { diff --git a/code/DefaultIOSystem.cpp b/code/DefaultIOSystem.cpp index 36c14e41d..ec0de6e3a 100644 --- a/code/DefaultIOSystem.cpp +++ b/code/DefaultIOSystem.cpp @@ -170,7 +170,7 @@ inline static void MakeAbsolutePath (const char* in, char* _out) if (!ret) { // preserve the input path, maybe someone else is able to fix // the path before it is accessed (e.g. our file system filter) - DefaultLogger::get()->warn("Invalid path: " + std::string(in)); + ASSIMP_LOG_WARN_F("Invalid path: ", std::string(in)); strcpy(_out, in); } @@ -179,7 +179,7 @@ inline static void MakeAbsolutePath (const char* in, char* _out) if (!ret) { // preserve the input path, maybe someone else is able to fix // the path before it is accessed (e.g. our file system filter) - DefaultLogger::get()->warn("Invalid path: " + std::string(in)); + ASSIMP_LOG_WARN("Invalid path: ", std::string(in)); strcpy(_out, in); } } @@ -189,7 +189,7 @@ inline static void MakeAbsolutePath (const char* in, char* _out) if(!ret) { // preserve the input path, maybe someone else is able to fix // the path before it is accessed (e.g. our file system filter) - DefaultLogger::get()->warn("Invalid path: "+std::string(in)); + ASSIMP_LOG_WARN("Invalid path: ", std::string(in)); strcpy(_out,in); } #endif diff --git a/code/FindInvalidDataProcess.cpp b/code/FindInvalidDataProcess.cpp index aac69950c..5e6b43dee 100644 --- a/code/FindInvalidDataProcess.cpp +++ b/code/FindInvalidDataProcess.cpp @@ -332,7 +332,7 @@ void FindInvalidDataProcess::ProcessAnimationChannel (aiNodeAnim* anim) i = 1; } if (1 == i) - DefaultLogger::get()->warn("Simplified dummy tracks with just one key"); + ASSIMP_LOG_WARN("Simplified dummy tracks with just one key"); } // ------------------------------------------------------------------------------------------------ diff --git a/code/HMPLoader.cpp b/code/HMPLoader.cpp index aafd3a25c..7f53f9b54 100644 --- a/code/HMPLoader.cpp +++ b/code/HMPLoader.cpp @@ -141,21 +141,21 @@ void HMPImporter::InternReadFile( const std::string& pFile, if (AI_HMP_MAGIC_NUMBER_LE_4 == iMagic || AI_HMP_MAGIC_NUMBER_BE_4 == iMagic) { - DefaultLogger::get()->debug("HMP subtype: 3D GameStudio A4, magic word is HMP4"); + ASSIMP_LOG_DEBUG("HMP subtype: 3D GameStudio A4, magic word is HMP4"); InternReadFile_HMP4(); } // HMP5 format else if (AI_HMP_MAGIC_NUMBER_LE_5 == iMagic || AI_HMP_MAGIC_NUMBER_BE_5 == iMagic) { - DefaultLogger::get()->debug("HMP subtype: 3D GameStudio A5, magic word is HMP5"); + ASSIMP_LOG_DEBUG("HMP subtype: 3D GameStudio A5, magic word is HMP5"); InternReadFile_HMP5(); } // HMP7 format else if (AI_HMP_MAGIC_NUMBER_LE_7 == iMagic || AI_HMP_MAGIC_NUMBER_BE_7 == iMagic) { - DefaultLogger::get()->debug("HMP subtype: 3D GameStudio A7, magic word is HMP7"); + ASSIMP_LOG_DEBUG("HMP subtype: 3D GameStudio A7, magic word is HMP7"); InternReadFile_HMP7(); } else diff --git a/code/Importer.cpp b/code/Importer.cpp index 1b3ccf2a1..f47160c5c 100644 --- a/code/Importer.cpp +++ b/code/Importer.cpp @@ -205,7 +205,7 @@ aiReturn Importer::RegisterPPStep(BaseProcess* pImp) ASSIMP_BEGIN_EXCEPTION_REGION(); pimpl->mPostProcessingSteps.push_back(pImp); - DefaultLogger::get()->info("Registering custom post-processing step"); + ASSIMP_LOG_INFO("Registering custom post-processing step"); ASSIMP_END_EXCEPTION_REGION(aiReturn); return AI_SUCCESS; @@ -232,7 +232,7 @@ aiReturn Importer::RegisterLoader(BaseImporter* pImp) #ifdef ASSIMP_BUILD_DEBUG if (IsExtensionSupported(*it)) { - DefaultLogger::get()->warn("The file extension " + *it + " is already in use"); + ASSIMP_LOG_WARN_F("The file extension ", *it, " is already in use"); } #endif baked += *it; @@ -240,7 +240,7 @@ aiReturn Importer::RegisterLoader(BaseImporter* pImp) // add the loader pimpl->mImporter.push_back(pImp); - DefaultLogger::get()->info("Registering custom importer for these file extensions: " + baked); + ASSIMP_LOG_INFO_F("Registering custom importer for these file extensions: ", baked); ASSIMP_END_EXCEPTION_REGION(aiReturn); return AI_SUCCESS; } @@ -260,10 +260,10 @@ aiReturn Importer::UnregisterLoader(BaseImporter* pImp) if (it != pimpl->mImporter.end()) { pimpl->mImporter.erase(it); - DefaultLogger::get()->info("Unregistering custom importer: "); + ASSIMP_LOG_INFO("Unregistering custom importer: "); return AI_SUCCESS; } - DefaultLogger::get()->warn("Unable to remove custom importer: I can't find you ..."); + ASSIMP_LOG_WARN("Unable to remove custom importer: I can't find you ..."); ASSIMP_END_EXCEPTION_REGION(aiReturn); return AI_FAILURE; } @@ -283,10 +283,10 @@ aiReturn Importer::UnregisterPPStep(BaseProcess* pImp) if (it != pimpl->mPostProcessingSteps.end()) { pimpl->mPostProcessingSteps.erase(it); - DefaultLogger::get()->info("Unregistering custom post-processing step"); + ASSIMP_LOG_INFO("Unregistering custom post-processing step"); return AI_SUCCESS; } - DefaultLogger::get()->warn("Unable to remove custom post-processing step: I can't find you .."); + ASSIMP_LOG_WARN("Unable to remove custom post-processing step: I can't find you .."); ASSIMP_END_EXCEPTION_REGION(aiReturn); return AI_FAILURE; } @@ -586,7 +586,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) // a scene. In this case we need to delete the old one if (pimpl->mScene) { - DefaultLogger::get()->debug("(Deleting previous scene)"); + ASSIMP_LOG_DEBUG("(Deleting previous scene)"); FreeScene(); } @@ -617,7 +617,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) // not so bad yet ... try format auto detection. const std::string::size_type s = pFile.find_last_of('.'); if (s != std::string::npos) { - DefaultLogger::get()->info("File extension not known, trying signature-based detection"); + ASSIMP_LOG_INFO("File extension not known, trying signature-based detection"); for( unsigned int a = 0; a < pimpl->mImporter.size(); a++) { if( pimpl->mImporter[a]->CanRead( pFile, pimpl->mIOHandler, true)) { imp = pimpl->mImporter[a]; @@ -648,7 +648,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) if ( NULL != desc ) { ext = desc->mName; } - DefaultLogger::get()->info("Found a matching importer for this file format: " + ext + "." ); + ASSIMP_LOG_INFO("Found a matching importer for this file format: " + ext + "." ); pimpl->mProgressHandler->UpdateFileRead( 0, fileSize ); if (profiler) { @@ -744,7 +744,7 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) // In debug builds: run basic flag validation ai_assert(_ValidateFlags(pFlags)); - DefaultLogger::get()->info("Entering post processing pipeline"); + ASSIMP_LOG_INFO("Entering post processing pipeline"); #ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS // The ValidateDS process plays an exceptional role. It isn't contained in the global @@ -768,7 +768,7 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) } #else if (pimpl->bExtraVerbose) { - DefaultLogger::get()->warn("Not a debug build, ignoring extra verbose setting"); + ASSIMP_LOG_WARN("Not a debug build, ignoring extra verbose setting"); } #endif // ! DEBUG @@ -800,7 +800,7 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) // If the extra verbose mode is active, execute the ValidateDataStructureStep again - after each step if (pimpl->bExtraVerbose) { - DefaultLogger::get()->debug("Verbose Import: re-validating data structures"); + ASSIMP_LOG_DEBUG("Verbose Import: re-validating data structures"); ValidateDSProcess ds; ds.ExecuteOnScene (this); @@ -820,7 +820,7 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) // clear any data allocated by post-process steps pimpl->mPPShared->Clean(); - DefaultLogger::get()->info("Leaving post processing pipeline"); + ASSIMP_LOG_INFO("Leaving post processing pipeline"); ASSIMP_END_EXCEPTION_REGION(const aiScene*); return pimpl->mScene; @@ -841,7 +841,7 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess } // In debug builds: run basic flag validation - DefaultLogger::get()->info( "Entering customized post processing pipeline" ); + ASSIMP_LOG_INFO( "Entering customized post processing pipeline" ); #ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS // The ValidateDS process plays an exceptional role. It isn't contained in the global @@ -864,7 +864,7 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess } #else if ( pimpl->bExtraVerbose ) { - DefaultLogger::get()->warn( "Not a debug build, ignoring extra verbose setting" ); + ASSIMP_LOG_WARN( "Not a debug build, ignoring extra verbose setting" ); } #endif // ! DEBUG @@ -882,7 +882,7 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess // If the extra verbose mode is active, execute the ValidateDataStructureStep again - after each step if ( pimpl->bExtraVerbose || requestValidation ) { - DefaultLogger::get()->debug( "Verbose Import: revalidating data structures" ); + ASSIMP_LOG_DEBUG( "Verbose Import: revalidating data structures" ); ValidateDSProcess ds; ds.ExecuteOnScene( this ); @@ -893,7 +893,7 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess // clear any data allocated by post-process steps pimpl->mPPShared->Clean(); - DefaultLogger::get()->info( "Leaving customized post processing pipeline" ); + ASSIMP_LOG_INFO( "Leaving customized post processing pipeline" ); ASSIMP_END_EXCEPTION_REGION( const aiScene* ); @@ -904,7 +904,7 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess // Helper function to check whether an extension is supported by ASSIMP bool Importer::IsExtensionSupported(const char* szExtension) const { - return NULL != GetImporter(szExtension); + return nullptr != GetImporter(szExtension); } // ------------------------------------------------------------------------------------------------ diff --git a/code/Importer/IFC/STEPFileReader.cpp b/code/Importer/IFC/STEPFileReader.cpp index ba33f3928..34981d0c5 100644 --- a/code/Importer/IFC/STEPFileReader.cpp +++ b/code/Importer/IFC/STEPFileReader.cpp @@ -296,7 +296,7 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme, } if ( !DefaultLogger::isNullLogger()){ - DefaultLogger::get()->debug((Formatter::format(),"STEP: got ",map.size()," object records with ", + ASSIMP_LOG_DEBUG((Formatter::format(),"STEP: got ",map.size()," object records with ", db.GetRefs().size()," inverse index entries")); } } diff --git a/code/ImproveCacheLocality.cpp b/code/ImproveCacheLocality.cpp index cc6e9db46..ef16aeac9 100644 --- a/code/ImproveCacheLocality.cpp +++ b/code/ImproveCacheLocality.cpp @@ -186,7 +186,7 @@ float ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int mesh // mesh, otherwise this value would normally be at least minimally // smaller than 3.0 ... ai_snprintf(szBuff,128,"Mesh %u: Not suitable for vcache optimization",meshNum); - DefaultLogger::get()->warn(szBuff); + ASSIMP_LOG_WARN(szBuff); return 0.f; } } diff --git a/code/JoinVerticesProcess.cpp b/code/JoinVerticesProcess.cpp index cffe74fb2..3ab5d5833 100644 --- a/code/JoinVerticesProcess.cpp +++ b/code/JoinVerticesProcess.cpp @@ -409,7 +409,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) } --a; - DefaultLogger::get()->warn("Removing bone -> no weights remaining"); + ASSIMP_LOG_WARN("Removing bone -> no weights remaining"); } } return pMesh->mNumVertices; diff --git a/code/LWOMaterial.cpp b/code/LWOMaterial.cpp index df8d328da..383d3acb7 100644 --- a/code/LWOMaterial.cpp +++ b/code/LWOMaterial.cpp @@ -164,7 +164,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex static_assert(sizeof(aiUVTransform)/sizeof(ai_real) == 5, "sizeof(aiUVTransform)/sizeof(ai_real) == 5"); pcMat->AddProperty(&trafo,1,AI_MATKEY_UVTRANSFORM(type,cur)); } - DefaultLogger::get()->debug("LWO2: Setting up non-UV mapping"); + ASSIMP_LOG_DEBUG("LWO2: Setting up non-UV mapping"); } // The older LWOB format does not use indirect references to clips. diff --git a/code/LWSLoader.cpp b/code/LWSLoader.cpp index 1fcc5f789..baff6ab06 100644 --- a/code/LWSLoader.cpp +++ b/code/LWSLoader.cpp @@ -105,7 +105,7 @@ void LWS::Element::Parse (const char*& buffer) if (children.back().tokens[0] == "Plugin") { - DefaultLogger::get()->debug("LWS: Skipping over plugin-specific data"); + ASSIMP_LOG_DEBUG("LWS: Skipping over plugin-specific data"); // strange stuff inside Plugin/Endplugin blocks. Needn't // follow LWS syntax, so we skip over it diff --git a/code/MD3Loader.cpp b/code/MD3Loader.cpp index e86c3e0ca..7b71ee42f 100644 --- a/code/MD3Loader.cpp +++ b/code/MD3Loader.cpp @@ -890,7 +890,7 @@ void MD3Importer::InternReadFile( const std::string& pFile, if (it != skins.textures.end()) { texture_name = &*( _texture_name = (*it).second).begin(); - DefaultLogger::get()->debug("MD3: Assigning skin texture " + (*it).second + " to surface " + pcSurfaces->NAME); + ASSIMP_LOG_DEBUG_F("MD3: Assigning skin texture ", (*it).second, " to surface ", pcSurfaces->NAME); (*it).resolved = true; // mark entry as resolved } diff --git a/code/MD5Parser.cpp b/code/MD5Parser.cpp index 5593a3a0b..d927d998a 100644 --- a/code/MD5Parser.cpp +++ b/code/MD5Parser.cpp @@ -70,7 +70,7 @@ MD5Parser::MD5Parser(char* _buffer, unsigned int _fileSize ) fileSize = _fileSize; lineNumber = 0; - DefaultLogger::get()->debug("MD5Parser begin"); + ASSIMP_LOG_DEBUG("MD5Parser begin"); // parse the file header ParseHeader(); @@ -88,7 +88,7 @@ MD5Parser::MD5Parser(char* _buffer, unsigned int _fileSize ) if ( !DefaultLogger::isNullLogger()) { char szBuffer[128]; // should be sufficiently large ::ai_snprintf(szBuffer,128,"MD5Parser end. Parsed %i sections",(int)mSections.size()); - DefaultLogger::get()->debug(szBuffer); + ASSIMP_LOG_DEBUG(szBuffer); } } @@ -243,7 +243,7 @@ bool MD5Parser::ParseSection(Section& out) // .MD5MESH parsing function MD5MeshParser::MD5MeshParser(SectionList& mSections) { - DefaultLogger::get()->debug("MD5MeshParser begin"); + ASSIMP_LOG_DEBUG("MD5MeshParser begin"); // now parse all sections for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end();iter != iterEnd;++iter){ @@ -354,14 +354,14 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections) } } } - DefaultLogger::get()->debug("MD5MeshParser end"); + ASSIMP_LOG_DEBUG("MD5MeshParser end"); } // ------------------------------------------------------------------------------------------------ // .MD5ANIM parsing function MD5AnimParser::MD5AnimParser(SectionList& mSections) { - DefaultLogger::get()->debug("MD5AnimParser begin"); + ASSIMP_LOG_DEBUG("MD5AnimParser begin"); fFrameRate = 24.0f; mNumAnimatedComponents = UINT_MAX; @@ -445,14 +445,14 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections) fast_atoreal_move((*iter).mGlobalValue.c_str(),fFrameRate); } } - DefaultLogger::get()->debug("MD5AnimParser end"); + ASSIMP_LOG_DEBUG("MD5AnimParser end"); } // ------------------------------------------------------------------------------------------------ // .MD5CAMERA parsing function MD5CameraParser::MD5CameraParser(SectionList& mSections) { - DefaultLogger::get()->debug("MD5CameraParser begin"); + ASSIMP_LOG_DEBUG("MD5CameraParser begin"); fFrameRate = 24.0f; for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end();iter != iterEnd;++iter) { diff --git a/code/MDLLoader.cpp b/code/MDLLoader.cpp index 3f2bb084b..aed244bc2 100644 --- a/code/MDLLoader.cpp +++ b/code/MDLLoader.cpp @@ -187,37 +187,37 @@ void MDLImporter::InternReadFile( const std::string& pFile, // Original Quake1 format if (AI_MDL_MAGIC_NUMBER_BE == iMagicWord || AI_MDL_MAGIC_NUMBER_LE == iMagicWord) { - DefaultLogger::get()->debug("MDL subtype: Quake 1, magic word is IDPO"); + ASSIMP_LOG_DEBUG("MDL subtype: Quake 1, magic word is IDPO"); iGSFileVersion = 0; InternReadFile_Quake1(); } // GameStudio A MDL2 format - used by some test models that come with 3DGS else if (AI_MDL_MAGIC_NUMBER_BE_GS3 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS3 == iMagicWord) { - DefaultLogger::get()->debug("MDL subtype: 3D GameStudio A2, magic word is MDL2"); + ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A2, magic word is MDL2"); iGSFileVersion = 2; InternReadFile_Quake1(); } // GameStudio A4 MDL3 format else if (AI_MDL_MAGIC_NUMBER_BE_GS4 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS4 == iMagicWord) { - DefaultLogger::get()->debug("MDL subtype: 3D GameStudio A4, magic word is MDL3"); + ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A4, magic word is MDL3"); iGSFileVersion = 3; InternReadFile_3DGS_MDL345(); } // GameStudio A5+ MDL4 format else if (AI_MDL_MAGIC_NUMBER_BE_GS5a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS5a == iMagicWord) { - DefaultLogger::get()->debug("MDL subtype: 3D GameStudio A4, magic word is MDL4"); + ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A4, magic word is MDL4"); iGSFileVersion = 4; InternReadFile_3DGS_MDL345(); } // GameStudio A5+ MDL5 format else if (AI_MDL_MAGIC_NUMBER_BE_GS5b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS5b == iMagicWord) { - DefaultLogger::get()->debug("MDL subtype: 3D GameStudio A5, magic word is MDL5"); + ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A5, magic word is MDL5"); iGSFileVersion = 5; InternReadFile_3DGS_MDL345(); } // GameStudio A7 MDL7 format else if (AI_MDL_MAGIC_NUMBER_BE_GS7 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS7 == iMagicWord) { - DefaultLogger::get()->debug("MDL subtype: 3D GameStudio A7, magic word is MDL7"); + ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A7, magic word is MDL7"); iGSFileVersion = 7; InternReadFile_3DGS_MDL7(); } @@ -225,7 +225,7 @@ void MDLImporter::InternReadFile( const std::string& pFile, else if (AI_MDL_MAGIC_NUMBER_BE_HL2a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2a == iMagicWord || AI_MDL_MAGIC_NUMBER_BE_HL2b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2b == iMagicWord) { - DefaultLogger::get()->debug("MDL subtype: Source(tm) Engine, magic word is IDST/IDSQ"); + ASSIMP_LOG_DEBUG("MDL subtype: Source(tm) Engine, magic word is IDST/IDSQ"); iGSFileVersion = 0; InternReadFile_HL2(); } @@ -258,7 +258,7 @@ void MDLImporter::SizeCheck(const void* szPos) } // ------------------------------------------------------------------------------------------------ -// Just for debgging purposes +// Just for debugging purposes void MDLImporter::SizeCheck(const void* szPos, const char* szFile, unsigned int iLine) { ai_assert(NULL != szFile); @@ -298,20 +298,20 @@ void MDLImporter::ValidateHeader_Quake1(const MDL::Header* pcHeader) if (!this->iGSFileVersion) { if (pcHeader->num_verts > AI_MDL_MAX_VERTS) - DefaultLogger::get()->warn("Quake 1 MDL model has more than AI_MDL_MAX_VERTS vertices"); + ASSIMP_LOG_WARN("Quake 1 MDL model has more than AI_MDL_MAX_VERTS vertices"); if (pcHeader->num_tris > AI_MDL_MAX_TRIANGLES) - DefaultLogger::get()->warn("Quake 1 MDL model has more than AI_MDL_MAX_TRIANGLES triangles"); + ASSIMP_LOG_WARN("Quake 1 MDL model has more than AI_MDL_MAX_TRIANGLES triangles"); if (pcHeader->num_frames > AI_MDL_MAX_FRAMES) - DefaultLogger::get()->warn("Quake 1 MDL model has more than AI_MDL_MAX_FRAMES frames"); + ASSIMP_LOG_WARN("Quake 1 MDL model has more than AI_MDL_MAX_FRAMES frames"); // (this does not apply for 3DGS MDLs) if (!this->iGSFileVersion && pcHeader->version != AI_MDL_VERSION) - DefaultLogger::get()->warn("Quake 1 MDL model has an unknown version: AI_MDL_VERSION (=6) is " + ASSIMP_LOG_WARN("Quake 1 MDL model has an unknown version: AI_MDL_VERSION (=6) is " "the expected file format version"); if(pcHeader->num_skins && (!pcHeader->skinwidth || !pcHeader->skinheight)) - DefaultLogger::get()->warn("Skin width or height are 0"); + ASSIMP_LOG_WARN("Skin width or height are 0"); } } @@ -692,7 +692,7 @@ void MDLImporter::InternReadFile_3DGS_MDL345( ) unsigned int iIndex = pcTriangles->index_xyz[c]; if (iIndex >= (unsigned int)pcHeader->num_verts) { iIndex = pcHeader->num_verts-1; - DefaultLogger::get()->warn("Index overflow in MDLn vertex list"); + ASSIMP_LOG_WARN("Index overflow in MDLn vertex list"); } aiVector3D& vec = pcMesh->mVertices[iCurrent]; @@ -747,7 +747,7 @@ void MDLImporter::InternReadFile_3DGS_MDL345( ) unsigned int iIndex = pcTriangles->index_xyz[c]; if (iIndex >= (unsigned int)pcHeader->num_verts) { iIndex = pcHeader->num_verts-1; - DefaultLogger::get()->warn("Index overflow in MDLn vertex list"); + ASSIMP_LOG_WARN("Index overflow in MDLn vertex list"); } aiVector3D& vec = pcMesh->mVertices[iCurrent]; @@ -798,7 +798,7 @@ void MDLImporter::ImportUVCoordinate_3DGS_MDL345( // validate UV indices if (iIndex >= (unsigned int) pcHeader->synctype) { iIndex = pcHeader->synctype-1; - DefaultLogger::get()->warn("Index overflow in MDLn UV coord list"); + ASSIMP_LOG_WARN("Index overflow in MDLn UV coord list"); } float s = (float)pcSrc[iIndex].u; @@ -835,7 +835,7 @@ void MDLImporter::CalculateUVCoordinates_MDL5() iWidth = (unsigned int)*piPtr; if (!iHeight || !iWidth) { - DefaultLogger::get()->warn("Either the width or the height of the " + ASSIMP_LOG_WARN("Either the width or the height of the " "embedded DDS texture is zero. Unable to compute final texture " "coordinates. The texture coordinates remain in their original " "0-x/0-y (x,y = texture size) range."); @@ -988,7 +988,7 @@ MDL::IntBone_MDL7** MDLImporter::LoadBones_3DGS_MDL7() AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_32_CHARS != pcHeader->bone_stc_size && AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_NOT_THERE != pcHeader->bone_stc_size) { - DefaultLogger::get()->warn("Unknown size of bone data structure"); + ASSIMP_LOG_WARN("Unknown size of bone data structure"); return NULL; } @@ -1026,7 +1026,7 @@ void MDLImporter::ReadFaces_3DGS_MDL7(const MDL::IntGroupInfo_MDL7& groupInfo, if(iIndex > (unsigned int)groupInfo.pcGroup->numverts) { // (we might need to read this section a second time - to process frame vertices correctly) pcGroupTris->v_index[c] = iIndex = groupInfo.pcGroup->numverts-1; - DefaultLogger::get()->warn("Index overflow in MDL7 vertex list"); + DASSIMP_LOG_WARN("Index overflow in MDL7 vertex list"); } // write the output face index @@ -1071,7 +1071,7 @@ void MDLImporter::ReadFaces_3DGS_MDL7(const MDL::IntGroupInfo_MDL7& groupInfo, iIndex = pcGroupTris->skinsets[0].st_index[c]; if(iIndex > (unsigned int)groupInfo.pcGroup->num_stpts) { iIndex = groupInfo.pcGroup->num_stpts-1; - DefaultLogger::get()->warn("Index overflow in MDL7 UV coordinate list (#1)"); + ASSIMP_LOG_WARN("Index overflow in MDL7 UV coordinate list (#1)"); } float u = groupInfo.pcGroupUVs[iIndex].u; @@ -1098,7 +1098,7 @@ void MDLImporter::ReadFaces_3DGS_MDL7(const MDL::IntGroupInfo_MDL7& groupInfo, iIndex = pcGroupTris->skinsets[1].st_index[c]; if(iIndex > (unsigned int)groupInfo.pcGroup->num_stpts) { iIndex = groupInfo.pcGroup->num_stpts-1; - DefaultLogger::get()->warn("Index overflow in MDL7 UV coordinate list (#2)"); + ASSIMP_LOG_WARN("Index overflow in MDL7 UV coordinate list (#2)"); } float u = groupInfo.pcGroupUVs[ iIndex ].u; @@ -1153,7 +1153,7 @@ bool MDLImporter::ProcessFrames_3DGS_MDL7(const MDL::IntGroupInfo_MDL7& groupInf frame.pcFrame->transmatrix_count * pcHeader->bonetrans_stc_size; if (((const char*)szCurrent - (const char*)pcHeader) + iAdd > (unsigned int)pcHeader->data_size) { - DefaultLogger::get()->warn("Index overflow in frame area. " + ASSIMP_LOG_WARN("Index overflow in frame area. " "Ignoring all frames and all further mesh groups, too."); // don't parse more groups if we can't even read one @@ -1171,7 +1171,7 @@ bool MDLImporter::ProcessFrames_3DGS_MDL7(const MDL::IntGroupInfo_MDL7& groupInf uint16_t iIndex = _AI_MDL7_ACCESS(pcFrameVertices,qq,pcHeader->framevertex_stc_size,MDL::Vertex_MDL7).vertindex; AI_SWAP2(iIndex); if (iIndex >= groupInfo.pcGroup->numverts) { - DefaultLogger::get()->warn("Invalid vertex index in frame vertex section"); + ASSIMP_LOG_WARN("Invalid vertex index in frame vertex section"); continue; } @@ -1257,7 +1257,7 @@ void MDLImporter::SortByMaterials_3DGS_MDL7( // sometimes MED writes -1, but normally only if there is only // one skin assigned. No warning in this case if(0xFFFFFFFF != groupData.pcFaces[iFace].iMatIndex[0]) - DefaultLogger::get()->warn("Index overflow in MDL7 material list [#0]"); + ASSIMP_LOG_WARN("Index overflow in MDL7 material list [#0]"); } else splitGroupData.aiSplit[groupData.pcFaces[iFace]. iMatIndex[0]]->push_back(iFace); @@ -1282,7 +1282,7 @@ void MDLImporter::SortByMaterials_3DGS_MDL7( // sometimes MED writes -1, but normally only if there is only // one skin assigned. No warning in this case if(UINT_MAX != iMatIndex) - DefaultLogger::get()->warn("Index overflow in MDL7 material list [#1]"); + ASSIMP_LOG_WARN("Index overflow in MDL7 material list [#1]"); iMatIndex = iNumMaterials-1; } unsigned int iMatIndex2 = groupData.pcFaces[iFace].iMatIndex[1]; @@ -1292,7 +1292,7 @@ void MDLImporter::SortByMaterials_3DGS_MDL7( if (iMatIndex2 >= iNumMaterials) { // sometimes MED writes -1, but normally only if there is only // one skin assigned. No warning in this case - DefaultLogger::get()->warn("Index overflow in MDL7 material list [#2]"); + ASSIMP_LOG_WARN("Index overflow in MDL7 material list [#2]"); iMatIndex2 = iNumMaterials-1; } @@ -1414,7 +1414,7 @@ void MDLImporter::InternReadFile_3DGS_MDL7( ) if (1 != groupInfo.pcGroup->typ) { // Not a triangle-based mesh - DefaultLogger::get()->warn("[3DGS MDL7] Not a triangle mesh group. Continuing happily"); + ASSIMP_LOG_WARN("[3DGS MDL7] Not a triangle mesh group. Continuing happily"); } // store the name of the group @@ -1516,7 +1516,7 @@ void MDLImporter::InternReadFile_3DGS_MDL7( ) sharedData.abNeedMaterials[qq] = true; } } - else DefaultLogger::get()->warn("[3DGS MDL7] Mesh group consists of 0 " + else ASSIMP_LOG_WARN("[3DGS MDL7] Mesh group consists of 0 " "vertices or faces. It will be skipped."); // process all frames and generate output meshes @@ -1664,7 +1664,7 @@ void MDLImporter::ParseBoneTrafoKeys_3DGS_MDL7( // read all transformation matrices for (unsigned int iTrafo = 0; iTrafo < frame.pcFrame->transmatrix_count;++iTrafo) { if(pcBoneTransforms->bone_index >= pcHeader->bones_num) { - DefaultLogger::get()->warn("Index overflow in frame area. " + ASSIMP_LOG_WARN("Index overflow in frame area. " "Unable to parse this bone transformation"); } else { @@ -1676,7 +1676,7 @@ void MDLImporter::ParseBoneTrafoKeys_3DGS_MDL7( } } else { - DefaultLogger::get()->warn("Ignoring animation keyframes in groups != 0"); + ASSIMP_LOG_WARN("Ignoring animation keyframes in groups != 0"); } } } diff --git a/code/MDLMaterialLoader.cpp b/code/MDLMaterialLoader.cpp index d50957094..8955455ef 100644 --- a/code/MDLMaterialLoader.cpp +++ b/code/MDLMaterialLoader.cpp @@ -531,7 +531,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( // ***** REFERENCE TO EXTERNAL FILE ***** if (1 != iHeight) { - DefaultLogger::get()->warn("Found a reference to an external texture, " + ASSIMP_LOG_WARN("Found a reference to an external texture, " "but texture height is not equal to 1, which is not supported by MED"); } @@ -552,7 +552,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( pcNew.reset(new aiTexture()); if (!iHeight || !iWidth) { - DefaultLogger::get()->warn("Found embedded texture, but its width " + ASSIMP_LOG_WARN("Found embedded texture, but its width " "an height are both 0. Is this a joke?"); // generate an empty chess pattern diff --git a/code/MS3DLoader.cpp b/code/MS3DLoader.cpp index 09b3be6e1..869c41afb 100644 --- a/code/MS3DLoader.cpp +++ b/code/MS3DLoader.cpp @@ -142,7 +142,7 @@ void MS3DImporter :: ReadComments(StreamReaderLE& stream, std::vector& outp) stream >> index >> clength; if(index >= outp.size()) { - DefaultLogger::get()->warn("MS3D: Invalid index in comment section"); + ASSIMP_LOG_WARN("MS3D: Invalid index in comment section"); } else if (clength > stream.GetRemainingSize()) { throw DeadlyImportError("MS3D: Failure reading comment, length field is out of range"); @@ -408,7 +408,7 @@ void MS3DImporter::InternReadFile( const std::string& pFile, // 2 ------------ convert to proper aiXX data structures ----------------------------------- if (need_default && materials.size()) { - DefaultLogger::get()->warn("MS3D: Found group with no material assigned, spawning default material"); + ASSIMP_LOG_WARN("MS3D: Found group with no material assigned, spawning default material"); // if one of the groups has no material assigned, but there are other // groups with materials, a default material needs to be added ( // scenepreprocessor adds a default material only if nummat==0). diff --git a/code/NDOLoader.cpp b/code/NDOLoader.cpp index b09fc1e2d..1e6c1e2ca 100644 --- a/code/NDOLoader.cpp +++ b/code/NDOLoader.cpp @@ -141,7 +141,7 @@ void NDOImporter::InternReadFile( const std::string& pFile, DefaultLogger::get()->info("NDO file format is 1.2"); } else { - DefaultLogger::get()->warn(std::string("Unrecognized nendo file format version, continuing happily ... :") + (head+6)); + ASSIMP_LOG_WARN(std::string("Unrecognized nendo file format version, continuing happily ... :") + (head+6)); } reader.IncPtr(2); /* skip flags */ diff --git a/code/NFFLoader.cpp b/code/NFFLoader.cpp index acd057d90..39f336112 100644 --- a/code/NFFLoader.cpp +++ b/code/NFFLoader.cpp @@ -125,7 +125,7 @@ const aiImporterDesc* NFFImporter::GetInfo () const do \ { \ if (!GetNextLine(buffer,line)) \ - {DefaultLogger::get()->warn("NFF2: Unexpected EOF, can't read next token");break;} \ + {ASSIMP_LOG_WARN("NFF2: Unexpected EOF, can't read next token");break;} \ SkipSpaces(line,&sz); \ } \ while(IsLineEnd(*sz)) @@ -346,7 +346,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, sz3 = sz; while (!IsSpaceOrNewLine(*sz))++sz; const unsigned int diff = (unsigned int)(sz-sz3); - if (!diff)DefaultLogger::get()->warn("NFF2: Found empty mtable token"); + if (!diff)ASSIMP_LOG_WARN("NFF2: Found empty mtable token"); else { // The material table has the file extension .mat. @@ -551,11 +551,11 @@ void NFFImporter::InternReadFile( const std::string& pFile, case 'u': case 'U': - DefaultLogger::get()->warn("Unsupported NFF2 texture attribute: trans"); + ASSIMP_LOG_WARN("Unsupported NFF2 texture attribute: trans"); }; if (!sz[1] || '_' != sz[2]) { - DefaultLogger::get()->warn("NFF2: Expected underscore after texture attributes"); + ASSIMP_LOG_WARN("NFF2: Expected underscore after texture attributes"); continue; } const char* sz2 = sz+3; diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index 7cd2d36c2..004778259 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -603,7 +603,7 @@ void ObjFileParser::getMaterialLib() { // Check if directive is valid. if ( 0 == strMatName.length() ) { - DefaultLogger::get()->warn( "OBJ: no name for material library specified." ); + ASSIMP_LOG_WARN( "OBJ: no name for material library specified." ); return; } @@ -660,7 +660,7 @@ void ObjFileParser::getNewMaterial() { std::map::iterator it = m_pModel->m_MaterialMap.find( strMat ); if ( it == m_pModel->m_MaterialMap.end() ) { // Show a warning, if material was not found - DefaultLogger::get()->warn("OBJ: Unsupported material requested: " + strMat); + ASSIMP_LOG_WARN("OBJ: Unsupported material requested: " + strMat); m_pModel->m_pCurrentMaterial = m_pModel->m_pDefaultMaterial; } else { // Set new material diff --git a/code/OgreMaterial.cpp b/code/OgreMaterial.cpp index c20c8fa6f..f0fb515d8 100644 --- a/code/OgreMaterial.cpp +++ b/code/OgreMaterial.cpp @@ -186,7 +186,7 @@ aiMaterial* OgreImporter::ReadMaterial(const std::string &pFile, Assimp::IOSyste std::unique_ptr stream(materialFile); if (stream->FileSize() == 0) { - DefaultLogger::get()->warn(Formatter::format() << "Source file for material '" << materialName << "' is empty (size is 0 bytes)"); + ASSIMP_LOG_WARN(Formatter::format() << "Source file for material '" << materialName << "' is empty (size is 0 bytes)"); return 0; } @@ -569,12 +569,12 @@ bool OgreImporter::ReadTextureUnit(const std::string &textureUnitName, stringstr if (textureRef.empty()) { - DefaultLogger::get()->warn("Texture reference is empty, ignoring texture_unit."); + ASSIMP_LOG_WARN("Texture reference is empty, ignoring texture_unit."); return false; } if (textureType == aiTextureType_NONE) { - DefaultLogger::get()->warn("Failed to detect texture type for '" + textureRef + "', ignoring texture_unit."); + ASSIMP_LOG_WARN("Failed to detect texture type for '" + textureRef + "', ignoring texture_unit."); return false; } diff --git a/code/OgreStructs.cpp b/code/OgreStructs.cpp index 0f3e2fa97..b2ad8e089 100644 --- a/code/OgreStructs.cpp +++ b/code/OgreStructs.cpp @@ -611,7 +611,7 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) } else { - DefaultLogger::get()->warn(Formatter::format() << "Ogre imported UV0 type " << uv1Element->TypeToString() << " is not compatible with Assimp. Ignoring UV."); + ASSIMP_LOG_WARN(Formatter::format() << "Ogre imported UV0 type " << uv1Element->TypeToString() << " is not compatible with Assimp. Ignoring UV."); uv1 = 0; } } @@ -624,7 +624,7 @@ aiMesh *SubMesh::ConvertToAssimpMesh(Mesh *parent) } else { - DefaultLogger::get()->warn(Formatter::format() << "Ogre imported UV0 type " << uv2Element->TypeToString() << " is not compatible with Assimp. Ignoring UV."); + ASSIMP_LOG_WARN(Formatter::format() << "Ogre imported UV0 type " << uv2Element->TypeToString() << " is not compatible with Assimp. Ignoring UV."); uv2 = 0; } } diff --git a/code/PlyParser.cpp b/code/PlyParser.cpp index 672ac9bde..b6bd60f9f 100644 --- a/code/PlyParser.cpp +++ b/code/PlyParser.cpp @@ -787,7 +787,7 @@ bool PLY::ElementInstance::ParseInstance(const char* &pCur, { if (!(PLY::PropertyInstance::ParseInstance(pCur, &(*a), &(*i)))) { - DefaultLogger::get()->warn("Unable to parse property instance. " + ASSIMP_LOG_WARN("Unable to parse property instance. " "Skipping this element instance"); PLY::PropertyInstance::ValueUnion v = PLY::PropertyInstance::DefaultValue((*a).eType); @@ -819,7 +819,7 @@ bool PLY::ElementInstance::ParseInstanceBinary( { if (!(PLY::PropertyInstance::ParseInstanceBinary(streamBuffer, buffer, pCur, bufferSize, &(*a), &(*i), p_bBE))) { - DefaultLogger::get()->warn("Unable to parse binary property instance. " + ASSIMP_LOG_WARN("Unable to parse binary property instance. " "Skipping this element instance"); (*i).avList.push_back(PLY::PropertyInstance::DefaultValue((*a).eType)); diff --git a/code/Q3DLoader.cpp b/code/Q3DLoader.cpp index 9495713a8..ebb80d537 100644 --- a/code/Q3DLoader.cpp +++ b/code/Q3DLoader.cpp @@ -433,7 +433,7 @@ outer: { if ((*fit).mat >= materials.size()) { - DefaultLogger::get()->warn("Quick3D: Material index overflow"); + ASSIMP_LOG_WARN("Quick3D: Material index overflow"); (*fit).mat = 0; } if (fidx[(*fit).mat].empty())++pScene->mNumMeshes; @@ -528,7 +528,7 @@ outer: { if (face.indices[n] >= m.verts.size()) { - DefaultLogger::get()->warn("Quick3D: Vertex index overflow"); + ASSIMP_LOG_WARN("Quick3D: Vertex index overflow"); face.indices[n] = 0; } @@ -561,7 +561,7 @@ outer: { if (face.uvindices[n] >= m.uv.size()) { - DefaultLogger::get()->warn("Quick3D: Texture coordinate index overflow"); + ASSIMP_LOG_WARN("Quick3D: Texture coordinate index overflow"); face.uvindices[n] = 0; } *uv = m.uv[face.uvindices[n]]; diff --git a/code/RemoveVCProcess.cpp b/code/RemoveVCProcess.cpp index 1c4975e35..ddb0023cc 100644 --- a/code/RemoveVCProcess.cpp +++ b/code/RemoveVCProcess.cpp @@ -242,7 +242,7 @@ void RemoveVCProcess::SetupProperties(const Importer* pImp) configDeleteFlags = pImp->GetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS,0x0); if (!configDeleteFlags) { - DefaultLogger::get()->warn("RemoveVCProcess: AI_CONFIG_PP_RVC_FLAGS is zero."); + ASSIMP_LOG_WARN("RemoveVCProcess: AI_CONFIG_PP_RVC_FLAGS is zero."); } } diff --git a/code/SIBImporter.cpp b/code/SIBImporter.cpp index 97df708ba..5c8c717b5 100644 --- a/code/SIBImporter.cpp +++ b/code/SIBImporter.cpp @@ -173,7 +173,7 @@ static void UnknownChunk(StreamReaderLE* /*stream*/, const SIBChunk& chunk) static_cast(chunk.Tag & 0xff), '\0' }; - DefaultLogger::get()->warn((Formatter::format(), "SIB: Skipping unknown '",temp,"' chunk.")); + ASSIMP_LOG_WARN((Formatter::format(), "SIB: Skipping unknown '",temp,"' chunk.")); } // Reads a UTF-16LE string and returns it at UTF-8. diff --git a/code/SMDLoader.cpp b/code/SMDLoader.cpp index ab7146daa..4f9ed5c1c 100644 --- a/code/SMDLoader.cpp +++ b/code/SMDLoader.cpp @@ -182,7 +182,7 @@ void SMDImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS { if (!(*i).mName.length()) { - DefaultLogger::get()->warn("SMD: Not all bones have been initialized"); + ASSIMP_LOG_WARN("SMD: Not all bones have been initialized"); break; } } @@ -230,7 +230,7 @@ void SMDImporter::LogWarning(const char* msg) char szTemp[1024]; ai_assert(strlen(msg) < 1000); ai_snprintf(szTemp,1024,"Line %u: %s",iLineNumber,msg); - DefaultLogger::get()->warn(szTemp); + ASSIMP_LOG_WARN(szTemp); } // ------------------------------------------------------------------------------------------------ @@ -715,7 +715,7 @@ void SMDImporter::ParseFile() if(!SkipSpaces(szCurrent,&szCurrent)) break; if (1 != strtoul10(szCurrent,&szCurrent)) { - DefaultLogger::get()->warn("SMD.version is not 1. This " + ASSIMP_LOG_WARN("SMD.version is not 1. This " "file format is not known. Continuing happily ..."); } continue; diff --git a/code/SceneCombiner.cpp b/code/SceneCombiner.cpp index 2b6b1e19a..d72477f50 100644 --- a/code/SceneCombiner.cpp +++ b/code/SceneCombiner.cpp @@ -75,7 +75,7 @@ void PrefixString(aiString& string,const char* prefix, unsigned int len) { return; if (len+string.length>=MAXLEN-1) { - DefaultLogger::get()->debug("Can't add an unique prefix because the string is too long"); + ASSIMP_LOG_DEBUG("Can't add an unique prefix because the string is too long"); ai_assert(false); return; } @@ -727,7 +727,7 @@ void SceneCombiner::MergeBones(aiMesh* out,std::vector::const_iterator // NOTE: different offset matrices for bones with equal names // are - at the moment - not handled correctly. if (wmit != (*it).pSrcBones.begin() && pc->mOffsetMatrix != (*wmit).first->mOffsetMatrix) { - DefaultLogger::get()->warn("Bones with equal names but different offset matrices can't be joined at the moment"); + ASSIMP_LOG_WARN("Bones with equal names but different offset matrices can't be joined at the moment"); continue; } pc->mOffsetMatrix = (*wmit).first->mOffsetMatrix; @@ -796,7 +796,7 @@ void SceneCombiner::MergeMeshes(aiMesh** _out, unsigned int /*flags*/, if ((*it)->mVertices) { ::memcpy(pv2,(*it)->mVertices,(*it)->mNumVertices*sizeof(aiVector3D)); } - else DefaultLogger::get()->warn("JoinMeshes: Positions expected but input mesh contains no positions"); + else ASSIMP_LOG_WARN("JoinMeshes: Positions expected but input mesh contains no positions"); pv2 += (*it)->mNumVertices; } } @@ -808,7 +808,7 @@ void SceneCombiner::MergeMeshes(aiMesh** _out, unsigned int /*flags*/, if ((*it)->mNormals) { ::memcpy(pv2,(*it)->mNormals,(*it)->mNumVertices*sizeof(aiVector3D)); } else { - DefaultLogger::get()->warn( "JoinMeshes: Normals expected but input mesh contains no normals" ); + ASSIMP_LOG_WARN( "JoinMeshes: Normals expected but input mesh contains no normals" ); } pv2 += (*it)->mNumVertices; } @@ -824,7 +824,7 @@ void SceneCombiner::MergeMeshes(aiMesh** _out, unsigned int /*flags*/, ::memcpy(pv2, (*it)->mTangents, (*it)->mNumVertices*sizeof(aiVector3D)); ::memcpy(pv2b,(*it)->mBitangents,(*it)->mNumVertices*sizeof(aiVector3D)); } else { - DefaultLogger::get()->warn( "JoinMeshes: Tangents expected but input mesh contains no tangents" ); + ASSIMP_LOG_WARN( "JoinMeshes: Tangents expected but input mesh contains no tangents" ); } pv2 += (*it)->mNumVertices; pv2b += (*it)->mNumVertices; @@ -840,7 +840,7 @@ void SceneCombiner::MergeMeshes(aiMesh** _out, unsigned int /*flags*/, if ((*it)->mTextureCoords[n]) { ::memcpy(pv2,(*it)->mTextureCoords[n],(*it)->mNumVertices*sizeof(aiVector3D)); } else { - DefaultLogger::get()->warn( "JoinMeshes: UVs expected but input mesh contains no UVs" ); + ASSIMP_LOG_WARN( "JoinMeshes: UVs expected but input mesh contains no UVs" ); } pv2 += (*it)->mNumVertices; } @@ -854,7 +854,7 @@ void SceneCombiner::MergeMeshes(aiMesh** _out, unsigned int /*flags*/, if ((*it)->mColors[n]) { ::memcpy(pv2,(*it)->mColors[n],(*it)->mNumVertices*sizeof(aiColor4D)); } else { - DefaultLogger::get()->warn( "JoinMeshes: VCs expected but input mesh contains no VCs" ); + ASSIMP_LOG_WARN( "JoinMeshes: VCs expected but input mesh contains no VCs" ); } pv2 += (*it)->mNumVertices; } diff --git a/code/ScenePreprocessor.cpp b/code/ScenePreprocessor.cpp index 2da890a84..eff6ecc6e 100644 --- a/code/ScenePreprocessor.cpp +++ b/code/ScenePreprocessor.cpp @@ -81,7 +81,7 @@ void ScenePreprocessor::ProcessScene () name.Set(AI_DEFAULT_MATERIAL_NAME); helper->AddProperty(&name,AI_MATKEY_NAME); - DefaultLogger::get()->debug("ScenePreprocessor: Adding default material \'" AI_DEFAULT_MATERIAL_NAME "\'"); + ASSIMP_LOG_DEBUG("ScenePreprocessor: Adding default material \'" AI_DEFAULT_MATERIAL_NAME "\'"); for (unsigned int i = 0; i < scene->mNumMeshes;++i) { scene->mMeshes[i]->mMaterialIndex = scene->mNumMaterials; @@ -122,7 +122,7 @@ void ScenePreprocessor::ProcessMesh (aiMesh* mesh) break; } if (p == end) { - DefaultLogger::get()->warn("ScenePreprocessor: UVs are declared to be 3D but they're obviously not. Reverting to 2D."); + ASSIMP_LOG_WARN("ScenePreprocessor: UVs are declared to be 3D but they're obviously not. Reverting to 2D."); mesh->mNumUVComponents[i] = 2; } } @@ -224,7 +224,7 @@ void ScenePreprocessor::ProcessAnimation (aiAnimation* anim) q.mTime = 0.; q.mValue = rotation; - DefaultLogger::get()->debug("ScenePreprocessor: Dummy rotation track has been generated"); + ASSIMP_LOG_DEBUG("ScenePreprocessor: Dummy rotation track has been generated"); } // No scaling keys? Generate a dummy track @@ -236,7 +236,7 @@ void ScenePreprocessor::ProcessAnimation (aiAnimation* anim) q.mTime = 0.; q.mValue = scaling; - DefaultLogger::get()->debug("ScenePreprocessor: Dummy scaling track has been generated"); + ASSIMP_LOG_DEBUG("ScenePreprocessor: Dummy scaling track has been generated"); } // No position keys? Generate a dummy track @@ -248,14 +248,14 @@ void ScenePreprocessor::ProcessAnimation (aiAnimation* anim) q.mTime = 0.; q.mValue = position; - DefaultLogger::get()->debug("ScenePreprocessor: Dummy position track has been generated"); + ASSIMP_LOG_DEBUG("ScenePreprocessor: Dummy position track has been generated"); } } } } if (anim->mDuration == -1.) { - DefaultLogger::get()->debug("ScenePreprocessor: Setting animation duration"); + ASSIMP_LOG_DEBUG("ScenePreprocessor: Setting animation duration"); anim->mDuration = last - std::min( first, 0. ); } } diff --git a/code/SplitByBoneCountProcess.cpp b/code/SplitByBoneCountProcess.cpp index 105ee517d..b33b6d95c 100644 --- a/code/SplitByBoneCountProcess.cpp +++ b/code/SplitByBoneCountProcess.cpp @@ -88,7 +88,7 @@ void SplitByBoneCountProcess::SetupProperties(const Importer* pImp) // Executes the post processing step on the given imported data. void SplitByBoneCountProcess::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("SplitByBoneCountProcess begin"); + ASSIMP_LOG_DEBUG("SplitByBoneCountProcess begin"); // early out bool isNecessary = false; @@ -98,7 +98,7 @@ void SplitByBoneCountProcess::Execute( aiScene* pScene) if( !isNecessary ) { - DefaultLogger::get()->debug( format() << "SplitByBoneCountProcess early-out: no meshes with more than " << mMaxBoneCount << " bones." ); + ASSIMP_LOG_DEBUG( format() << "SplitByBoneCountProcess early-out: no meshes with more than " << mMaxBoneCount << " bones." ); return; } @@ -146,7 +146,7 @@ void SplitByBoneCountProcess::Execute( aiScene* pScene) // recurse through all nodes and translate the node's mesh indices to fit the new mesh array UpdateNode( pScene->mRootNode); - DefaultLogger::get()->debug( format() << "SplitByBoneCountProcess end: split " << mSubMeshIndices.size() << " meshes into " << meshes.size() << " submeshes." ); + ASSIMP_LOG_DEBUG( format() << "SplitByBoneCountProcess end: split " << mSubMeshIndices.size() << " meshes into " << meshes.size() << " submeshes." ); } // ------------------------------------------------------------------------------------------------ diff --git a/code/Subdivision.cpp b/code/Subdivision.cpp index 450e03883..f2e480db1 100644 --- a/code/Subdivision.cpp +++ b/code/Subdivision.cpp @@ -346,7 +346,7 @@ void CatmullClarkSubdivider::InternSubdivide ( ai_snprintf(tmp, 512, "Catmull-Clark Subdivider: got %u bad edges touching only one face (totally %u edges). ", bad_cnt,static_cast(edges.size())); - DefaultLogger::get()->debug(tmp); + DASSIMP_LOG_DEBUG(tmp); }} // --------------------------------------------------------------------- @@ -404,7 +404,7 @@ void CatmullClarkSubdivider::InternSubdivide ( } ai_assert(haveit); if (!haveit) { - DefaultLogger::get()->debug("Catmull-Clark Subdivider: Index not used"); + ASSIMP_LOG_DEBUG("Catmull-Clark Subdivider: Index not used"); } break; } diff --git a/code/TextureTransform.cpp b/code/TextureTransform.cpp index 79914b898..62bbadd08 100644 --- a/code/TextureTransform.cpp +++ b/code/TextureTransform.cpp @@ -331,7 +331,7 @@ void TextureTransformStep::Execute( aiScene* pScene) } if (mesh->mNumUVComponents[info.uvIndex] >= 3){ - DefaultLogger::get()->warn("UV transformations on 3D mapping channels are not supported"); + ASSIMP_LOG_WARN("UV transformations on 3D mapping channels are not supported"); continue; } diff --git a/code/ValidateDataStructure.cpp b/code/ValidateDataStructure.cpp index 045776204..20b348763 100644 --- a/code/ValidateDataStructure.cpp +++ b/code/ValidateDataStructure.cpp @@ -106,7 +106,7 @@ void ValidateDSProcess::ReportWarning(const char* msg,...) ai_assert(iLen > 0); va_end(args); - DefaultLogger::get()->warn("Validation warning: " + std::string(szBuffer,iLen)); + ASSIMP_LOG_WARN("Validation warning: " + std::string(szBuffer,iLen)); } // ------------------------------------------------------------------------------------------------ diff --git a/include/assimp/Profiler.h b/include/assimp/Profiler.h index 272085ea5..da5af2726 100644 --- a/include/assimp/Profiler.h +++ b/include/assimp/Profiler.h @@ -72,7 +72,7 @@ public: /** Start a named timer */ void BeginRegion(const std::string& region) { regions[region] = std::chrono::system_clock::now(); - DefaultLogger::get()->debug((format("START `"),region,"`")); + ASSIMP_LOG_DEBUG((format("START `"),region,"`")); } @@ -84,7 +84,7 @@ public: } std::chrono::duration elapsedSeconds = std::chrono::system_clock::now() - regions[region]; - DefaultLogger::get()->debug((format("END `"),region,"`, dt= ", elapsedSeconds.count()," s")); + ASSIMP_LOG_DEBUG((format("END `"),region,"`, dt= ", elapsedSeconds.count()," s")); } private: From 0e15b25cd132f23e8bcf48314500f88cfdd0321a Mon Sep 17 00:00:00 2001 From: kimkulling Date: Fri, 20 Apr 2018 16:23:24 +0200 Subject: [PATCH 03/11] Next log call changes. --- code/AMFImporter.cpp | 2 +- code/AMFImporter.hpp | 12 ------ code/COBLoader.cpp | 8 ++-- code/CSMLoader.cpp | 2 +- code/DXFLoader.cpp | 35 +++++++--------- code/Exporter.cpp | 2 +- code/FBXDocument.cpp | 2 +- code/FBXDocumentUtil.cpp | 2 +- code/FBXExporter.cpp | 6 +-- code/IRRLoader.cpp | 56 ++++++++++++------------- code/IRRMeshLoader.cpp | 18 ++++---- code/IRRShared.cpp | 25 +++++------ code/Importer.cpp | 50 +++++++++------------- code/Importer/IFC/STEPFileReader.cpp | 18 ++++---- code/LWOBLoader.cpp | 36 +++++++++------- code/LWOLoader.cpp | 63 +++++++++++++++------------- code/LWOLoader.h | 2 +- code/LWOMaterial.cpp | 38 ++++++++--------- code/LWSLoader.cpp | 40 +++++++++--------- code/MD2Loader.cpp | 20 ++++----- code/MD3Loader.cpp | 55 ++++++++++++------------ code/MD5Loader.cpp | 9 ++-- code/MD5Parser.cpp | 2 +- code/MaterialSystem.cpp | 6 +-- code/Subdivision.cpp | 8 ++-- code/glTFAsset.inl | 2 +- code/glTFExporter.cpp | 2 +- include/assimp/fast_atof.h | 2 +- 28 files changed, 247 insertions(+), 276 deletions(-) diff --git a/code/AMFImporter.cpp b/code/AMFImporter.cpp index d20be6b9f..e5b41b3ad 100644 --- a/code/AMFImporter.cpp +++ b/code/AMFImporter.cpp @@ -230,7 +230,7 @@ casu_cres: if(!skipped_before[sk_idx]) { skipped_before[sk_idx] = true; - LogWarning("Skipping node \"" + nn + "\" in " + pParentNodeName + "."); + ASSIMP_LOG_WARN_F("Skipping node \"", nn, "\" in ", pParentNodeName, "."); } } diff --git a/code/AMFImporter.hpp b/code/AMFImporter.hpp index 060cbf10a..3c60caeab 100644 --- a/code/AMFImporter.hpp +++ b/code/AMFImporter.hpp @@ -358,18 +358,6 @@ private: /************** Functions: LOG set *************/ /***********************************************/ - /// \fn void LogInfo(const std::string& pMessage) - /// Short variant for calling \ref DefaultLogger::get()->info() - void LogInfo(const std::string& pMessage) { DefaultLogger::get()->info(pMessage); } - - /// \fn void LogWarning(const std::string& pMessage) - /// Short variant for calling \ref DefaultLogger::get()->warn() - void LogWarning(const std::string& pMessage) { DefaultLogger::get()->warn(pMessage); } - - /// \fn void LogError(const std::string& pMessage) - /// Short variant for calling \ref DefaultLogger::get()->error() - void LogError(const std::string& pMessage) { DefaultLogger::get()->error(pMessage); } - /***********************************************/ /************** Functions: XML set *************/ /***********************************************/ diff --git a/code/COBLoader.cpp b/code/COBLoader.cpp index ae65f8f93..8571bc492 100644 --- a/code/COBLoader.cpp +++ b/code/COBLoader.cpp @@ -509,22 +509,22 @@ void COBImporter::LogDebug_Ascii(const LineSplitter& splitter, const format& mes // ------------------------------------------------------------------------------------------------ void COBImporter::LogWarn_Ascii(const Formatter::format& message) { - DefaultLogger::get()->warn(std::string("COB: ")+=message); + ASSIMP_LOG_WARN_F( "COB: ", message ); } // ------------------------------------------------------------------------------------------------ void COBImporter::LogError_Ascii(const Formatter::format& message) { - DefaultLogger::get()->error(std::string("COB: ")+=message); + ASSIMP_LOG_ERROR_F( "COB: ", message); } // ------------------------------------------------------------------------------------------------ void COBImporter::LogInfo_Ascii(const Formatter::format& message) { - DefaultLogger::get()->info(std::string("COB: ")+=message); + ASSIMP_LOG_INFO_F("COB: ", message); } // ------------------------------------------------------------------------------------------------ void COBImporter::LogDebug_Ascii(const Formatter::format& message) { - DefaultLogger::get()->debug(std::string("COB: ")+=message); + ASSIMP_LOG_DEBUG_F("COB: ", message); } // ------------------------------------------------------------------------------------------------ diff --git a/code/CSMLoader.cpp b/code/CSMLoader.cpp index 7160740c1..777b6cf1b 100644 --- a/code/CSMLoader.cpp +++ b/code/CSMLoader.cpp @@ -233,7 +233,7 @@ void CSMImporter::InternReadFile( const std::string& pFile, if (TokenMatchI(buffer, "DROPOUT", 7)) { // seems this is invalid marker data; at least the doc says it's possible - DefaultLogger::get()->warn("CSM: Encountered invalid marker data (DROPOUT)"); + ASSIMP_LOG_WARN("CSM: Encountered invalid marker data (DROPOUT)"); } else { aiVectorKey* sub = s->mPositionKeys + s->mNumPositionKeys; diff --git a/code/DXFLoader.cpp b/code/DXFLoader.cpp index 89cc1d654..7d8b6eca2 100644 --- a/code/DXFLoader.cpp +++ b/code/DXFLoader.cpp @@ -200,7 +200,7 @@ void DXFImporter::InternReadFile( const std::string& pFile, // comments else if (reader.Is(999)) { - DefaultLogger::get()->info("DXF Comment: " + reader.Value()); + ASSIMP_LOG_INFO_F("DXF Comment: ", reader.Value()); } // don't read past the official EOF sign @@ -393,7 +393,7 @@ void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& bloc // XXX rotation currently ignored - I didn't find an appropriate sample model. if (insert.angle != 0.f) { - DefaultLogger::get()->warn("DXF: BLOCK rotation not currently implemented"); + ASSIMP_LOG_WARN("DXF: BLOCK rotation not currently implemented"); } for (aiVector3D& v : pl_out->positions) { @@ -523,7 +523,7 @@ void DXFImporter::ParseBlock(DXF::LineReader& reader, DXF::FileData& output) // XXX is this a valid case? if (reader.Is(0,"INSERT")) { - DefaultLogger::get()->warn("DXF: INSERT within a BLOCK not currently supported; skipping"); + ASSIMP_LOG_WARN("DXF: INSERT within a BLOCK not currently supported; skipping"); for( ;!reader.End() && !reader.Is(0,"ENDBLK"); ++reader); break; } @@ -678,16 +678,15 @@ void DXFImporter::ParsePolyLine(DXF::LineReader& reader, DXF::FileData& output) //} if (vguess && line.positions.size() != vguess) { - DefaultLogger::get()->warn((Formatter::format("DXF: unexpected vertex count in polymesh: "), - line.positions.size(),", expected ", vguess - )); + ASSIMP_LOG_WARN_F("DXF: unexpected vertex count in polymesh: ", + line.positions.size(),", expected ", vguess ); } if (line.flags & DXF_POLYLINE_FLAG_POLYFACEMESH ) { if (line.positions.size() < 3 || line.indices.size() < 3) { - DefaultLogger::get()->warn("DXF: not enough vertices for polymesh; ignoring"); - output.blocks.back().lines.pop_back(); - return; + ASSIMP_LOG_WARN("DXF: not enough vertices for polymesh; ignoring"); + output.blocks.back().lines.pop_back(); + return; } // if these numbers are wrong, parsing might have gone wild. @@ -695,13 +694,11 @@ void DXFImporter::ParsePolyLine(DXF::LineReader& reader, DXF::FileData& output) // to set the 71 and 72 fields, respectively, to valid values. // So just fire a warning. if (iguess && line.counts.size() != iguess) { - DefaultLogger::get()->warn((Formatter::format("DXF: unexpected face count in polymesh: "), - line.counts.size(),", expected ", iguess - )); + ASSIMP_LOG_WARN_F( "DXF: unexpected face count in polymesh: ", line.counts.size(),", expected ", iguess ); } } else if (!line.indices.size() && !line.counts.size()) { - // a polyline - so there are no indices yet. + // a poly-line - so there are no indices yet. size_t guess = line.positions.size() + (line.flags & DXF_POLYLINE_FLAG_CLOSED ? 1 : 0); line.indices.reserve(guess); @@ -743,10 +740,10 @@ void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& li { case 8: // layer to which the vertex belongs to - assume that - // this is always the layer the top-level polyline + // this is always the layer the top-level poly-line // entity resides on as well. if(reader.Value() != line.layer) { - DefaultLogger::get()->warn("DXF: expected vertex to be part of a polyface but the 0x128 flag isn't set"); + ASSIMP_LOG_WARN("DXF: expected vertex to be part of a poly-face but the 0x128 flag isn't set"); } break; @@ -765,7 +762,7 @@ void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& li case 73: case 74: if (cnti == 4) { - DefaultLogger::get()->warn("DXF: more than 4 indices per face not supported; ignoring"); + ASSIMP_LOG_WARN("DXF: more than 4 indices per face not supported; ignoring"); break; } indices[cnti++] = reader.ValueAsUnsignedInt(); @@ -781,7 +778,7 @@ void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& li } if (line.flags & DXF_POLYLINE_FLAG_POLYFACEMESH && !(flags & DXF_VERTEX_FLAG_PART_OF_POLYFACE)) { - DefaultLogger::get()->warn("DXF: expected vertex to be part of a polyface but the 0x128 flag isn't set"); + ASSIMP_LOG_WARN("DXF: expected vertex to be part of a polyface but the 0x128 flag isn't set"); } if (cnti) { @@ -789,7 +786,7 @@ void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& li for (unsigned int i = 0; i < cnti; ++i) { // IMPORTANT NOTE: POLYMESH indices are ONE-BASED if (indices[i] == 0) { - DefaultLogger::get()->warn("DXF: invalid vertex index, indices are one-based."); + ASSIMP_LOG_WARN("DXF: invalid vertex index, indices are one-based."); --line.counts.back(); continue; } @@ -906,7 +903,7 @@ void DXFImporter::Parse3DFace(DXF::LineReader& reader, DXF::FileData& output) // sanity checks to see if we got something meaningful if ((b[1] && !b[0]) || !b[2] || !b[3]) { - DefaultLogger::get()->warn("DXF: unexpected vertex setup in 3DFACE/LINE/FACE entity; ignoring"); + ASSIMP_LOG_WARN("DXF: unexpected vertex setup in 3DFACE/LINE/FACE entity; ignoring"); output.blocks.back().lines.pop_back(); return; } diff --git a/code/Exporter.cpp b/code/Exporter.cpp index b7478c0be..0a8f054b7 100644 --- a/code/Exporter.cpp +++ b/code/Exporter.cpp @@ -363,7 +363,7 @@ aiReturn Exporter::Export( const aiScene* pScene, const char* pFormatId, const c } if (verbosify || (exp.mEnforcePP & aiProcess_JoinIdenticalVertices)) { - DefaultLogger::get()->debug("export: Scene data not in verbose format, applying MakeVerboseFormat step first"); + ASSIMP_LOG_DEBUG("export: Scene data not in verbose format, applying MakeVerboseFormat step first"); MakeVerboseFormatProcess proc; proc.Execute(scenecopy.get()); diff --git a/code/FBXDocument.cpp b/code/FBXDocument.cpp index a1fbd2cf0..2965a54ff 100644 --- a/code/FBXDocument.cpp +++ b/code/FBXDocument.cpp @@ -214,7 +214,7 @@ const Object* LazyObject::Get(bool dieOnError) // note: the error message is already formatted, so raw logging is ok if(!DefaultLogger::isNullLogger()) { - DefaultLogger::get()->error(ex.what()); + ASSIMP_LOG_ERROR(ex.what()); } return NULL; } diff --git a/code/FBXDocumentUtil.cpp b/code/FBXDocumentUtil.cpp index 775067021..3b1435b5c 100644 --- a/code/FBXDocumentUtil.cpp +++ b/code/FBXDocumentUtil.cpp @@ -79,7 +79,7 @@ void DOMError(const std::string& message, const Element* element /*= NULL*/) void DOMWarning(const std::string& message, const Token& token) { if(DefaultLogger::get()) { - DefaultLogger::get()->warn(Util::AddTokenText("FBX-DOM",message,&token)); + ASSIMP_LOG_WARN(Util::AddTokenText("FBX-DOM",message,&token)); } } diff --git a/code/FBXExporter.cpp b/code/FBXExporter.cpp index c524e3911..4945ec5dc 100644 --- a/code/FBXExporter.cpp +++ b/code/FBXExporter.cpp @@ -1124,7 +1124,7 @@ void FBXExporter::WriteObjects () err << " has " << m->mNumUVComponents[uvi]; err << " components! Data will be preserved,"; err << " but may be incorrectly interpreted on load."; - DefaultLogger::get()->warn(err.str()); + ASSIMP_LOG_WARN(err.str()); } FBX::Node uv("LayerElementUV", int32_t(uvi)); uv.Begin(outstream, binary, indent); @@ -1449,7 +1449,7 @@ void FBXExporter::WriteObjects () err << "Multilayer textures not supported (for now),"; err << " skipping texture type " << j; err << " of material " << i; - DefaultLogger::get()->warn(err.str()); + ASSIMP_LOG_WARN(err.str()); } // get image path for this (single-image) texture @@ -1484,7 +1484,7 @@ void FBXExporter::WriteObjects () err << "Not sure how to handle texture of type " << j; err << " on material " << i; err << ", skipping..."; - DefaultLogger::get()->warn(err.str()); + ASSIMP_LOG_WARN(err.str()); continue; } const std::string& prop_name = elem2->second; diff --git a/code/IRRLoader.cpp b/code/IRRLoader.cpp index 66d15c5c4..0640b0d66 100644 --- a/code/IRRLoader.cpp +++ b/code/IRRLoader.cpp @@ -131,7 +131,7 @@ void IRRImporter::SetupProperties(const Importer* pImp) // read the output frame rate of all node animation channels fps = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_IRR_ANIM_FPS,100); if (fps < 10.) { - DefaultLogger::get()->error("IRR: Invalid FPS configuration"); + ASSIMP_LOG_ERROR("IRR: Invalid FPS configuration"); fps = 100; } @@ -281,7 +281,7 @@ void IRRImporter::CopyMaterial(std::vector& materials, return; } else if (inmaterials.size() > 1) { - DefaultLogger::get()->info("IRR: Skipping additional materials"); + ASSIMP_LOG_INFO("IRR: Skipping additional materials"); } mesh->mMaterialIndex = (unsigned int)materials.size(); @@ -319,17 +319,18 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vectoranimators.empty()) { return; } - unsigned int total = 0; + unsigned int total( 0 ); for (std::list::iterator it = root->animators.begin();it != root->animators.end(); ++it) { if ((*it).type == Animator::UNKNOWN || (*it).type == Animator::OTHER) { - DefaultLogger::get()->warn("IRR: Skipping unknown or unsupported animator"); + ASSIMP_LOG_WARN("IRR: Skipping unknown or unsupported animator"); continue; } ++total; } - if (!total)return; - else if (1 == total) { - DefaultLogger::get()->warn("IRR: Adding dummy nodes to simulate multiple animators"); + if (!total) { + return; + } else if (1 == total) { + ASSIMP_LOG_WARN("IRR: Adding dummy nodes to simulate multiple animators"); } // NOTE: 1 tick == i millisecond @@ -518,9 +519,9 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vectorwarn("IRR: Spline animators with no points defined"); + ASSIMP_LOG_WARN("IRR: Spline animators with no points defined"); - delete anim;anim = NULL; + delete anim;anim = nullptr; break; } else if (size == 1) { @@ -672,7 +673,7 @@ void IRRImporter::GenerateGraph(Node* root,aiNode* rootOut ,aiScene* scene, // graph we're currently building aiScene* scene = batch.GetImport(root->id); if (!scene) { - DefaultLogger::get()->error("IRR: Unable to load external file: " + root->meshPath); + ASSIMP_LOG_ERROR("IRR: Unable to load external file: " + root->meshPath); break; } attach.push_back(AttachmentInfo(scene,rootOut)); @@ -683,7 +684,7 @@ void IRRImporter::GenerateGraph(Node* root,aiNode* rootOut ,aiScene* scene, // should be equal. If they are not, we can impossibly // do this ... if (root->materials.size() != (unsigned int)scene->mNumMaterials) { - DefaultLogger::get()->warn("IRR: Failed to match imported materials " + ASSIMP_LOG_WARN("IRR: Failed to match imported materials " "with the materials found in the IRR scene file"); break; @@ -722,7 +723,7 @@ void IRRImporter::GenerateGraph(Node* root,aiNode* rootOut ,aiScene* scene, } } if (bdo) { - DefaultLogger::get()->info("IRR: Replacing mesh vertex alpha with common opacity"); + ASSIMP_LOG_INFO("IRR: Replacing mesh vertex alpha with common opacity"); for (unsigned int a = 0; a < mesh->mNumVertices;++a) mesh->mColors[0][a].a = 1.f; @@ -806,7 +807,7 @@ void IRRImporter::GenerateGraph(Node* root,aiNode* rootOut ,aiScene* scene, { // A skybox is defined by six materials if (root->materials.size() < 6) { - DefaultLogger::get()->error("IRR: There should be six materials for a skybox"); + ASSIMP_LOG_ERROR("IRR: There should be six materials for a skybox"); break; } @@ -823,7 +824,7 @@ void IRRImporter::GenerateGraph(Node* root,aiNode* rootOut ,aiScene* scene, // for IRR skyboxes. We add a 'IRR.SkyBox_' prefix to the node. // ************************************************************* root->name = "IRR.SkyBox_" + root->name; - DefaultLogger::get()->info("IRR: Loading skybox, this will " + ASSIMP_LOG_INFO("IRR: Loading skybox, this will " "require special handling to be displayed correctly"); } break; @@ -831,7 +832,7 @@ void IRRImporter::GenerateGraph(Node* root,aiNode* rootOut ,aiScene* scene, case Node::TERRAIN: { // to support terrains, we'd need to have a texture decoder - DefaultLogger::get()->error("IRR: Unsupported node - TERRAIN"); + ASSIMP_LOG_ERROR("IRR: Unsupported node - TERRAIN"); } break; default: @@ -1010,11 +1011,11 @@ void IRRImporter::InternReadFile( const std::string& pFile, } else if (!ASSIMP_stricmp(sz,"billBoard")) { // We don't support billboards, so ignore them - DefaultLogger::get()->error("IRR: Billboards are not supported by Assimp"); + ASSIMP_LOG_ERROR("IRR: Billboards are not supported by Assimp"); nd = new Node(Node::DUMMY); } else { - DefaultLogger::get()->warn("IRR: Found unknown node: " + std::string(sz)); + ASSIMP_LOG_WARN("IRR: Found unknown node: " + std::string(sz)); /* We skip the contents of nodes we don't know. * We parse the transformation and all animators @@ -1041,7 +1042,7 @@ void IRRImporter::InternReadFile( const std::string& pFile, */ if (!curNode) { #if 0 - DefaultLogger::get()->error("IRR: Encountered element, but " + ASSIMP_LOG_ERROR("IRR: Encountered element, but " "there is no node active"); #endif continue; @@ -1269,7 +1270,7 @@ void IRRImporter::InternReadFile( const std::string& pFile, lights.pop_back(); curNode->type = Node::DUMMY; - DefaultLogger::get()->error("Ignoring light of unknown type: " + prop.value); + ASSIMP_LOG_ERROR("Ignoring light of unknown type: " + prop.value); } } else if ((prop.name == "Mesh" && Node::MESH == curNode->type) || @@ -1277,7 +1278,7 @@ void IRRImporter::InternReadFile( const std::string& pFile, { /* This is the file name of the mesh - either * animated or not. We need to make sure we setup - * the correct postprocessing settings here. + * the correct post-processing settings here. */ unsigned int pp = 0; BatchLoader::PropertyMap map; @@ -1299,7 +1300,7 @@ void IRRImporter::InternReadFile( const std::string& pFile, const std::string extension = GetExtension(prop.value); if ("irr" == extension) { - DefaultLogger::get()->error("IRR: Can't load another IRR file recursively"); + ASSIMP_LOG_ERROR("IRR: Can't load another IRR file recursively"); } else { @@ -1323,7 +1324,7 @@ void IRRImporter::InternReadFile( const std::string& pFile, curAnim->type = Animator::FOLLOW_SPLINE; } else { - DefaultLogger::get()->warn("IRR: Ignoring unknown animator: " + ASSIMP_LOG_WARN("IRR: Ignoring unknown animator: " + prop.value); curAnim->type = Animator::UNKNOWN; @@ -1348,7 +1349,7 @@ void IRRImporter::InternReadFile( const std::string& pFile, // back in the node hierarchy if (!curParent) { curParent = root; - DefaultLogger::get()->error("IRR: Too many closing elements"); + ASSIMP_LOG_ERROR("IRR: Too many closing elements"); } else curParent = curParent->parent; } @@ -1369,15 +1370,14 @@ void IRRImporter::InternReadFile( const std::string& pFile, } } - /* Now iterate through all cameras and compute their final (horizontal) FOV - */ + // Now iterate through all cameras and compute their final (horizontal) FOV for (aiCamera *cam : cameras) { - // screen aspect could be missing if (cam->mAspect) { cam->mHorizontalFOV *= cam->mAspect; + } else { + ASSIMP_LOG_WARN("IRR: Camera aspect is not given, can't compute horizontal FOV"); } - else DefaultLogger::get()->warn("IRR: Camera aspect is not given, can't compute horizontal FOV"); } batch.LoadAll(); @@ -1472,7 +1472,7 @@ void IRRImporter::InternReadFile( const std::string& pFile, * models from external files */ if (!pScene->mNumMeshes || !pScene->mNumMaterials) { - DefaultLogger::get()->warn("IRR: No meshes loaded, setting AI_SCENE_FLAGS_INCOMPLETE"); + ASSIMP_LOG_WARN("IRR: No meshes loaded, setting AI_SCENE_FLAGS_INCOMPLETE"); pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE; } diff --git a/code/IRRMeshLoader.cpp b/code/IRRMeshLoader.cpp index 5885d69a2..1ed16acd6 100644 --- a/code/IRRMeshLoader.cpp +++ b/code/IRRMeshLoader.cpp @@ -175,7 +175,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile, if (!ASSIMP_stricmp(reader->getNodeName(),"buffer") && (curMat || curMesh)) { // end of previous buffer. A material and a mesh should be there if ( !curMat || !curMesh) { - DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material"); + ASSIMP_LOG_ERROR("IRRMESH: A buffer must contain a mesh and a material"); releaseMaterial( &curMat ); releaseMesh( &curMesh ); } else { @@ -197,7 +197,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile, if (!ASSIMP_stricmp(reader->getNodeName(),"material")) { if (curMat) { - DefaultLogger::get()->warn("IRRMESH: Only one material description per buffer, please"); + ASSIMP_LOG_WARN("IRRMESH: Only one material description per buffer, please"); releaseMaterial( &curMat ); } curMat = ParseMaterial(curMatFlags); @@ -208,7 +208,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile, if (!num) { // This is possible ... remove the mesh from the list and skip further reading - DefaultLogger::get()->warn("IRRMESH: Found mesh with zero vertices"); + ASSIMP_LOG_WARN("IRRMESH: Found mesh with zero vertices"); releaseMaterial( &curMat ); releaseMesh( &curMesh ); @@ -255,7 +255,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile, } else if (ASSIMP_stricmp("standard", t)) { releaseMaterial( &curMat ); - DefaultLogger::get()->warn("IRRMESH: Unknown vertex format"); + ASSIMP_LOG_WARN("IRRMESH: Unknown vertex format"); } else vertexFormat = 0; textMeaning = 1; @@ -275,7 +275,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile, curMesh->mNumVertices = reader->getAttributeValueAsInt("indexCount"); if (!curMesh->mNumVertices) { // This is possible ... remove the mesh from the list and skip further reading - DefaultLogger::get()->warn("IRRMESH: Found mesh with zero indices"); + ASSIMP_LOG_WARN("IRRMESH: Found mesh with zero indices"); // mesh - away releaseMesh( &curMesh ); @@ -288,7 +288,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile, } if (curMesh->mNumVertices % 3) { - DefaultLogger::get()->warn("IRRMESH: Number if indices isn't divisible by 3"); + ASSIMP_LOG_WARN("IRRMESH: Number if indices isn't divisible by 3"); } curMesh->mNumFaces = curMesh->mNumVertices / 3; @@ -439,7 +439,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile, unsigned int total = 0; while(SkipSpacesAndLineEnd(&sz)) { if (curFace >= faceEnd) { - DefaultLogger::get()->error("IRRMESH: Too many indices"); + ASSIMP_LOG_ERROR("IRRMESH: Too many indices"); break; } if (!curIdx) { @@ -449,7 +449,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile, unsigned int idx = strtoul10(sz,&sz); if (idx >= curVertices.size()) { - DefaultLogger::get()->error("IRRMESH: Index out of range"); + ASSIMP_LOG_ERROR("IRRMESH: Index out of range"); idx = 0; } @@ -492,7 +492,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile, // End of the last buffer. A material and a mesh should be there if (curMat || curMesh) { if ( !curMat || !curMesh) { - DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material"); + ASSIMP_LOG_ERROR("IRRMESH: A buffer must contain a mesh and a material"); releaseMaterial( &curMat ); releaseMesh( &curMesh ); } diff --git a/code/IRRShared.cpp b/code/IRRShared.cpp index fa90916b3..1e69f1d09 100644 --- a/code/IRRShared.cpp +++ b/code/IRRShared.cpp @@ -179,14 +179,14 @@ void IrrlichtBase::ReadVectorProperty (VectorProperty& out) SkipSpaces(&ptr); if (',' != *ptr) { - DefaultLogger::get()->error("IRR(MESH): Expected comma in vector definition"); + ASSIMP_LOG_ERROR("IRR(MESH): Expected comma in vector definition"); } else SkipSpaces(ptr+1,&ptr); ptr = fast_atoreal_move( ptr,(float&)out.value.y ); SkipSpaces(&ptr); if (',' != *ptr) { - DefaultLogger::get()->error("IRR(MESH): Expected comma in vector definition"); + ASSIMP_LOG_ERROR("IRR(MESH): Expected comma in vector definition"); } else SkipSpaces(ptr+1,&ptr); ptr = fast_atoreal_move( ptr,(float&)out.value.z ); @@ -360,7 +360,7 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags) matFlags = AI_IRRMESH_MAT_normalmap_ta; } else { - DefaultLogger::get()->warn("IRRMat: Unrecognized material type: " + prop.value); + ASSIMP_LOG_WARN("IRRMat: Unrecognized material type: " + prop.value); } } @@ -391,9 +391,7 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags) // set the corresponding material flag matFlags |= AI_IRRMESH_EXTRA_2ND_TEXTURE; - } - // or just as second diffuse texture - else if (matFlags & AI_IRRMESH_MAT_solid_2layer) { + } else if (matFlags & AI_IRRMESH_MAT_solid_2layer) {// or just as second diffuse texture ++cnt; s.Set(prop.value); mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(1)); @@ -401,19 +399,15 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags) // set the corresponding material flag matFlags |= AI_IRRMESH_EXTRA_2ND_TEXTURE; + } else { + ASSIMP_LOG_WARN("IRRmat: Skipping second texture"); } - else DefaultLogger::get()->warn("IRRmat: Skipping second texture"); - } - - else if (prop.name == "Texture3" && cnt == 2) - { + } else if (prop.name == "Texture3" && cnt == 2) { // Irrlicht does not seem to use these channels. ++cnt; s.Set(prop.value); mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(nd+1)); - } - else if (prop.name == "Texture4" && cnt == 3) - { + } else if (prop.name == "Texture4" && cnt == 3) { // Irrlicht does not seem to use these channels. ++cnt; s.Set(prop.value); @@ -499,7 +493,8 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags) break; } } - DefaultLogger::get()->error("IRRMESH: Unexpected end of file. Material is not complete"); + ASSIMP_LOG_ERROR("IRRMESH: Unexpected end of file. Material is not complete"); + return mat; } diff --git a/code/Importer.cpp b/code/Importer.cpp index f47160c5c..36afc8723 100644 --- a/code/Importer.cpp +++ b/code/Importer.cpp @@ -504,62 +504,50 @@ const aiScene* Importer::ReadFileFromMemory( const void* pBuffer, // ------------------------------------------------------------------------------------------------ void WriteLogOpening(const std::string& file) { - Logger* l = DefaultLogger::get(); - if (!l) { - return; - } - l->info("Load " + file); + ASSIMP_LOG_INFO_F("Load ", file); // print a full version dump. This is nice because we don't // need to ask the authors of incoming bug reports for // the library version they're using - a log dump is // sufficient. const unsigned int flags = aiGetCompileFlags(); - l->debug(format() - << "Assimp " - << aiGetVersionMajor() - << "." - << aiGetVersionMinor() - << "." - << aiGetVersionRevision() - - << " " + ASSIMP_LOG_DEBUG_F( "Assimp ", aiGetVersionMajor(), ".", aiGetVersionMinor(), ".", aiGetVersionRevision(), " " #if defined(ASSIMP_BUILD_ARCHITECTURE) - << ASSIMP_BUILD_ARCHITECTURE + ,ASSIMP_BUILD_ARCHITECTURE #elif defined(_M_IX86) || defined(__x86_32__) || defined(__i386__) - << "x86" + , "x86" #elif defined(_M_X64) || defined(__x86_64__) - << "amd64" + , "amd64" #elif defined(_M_IA64) || defined(__ia64__) - << "itanium" + , "itanium" #elif defined(__ppc__) || defined(__powerpc__) - << "ppc32" + , "ppc32" #elif defined(__powerpc64__) - << "ppc64" + , "ppc64" #elif defined(__arm__) - << "arm" + , "arm" #else - << "" + , "" #endif - << " " + , " " #if defined(ASSIMP_BUILD_COMPILER) - << ASSIMP_BUILD_COMPILER + , ASSIMP_BUILD_COMPILER #elif defined(_MSC_VER) - << "msvc" + , "msvc" #elif defined(__GNUC__) - << "gcc" + , "gcc" #else - << "" + , "" #endif #ifdef ASSIMP_BUILD_DEBUG - << " debug" + , " debug" #endif - << (flags & ASSIMP_CFLAGS_NOBOOST ? " noboost" : "") - << (flags & ASSIMP_CFLAGS_SHARED ? " shared" : "") - << (flags & ASSIMP_CFLAGS_SINGLETHREADED ? " singlethreaded" : "") + , (flags & ASSIMP_CFLAGS_NOBOOST ? " noboost" : "") + , (flags & ASSIMP_CFLAGS_SHARED ? " shared" : "") + , (flags & ASSIMP_CFLAGS_SINGLETHREADED ? " singlethreaded" : "") ); } diff --git a/code/Importer/IFC/STEPFileReader.cpp b/code/Importer/IFC/STEPFileReader.cpp index 34981d0c5..b1390b9de 100644 --- a/code/Importer/IFC/STEPFileReader.cpp +++ b/code/Importer/IFC/STEPFileReader.cpp @@ -126,7 +126,7 @@ STEP::DB* STEP::ReadFileHeader(std::shared_ptr stream) // XXX need support for multiple schemas? if (list->GetSize() > 1) { - DefaultLogger::get()->warn(AddLineNumber("multiple schemas currently not supported",line)); + ASSIMP_LOG_WARN(AddLineNumber("multiple schemas currently not supported",line)); } const EXPRESS::STRING* string( nullptr ); if (!list->GetSize() || !(string=dynamic_cast( (*list)[0].get() ))) { @@ -192,7 +192,7 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme, // LineSplitter already ignores empty lines ai_assert(s.length()); if (s[0] != '#') { - DefaultLogger::get()->warn(AddLineNumber("expected token \'#\'",line)); + ASSIMP_LOG_WARN(AddLineNumber("expected token \'#\'",line)); ++splitter; continue; } @@ -202,14 +202,14 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme, // --- const std::string::size_type n0 = s.find_first_of('='); if (n0 == std::string::npos) { - DefaultLogger::get()->warn(AddLineNumber("expected token \'=\'",line)); + ASSIMP_LOG_WARN(AddLineNumber("expected token \'=\'",line)); ++splitter; continue; } const uint64_t id = strtoul10_64(s.substr(1,n0-1).c_str()); if (!id) { - DefaultLogger::get()->warn(AddLineNumber("expected positive, numeric entity id",line)); + ASSIMP_LOG_WARN(AddLineNumber("expected positive, numeric entity id",line)); ++splitter; continue; } @@ -236,7 +236,7 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme, } if(!ok) { - DefaultLogger::get()->warn(AddLineNumber("expected token \'(\'",line)); + ASSIMP_LOG_WARN(AddLineNumber("expected token \'(\'",line)); continue; } } @@ -263,13 +263,13 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme, } } if(!ok) { - DefaultLogger::get()->warn(AddLineNumber("expected token \')\'",line)); + ASSIMP_LOG_WARN(AddLineNumber("expected token \')\'",line)); continue; } } if (map.find(id) != map.end()) { - DefaultLogger::get()->warn(AddLineNumber((Formatter::format(),"an object with the id #",id," already exists"),line)); + ASSIMP_LOG_WARN(AddLineNumber((Formatter::format(),"an object with the id #",id," already exists"),line)); } std::string::size_type ns = n0; @@ -292,7 +292,7 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme, } if (!splitter) { - DefaultLogger::get()->warn("STEP: ignoring unexpected EOF"); + ASSIMP_LOG_WARN("STEP: ignoring unexpected EOF"); } if ( !DefaultLogger::isNullLogger()){ @@ -392,7 +392,7 @@ std::shared_ptr EXPRESS::DataType::Parse(const char*& i std::string stemp = std::string(start, static_cast(cur - start)); if(!StringToUTF8(stemp)) { // TODO: route this to a correct logger with line numbers etc., better error messages - DefaultLogger::get()->error("an error occurred reading escape sequences in ASCII text"); + ASSIMP_LOG_ERROR("an error occurred reading escape sequences in ASCII text"); } return std::make_shared(stemp); diff --git a/code/LWOBLoader.cpp b/code/LWOBLoader.cpp index 45e149914..fabf99cad 100644 --- a/code/LWOBLoader.cpp +++ b/code/LWOBLoader.cpp @@ -74,7 +74,7 @@ void LWOImporter::LoadLWOBFile() case AI_LWO_PNTS: { if (!mCurLayer->mTempPoints.empty()) - DefaultLogger::get()->warn("LWO: PNTS chunk encountered twice"); + ASSIMP_LOG_WARN("LWO: PNTS chunk encountered twice"); else LoadLWOPoints(head.length); break; } @@ -83,7 +83,7 @@ void LWOImporter::LoadLWOBFile() { if (!mCurLayer->mFaces.empty()) - DefaultLogger::get()->warn("LWO: POLS chunk encountered twice"); + ASSIMP_LOG_WARN("LWO: POLS chunk encountered twice"); else LoadLWOBPolygons(head.length); break; } @@ -91,7 +91,7 @@ void LWOImporter::LoadLWOBFile() case AI_LWO_SRFS: { if (!mTags->empty()) - DefaultLogger::get()->warn("LWO: SRFS chunk encountered twice"); + ASSIMP_LOG_WARN("LWO: SRFS chunk encountered twice"); else LoadLWOTags(head.length); break; } @@ -183,20 +183,20 @@ void LWOImporter::CopyFaceIndicesLWOB(FaceList::iterator& it, break; } face.mIndices = new unsigned int[face.mNumIndices]; - for (unsigned int i = 0; i < face.mNumIndices;++i) - { + for (unsigned int i = 0; i < face.mNumIndices;++i) { unsigned int & mi = face.mIndices[i]; uint16_t index; ::memcpy(&index, cursor++, 2); mi = index; if (mi > mCurLayer->mTempPoints.size()) { - DefaultLogger::get()->warn("LWOB: face index is out of range"); + ASSIMP_LOG_WARN("LWOB: face index is out of range"); mi = (unsigned int)mCurLayer->mTempPoints.size()-1; } } + } else { + ASSIMP_LOG_WARN("LWOB: Face has 0 indices"); } - else DefaultLogger::get()->warn("LWOB: Face has 0 indices"); int16_t surface; ::memcpy(&surface, cursor++, 2); if (surface < 0) @@ -242,7 +242,7 @@ LWO::Texture* LWOImporter::SetupNewTextureLWOB(LWO::TextureList& list,unsigned i else { // procedural or gradient, not supported - DefaultLogger::get()->error("LWOB: Unsupported legacy texture: " + type); + ASSIMP_LOG_ERROR_F("LWOB: Unsupported legacy texture: ", type); } return tex; @@ -273,7 +273,7 @@ void LWOImporter::LoadLWOBSurface(unsigned int size) * how much storage is actually left and work with this value from now on. */ if (mFileBuffer + head.length > end) { - DefaultLogger::get()->error("LWOB: Invalid surface chunk length. Trying to continue."); + ASSIMP_LOG_ERROR("LWOB: Invalid surface chunk length. Trying to continue."); head.length = (uint16_t) (end - mFileBuffer); } @@ -381,8 +381,9 @@ void LWOImporter::LoadLWOBSurface(unsigned int size) { if (pTex) { GetS0(pTex->mFileName,head.length); + } else { + ASSIMP_LOG_WARN("LWOB: Unexpected TIMG chunk"); } - else DefaultLogger::get()->warn("LWOB: Unexpected TIMG chunk"); break; } // texture strength @@ -391,8 +392,9 @@ void LWOImporter::LoadLWOBSurface(unsigned int size) AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,TVAL,1); if (pTex) { pTex->mStrength = (float)GetU1()/ 255.f; + } else { + ASSIMP_LOG_ERROR("LWOB: Unexpected TVAL chunk"); } - else DefaultLogger::get()->warn("LWOB: Unexpected TVAL chunk"); break; } // texture flags @@ -400,8 +402,7 @@ void LWOImporter::LoadLWOBSurface(unsigned int size) { AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,TFLG,2); - if (pTex) - { + if (nullptr != pTex) { const uint16_t s = GetU2(); if (s & 1) pTex->majorAxis = LWO::Texture::AXIS_X; @@ -410,10 +411,13 @@ void LWOImporter::LoadLWOBSurface(unsigned int size) else if (s & 4) pTex->majorAxis = LWO::Texture::AXIS_Z; - if (s & 16) - DefaultLogger::get()->warn("LWOB: Ignoring \'negate\' flag on texture"); + if (s & 16) { + ASSIMP_LOG_WARN("LWOB: Ignoring \'negate\' flag on texture"); + } + } + else { + ASSIMP_LOG_WARN("LWOB: Unexpected TFLG chunk"); } - else DefaultLogger::get()->warn("LWOB: Unexpected TFLG chunk"); break; } } diff --git a/code/LWOLoader.cpp b/code/LWOLoader.cpp index e908ea178..d654935b4 100644 --- a/code/LWOLoader.cpp +++ b/code/LWOLoader.cpp @@ -188,7 +188,7 @@ void LWOImporter::InternReadFile( const std::string& pFile, // old lightwave file format (prior to v6) if (AI_LWO_FOURCC_LWOB == fileType) { - DefaultLogger::get()->info("LWO file format: LWOB (<= LightWave 5.5)"); + ASSIMP_LOG_INFO("LWO file format: LWOB (<= LightWave 5.5)"); mIsLWO2 = false; mIsLXOB = false; @@ -197,12 +197,12 @@ void LWOImporter::InternReadFile( const std::string& pFile, // New lightwave format else if (AI_LWO_FOURCC_LWO2 == fileType) { mIsLXOB = false; - DefaultLogger::get()->info("LWO file format: LWO2 (>= LightWave 6)"); + ASSIMP_LOG_INFO("LWO file format: LWO2 (>= LightWave 6)"); } // MODO file format else if (AI_LWO_FOURCC_LXOB == fileType) { mIsLXOB = true; - DefaultLogger::get()->info("LWO file format: LXOB (Modo)"); + ASSIMP_LOG_INFO("LWO file format: LXOB (Modo)"); } // we don't know this format else @@ -271,7 +271,7 @@ void LWOImporter::InternReadFile( const std::string& pFile, unsigned int idx = (*it).surfaceIndex; if (idx >= mTags->size()) { - DefaultLogger::get()->warn("LWO: Invalid face surface index"); + ASSIMP_LOG_WARN("LWO: Invalid face surface index"); idx = UINT_MAX; } if(UINT_MAX == idx || UINT_MAX == (idx = _mMapping[idx])) { @@ -423,7 +423,9 @@ void LWOImporter::InternReadFile( const std::string& pFile, // So we use a separate implementation. ComputeNormals(mesh,smoothingGroups,_mSurfaces[i]); } - else DefaultLogger::get()->debug("LWO2: No need to compute normals, they're already there"); + else { + ASSIMP_LOG_DEBUG("LWO2: No need to compute normals, they're already there"); + } ++p; } } @@ -686,13 +688,13 @@ void LWOImporter::ResolveClips() if (Clip::REF == clip.type) { if (clip.clipRef >= mClips.size()) { - DefaultLogger::get()->error("LWO2: Clip referrer index is out of range"); + ASSIMP_LOG_ERROR("LWO2: Clip referrer index is out of range"); clip.clipRef = 0; } Clip& dest = mClips[clip.clipRef]; if (Clip::REF == dest.type) { - DefaultLogger::get()->error("LWO2: Clip references another clip reference"); + ASSIMP_LOG_ERROR("LWO2: Clip references another clip reference"); clip.type = Clip::UNSUPPORTED; } @@ -711,7 +713,7 @@ void LWOImporter::AdjustTexturePath(std::string& out) if (!mIsLWO2 && ::strstr(out.c_str(), "(sequence)")) { // remove the (sequence) and append 000 - DefaultLogger::get()->info("LWOB: Sequence of animated texture found. It will be ignored"); + ASSIMP_LOG_INFO("LWOB: Sequence of animated texture found. It will be ignored"); out = out.substr(0,out.length()-10) + "000"; } @@ -786,10 +788,10 @@ void LWOImporter::LoadLWO2Polygons(unsigned int length) { // read unsupported stuff too (although we won't process it) case AI_LWO_MBAL: - DefaultLogger::get()->warn("LWO2: Encountered unsupported primitive chunk (METABALL)"); + ASSIMP_LOG_WARN("LWO2: Encountered unsupported primitive chunk (METABALL)"); break; case AI_LWO_CURV: - DefaultLogger::get()->warn("LWO2: Encountered unsupported primitive chunk (SPLINE)");; + ASSIMP_LOG_WARN("LWO2: Encountered unsupported primitive chunk (SPLINE)");; break; // These are ok with no restrictions @@ -801,7 +803,7 @@ void LWOImporter::LoadLWO2Polygons(unsigned int length) default: // hm!? wtf is this? ok ... - DefaultLogger::get()->error("LWO2: Ignoring unknown polygon type."); + ASSIMP_LOG_ERROR("LWO2: Ignoring unknown polygon type."); break; } @@ -864,7 +866,7 @@ void LWOImporter::CopyFaceIndicesLWO2(FaceList::iterator& it, face.mIndices[i] = ReadVSizedIntLWO2((uint8_t*&)cursor) + mCurLayer->mPointIDXOfs; if(face.mIndices[i] > mCurLayer->mTempPoints.size()) { - DefaultLogger::get()->warn("LWO2: Failure evaluating face record, index is out of range"); + ASSIMP_LOG_WARN("LWO2: Failure evaluating face record, index is out of range"); face.mIndices[i] = (unsigned int)mCurLayer->mTempPoints.size()-1; } } @@ -891,7 +893,7 @@ void LWOImporter::LoadLWO2PolygonTags(unsigned int length) unsigned int j = GetU2(); if (i >= mCurLayer->mFaces.size()) { - DefaultLogger::get()->warn("LWO2: face index in PTAG is out of range"); + ASSIMP_LOG_WARN("LWO2: face index in PTAG is out of range"); continue; } @@ -914,7 +916,7 @@ VMapEntry* FindEntry(std::vector< T >& list,const std::string& name, bool perPol for (auto & elem : list) { if (elem.name == name) { if (!perPoly) { - DefaultLogger::get()->warn("LWO2: Found two VMAP sections with equal names"); + ASSIMP_LOG_WARN("LWO2: Found two VMAP sections with equal names"); } return &elem; } @@ -999,7 +1001,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) { case AI_LWO_TXUV: if (dims != 2) { - DefaultLogger::get()->warn("LWO2: Skipping UV channel \'" + ASSIMP_LOG_WARN("LWO2: Skipping UV channel \'" + name + "\' with !2 components"); return; } @@ -1008,7 +1010,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) case AI_LWO_WGHT: case AI_LWO_MNVW: if (dims != 1) { - DefaultLogger::get()->warn("LWO2: Skipping Weight Channel \'" + ASSIMP_LOG_WARN("LWO2: Skipping Weight Channel \'" + name + "\' with !1 components"); return; } @@ -1018,7 +1020,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) case AI_LWO_RGB: case AI_LWO_RGBA: if (dims != 3 && dims != 4) { - DefaultLogger::get()->warn("LWO2: Skipping Color Map \'" + ASSIMP_LOG_WARN("LWO2: Skipping Color Map \'" + name + "\' with a dimension > 4 or < 3"); return; } @@ -1033,7 +1035,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) if (name != "vert_normals" || dims != 3 || mCurLayer->mNormals.name.length()) return; - DefaultLogger::get()->info("Processing non-standard extension: MODO VMAP.NORM.vert_normals"); + ASSIMP_LOG_INFO("Processing non-standard extension: MODO VMAP.NORM.vert_normals"); mCurLayer->mNormals.name = name; base = & mCurLayer->mNormals; @@ -1048,7 +1050,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) if (name == "APS.Level") { // XXX handle this (seems to be subdivision-related). } - DefaultLogger::get()->warn("LWO2: Skipping unknown VMAP/VMAD channel \'" + name + "\'"); + ASSIMP_LOG_WARN_F("LWO2: Skipping unknown VMAP/VMAD channel \'", name, "\'"); return; }; base->Allocate((unsigned int)mCurLayer->mTempPoints.size()); @@ -1068,7 +1070,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) unsigned int idx = ReadVSizedIntLWO2(mFileBuffer) + mCurLayer->mPointIDXOfs; if (idx >= numPoints) { - DefaultLogger::get()->warn("LWO2: Failure evaluating VMAP/VMAD entry \'" + name + "\', vertex index is out of range"); + ASSIMP_LOG_WARN_F("LWO2: Failure evaluating VMAP/VMAD entry \'", name, "\', vertex index is out of range"); mFileBuffer += base->dims<<2u; continue; } @@ -1119,7 +1121,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) CreateNewEntry(mCurLayer->mNormals, srcIdx ); } if (!had) { - DefaultLogger::get()->warn("LWO2: Failure evaluating VMAD entry \'" + name + "\', vertex index wasn't found in that polygon"); + ASSIMP_LOG_WARN_F("LWO2: Failure evaluating VMAD entry \'", name, "\', vertex index wasn't found in that polygon"); ai_assert(had); } } @@ -1180,11 +1182,11 @@ void LWOImporter::LoadLWO2Clip(unsigned int length) break; case AI_LWO_STCC: - DefaultLogger::get()->warn("LWO2: Color shifted images are not supported"); + ASSIMP_LOG_WARN("LWO2: Color shifted images are not supported"); break; case AI_LWO_ANIM: - DefaultLogger::get()->warn("LWO2: Animated textures are not supported"); + ASSIMP_LOG_WARN("LWO2: Animated textures are not supported"); break; case AI_LWO_XREF: @@ -1201,7 +1203,7 @@ void LWOImporter::LoadLWO2Clip(unsigned int length) break; default: - DefaultLogger::get()->warn("LWO2: Encountered unknown CLIP subchunk"); + ASSIMP_LOG_WARN("LWO2: Encountered unknown CLIP sub-chunk"); } } @@ -1282,7 +1284,7 @@ void LWOImporter::LoadLWO2Envelope(unsigned int length) { AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,SPAN,4); if (envelope.keys.size()<2) - DefaultLogger::get()->warn("LWO2: Unexpected SPAN chunk"); + ASSIMP_LOG_WARN("LWO2: Unexpected SPAN chunk"); else { LWO::Key& key = envelope.keys.back(); switch (GetU4()) @@ -1300,7 +1302,7 @@ void LWOImporter::LoadLWO2Envelope(unsigned int length) case AI_LWO_BEZ2: key.inter = LWO::IT_BEZ2;break; default: - DefaultLogger::get()->warn("LWO2: Unknown interval interpolation mode"); + ASSIMP_LOG_WARN("LWO2: Unknown interval interpolation mode"); }; // todo ... read params @@ -1309,7 +1311,8 @@ void LWOImporter::LoadLWO2Envelope(unsigned int length) } default: - DefaultLogger::get()->warn("LWO2: Encountered unknown ENVL subchunk"); + ASSIMP_LOG_WARN("LWO2: Encountered unknown ENVL subchunk"); + break; } // regardless how much we did actually read, go to the next chunk mFileBuffer = next; @@ -1408,7 +1411,7 @@ void LWOImporter::LoadLWO2File() case AI_LWO_VMAD: if (mCurLayer->mFaces.empty()) { - DefaultLogger::get()->warn("LWO2: Unexpected VMAD chunk"); + ASSIMP_LOG_WARN("LWO2: Unexpected VMAD chunk"); break; } // --- intentionally no break here @@ -1418,7 +1421,7 @@ void LWOImporter::LoadLWO2File() break; if (mCurLayer->mTempPoints.empty()) - DefaultLogger::get()->warn("LWO2: Unexpected VMAP chunk"); + ASSIMP_LOG_WARN("LWO2: Unexpected VMAP chunk"); else LoadLWO2VertexMap(head.length,head.type == AI_LWO_VMAD); break; } @@ -1448,7 +1451,7 @@ void LWOImporter::LoadLWO2File() case AI_LWO_TAGS: { if (!mTags->empty()) - DefaultLogger::get()->warn("LWO2: SRFS chunk encountered twice"); + ASSIMP_LOG_WARN("LWO2: SRFS chunk encountered twice"); else LoadLWOTags(head.length); break; } diff --git a/code/LWOLoader.h b/code/LWOLoader.h index fa646648d..4d42eb2d2 100644 --- a/code/LWOLoader.h +++ b/code/LWOLoader.h @@ -473,7 +473,7 @@ inline void LWOImporter::GetS0(std::string& out,unsigned int max) { if (++iCursor > max) { - DefaultLogger::get()->warn("LWO: Invalid file, string is is too long"); + ASSIMP_LOG_WARN("LWO: Invalid file, string is is too long"); break; } ++mFileBuffer; diff --git a/code/LWOMaterial.cpp b/code/LWOMaterial.cpp index 383d3acb7..f4f43ced6 100644 --- a/code/LWOMaterial.cpp +++ b/code/LWOMaterial.cpp @@ -74,7 +74,7 @@ inline aiTextureMapMode GetMapMode(LWO::Texture::Wrap in) return aiTextureMapMode_Mirror; case LWO::Texture::RESET: - DefaultLogger::get()->warn("LWO2: Unsupported texture map mode: RESET"); + ASSIMP_LOG_WARN("LWO2: Unsupported texture map mode: RESET"); // fall though here case LWO::Texture::EDGE: @@ -117,7 +117,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex mapping = aiTextureMapping_BOX; break; case LWO::Texture::FrontProjection: - DefaultLogger::get()->error("LWO2: Unsupported texture mapping: FrontProjection"); + ASSIMP_LOG_ERROR("LWO2: Unsupported texture mapping: FrontProjection"); mapping = aiTextureMapping_OTHER; break; case LWO::Texture::UV: @@ -181,7 +181,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex } if (candidate == end) { - DefaultLogger::get()->error("LWO2: Clip index is out of bounds"); + ASSIMP_LOG_ERROR("LWO2: Clip index is out of bounds"); temp = 0; // fixme: apparently some LWO files shipping with Doom3 don't @@ -194,7 +194,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex } else { if (Clip::UNSUPPORTED == (*candidate).type) { - DefaultLogger::get()->error("LWO2: Clip type is not supported"); + ASSIMP_LOG_ERROR("LWO2: Clip type is not supported"); continue; } AdjustTexturePath((*candidate).path); @@ -212,7 +212,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex { std::string ss = texture.mFileName; if (!ss.length()) { - DefaultLogger::get()->error("LWOB: Empty file name"); + ASSIMP_LOG_WARN("LWOB: Empty file name"); continue; } AdjustTexturePath(ss); @@ -246,7 +246,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex default: temp = (unsigned int)aiTextureOp_Multiply; - DefaultLogger::get()->warn("LWO2: Unsupported texture blend mode: alpha or displacement"); + ASSIMP_LOG_WARN("LWO2: Unsupported texture blend mode: alpha or displacement"); } // Setup texture operation @@ -347,20 +347,20 @@ void LWOImporter::ConvertMaterial(const LWO::Surface& surf,aiMaterial* pcMat) // the surface and search for a name which we know ... for (const auto &shader : surf.mShaders) { if (shader.functionName == "LW_SuperCelShader" || shader.functionName == "AH_CelShader") { - DefaultLogger::get()->info("LWO2: Mapping LW_SuperCelShader/AH_CelShader to aiShadingMode_Toon"); + ASSIMP_LOG_INFO("LWO2: Mapping LW_SuperCelShader/AH_CelShader to aiShadingMode_Toon"); m = aiShadingMode_Toon; break; } else if (shader.functionName == "LW_RealFresnel" || shader.functionName == "LW_FastFresnel") { - DefaultLogger::get()->info("LWO2: Mapping LW_RealFresnel/LW_FastFresnel to aiShadingMode_Fresnel"); + ASSIMP_LOG_INFO("LWO2: Mapping LW_RealFresnel/LW_FastFresnel to aiShadingMode_Fresnel"); m = aiShadingMode_Fresnel; break; } else { - DefaultLogger::get()->warn("LWO2: Unknown surface shader: " + shader.functionName); + ASSIMP_LOG_WARN_F("LWO2: Unknown surface shader: ", shader.functionName); } } if (surf.mMaximumSmoothAngle <= 0.0) @@ -398,7 +398,7 @@ char LWOImporter::FindUVChannels(LWO::TextureList& list, } else { // channel mismatch. need to duplicate the material. - DefaultLogger::get()->warn("LWO: Channel mismatch, would need to duplicate surface [design bug]"); + ASSIMP_LOG_WARN("LWO: Channel mismatch, would need to duplicate surface [design bug]"); // TODO } @@ -429,7 +429,7 @@ void LWOImporter::FindUVChannels(LWO::Surface& surf, if (extra >= AI_MAX_NUMBER_OF_TEXTURECOORDS) { - DefaultLogger::get()->error("LWO: Maximum number of UV channels for " + ASSIMP_LOG_ERROR("LWO: Maximum number of UV channels for " "this mesh reached. Skipping channel \'" + uv.name + "\'"); } @@ -502,7 +502,7 @@ void LWOImporter::FindVCChannels(const LWO::Surface& surf, LWO::SortedRep& sorte if (vc.abAssigned[idx] && ((aiColor4D*)&vc.rawData[0])[idx] != aiColor4D(0.0,0.0,0.0,1.0)) { if (next >= AI_MAX_NUMBER_OF_COLOR_SETS) { - DefaultLogger::get()->error("LWO: Maximum number of vertex color channels for " + ASSIMP_LOG_ERROR("LWO: Maximum number of vertex color channels for " "this mesh reached. Skipping channel \'" + vc.name + "\'"); } @@ -567,7 +567,7 @@ void LWOImporter::LoadLWO2ImageMap(unsigned int size, LWO::Texture& tex ) void LWOImporter::LoadLWO2Procedural(unsigned int /*size*/, LWO::Texture& tex ) { // --- not supported at the moment - DefaultLogger::get()->error("LWO2: Found procedural texture, this is not supported"); + ASSIMP_LOG_ERROR("LWO2: Found procedural texture, this is not supported"); tex.bCanUse = false; } @@ -575,7 +575,7 @@ void LWOImporter::LoadLWO2Procedural(unsigned int /*size*/, LWO::Texture& tex ) void LWOImporter::LoadLWO2Gradient(unsigned int /*size*/, LWO::Texture& tex ) { // --- not supported at the moment - DefaultLogger::get()->error("LWO2: Found gradient texture, this is not supported"); + ASSIMP_LOG_ERROR("LWO2: Found gradient texture, this is not supported"); tex.bCanUse = false; } @@ -590,7 +590,7 @@ void LWOImporter::LoadLWO2TextureHeader(unsigned int size, LWO::Texture& tex ) // we could crash later if this is an empty string ... if (!tex.ordinal.length()) { - DefaultLogger::get()->error("LWO2: Ill-formed SURF.BLOK ordinal string"); + ASSIMP_LOG_ERROR("LWO2: Ill-formed SURF.BLOK ordinal string"); tex.ordinal = "\x00"; } while (true) @@ -662,7 +662,7 @@ void LWOImporter::LoadLWO2TextureBlock(LE_NCONST IFF::SubChunkHeader* head, unsi case AI_LWO_REFL: listRef = &surf.mReflectionTextures;break; default: - DefaultLogger::get()->warn("LWO2: Encountered unknown texture type"); + ASSIMP_LOG_WARN("LWO2: Encountered unknown texture type"); return; } @@ -691,7 +691,7 @@ void LWOImporter::LoadLWO2ShaderBlock(LE_NCONST IFF::SubChunkHeader* /*head*/, u // we could crash later if this is an empty string ... if (!shader.ordinal.length()) { - DefaultLogger::get()->error("LWO2: Ill-formed SURF.BLOK ordinal string"); + ASSIMP_LOG_ERROR("LWO2: Ill-formed SURF.BLOK ordinal string"); shader.ordinal = "\x00"; } @@ -750,7 +750,7 @@ void LWOImporter::LoadLWO2Surface(unsigned int size) } } if (derived.size()) - DefaultLogger::get()->warn("LWO2: Unable to find source surface: " + derived); + ASSIMP_LOG_WARN("LWO2: Unable to find source surface: " + derived); } while (true) @@ -886,7 +886,7 @@ void LWOImporter::LoadLWO2Surface(unsigned int size) break; default: - DefaultLogger::get()->warn("LWO2: Found an unsupported surface BLOK"); + ASSIMP_LOG_WARN("LWO2: Found an unsupported surface BLOK"); }; break; diff --git a/code/LWSLoader.cpp b/code/LWSLoader.cpp index baff6ab06..4313359d8 100644 --- a/code/LWSLoader.cpp +++ b/code/LWSLoader.cpp @@ -200,7 +200,7 @@ void LWSImporter::SetupProperties(const Importer* pImp) void LWSImporter::ReadEnvelope(const LWS::Element& dad, LWO::Envelope& fill ) { if (dad.children.empty()) { - DefaultLogger::get()->error("LWS: Envelope descriptions must not be empty"); + ASSIMP_LOG_ERROR("LWS: Envelope descriptions must not be empty"); return; } @@ -248,7 +248,7 @@ void LWSImporter::ReadEnvelope(const LWS::Element& dad, LWO::Envelope& fill ) num = 4; break; default: - DefaultLogger::get()->error("LWS: Unknown span type"); + ASSIMP_LOG_ERROR("LWS: Unknown span type"); } for (unsigned int i = 0; i < num;++i) { SkipSpaces(&c); @@ -305,7 +305,7 @@ void LWSImporter::ReadEnvelope_Old( return; unexpected_end: - DefaultLogger::get()->error("LWS: Encountered unexpected end of file while parsing object motion"); + ASSIMP_LOG_ERROR("LWS: Encountered unexpected end of file while parsing object motion"); } // ------------------------------------------------------------------------------------------------ @@ -352,7 +352,7 @@ void LWSImporter::BuildGraph(aiNode* nd, LWS::NodeDesc& src, std::vectorerror("LWS: Failed to read external file " + src.path); + ASSIMP_LOG_ERROR("LWS: Failed to read external file " + src.path); } else { if (obj->mRootNode->mNumChildren == 1) { @@ -551,7 +551,7 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, // get file format version and print to log ++it; unsigned int version = strtoul10((*it).tokens[0].c_str()); - DefaultLogger::get()->info("LWS file format version is " + (*it).tokens[0]); + ASSIMP_LOG_INFO("LWS file format version is " + (*it).tokens[0]); first = 0.; last = 60.; fps = 25.; /* seems to be a good default frame rate */ @@ -656,7 +656,7 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, d.number = cur_object++; nodes.push_back(d); } - else DefaultLogger::get()->error("LWS: Unexpected keyword: \'Channel\'"); + ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'Channel\'"); } // important: index of channel @@ -673,7 +673,7 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, // 'Envelope': a single animation channel else if ((*it).tokens[0] == "Envelope") { if (nodes.empty() || nodes.back().channels.empty()) - DefaultLogger::get()->error("LWS: Unexpected keyword: \'Envelope\'"); + ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'Envelope\'"); else { ReadEnvelope((*it),nodes.back().channels.back()); } @@ -684,7 +684,7 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, (*it).tokens[0] == "LightMotion")) { if (nodes.empty()) - DefaultLogger::get()->error("LWS: Unexpected keyword: \'Motion\'"); + DASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'Motion\'"); else { ReadEnvelope_Old(it,root.children.end(),nodes.back(),version); } @@ -692,7 +692,7 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, // 'Pre/PostBehavior': pre/post animation behaviour for LWSC 2 else if (version == 2 && (*it).tokens[0] == "Pre/PostBehavior") { if (nodes.empty()) - DefaultLogger::get()->error("LWS: Unexpected keyword: \'Pre/PostBehavior'"); + ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'Pre/PostBehavior'"); else { for (std::list::iterator it = nodes.back().channels.begin(); it != nodes.back().channels.end(); ++it) { // two ints per envelope @@ -705,14 +705,14 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, // 'ParentItem': specifies the parent of the current element else if ((*it).tokens[0] == "ParentItem") { if (nodes.empty()) - DefaultLogger::get()->error("LWS: Unexpected keyword: \'ParentItem\'"); + ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'ParentItem\'"); else nodes.back().parent = strtoul16(c,&c); } // 'ParentObject': deprecated one for older formats else if (version < 3 && (*it).tokens[0] == "ParentObject") { if (nodes.empty()) - DefaultLogger::get()->error("LWS: Unexpected keyword: \'ParentObject\'"); + ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'ParentObject\'"); else { nodes.back().parent = strtoul10(c,&c) | (1u << 28u); @@ -736,7 +736,7 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, // 'CameraName': set name of currently active camera else if ((*it).tokens[0] == "CameraName") { if (nodes.empty() || nodes.back().type != LWS::NodeDesc::CAMERA) - DefaultLogger::get()->error("LWS: Unexpected keyword: \'CameraName\'"); + ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'CameraName\'"); else nodes.back().name = c; } @@ -758,14 +758,14 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, // 'LightName': set name of currently active light else if ((*it).tokens[0] == "LightName") { if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) - DefaultLogger::get()->error("LWS: Unexpected keyword: \'LightName\'"); + ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightName\'"); else nodes.back().name = c; } // 'LightIntensity': set intensity of currently active light else if ((*it).tokens[0] == "LightIntensity" || (*it).tokens[0] == "LgtIntensity" ) { if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) - DefaultLogger::get()->error("LWS: Unexpected keyword: \'LightIntensity\'"); + ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightIntensity\'"); else fast_atoreal_move(c, nodes.back().lightIntensity ); @@ -781,7 +781,7 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, // 'LightFalloffType': set falloff type of currently active light else if ((*it).tokens[0] == "LightFalloffType") { if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) - DefaultLogger::get()->error("LWS: Unexpected keyword: \'LightFalloffType\'"); + ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightFalloffType\'"); else nodes.back().lightFalloffType = strtoul10(c); @@ -789,7 +789,7 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, // 'LightConeAngle': set cone angle of currently active light else if ((*it).tokens[0] == "LightConeAngle") { if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) - DefaultLogger::get()->error("LWS: Unexpected keyword: \'LightConeAngle\'"); + ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightConeAngle\'"); else nodes.back().lightConeAngle = fast_atof(c); @@ -797,7 +797,7 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, // 'LightEdgeAngle': set area where we're smoothing from min to max intensity else if ((*it).tokens[0] == "LightEdgeAngle") { if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) - DefaultLogger::get()->error("LWS: Unexpected keyword: \'LightEdgeAngle\'"); + ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightEdgeAngle\'"); else nodes.back().lightEdgeAngle = fast_atof(c); @@ -805,7 +805,7 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, // 'LightColor': set color of currently active light else if ((*it).tokens[0] == "LightColor") { if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) - DefaultLogger::get()->error("LWS: Unexpected keyword: \'LightColor\'"); + ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightColor\'"); else { c = fast_atoreal_move(c, (float&) nodes.back().lightColor.r ); @@ -819,7 +819,7 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, // 'PivotPosition': position of local transformation origin else if ((*it).tokens[0] == "PivotPosition" || (*it).tokens[0] == "PivotPoint") { if (nodes.empty()) - DefaultLogger::get()->error("LWS: Unexpected keyword: \'PivotPosition\'"); + ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'PivotPosition\'"); else { c = fast_atoreal_move(c, (float&) nodes.back().pivotPos.x ); SkipSpaces(&c); @@ -840,7 +840,7 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, if (dit != it && *it == (*dit).parent) { if ((*dit).parent_resolved) { // fixme: it's still possible to produce an overflow due to cross references .. - DefaultLogger::get()->error("LWS: Found cross reference in scenegraph"); + ASSIMP_LOG_ERROR("LWS: Found cross reference in scene-graph"); continue; } diff --git a/code/MD2Loader.cpp b/code/MD2Loader.cpp index 8f5b1c045..cfd5458e7 100644 --- a/code/MD2Loader.cpp +++ b/code/MD2Loader.cpp @@ -83,7 +83,7 @@ void MD2::LookupNormalIndex(uint8_t iNormalIndex,aiVector3D& vOut) { // make sure the normal index has a valid value if (iNormalIndex >= ARRAYSIZE(g_avNormals)) { - DefaultLogger::get()->warn("Index overflow in Quake II normal vector list"); + ASSIMP_LOG_WARN("Index overflow in Quake II normal vector list"); iNormalIndex = ARRAYSIZE(g_avNormals) - 1; } vOut = *((const aiVector3D*)(&g_avNormals[iNormalIndex])); @@ -161,7 +161,7 @@ void MD2Importer::ValidateHeader( ) // check file format version if (m_pcHeader->version != 8) - DefaultLogger::get()->warn( "Unsupported md2 file version. Continuing happily ..."); + ASSIMP_LOG_WARN( "Unsupported md2 file version. Continuing happily ..."); // check some values whether they are valid if (0 == m_pcHeader->numFrames) @@ -203,11 +203,11 @@ void MD2Importer::ValidateHeader( ) } if (m_pcHeader->numSkins > AI_MD2_MAX_SKINS) - DefaultLogger::get()->warn("The model contains more skins than Quake 2 supports"); + ASSIMP_LOG_WARN("The model contains more skins than Quake 2 supports"); if ( m_pcHeader->numFrames > AI_MD2_MAX_FRAMES) - DefaultLogger::get()->warn("The model contains more frames than Quake 2 supports"); + ASSIMP_LOG_WARN("The model contains more frames than Quake 2 supports"); if (m_pcHeader->numVertices > AI_MD2_MAX_VERTS) - DefaultLogger::get()->warn("The model contains more vertices than Quake 2 supports"); + ASSIMP_LOG_WARN("The model contains more vertices than Quake 2 supports"); if (m_pcHeader->numFrames <= configFrameID ) throw DeadlyImportError("The requested frame is not existing the file"); @@ -352,7 +352,7 @@ void MD2Importer::InternReadFile( const std::string& pFile, pcHelper->AddProperty(&szString,AI_MATKEY_TEXTURE_DIFFUSE(0)); } else{ - DefaultLogger::get()->warn("Texture file name has zero length. It will be skipped."); + ASSIMP_LOG_WARN("Texture file name has zero length. It will be skipped."); } } else { @@ -390,11 +390,11 @@ void MD2Importer::InternReadFile( const std::string& pFile, // check whether the skin width or height are zero (this would // cause a division through zero) if (!m_pcHeader->skinWidth) { - DefaultLogger::get()->error("MD2: No valid skin width given"); + ASSIMP_LOG_ERROR("MD2: No valid skin width given"); } else fDivisorU = (float)m_pcHeader->skinWidth; if (!m_pcHeader->skinHeight){ - DefaultLogger::get()->error("MD2: No valid skin height given"); + ASSIMP_LOG_ERROR("MD2: No valid skin height given"); } else fDivisorV = (float)m_pcHeader->skinHeight; } @@ -412,7 +412,7 @@ void MD2Importer::InternReadFile( const std::string& pFile, // validate vertex indices unsigned int iIndex = (unsigned int)pcTriangles[i].vertexIndices[c]; if (iIndex >= m_pcHeader->numVertices) { - DefaultLogger::get()->error("MD2: Vertex index is outside the allowed range"); + ASSIMP_LOG_ERROR("MD2: Vertex index is outside the allowed range"); iIndex = m_pcHeader->numVertices-1; } @@ -440,7 +440,7 @@ void MD2Importer::InternReadFile( const std::string& pFile, // validate texture coordinates iIndex = pcTriangles[i].textureIndices[c]; if (iIndex >= m_pcHeader->numTexCoords) { - DefaultLogger::get()->error("MD2: UV index is outside the allowed range"); + ASSIMP_LOG_ERROR("MD2: UV index is outside the allowed range"); iIndex = m_pcHeader->numTexCoords-1; } diff --git a/code/MD3Loader.cpp b/code/MD3Loader.cpp index 7b71ee42f..4e0b24acb 100644 --- a/code/MD3Loader.cpp +++ b/code/MD3Loader.cpp @@ -101,7 +101,7 @@ Q3Shader::BlendFunc StringToBlendFunc(const std::string& m) if (m == "GL_ONE_MINUS_DST_COLOR") { return Q3Shader::BLEND_GL_ONE_MINUS_DST_COLOR; } - DefaultLogger::get()->error("Q3Shader: Unknown blend function: " + m); + ASSIMP_LOG_ERROR("Q3Shader: Unknown blend function: " + m); return Q3Shader::BLEND_NONE; } @@ -113,7 +113,7 @@ bool Q3Shader::LoadShader(ShaderData& fill, const std::string& pFile,IOSystem* i if (!file.get()) return false; // if we can't access the file, don't worry and return - DefaultLogger::get()->info("Loading Quake3 shader file " + pFile); + ASSIMP_LOG_INFO_F("Loading Quake3 shader file ", pFile); // read file in memory const size_t s = file->FileSize(); @@ -136,7 +136,7 @@ bool Q3Shader::LoadShader(ShaderData& fill, const std::string& pFile,IOSystem* i // append to last section, if any if (!curData) { - DefaultLogger::get()->error("Q3Shader: Unexpected shader section token \'{\'"); + ASSIMP_LOG_ERROR("Q3Shader: Unexpected shader section token \'{\'"); return true; // still no failure, the file is there } @@ -206,19 +206,16 @@ bool Q3Shader::LoadShader(ShaderData& fill, const std::string& pFile,IOSystem* i SkipSpaces(&buff); if (!ASSIMP_strincmp(buff,"back",4)) { curData->cull = Q3Shader::CULL_CCW; - } - else if (!ASSIMP_strincmp(buff,"front",5)) { + } else if (!ASSIMP_strincmp(buff,"front",5)) { curData->cull = Q3Shader::CULL_CW; - } - else if (!ASSIMP_strincmp(buff,"none",4) || !ASSIMP_strincmp(buff,"disable",7)) { + } else if (!ASSIMP_strincmp(buff,"none",4) || !ASSIMP_strincmp(buff,"disable",7)) { curData->cull = Q3Shader::CULL_NONE; + } else { + ASSIMP_LOG_ERROR("Q3Shader: Unrecognized cull mode"); } - else DefaultLogger::get()->error("Q3Shader: Unrecognized cull mode"); } } - } - - else { + } else { // add new section fill.blocks.push_back(Q3Shader::ShaderDataBlock()); curData = &fill.blocks.back(); @@ -238,7 +235,7 @@ bool Q3Shader::LoadSkin(SkinData& fill, const std::string& pFile,IOSystem* io) if (!file.get()) return false; // if we can't access the file, don't worry and return - DefaultLogger::get()->info("Loading Quake3 skin file " + pFile); + ASSIMP_LOG_INFO("Loading Quake3 skin file " + pFile); // read file in memory const size_t s = file->FileSize(); @@ -397,7 +394,7 @@ void MD3Importer::ValidateHeaderOffsets() // Check file format version if (pcHeader->VERSION > 15) - DefaultLogger::get()->warn( "Unsupported MD3 file version. Continuing happily ..."); + ASSIMP_LOG_WARN( "Unsupported MD3 file version. Continuing happily ..."); // Check some offset values whether they are valid if (!pcHeader->NUM_SURFACES) @@ -438,25 +435,24 @@ void MD3Importer::ValidateSurfaceHeaderOffsets(const MD3::Surface* pcSurf) // Check whether all requirements for Q3 files are met. We don't // care, but probably someone does. if (pcSurf->NUM_TRIANGLES > AI_MD3_MAX_TRIANGLES) { - DefaultLogger::get()->warn("MD3: Quake III triangle limit exceeded"); + ASSIMP_LOG_WARN("MD3: Quake III triangle limit exceeded"); } if (pcSurf->NUM_SHADER > AI_MD3_MAX_SHADERS) { - DefaultLogger::get()->warn("MD3: Quake III shader limit exceeded"); + ASSIMP_LOG_WARN("MD3: Quake III shader limit exceeded"); } if (pcSurf->NUM_VERTICES > AI_MD3_MAX_VERTS) { - DefaultLogger::get()->warn("MD3: Quake III vertex limit exceeded"); + ASSIMP_LOG_WARN("MD3: Quake III vertex limit exceeded"); } if (pcSurf->NUM_FRAMES > AI_MD3_MAX_FRAMES) { - DefaultLogger::get()->warn("MD3: Quake III frame limit exceeded"); + ASSIMP_LOG_WARN("MD3: Quake III frame limit exceeded"); } } // ------------------------------------------------------------------------------------------------ -const aiImporterDesc* MD3Importer::GetInfo () const -{ +const aiImporterDesc* MD3Importer::GetInfo () const { return &desc; } @@ -579,7 +575,7 @@ bool MD3Importer::ReadMultipartFile() aiNode* tag_torso, *tag_head; std::vector attach; - DefaultLogger::get()->info("Multi part MD3 player model: lower, upper and head parts are joined"); + ASSIMP_LOG_INFO("Multi part MD3 player model: lower, upper and head parts are joined"); // ensure we won't try to load ourselves recursively BatchLoader::PropertyMap props; @@ -600,21 +596,21 @@ bool MD3Importer::ReadMultipartFile() // ... and get them. We need all of them. scene_lower = batch.GetImport(_lower); if (!scene_lower) { - DefaultLogger::get()->error("M3D: Failed to read multi part model, lower.md3 fails to load"); + ASSIMP_LOG_ERROR("M3D: Failed to read multi part model, lower.md3 fails to load"); failure = "lower"; goto error_cleanup; } scene_upper = batch.GetImport(_upper); if (!scene_upper) { - DefaultLogger::get()->error("M3D: Failed to read multi part model, upper.md3 fails to load"); + ASSIMP_LOG_ERROR("M3D: Failed to read multi part model, upper.md3 fails to load"); failure = "upper"; goto error_cleanup; } scene_head = batch.GetImport(_head); if (!scene_head) { - DefaultLogger::get()->error("M3D: Failed to read multi part model, head.md3 fails to load"); + ASSIMP_LOG_ERROR("M3D: Failed to read multi part model, head.md3 fails to load"); failure = "head"; goto error_cleanup; } @@ -628,7 +624,7 @@ bool MD3Importer::ReadMultipartFile() // tag_torso tag_torso = scene_lower->mRootNode->FindNode("tag_torso"); if (!tag_torso) { - DefaultLogger::get()->error("M3D: Failed to find attachment tag for multi part model: tag_torso expected"); + ASSIMP_LOG_ERROR("M3D: Failed to find attachment tag for multi part model: tag_torso expected"); goto error_cleanup; } scene_upper->mRootNode->mName.Set("upper"); @@ -637,7 +633,7 @@ bool MD3Importer::ReadMultipartFile() // tag_head tag_head = scene_upper->mRootNode->FindNode("tag_head"); if (!tag_head) { - DefaultLogger::get()->error("M3D: Failed to find attachment tag for multi part model: tag_head expected"); + ASSIMP_LOG_ERROR( "M3D: Failed to find attachment tag for multi part model: tag_head expected"); goto error_cleanup; } scene_head->mRootNode->mName.Set("head"); @@ -919,9 +915,10 @@ void MD3Importer::InternReadFile( const std::string& pFile, if (dit != shaders.blocks.end()) { // Hurra, wir haben einen. Tolle Sache. shader = &*dit; - DefaultLogger::get()->info("Found shader record for " +without_ext ); + ASSIMP_LOG_INFO("Found shader record for " +without_ext ); + } else { + ASSIMP_LOG_WARN("Unable to find shader record for " + without_ext); } - else DefaultLogger::get()->warn("Unable to find shader record for " +without_ext ); } aiMaterial* pcHelper = new aiMaterial(); @@ -950,7 +947,7 @@ void MD3Importer::InternReadFile( const std::string& pFile, szString.Set(convertedPath); } else { - DefaultLogger::get()->warn("Texture file name has zero length. Using default name"); + ASSIMP_LOG_WARN("Texture file name has zero length. Using default name"); szString.Set("dummy_texture.bmp"); } pcHelper->AddProperty(&szString,AI_MATKEY_TEXTURE_DIFFUSE(0)); @@ -1040,7 +1037,7 @@ void MD3Importer::InternReadFile( const std::string& pFile, if (!DefaultLogger::isNullLogger()) { for (std::list< Q3Shader::SkinData::TextureEntry>::const_iterator it = skins.textures.begin();it != skins.textures.end(); ++it) { if (!(*it).resolved) { - DefaultLogger::get()->error("MD3: Failed to match skin " + (*it).first + " to surface " + (*it).second); + ASSIMP_LOG_ERROR("MD3: Failed to match skin ", (*it).first, " to surface ", (*it).second); } } } diff --git a/code/MD5Loader.cpp b/code/MD5Loader.cpp index d5aea6a47..fc9c97cf3 100644 --- a/code/MD5Loader.cpp +++ b/code/MD5Loader.cpp @@ -359,7 +359,7 @@ void MD5Importer::LoadMD5MeshFile () // Check whether we can read from the file if( file.get() == NULL || !file->FileSize()) { - DefaultLogger::get()->warn("Failed to access MD5MESH file: " + pFile); + ASSIMP_LOG_WARN("Failed to access MD5MESH file: " + pFile); return; } bHadMD5Mesh = true; @@ -482,7 +482,7 @@ void MD5Importer::LoadMD5MeshFile () for (unsigned int jub = (*iter).mFirstWeight, w = jub; w < jub + (*iter).mNumWeights;++w) fSum += meshSrc.mWeights[w].mWeight; if (!fSum) { - DefaultLogger::get()->error("MD5MESH: The sum of all vertex bone weights is 0"); + ASSIMP_LOG_ERROR("MD5MESH: The sum of all vertex bone weights is 0"); continue; } @@ -574,7 +574,7 @@ void MD5Importer::LoadMD5AnimFile () // Check whether we can read from the file if( !file.get() || !file->FileSize()) { - DefaultLogger::get()->warn("Failed to read MD5ANIM file: " + pFile); + ASSIMP_LOG_WARN("Failed to read MD5ANIM file: " + pFile); return; } LoadFileIntoMemory(file.get()); @@ -588,8 +588,7 @@ void MD5Importer::LoadMD5AnimFile () // generate and fill the output animation if (animParser.mAnimatedBones.empty() || animParser.mFrames.empty() || animParser.mBaseFrames.size() != animParser.mAnimatedBones.size()) { - - DefaultLogger::get()->error("MD5ANIM: No frames or animated bones loaded"); + ASSIMP_LOG_ERROR("MD5ANIM: No frames or animated bones loaded"); } else { bHadMD5Anim = true; diff --git a/code/MD5Parser.cpp b/code/MD5Parser.cpp index d927d998a..7fa4db1ba 100644 --- a/code/MD5Parser.cpp +++ b/code/MD5Parser.cpp @@ -107,7 +107,7 @@ MD5Parser::MD5Parser(char* _buffer, unsigned int _fileSize ) { char szBuffer[1024]; ::sprintf(szBuffer,"[MD5] Line %u: %s",line,warn); - DefaultLogger::get()->warn(szBuffer); + ASSIMP_LOG_WARN(szBuffer); } // ------------------------------------------------------------------------------------------------ diff --git a/code/MaterialSystem.cpp b/code/MaterialSystem.cpp index e7e8a077d..97892658f 100644 --- a/code/MaterialSystem.cpp +++ b/code/MaterialSystem.cpp @@ -160,7 +160,7 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat, break; } if ( !IsSpace(*cur) ) { - DefaultLogger::get()->error("Material property" + std::string(pKey) + + ASSIMP_LOG_ERROR("Material property" + std::string(pKey) + " is a string; failed to parse a float array out of it."); return AI_FAILURE; } @@ -233,7 +233,7 @@ aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat, break; } if(!IsSpace(*cur)) { - DefaultLogger::get()->error("Material property" + std::string(pKey) + + ASSIMP_LOG_ERROR("Material property" + std::string(pKey) + " is a string; failed to parse an integer array out of it."); return AI_FAILURE; } @@ -305,7 +305,7 @@ aiReturn aiGetMaterialString(const aiMaterial* pMat, } else { // TODO - implement lexical cast as well - DefaultLogger::get()->error("Material property" + std::string(pKey) + + ASSIMP_LOG_ERROR("Material property" + std::string(pKey) + " was found, but is no string" ); return AI_FAILURE; } diff --git a/code/Subdivision.cpp b/code/Subdivision.cpp index f2e480db1..ced560764 100644 --- a/code/Subdivision.cpp +++ b/code/Subdivision.cpp @@ -177,7 +177,7 @@ void CatmullClarkSubdivider::Subdivide ( aiMesh* i = smesh[s]; // FIX - mPrimitiveTypes might not yet be initialized if (i->mPrimitiveTypes && (i->mPrimitiveTypes & (aiPrimitiveType_LINE|aiPrimitiveType_POINT))==i->mPrimitiveTypes) { - DefaultLogger::get()->debug("Catmull-Clark Subdivider: Skipping pure line/point mesh"); + ASSIMP_LOG_DEBUG("Catmull-Clark Subdivider: Skipping pure line/point mesh"); if (discard_input) { out[s] = i; @@ -198,12 +198,12 @@ void CatmullClarkSubdivider::Subdivide ( // checking any ranges. ai_assert(inmeshes.size()==outmeshes.size()&&inmeshes.size()==maptbl.size()); if (inmeshes.empty()) { - DefaultLogger::get()->warn("Catmull-Clark Subdivider: Pure point/line scene, I can't do anything"); + ASSIMP_LOG_WARN("Catmull-Clark Subdivider: Pure point/line scene, I can't do anything"); return; } InternSubdivide(&inmeshes.front(),inmeshes.size(),&outmeshes.front(),num); for (unsigned int i = 0; i < maptbl.size(); ++i) { - ai_assert(outmeshes[i]); + ai_assert(nullptr != outmeshes[i]); out[maptbl[i]] = outmeshes[i]; } @@ -563,7 +563,7 @@ void CatmullClarkSubdivider::InternSubdivide ( // this invariant *must* hold if the vertex-to-face adjacency table is valid ai_assert(haveit); if ( !haveit ) { - DefaultLogger::get()->warn( "OBJ: no name for material library specified." ); + ASSIMP_LOG_WARN( "OBJ: no name for material library specified." ); } } diff --git a/code/glTFAsset.inl b/code/glTFAsset.inl index bd43b19f2..267cbd4a3 100644 --- a/code/glTFAsset.inl +++ b/code/glTFAsset.inl @@ -869,7 +869,7 @@ inline void Mesh::Read(Value& pJSON_Object, Asset& pAsset_Root) if(comp_data == nullptr) throw DeadlyImportError("GLTF: \"Open3DGC-compression\" must has \"compressedData\"."); - DefaultLogger::get()->info("GLTF: Decompressing Open3DGC data."); + ASSIMP_LOG_INFO("GLTF: Decompressing Open3DGC data."); /************** Read data from JSON-document **************/ #define MESH_READ_COMPRESSEDDATA_MEMBER(pFieldName, pOut) \ diff --git a/code/glTFExporter.cpp b/code/glTFExporter.cpp index ccbbd7fa2..7dfe5b3ff 100644 --- a/code/glTFExporter.cpp +++ b/code/glTFExporter.cpp @@ -568,7 +568,7 @@ void glTFExporter::ExportMeshes() else msg = "mesh must has vertices and faces."; - DefaultLogger::get()->warn("GLTF: can not use Open3DGC-compression: " + msg); + ASSIMP_LOG_WARN_F("GLTF: can not use Open3DGC-compression: ", msg); comp_allow = false; } diff --git a/include/assimp/fast_atof.h b/include/assimp/fast_atof.h index e66f1b37d..735cfe2da 100644 --- a/include/assimp/fast_atof.h +++ b/include/assimp/fast_atof.h @@ -199,7 +199,7 @@ uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* max_ino // numeric overflow, we rely on you if ( new_value < value ) { - DefaultLogger::get()->warn( std::string( "Converting the string \"" ) + in + "\" into a value resulted in overflow." ); + ASSIMP_LOG_WARN_F( "Converting the string \"", in, "\" into a value resulted in overflow." ); return 0; } From 30c20eb5fcbd0d54cc44eb5ee25710dce73e7673 Mon Sep 17 00:00:00 2001 From: kimkulling Date: Thu, 26 Apr 2018 14:10:18 +0200 Subject: [PATCH 04/11] INtroduce new log macros. --- code/Assimp.cpp | 2 +- code/BlenderDNA.cpp | 2 +- code/BlenderDNA.inl | 2 +- code/BlenderModifier.h | 2 +- code/COBLoader.cpp | 92 +++++++------------------------ code/COBLoader.h | 22 +------- code/CalcTangentsProcess.cpp | 12 ++-- code/ComputeUVMappingProcess.cpp | 12 ++-- code/ConvertToLHProcess.cpp | 18 +++--- code/DeboneProcess.cpp | 8 +-- code/EmbedTexturesProcess.cpp | 8 +-- code/FBXDocumentUtil.cpp | 2 +- code/FindDegenerates.cpp | 13 ++--- code/FindInstancesProcess.cpp | 10 ++-- code/FindInvalidDataProcess.cpp | 12 ++-- code/FixNormalsStep.cpp | 38 +++++++------ code/GenFaceNormalsProcess.cpp | 17 +++--- code/GenVertexNormalsProcess.cpp | 17 +++--- code/IRRMeshLoader.cpp | 2 +- code/Importer.cpp | 43 ++++++++------- code/ImproveCacheLocality.cpp | 20 ++----- code/JoinVerticesProcess.cpp | 28 ++++------ code/LWOLoader.cpp | 16 ++++-- code/LWSLoader.cpp | 4 +- code/LimitBoneWeightsProcess.cpp | 16 +++--- code/MD5Parser.cpp | 4 +- code/MDCLoader.cpp | 10 ++-- code/MDLLoader.cpp | 6 +- code/MDLMaterialLoader.cpp | 13 +++-- code/MS3DLoader.cpp | 5 +- code/MakeVerboseFormat.cpp | 11 ++-- code/NDOLoader.cpp | 8 +-- code/NFFLoader.cpp | 33 +++++------ code/OFFLoader.cpp | 8 +-- code/ObjFileImporter.cpp | 4 +- code/ObjFileMtlImporter.cpp | 2 +- code/ObjFileParser.cpp | 16 +++--- code/OgreBinarySerializer.cpp | 44 +++++++-------- code/OgreMaterial.cpp | 33 ++++++----- code/OgreXmlSerializer.cpp | 66 ++++++++++------------ code/OpenGEXImporter.cpp | 7 +-- code/OptimizeGraph.cpp | 10 ++-- code/OptimizeMeshes.cpp | 10 ++-- code/PlyParser.cpp | 34 ++++++------ code/PretransformVertices.cpp | 26 +++------ code/ProcessHelper.cpp | 2 +- code/ProcessHelper.h | 2 +- code/Q3DLoader.cpp | 4 +- code/RawLoader.cpp | 2 +- code/RemoveRedundantMaterials.cpp | 12 ++-- code/RemoveVCProcess.cpp | 11 ++-- code/SIBImporter.cpp | 4 +- code/SMDLoader.cpp | 8 +-- code/STEPFile.h | 4 +- code/STLLoader.cpp | 12 ++-- code/SortByPTypeProcess.cpp | 8 +-- code/SplitLargeMeshes.cpp | 19 ++++--- code/Subdivision.cpp | 7 +-- code/TerragenLoader.cpp | 2 +- code/TextureTransform.cpp | 32 +++++------ code/TriangulateProcess.cpp | 11 ++-- code/ValidateDataStructure.cpp | 4 +- code/XFileImporter.cpp | 2 +- code/XFileParser.cpp | 20 +++---- include/assimp/LogAux.h | 10 ++-- 65 files changed, 413 insertions(+), 531 deletions(-) diff --git a/code/Assimp.cpp b/code/Assimp.cpp index 44e3ed563..b682d257b 100644 --- a/code/Assimp.cpp +++ b/code/Assimp.cpp @@ -146,7 +146,7 @@ private: // ------------------------------------------------------------------------------------------------ void ReportSceneNotFoundError() { - DefaultLogger::get()->error("Unable to find the Assimp::Importer for this aiScene. " + ASSIMP_LOG_ERROR("Unable to find the Assimp::Importer for this aiScene. " "The C-API does not accept scenes produced by the C++ API and vice versa"); ai_assert(false); diff --git a/code/BlenderDNA.cpp b/code/BlenderDNA.cpp index 0bca902c6..afcbb34e3 100644 --- a/code/BlenderDNA.cpp +++ b/code/BlenderDNA.cpp @@ -210,7 +210,7 @@ void DNAParser::Parse () s.size = offset; } - ASSIMP_LOG_DEBUG( "BlenderDNA: Got ", dna.structures.size()," structures with totally ",fields," fields"); + ASSIMP_LOG_DEBUG_F( "BlenderDNA: Got ", dna.structures.size()," structures with totally ",fields," fields"); #ifdef ASSIMP_BUILD_BLENDER_DEBUG dna.DumpToFile(); diff --git a/code/BlenderDNA.inl b/code/BlenderDNA.inl index 1f345b631..e43d15d38 100644 --- a/code/BlenderDNA.inl +++ b/code/BlenderDNA.inl @@ -468,7 +468,7 @@ template <> bool Structure :: ResolvePointer(std::shar // this might happen if DNA::RegisterConverters hasn't been called so far // or if the target type is not contained in `our` DNA. out.reset(); - ASSIMP_LOG_WARN( "Failed to find a converter for the `",s.name,"` structure" ); + ASSIMP_LOG_WARN_F( "Failed to find a converter for the `",s.name,"` structure" ); return false; } diff --git a/code/BlenderModifier.h b/code/BlenderModifier.h index 1b0976b1e..b8797691b 100644 --- a/code/BlenderModifier.h +++ b/code/BlenderModifier.h @@ -86,7 +86,7 @@ public: const Scene& /*in*/, const Object& /*orig_object*/ ) { - ASSIMP_LOG_INFO_F("This modifier is not supported, skipping: "),orig_modifier.dna_type); + ASSIMP_LOG_INFO_F("This modifier is not supported, skipping: ",orig_modifier.dna_type ); return; } }; diff --git a/code/COBLoader.cpp b/code/COBLoader.cpp index 8571bc492..1d4ee2464 100644 --- a/code/COBLoader.cpp +++ b/code/COBLoader.cpp @@ -487,46 +487,6 @@ void COBImporter::UnsupportedChunk_Ascii(LineSplitter& splitter, const ChunkInfo else ThrowException(error); } -// ------------------------------------------------------------------------------------------------ -void COBImporter::LogWarn_Ascii(const LineSplitter& splitter, const format& message) { - LogWarn_Ascii(message << " [at line "<< splitter.get_index()<<"]"); -} - -// ------------------------------------------------------------------------------------------------ -void COBImporter::LogError_Ascii(const LineSplitter& splitter, const format& message) { - LogError_Ascii(message << " [at line "<< splitter.get_index()<<"]"); -} - -// ------------------------------------------------------------------------------------------------ -void COBImporter::LogInfo_Ascii(const LineSplitter& splitter, const format& message) { - LogInfo_Ascii(message << " [at line "<< splitter.get_index()<<"]"); -} - -// ------------------------------------------------------------------------------------------------ -void COBImporter::LogDebug_Ascii(const LineSplitter& splitter, const format& message) { - LogDebug_Ascii(message << " [at line "<< splitter.get_index()<<"]"); -} - -// ------------------------------------------------------------------------------------------------ -void COBImporter::LogWarn_Ascii(const Formatter::format& message) { - ASSIMP_LOG_WARN_F( "COB: ", message ); -} - -// ------------------------------------------------------------------------------------------------ -void COBImporter::LogError_Ascii(const Formatter::format& message) { - ASSIMP_LOG_ERROR_F( "COB: ", message); -} - -// ------------------------------------------------------------------------------------------------ -void COBImporter::LogInfo_Ascii(const Formatter::format& message) { - ASSIMP_LOG_INFO_F("COB: ", message); -} - -// ------------------------------------------------------------------------------------------------ -void COBImporter::LogDebug_Ascii(const Formatter::format& message) { - ASSIMP_LOG_DEBUG_F("COB: ", message); -} - // ------------------------------------------------------------------------------------------------ void COBImporter::ReadBasicNodeInfo_Ascii(Node& msh, LineSplitter& splitter, const ChunkInfo& /*nfo*/) { @@ -576,8 +536,7 @@ void COBImporter::ReadMat1_Ascii(Scene& out, LineSplitter& splitter, const Chunk ++splitter; if (!splitter.match_start("mat# ")) { - LogWarn_Ascii(splitter,format()<< - "Expected `mat#` line in `Mat1` chunk "<unit_scale = t>=sizeof(units)/sizeof(units[0])?( - LogWarn_Ascii(splitter,format()<(reader.GetI1()); @@ -1289,16 +1238,13 @@ void COBImporter::ReadUnit_Binary(COB::Scene& out, StreamReaderLE& reader, const if (nd->id == nfo.parent_id) { const unsigned int t=reader.GetI2(); nd->unit_scale = t>=sizeof(units)/sizeof(units[0])?( - LogWarn_Ascii(format()<debug("CalcTangentsProcess begin"); + ASSIMP_LOG_DEBUG("CalcTangentsProcess begin"); bool bHas = false; for ( unsigned int a = 0; a < pScene->mNumMeshes; a++ ) { @@ -103,9 +103,9 @@ void CalcTangentsProcess::Execute( aiScene* pScene) } if ( bHas ) { - DefaultLogger::get()->info("CalcTangentsProcess finished. Tangents have been calculated"); + ASSIMP_LOG_INFO("CalcTangentsProcess finished. Tangents have been calculated"); } else { - DefaultLogger::get()->debug("CalcTangentsProcess finished"); + ASSIMP_LOG_DEBUG("CalcTangentsProcess finished"); } } @@ -126,19 +126,19 @@ bool CalcTangentsProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) // are undefined. if (!(pMesh->mPrimitiveTypes & (aiPrimitiveType_TRIANGLE | aiPrimitiveType_POLYGON))) { - DefaultLogger::get()->info("Tangents are undefined for line and point meshes"); + ASSIMP_LOG_INFO("Tangents are undefined for line and point meshes"); return false; } // what we can check, though, is if the mesh has normals and texture coordinates. That's a requirement if( pMesh->mNormals == NULL) { - DefaultLogger::get()->error("Failed to compute tangents; need normals"); + ASSIMP_LOG_ERROR("Failed to compute tangents; need normals"); return false; } if( configSourceUV >= AI_MAX_NUMBER_OF_TEXTURECOORDS || !pMesh->mTextureCoords[configSourceUV] ) { - DefaultLogger::get()->error((Formatter::format("Failed to compute tangents; need UV data in channel"),configSourceUV)); + ASSIMP_LOG_ERROR((Formatter::format("Failed to compute tangents; need UV data in channel"),configSourceUV)); return false; } diff --git a/code/ComputeUVMappingProcess.cpp b/code/ComputeUVMappingProcess.cpp index 6e778ddba..3b0577b2d 100644 --- a/code/ComputeUVMappingProcess.cpp +++ b/code/ComputeUVMappingProcess.cpp @@ -99,7 +99,7 @@ inline unsigned int FindEmptyUVChannel (aiMesh* mesh) for (unsigned int m = 0; m < AI_MAX_NUMBER_OF_TEXTURECOORDS;++m) if (!mesh->mTextureCoords[m])return m; - DefaultLogger::get()->error("Unable to compute UV coordinates, no free UV slot found"); + ASSIMP_LOG_ERROR("Unable to compute UV coordinates, no free UV slot found"); return UINT_MAX; } @@ -384,13 +384,13 @@ void ComputeUVMappingProcess::ComputePlaneMapping(aiMesh* mesh,const aiVector3D& // ------------------------------------------------------------------------------------------------ void ComputeUVMappingProcess::ComputeBoxMapping( aiMesh*, aiVector3D* ) { - DefaultLogger::get()->error("Mapping type currently not implemented"); + ASSIMP_LOG_ERROR("Mapping type currently not implemented"); } // ------------------------------------------------------------------------------------------------ void ComputeUVMappingProcess::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("GenUVCoordsProcess begin"); + ASSIMP_LOG_DEBUG("GenUVCoordsProcess begin"); char buffer[1024]; if (pScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) @@ -418,7 +418,7 @@ void ComputeUVMappingProcess::Execute( aiScene* pScene) TextureTypeToString((aiTextureType)prop->mSemantic),prop->mIndex, MappingTypeToString(mapping)); - DefaultLogger::get()->info(buffer); + ASSIMP_LOG_INFO(buffer); } if (aiTextureMapping_OTHER == mapping) @@ -485,7 +485,7 @@ void ComputeUVMappingProcess::Execute( aiScene* pScene) } if (m && idx != outIdx) { - DefaultLogger::get()->warn("UV index mismatch. Not all meshes assigned to " + ASSIMP_LOG_WARN("UV index mismatch. Not all meshes assigned to " "this material have equal numbers of UV channels. The UV index stored in " "the material structure does therefore not apply for all meshes. "); } @@ -502,5 +502,5 @@ void ComputeUVMappingProcess::Execute( aiScene* pScene) } } } - DefaultLogger::get()->debug("GenUVCoordsProcess finished"); + ASSIMP_LOG_DEBUG("GenUVCoordsProcess finished"); } diff --git a/code/ConvertToLHProcess.cpp b/code/ConvertToLHProcess.cpp index ba8371439..37ba970e4 100644 --- a/code/ConvertToLHProcess.cpp +++ b/code/ConvertToLHProcess.cpp @@ -85,7 +85,7 @@ void MakeLeftHandedProcess::Execute( aiScene* pScene) { // Check for an existent root node to proceed ai_assert(pScene->mRootNode != NULL); - DefaultLogger::get()->debug("MakeLeftHandedProcess begin"); + ASSIMP_LOG_DEBUG("MakeLeftHandedProcess begin"); // recursively convert all the nodes ProcessNode( pScene->mRootNode, aiMatrix4x4()); @@ -110,7 +110,7 @@ void MakeLeftHandedProcess::Execute( aiScene* pScene) ProcessAnimation( nodeAnim); } } - DefaultLogger::get()->debug("MakeLeftHandedProcess finished"); + ASSIMP_LOG_DEBUG("MakeLeftHandedProcess finished"); } // ------------------------------------------------------------------------------------------------ @@ -140,7 +140,7 @@ void MakeLeftHandedProcess::ProcessNode( aiNode* pNode, const aiMatrix4x4& pPare // Converts a single mesh to left handed coordinates. void MakeLeftHandedProcess::ProcessMesh( aiMesh* pMesh) { if ( nullptr == pMesh ) { - DefaultLogger::get()->error( "Nullptr to mesh found." ); + ASSIMP_LOG_ERROR( "Nullptr to mesh found." ); return; } // mirror positions, normals and stuff along the Z axis @@ -180,7 +180,7 @@ void MakeLeftHandedProcess::ProcessMesh( aiMesh* pMesh) { // Converts a single material to left handed coordinates. void MakeLeftHandedProcess::ProcessMaterial( aiMaterial* _mat) { if ( nullptr == _mat ) { - DefaultLogger::get()->error( "Nullptr to aiMaterial found." ); + ASSIMP_LOG_ERROR( "Nullptr to aiMaterial found." ); return; } @@ -245,13 +245,13 @@ bool FlipUVsProcess::IsActive( unsigned int pFlags) const // Executes the post processing step on the given imported data. void FlipUVsProcess::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("FlipUVsProcess begin"); + ASSIMP_LOG_DEBUG("FlipUVsProcess begin"); for (unsigned int i = 0; i < pScene->mNumMeshes;++i) ProcessMesh(pScene->mMeshes[i]); for (unsigned int i = 0; i < pScene->mNumMaterials;++i) ProcessMaterial(pScene->mMaterials[i]); - DefaultLogger::get()->debug("FlipUVsProcess finished"); + ASSIMP_LOG_DEBUG("FlipUVsProcess finished"); } // ------------------------------------------------------------------------------------------------ @@ -262,7 +262,7 @@ void FlipUVsProcess::ProcessMaterial (aiMaterial* _mat) for (unsigned int a = 0; a < mat->mNumProperties;++a) { aiMaterialProperty* prop = mat->mProperties[a]; if( !prop ) { - DefaultLogger::get()->debug( "Property is null" ); + ASSIMP_LOG_DEBUG( "Property is null" ); continue; } @@ -319,10 +319,10 @@ bool FlipWindingOrderProcess::IsActive( unsigned int pFlags) const // Executes the post processing step on the given imported data. void FlipWindingOrderProcess::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("FlipWindingOrderProcess begin"); + ASSIMP_LOG_DEBUG("FlipWindingOrderProcess begin"); for (unsigned int i = 0; i < pScene->mNumMeshes;++i) ProcessMesh(pScene->mMeshes[i]); - DefaultLogger::get()->debug("FlipWindingOrderProcess finished"); + ASSIMP_LOG_DEBUG("FlipWindingOrderProcess finished"); } // ------------------------------------------------------------------------------------------------ diff --git a/code/DeboneProcess.cpp b/code/DeboneProcess.cpp index 5a742dcf4..bc6afa36e 100644 --- a/code/DeboneProcess.cpp +++ b/code/DeboneProcess.cpp @@ -91,7 +91,7 @@ void DeboneProcess::SetupProperties(const Importer* pImp) // Executes the post processing step on the given imported data. void DeboneProcess::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("DeboneProcess begin"); + ASSIMP_LOG_DEBUG("DeboneProcess begin"); if(!pScene->mNumMeshes) { return; @@ -148,9 +148,7 @@ void DeboneProcess::Execute( aiScene* pScene) } if(!DefaultLogger::isNullLogger()) { - char buffer[1024]; - ::ai_snprintf(buffer,1024,"Removed %u bones. Input bones: %u. Output bones: %u",in-out,in,out); - DefaultLogger::get()->info(buffer); + ASSIMP_LOG_INFO_F("Removed %u bones. Input bones:", in - out, ". Output bones: ", out); } // and destroy the source mesh. It should be completely contained inside the new submeshes @@ -173,7 +171,7 @@ void DeboneProcess::Execute( aiScene* pScene) UpdateNode( pScene->mRootNode); } - DefaultLogger::get()->debug("DeboneProcess end"); + ASSIMP_LOG_DEBUG("DeboneProcess end"); } // ------------------------------------------------------------------------------------------------ diff --git a/code/EmbedTexturesProcess.cpp b/code/EmbedTexturesProcess.cpp index 076339468..2fafc2de7 100644 --- a/code/EmbedTexturesProcess.cpp +++ b/code/EmbedTexturesProcess.cpp @@ -93,9 +93,7 @@ void EmbedTexturesProcess::Execute(aiScene* pScene) { } } - char stringBuffer[128]; - ::ai_snprintf(stringBuffer, 128, "EmbedTexturesProcess finished. Embedded %u textures.", embeddedTexturesCount); - DefaultLogger::get()->info(stringBuffer); + ASSIMP_LOG_INFO_F("EmbedTexturesProcess finished. Embedded ", embeddedTexturesCount, " textures." ); } bool EmbedTexturesProcess::addTexture(aiScene* pScene, std::string path) const { @@ -105,7 +103,7 @@ bool EmbedTexturesProcess::addTexture(aiScene* pScene, std::string path) const { // Test path directly std::ifstream file(imagePath, std::ios::binary | std::ios::ate); if ((imageSize = file.tellg()) == std::streampos(-1)) { - DefaultLogger::get()->warn("EmbedTexturesProcess: Cannot find image: " + imagePath + ". Will try to find it in root folder."); + ASSIMP_LOG_WARN_F("EmbedTexturesProcess: Cannot find image: ", imagePath, ". Will try to find it in root folder."); // Test path in root path imagePath = mRootPath + path; @@ -115,7 +113,7 @@ bool EmbedTexturesProcess::addTexture(aiScene* pScene, std::string path) const { imagePath = mRootPath + path.substr(path.find_last_of("\\/") + 1u); file.open(imagePath, std::ios::binary | std::ios::ate); if ((imageSize = file.tellg()) == std::streampos(-1)) { - DefaultLogger::get()->error("EmbedTexturesProcess: Unable to embed texture: " + path + "."); + ASSIMP_LOG_ERROR_F("EmbedTexturesProcess: Unable to embed texture: ", path, "."); return false; } } diff --git a/code/FBXDocumentUtil.cpp b/code/FBXDocumentUtil.cpp index 3b1435b5c..b7de8d91d 100644 --- a/code/FBXDocumentUtil.cpp +++ b/code/FBXDocumentUtil.cpp @@ -91,7 +91,7 @@ void DOMWarning(const std::string& message, const Element* element /*= NULL*/) return; } if(DefaultLogger::get()) { - DefaultLogger::get()->warn("FBX-DOM: " + message); + ASSIMP_LOG_WARN("FBX-DOM: " + message); } } diff --git a/code/FindDegenerates.cpp b/code/FindDegenerates.cpp index dc2b5d01c..c0023c9a4 100644 --- a/code/FindDegenerates.cpp +++ b/code/FindDegenerates.cpp @@ -85,11 +85,11 @@ void FindDegeneratesProcess::SetupProperties(const Importer* pImp) { // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. void FindDegeneratesProcess::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("FindDegeneratesProcess begin"); + ASSIMP_LOG_DEBUG("FindDegeneratesProcess begin"); for (unsigned int i = 0; i < pScene->mNumMeshes;++i){ ExecuteOnMesh( pScene->mMeshes[ i ] ); } - DefaultLogger::get()->debug("FindDegeneratesProcess finished"); + ASSIMP_LOG_DEBUG("FindDegeneratesProcess finished"); } static ai_real heron( ai_real a, ai_real b, ai_real c ) { @@ -242,7 +242,7 @@ evil_jump_outside: if (!mesh->mNumFaces) { // WTF!? // OK ... for completeness and because I'm not yet tired, - // let's write code that willl hopefully never be called + // let's write code that will hopefully never be called // (famous last words) // OK ... bad idea. @@ -250,10 +250,7 @@ evil_jump_outside: } } - if (deg && !DefaultLogger::isNullLogger()) - { - char s[64]; - ASSIMP_itoa10(s,deg); - DefaultLogger::get()->warn(std::string("Found ") + s + " degenerated primitives"); + if (deg && !DefaultLogger::isNullLogger()) { + ASSIMP_LOG_WARN_F( "Found ", deg, " degenerated primitives"); } } diff --git a/code/FindInstancesProcess.cpp b/code/FindInstancesProcess.cpp index 089e6c078..25dcc51e8 100644 --- a/code/FindInstancesProcess.cpp +++ b/code/FindInstancesProcess.cpp @@ -119,7 +119,7 @@ void UpdateMeshIndices(aiNode* node, unsigned int* lookup) // Executes the post processing step on the given imported data. void FindInstancesProcess::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("FindInstancesProcess begin"); + ASSIMP_LOG_DEBUG("FindInstancesProcess begin"); if (pScene->mNumMeshes) { // use a pseudo hash for all meshes in the scene to quickly find @@ -267,13 +267,11 @@ void FindInstancesProcess::Execute( aiScene* pScene) // write to log if (!DefaultLogger::isNullLogger()) { - - char buffer[512]; - ::ai_snprintf(buffer,512,"FindInstancesProcess finished. Found %i instances",pScene->mNumMeshes-numMeshesOut); - DefaultLogger::get()->info(buffer); + ASSIMP_LOG_INFO_F( "FindInstancesProcess finished. Found ", (pScene->mNumMeshes - numMeshesOut), " instances" ); } pScene->mNumMeshes = numMeshesOut; + } else { + ASSIMP_LOG_DEBUG("FindInstancesProcess finished. No instanced meshes found"); } - else DefaultLogger::get()->debug("FindInstancesProcess finished. No instanced meshes found"); } } diff --git a/code/FindInvalidDataProcess.cpp b/code/FindInvalidDataProcess.cpp index 5e6b43dee..b1a296a54 100644 --- a/code/FindInvalidDataProcess.cpp +++ b/code/FindInvalidDataProcess.cpp @@ -118,7 +118,7 @@ void UpdateMeshReferences(aiNode* node, const std::vector& meshMap // Executes the post processing step on the given imported data. void FindInvalidDataProcess::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("FindInvalidDataProcess begin"); + ASSIMP_LOG_DEBUG("FindInvalidDataProcess begin"); bool out = false; std::vector meshMapping(pScene->mNumMeshes); @@ -163,9 +163,10 @@ void FindInvalidDataProcess::Execute( aiScene* pScene) pScene->mNumMeshes = real; } - DefaultLogger::get()->info("FindInvalidDataProcess finished. Found issues ..."); + ASSIMP_LOG_INFO("FindInvalidDataProcess finished. Found issues ..."); + } else { + ASSIMP_LOG_DEBUG("FindInvalidDataProcess finished. Everything seems to be OK."); } - else DefaultLogger::get()->debug("FindInvalidDataProcess finished. Everything seems to be OK."); } // ------------------------------------------------------------------------------------------------ @@ -212,8 +213,7 @@ inline bool ProcessArray(T*& in, unsigned int num,const char* name, { const char* err = ValidateArrayContents(in,num,dirtyMask,mayBeIdentical,mayBeZero); if (err) { - DefaultLogger::get()->error(std::string("FindInvalidDataProcess fails on mesh ") + name + ": " + err); - + ASSIMP_LOG_ERROR_F( "FindInvalidDataProcess fails on mesh ", name, ": ", err); delete[] in; in = NULL; return true; @@ -354,7 +354,7 @@ int FindInvalidDataProcess::ProcessMesh (aiMesh* pMesh) // Process vertex positions if (pMesh->mVertices && ProcessArray(pMesh->mVertices, pMesh->mNumVertices, "positions", dirtyMask)) { - DefaultLogger::get()->error("Deleting mesh: Unable to continue without vertex positions"); + ASSIMP_LOG_ERROR("Deleting mesh: Unable to continue without vertex positions"); return 2; } diff --git a/code/FixNormalsStep.cpp b/code/FixNormalsStep.cpp index e66fec5ef..668b50c24 100644 --- a/code/FixNormalsStep.cpp +++ b/code/FixNormalsStep.cpp @@ -82,28 +82,35 @@ bool FixInfacingNormalsProcess::IsActive( unsigned int pFlags) const // Executes the post processing step on the given imported data. void FixInfacingNormalsProcess::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("FixInfacingNormalsProcess begin"); + ASSIMP_LOG_DEBUG("FixInfacingNormalsProcess begin"); - bool bHas = false; - for( unsigned int a = 0; a < pScene->mNumMeshes; a++) - if(ProcessMesh( pScene->mMeshes[a],a))bHas = true; + bool bHas( false ); + for (unsigned int a = 0; a < pScene->mNumMeshes; ++a) { + if (ProcessMesh(pScene->mMeshes[a], a)) { + bHas = true; + } + } - if (bHas) - DefaultLogger::get()->debug("FixInfacingNormalsProcess finished. Found issues."); - else DefaultLogger::get()->debug("FixInfacingNormalsProcess finished. No changes to the scene."); + if (bHas) { + ASSIMP_LOG_DEBUG("FixInfacingNormalsProcess finished. Found issues."); + } else { + ASSIMP_LOG_DEBUG("FixInfacingNormalsProcess finished. No changes to the scene."); + } } // ------------------------------------------------------------------------------------------------ // Apply the step to the mesh bool FixInfacingNormalsProcess::ProcessMesh( aiMesh* pcMesh, unsigned int index) { - ai_assert(NULL != pcMesh); + ai_assert(nullptr != pcMesh); // Nothing to do if there are no model normals - if (!pcMesh->HasNormals())return false; + if (!pcMesh->HasNormals()) { + return false; + } // Compute the bounding box of both the model vertices + normals and - // the umodified model vertices. Then check whether the first BB + // the unmodified model vertices. Then check whether the first BB // is smaller than the second. In this case we can assume that the // normals need to be flipped, although there are a few special cases .. // convex, concave, planar models ... @@ -155,14 +162,9 @@ bool FixInfacingNormalsProcess::ProcessMesh( aiMesh* pcMesh, unsigned int index) if (fDelta1_z < 0.05f * std::sqrt( fDelta1_y * fDelta1_x ))return false; // now compare the volumes of the bounding boxes - if (std::fabs(fDelta0_x * fDelta0_y * fDelta0_z) < - std::fabs(fDelta1_x * fDelta1_yz)) - { - if (!DefaultLogger::isNullLogger()) - { - char buffer[128]; // should be sufficiently large - ai_snprintf(buffer,128,"Mesh %u: Normals are facing inwards (or the mesh is planar)",index); - DefaultLogger::get()->info(buffer); + if (std::fabs(fDelta0_x * fDelta0_y * fDelta0_z) < std::fabs(fDelta1_x * fDelta1_yz)) { + if (!DefaultLogger::isNullLogger()) { + ASSIMP_LOG_INFO_F("Mesh ", index, ": Normals are facing inwards (or the mesh is planar)", index); } // Invert normals diff --git a/code/GenFaceNormalsProcess.cpp b/code/GenFaceNormalsProcess.cpp index be726302c..2639868f1 100644 --- a/code/GenFaceNormalsProcess.cpp +++ b/code/GenFaceNormalsProcess.cpp @@ -72,16 +72,14 @@ GenFaceNormalsProcess::~GenFaceNormalsProcess() // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. -bool GenFaceNormalsProcess::IsActive( unsigned int pFlags) const -{ +bool GenFaceNormalsProcess::IsActive( unsigned int pFlags) const { return (pFlags & aiProcess_GenNormals) != 0; } // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void GenFaceNormalsProcess::Execute( aiScene* pScene) -{ - DefaultLogger::get()->debug("GenFaceNormalsProcess begin"); +void GenFaceNormalsProcess::Execute( aiScene* pScene) { + ASSIMP_LOG_DEBUG("GenFaceNormalsProcess begin"); if (pScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) { throw DeadlyImportError("Post-processing order mismatch: expecting pseudo-indexed (\"verbose\") vertices here"); @@ -94,11 +92,12 @@ void GenFaceNormalsProcess::Execute( aiScene* pScene) } } if (bHas) { - DefaultLogger::get()->info("GenFaceNormalsProcess finished. " + ASSIMP_LOG_INFO("GenFaceNormalsProcess finished. " "Face normals have been calculated"); + } else { + ASSIMP_LOG_DEBUG("GenFaceNormalsProcess finished. " + "Normals are already there"); } - else DefaultLogger::get()->debug("GenFaceNormalsProcess finished. " - "Normals are already there"); } // ------------------------------------------------------------------------------------------------ @@ -113,7 +112,7 @@ bool GenFaceNormalsProcess::GenMeshFaceNormals (aiMesh* pMesh) // triangles or higher-order polygons the normal vectors // are undefined. if (!(pMesh->mPrimitiveTypes & (aiPrimitiveType_TRIANGLE | aiPrimitiveType_POLYGON))) { - DefaultLogger::get()->info("Normal vectors are undefined for line and point meshes"); + ASSIMP_LOG_INFO("Normal vectors are undefined for line and point meshes"); return false; } diff --git a/code/GenVertexNormalsProcess.cpp b/code/GenVertexNormalsProcess.cpp index f746f3776..7f29411c3 100644 --- a/code/GenVertexNormalsProcess.cpp +++ b/code/GenVertexNormalsProcess.cpp @@ -88,24 +88,25 @@ void GenVertexNormalsProcess::SetupProperties(const Importer* pImp) // Executes the post processing step on the given imported data. void GenVertexNormalsProcess::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("GenVertexNormalsProcess begin"); + ASSIMP_LOG_DEBUG("GenVertexNormalsProcess begin"); - if (pScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) + if (pScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) { throw DeadlyImportError("Post-processing order mismatch: expecting pseudo-indexed (\"verbose\") vertices here"); + } bool bHas = false; - for( unsigned int a = 0; a < pScene->mNumMeshes; a++) - { + for( unsigned int a = 0; a < pScene->mNumMeshes; ++a) { if(GenMeshVertexNormals( pScene->mMeshes[a],a)) bHas = true; } if (bHas) { - DefaultLogger::get()->info("GenVertexNormalsProcess finished. " + ASSIMP_LOG_INFO("GenVertexNormalsProcess finished. " "Vertex normals have been calculated"); + } else { + ASSIMP_LOG_DEBUG("GenVertexNormalsProcess finished. " + "Normals are already there"); } - else DefaultLogger::get()->debug("GenVertexNormalsProcess finished. " - "Normals are already there"); } // ------------------------------------------------------------------------------------------------ @@ -120,7 +121,7 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int // are undefined. if (!(pMesh->mPrimitiveTypes & (aiPrimitiveType_TRIANGLE | aiPrimitiveType_POLYGON))) { - DefaultLogger::get()->info("Normal vectors are undefined for line and point meshes"); + ASSIMP_LOG_INFO("Normal vectors are undefined for line and point meshes"); return false; } diff --git a/code/IRRMeshLoader.cpp b/code/IRRMeshLoader.cpp index 1ed16acd6..85de42195 100644 --- a/code/IRRMeshLoader.cpp +++ b/code/IRRMeshLoader.cpp @@ -470,7 +470,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile, } if (curFace != faceEnd) - DefaultLogger::get()->error("IRRMESH: Not enough indices"); + ASSIMP_LOG_ERROR("IRRMESH: Not enough indices"); // Finish processing the mesh - do some small material workarounds if (curMatFlags & AI_IRRMESH_MAT_trans_vertex_alpha && !useColors) { diff --git a/code/Importer.cpp b/code/Importer.cpp index 36afc8723..9fbba61c4 100644 --- a/code/Importer.cpp +++ b/code/Importer.cpp @@ -510,45 +510,46 @@ void WriteLogOpening(const std::string& file) // need to ask the authors of incoming bug reports for // the library version they're using - a log dump is // sufficient. - const unsigned int flags = aiGetCompileFlags(); - ASSIMP_LOG_DEBUG_F( "Assimp ", aiGetVersionMajor(), ".", aiGetVersionMinor(), ".", aiGetVersionRevision(), " " + const unsigned int flags( aiGetCompileFlags() ); + std::stringstream stream; + stream << "Assimp " << aiGetVersionMajor() << "." << aiGetVersionMinor() << "." << aiGetVersionRevision() << " " #if defined(ASSIMP_BUILD_ARCHITECTURE) - ,ASSIMP_BUILD_ARCHITECTURE + << ASSIMP_BUILD_ARCHITECTURE #elif defined(_M_IX86) || defined(__x86_32__) || defined(__i386__) - , "x86" + << "x86" #elif defined(_M_X64) || defined(__x86_64__) - , "amd64" + << "amd64" #elif defined(_M_IA64) || defined(__ia64__) - , "itanium" + << "itanium" #elif defined(__ppc__) || defined(__powerpc__) - , "ppc32" + << "ppc32" #elif defined(__powerpc64__) - , "ppc64" + << "ppc64" #elif defined(__arm__) - , "arm" + << "arm" #else - , "" + << "" #endif - - , " " + << " " #if defined(ASSIMP_BUILD_COMPILER) - , ASSIMP_BUILD_COMPILER + << ( ASSIMP_BUILD_COMPILER ) #elif defined(_MSC_VER) - , "msvc" + << "msvc" #elif defined(__GNUC__) - , "gcc" + << "gcc" #else - , "" + << "" #endif #ifdef ASSIMP_BUILD_DEBUG - , " debug" + << " debug" #endif - , (flags & ASSIMP_CFLAGS_NOBOOST ? " noboost" : "") - , (flags & ASSIMP_CFLAGS_SHARED ? " shared" : "") - , (flags & ASSIMP_CFLAGS_SINGLETHREADED ? " singlethreaded" : "") - ); + << (flags & ASSIMP_CFLAGS_NOBOOST ? " noboost" : "") + << (flags & ASSIMP_CFLAGS_SHARED ? " shared" : "") + << (flags & ASSIMP_CFLAGS_SINGLETHREADED ? " singlethreaded" : ""); + + ASSIMP_LOG_DEBUG(stream.str()); } // ------------------------------------------------------------------------------------------------ diff --git a/code/ImproveCacheLocality.cpp b/code/ImproveCacheLocality.cpp index ef16aeac9..781462a92 100644 --- a/code/ImproveCacheLocality.cpp +++ b/code/ImproveCacheLocality.cpp @@ -95,11 +95,11 @@ void ImproveCacheLocalityProcess::SetupProperties(const Importer* pImp) void ImproveCacheLocalityProcess::Execute( aiScene* pScene) { if (!pScene->mNumMeshes) { - DefaultLogger::get()->debug("ImproveCacheLocalityProcess skipped; there are no meshes"); + ASSIMP_LOG_DEBUG("ImproveCacheLocalityProcess skipped; there are no meshes"); return; } - DefaultLogger::get()->debug("ImproveCacheLocalityProcess begin"); + ASSIMP_LOG_DEBUG("ImproveCacheLocalityProcess begin"); float out = 0.f; unsigned int numf = 0, numm = 0; @@ -112,12 +112,8 @@ void ImproveCacheLocalityProcess::Execute( aiScene* pScene) } } if (!DefaultLogger::isNullLogger()) { - char szBuff[128]; // should be sufficiently large in every case - ai_snprintf(szBuff,128,"Cache relevant are %u meshes (%u faces). Average output ACMR is %f", - numm,numf,out/numf); - - DefaultLogger::get()->info(szBuff); - DefaultLogger::get()->debug("ImproveCacheLocalityProcess finished. "); + ASSIMP_LOG_INFO_F("Cache relevant are ", numm, " meshes (", numf," faces). Average output ACMR is ", out / numf ); + ASSIMP_LOG_DEBUG("ImproveCacheLocalityProcess finished. "); } } @@ -135,7 +131,7 @@ float ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int mesh return 0.f; if (pMesh->mPrimitiveTypes != aiPrimitiveType_TRIANGLE) { - DefaultLogger::get()->error("This algorithm works on triangle meshes only"); + ASSIMP_LOG_ERROR("This algorithm works on triangle meshes only"); return 0.f; } @@ -363,11 +359,7 @@ float ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int mesh // very intense verbose logging ... prepare for much text if there are many meshes if ( DefaultLogger::get()->getLogSeverity() == Logger::VERBOSE) { - char szBuff[128]; // should be sufficiently large in every case - - ai_snprintf(szBuff,128,"Mesh %u | ACMR in: %f out: %f | ~%.1f%%",meshNum,fACMR,fACMR2, - ((fACMR - fACMR2) / fACMR) * 100.f); - DefaultLogger::get()->debug(szBuff); + ASSIMP_LOG_DEBUG_F("Mesh %u | ACMR in: ", meshNum, " out: ", fACMR, " | ~", fACMR2, ((fACMR - fACMR2) / fACMR) * 100.f); } fACMR2 *= pMesh->mNumFaces; diff --git a/code/JoinVerticesProcess.cpp b/code/JoinVerticesProcess.cpp index 3ab5d5833..1bbd18145 100644 --- a/code/JoinVerticesProcess.cpp +++ b/code/JoinVerticesProcess.cpp @@ -79,7 +79,7 @@ bool JoinVerticesProcess::IsActive( unsigned int pFlags) const // Executes the post processing step on the given imported data. void JoinVerticesProcess::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("JoinVerticesProcess begin"); + ASSIMP_LOG_DEBUG("JoinVerticesProcess begin"); // get the total number of vertices BEFORE the step is executed int iNumOldVertices = 0; @@ -95,19 +95,13 @@ void JoinVerticesProcess::Execute( aiScene* pScene) iNumVertices += ProcessMesh( pScene->mMeshes[a],a); // if logging is active, print detailed statistics - if (!DefaultLogger::isNullLogger()) - { - if (iNumOldVertices == iNumVertices) - { - DefaultLogger::get()->debug("JoinVerticesProcess finished "); - } else - { - char szBuff[128]; // should be sufficiently large in every case - ::ai_snprintf(szBuff,128,"JoinVerticesProcess finished | Verts in: %i out: %i | ~%.1f%%", - iNumOldVertices, - iNumVertices, - ((iNumOldVertices - iNumVertices) / (float)iNumOldVertices) * 100.f); - DefaultLogger::get()->info(szBuff); + if (!DefaultLogger::isNullLogger()) { + if (iNumOldVertices == iNumVertices) { + ASSIMP_LOG_DEBUG("JoinVerticesProcess finished "); + } else { + ASSIMP_LOG_INFO_F("JoinVerticesProcess finished | Verts in: ", iNumOldVertices, + " out: ", iNumVertices, " | ~", + ((iNumOldVertices - iNumVertices) / (float)iNumOldVertices) * 100.f ); } } @@ -274,7 +268,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) } if (!DefaultLogger::isNullLogger() && DefaultLogger::get()->getLogSeverity() == Logger::VERBOSE) { - DefaultLogger::get()->debug((Formatter::format(), + ASSIMP_LOG_DEBUG_F( "Mesh ",meshIndex, " (", (pMesh->mName.length ? pMesh->mName.data : "unnamed"), @@ -284,7 +278,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) " | ~", ((pMesh->mNumVertices - uniqueVertices.size()) / (float)pMesh->mNumVertices) * 100.f, "%" - )); + ); } // replace vertex data with the unique data sets @@ -375,7 +369,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) } } } else { - DefaultLogger::get()->error( "X-Export: aiBone shall contain weights, but pointer to them is NULL." ); + ASSIMP_LOG_ERROR( "X-Export: aiBone shall contain weights, but pointer to them is NULL." ); } if (newWeights.size() > 0) { diff --git a/code/LWOLoader.cpp b/code/LWOLoader.cpp index d654935b4..fbefe4a1e 100644 --- a/code/LWOLoader.cpp +++ b/code/LWOLoader.cpp @@ -1080,7 +1080,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) // we have already a VMAP entry for this vertex - thus // we need to duplicate the corresponding polygon. if (polyIdx >= numFaces) { - DefaultLogger::get()->warn("LWO2: Failure evaluating VMAD entry \'" + name + "\', polygon index is out of range"); + ASSIMP_LOG_WARN_F("LWO2: Failure evaluating VMAD entry \'", name, "\', polygon index is out of range"); mFileBuffer += base->dims<<2u; continue; } @@ -1442,17 +1442,21 @@ void LWOImporter::LoadLWO2File() if (skip) break; - if (mCurLayer->mFaces.empty()) - DefaultLogger::get()->warn("LWO2: Unexpected PTAG"); - else LoadLWO2PolygonTags(head.length); + if (mCurLayer->mFaces.empty()) { + ASSIMP_LOG_WARN("LWO2: Unexpected PTAG"); + } else { + LoadLWO2PolygonTags(head.length); + } break; } // list of tags case AI_LWO_TAGS: { - if (!mTags->empty()) + if (!mTags->empty()) { ASSIMP_LOG_WARN("LWO2: SRFS chunk encountered twice"); - else LoadLWOTags(head.length); + } else { + LoadLWOTags(head.length); + } break; } diff --git a/code/LWSLoader.cpp b/code/LWSLoader.cpp index 4313359d8..518b893e9 100644 --- a/code/LWSLoader.cpp +++ b/code/LWSLoader.cpp @@ -684,7 +684,7 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, (*it).tokens[0] == "LightMotion")) { if (nodes.empty()) - DASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'Motion\'"); + ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'Motion\'"); else { ReadEnvelope_Old(it,root.children.end(),nodes.back(),version); } @@ -773,7 +773,7 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene, // 'LightType': set type of currently active light else if ((*it).tokens[0] == "LightType") { if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) - DefaultLogger::get()->error("LWS: Unexpected keyword: \'LightType\'"); + ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightType\'"); else nodes.back().lightType = strtoul10(c); diff --git a/code/LimitBoneWeightsProcess.cpp b/code/LimitBoneWeightsProcess.cpp index 8c21f2394..cc87e407c 100644 --- a/code/LimitBoneWeightsProcess.cpp +++ b/code/LimitBoneWeightsProcess.cpp @@ -76,13 +76,13 @@ bool LimitBoneWeightsProcess::IsActive( unsigned int pFlags) const // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. -void LimitBoneWeightsProcess::Execute( aiScene* pScene) -{ - DefaultLogger::get()->debug("LimitBoneWeightsProcess begin"); - for( unsigned int a = 0; a < pScene->mNumMeshes; a++) - ProcessMesh( pScene->mMeshes[a]); +void LimitBoneWeightsProcess::Execute( aiScene* pScene) { + ASSIMP_LOG_DEBUG("LimitBoneWeightsProcess begin"); + for (unsigned int a = 0; a < pScene->mNumMeshes; ++a ) { + ProcessMesh(pScene->mMeshes[a]); + } - DefaultLogger::get()->debug("LimitBoneWeightsProcess end"); + ASSIMP_LOG_DEBUG("LimitBoneWeightsProcess end"); } // ------------------------------------------------------------------------------------------------ @@ -195,9 +195,7 @@ void LimitBoneWeightsProcess::ProcessMesh( aiMesh* pMesh) } if (!DefaultLogger::isNullLogger()) { - char buffer[1024]; - ai_snprintf(buffer,1024,"Removed %u weights. Input bones: %u. Output bones: %u",removed,old_bones,pMesh->mNumBones); - DefaultLogger::get()->info(buffer); + ASSIMP_LOG_INFO_F("Removed ", removed, " weights. Input bones: ", old_bones, ". Output bones: ", pMesh->mNumBones ); } } } diff --git a/code/MD5Parser.cpp b/code/MD5Parser.cpp index 7fa4db1ba..6f942228c 100644 --- a/code/MD5Parser.cpp +++ b/code/MD5Parser.cpp @@ -130,7 +130,7 @@ void MD5Parser::ParseHeader() // FIX: can break the log length limit, so we need to be careful char* sz = buffer; while (!IsLineEnd( *buffer++)); - DefaultLogger::get()->info(std::string(sz,std::min((uintptr_t)MAX_LOG_MESSAGE_LENGTH, (uintptr_t)(buffer-sz)))); + ASSIMP_LOG_INFO(std::string(sz,std::min((uintptr_t)MAX_LOG_MESSAGE_LENGTH, (uintptr_t)(buffer-sz)))); SkipSpacesAndLineEnd(); } @@ -483,6 +483,6 @@ MD5CameraParser::MD5CameraParser(SectionList& mSections) } } } - DefaultLogger::get()->debug("MD5CameraParser end"); + ASSIMP_LOG_DEBUG("MD5CameraParser end"); } diff --git a/code/MDCLoader.cpp b/code/MDCLoader.cpp index 34ead53a9..e294a1912 100644 --- a/code/MDCLoader.cpp +++ b/code/MDCLoader.cpp @@ -159,8 +159,9 @@ void MDCImporter::ValidateHeader() "magic word found is " + std::string( szBuffer )); } - if (pcHeader->ulVersion != AI_MDC_VERSION) - DefaultLogger::get()->warn("Unsupported MDC file version (2 (AI_MDC_VERSION) was expected)"); + if (pcHeader->ulVersion != AI_MDC_VERSION) { + ASSIMP_LOG_WARN("Unsupported MDC file version (2 (AI_MDC_VERSION) was expected)"); + } if (pcHeader->ulOffsetBorderFrames + pcHeader->ulNumFrames * sizeof(MDC::Frame) > this->fileSize || pcHeader->ulOffsetSurfaces + pcHeader->ulNumSurfaces * sizeof(MDC::Surface) > this->fileSize) @@ -169,8 +170,9 @@ void MDCImporter::ValidateHeader() "and point to something behind the file."); } - if (this->configFrameID >= this->pcHeader->ulNumFrames) + if (this->configFrameID >= this->pcHeader->ulNumFrames) { throw DeadlyImportError("The requested frame is not available"); + } } // ------------------------------------------------------------------------------------------------ @@ -388,7 +390,7 @@ void MDCImporter::InternReadFile( uint32_t quak = pcTriangle->aiIndices[iIndex]; if (quak >= pcSurface->ulNumVertices) { - DefaultLogger::get()->error("MDC vertex index is out of range"); + ASSIMP_LOG_ERROR("MDC vertex index is out of range"); quak = pcSurface->ulNumVertices-1; } diff --git a/code/MDLLoader.cpp b/code/MDLLoader.cpp index aed244bc2..4c43bc64f 100644 --- a/code/MDLLoader.cpp +++ b/code/MDLLoader.cpp @@ -481,7 +481,7 @@ void MDLImporter::InternReadFile_Quake1() { if (iIndex >= (unsigned int)pcHeader->num_verts) { iIndex = pcHeader->num_verts-1; - DefaultLogger::get()->warn("Index overflow in Q1-MDL vertex list."); + ASSIMP_LOG_WARN("Index overflow in Q1-MDL vertex list."); } aiVector3D& vec = pcMesh->mVertices[iCurrent]; @@ -1026,7 +1026,7 @@ void MDLImporter::ReadFaces_3DGS_MDL7(const MDL::IntGroupInfo_MDL7& groupInfo, if(iIndex > (unsigned int)groupInfo.pcGroup->numverts) { // (we might need to read this section a second time - to process frame vertices correctly) pcGroupTris->v_index[c] = iIndex = groupInfo.pcGroup->numverts-1; - DASSIMP_LOG_WARN("Index overflow in MDL7 vertex list"); + ASSIMP_LOG_WARN("Index overflow in MDL7 vertex list"); } // write the output face index @@ -1894,7 +1894,7 @@ void MDLImporter::GenerateOutputMeshes_3DGS_MDL7( unsigned int iBone = groupData.aiBones[ oldFace.mIndices[c] ]; if (UINT_MAX != iBone) { if (iBone >= iNumOutBones) { - DefaultLogger::get()->error("Bone index overflow. " + ASSIMP_LOG_ERROR("Bone index overflow. " "The bone index of a vertex exceeds the allowed range. "); iBone = iNumOutBones-1; } diff --git a/code/MDLMaterialLoader.cpp b/code/MDLMaterialLoader.cpp index 8955455ef..e80d3b560 100644 --- a/code/MDLMaterialLoader.cpp +++ b/code/MDLMaterialLoader.cpp @@ -64,7 +64,7 @@ using namespace Assimp; static aiTexel* const bad_texel = reinterpret_cast(SIZE_MAX); // ------------------------------------------------------------------------------------------------ -// Find a suitable pallette file or take the default one +// Find a suitable palette file or take the default one void MDLImporter::SearchPalette(const unsigned char** pszColorMap) { // now try to find the color map in the current directory @@ -75,10 +75,11 @@ void MDLImporter::SearchPalette(const unsigned char** pszColorMap) { if (pcStream->FileSize() >= 768) { - unsigned char* colorMap = new unsigned char[256*3]; + constexpr size_t len = 256 * 3; + unsigned char* colorMap = new unsigned char[len]; szColorMap = colorMap; - pcStream->Read(colorMap,256*3,1); - DefaultLogger::get()->info("Found valid colormap.lmp in directory. " + pcStream->Read(colorMap, len,1); + ASSIMP_LOG_INFO("Found valid colormap.lmp in directory. " "It will be used to decode embedded textures in palletized formats."); } delete pcStream; @@ -186,7 +187,7 @@ void MDLImporter::CreateTexture_3DGS_MDL4(const unsigned char* szData, if (iType == 1 || iType > 3) { - DefaultLogger::get()->error("Unsupported texture file format"); + ASSIMP_LOG_ERROR("Unsupported texture file format"); return; } @@ -508,7 +509,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( // ***** EMBEDDED DDS FILE ***** if (1 != iHeight) { - DefaultLogger::get()->warn("Found a reference to an embedded DDS texture, " + ASSIMP_LOG_WARN("Found a reference to an embedded DDS texture, " "but texture height is not equal to 1, which is not supported by MED"); } diff --git a/code/MS3DLoader.cpp b/code/MS3DLoader.cpp index 869c41afb..b06bea31c 100644 --- a/code/MS3DLoader.cpp +++ b/code/MS3DLoader.cpp @@ -349,9 +349,6 @@ void MS3DImporter::InternReadFile( const std::string& pFile, stream.CopyAndAdvance(j.parentName,32); j.parentName[32] = '\0'; - // DefaultLogger::get()->debug(j.name); - // DefaultLogger::get()->debug(j.parentName); - ReadVector(stream,j.rotation); ReadVector(stream,j.position); @@ -386,7 +383,7 @@ void MS3DImporter::InternReadFile( const std::string& pFile, } const std::string& s = std::string(reinterpret_cast(stream.GetPtr()),len); - DefaultLogger::get()->debug("MS3D: Model comment: " + s); + ASSIMP_LOG_DEBUG_F("MS3D: Model comment: ", s); } if(stream.GetRemainingSize() > 4 && inrange((stream >> subversion,subversion),1u,3u)) { diff --git a/code/MakeVerboseFormat.cpp b/code/MakeVerboseFormat.cpp index f6a978e56..b6f5cabd9 100644 --- a/code/MakeVerboseFormat.cpp +++ b/code/MakeVerboseFormat.cpp @@ -65,7 +65,7 @@ MakeVerboseFormatProcess::~MakeVerboseFormatProcess() void MakeVerboseFormatProcess::Execute( aiScene* pScene) { ai_assert(NULL != pScene); - DefaultLogger::get()->debug("MakeVerboseFormatProcess begin"); + ASSIMP_LOG_DEBUG("MakeVerboseFormatProcess begin"); bool bHas = false; for( unsigned int a = 0; a < pScene->mNumMeshes; a++) @@ -73,12 +73,15 @@ void MakeVerboseFormatProcess::Execute( aiScene* pScene) if( MakeVerboseFormat( pScene->mMeshes[a])) bHas = true; } - if (bHas) DefaultLogger::get()->info("MakeVerboseFormatProcess finished. There was much work to do ..."); - else DefaultLogger::get()->debug("MakeVerboseFormatProcess. There was nothing to do."); + if (bHas) { + ASSIMP_LOG_INFO("MakeVerboseFormatProcess finished. There was much work to do ..."); + } else { + ASSIMP_LOG_DEBUG("MakeVerboseFormatProcess. There was nothing to do."); + } pScene->mFlags &= ~AI_SCENE_FLAGS_NON_VERBOSE_FORMAT; - } + // ------------------------------------------------------------------------------------------------ // Executes the post processing step on the given imported data. bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh) diff --git a/code/NDOLoader.cpp b/code/NDOLoader.cpp index 1e6c1e2ca..17c9e135b 100644 --- a/code/NDOLoader.cpp +++ b/code/NDOLoader.cpp @@ -130,18 +130,18 @@ void NDOImporter::InternReadFile( const std::string& pFile, unsigned int file_format = 12; if (!strncmp("1.0",head+6,3)) { file_format = 10; - DefaultLogger::get()->info("NDO file format is 1.0"); + ASSIMP_LOG_INFO("NDO file format is 1.0"); } else if (!strncmp("1.1",head+6,3)) { file_format = 11; - DefaultLogger::get()->info("NDO file format is 1.1"); + ASSIMP_LOG_INFO("NDO file format is 1.1"); } else if (!strncmp("1.2",head+6,3)) { file_format = 12; - DefaultLogger::get()->info("NDO file format is 1.2"); + ASSIMP_LOG_INFO("NDO file format is 1.2"); } else { - ASSIMP_LOG_WARN(std::string("Unrecognized nendo file format version, continuing happily ... :") + (head+6)); + ASSIMP_LOG_WARN_F( "Unrecognized nendo file format version, continuing happily ... :", (head+6)); } reader.IncPtr(2); /* skip flags */ diff --git a/code/NFFLoader.cpp b/code/NFFLoader.cpp index 39f336112..2c7eeaa20 100644 --- a/code/NFFLoader.cpp +++ b/code/NFFLoader.cpp @@ -132,7 +132,7 @@ const aiImporterDesc* NFFImporter::GetInfo () const // ------------------------------------------------------------------------------------------------ -// Loads the materail table for the NFF2 file format from an external file +// Loads the material table for the NFF2 file format from an external file void NFFImporter::LoadNFF2MaterialTable(std::vector& output, const std::string& path, IOSystem* pIOHandler) { @@ -140,7 +140,7 @@ void NFFImporter::LoadNFF2MaterialTable(std::vector& output, // Check whether we can read from the file if( !file.get()) { - DefaultLogger::get()->error("NFF2: Unable to open material library " + path + "."); + ASSIMP_LOG_ERROR("NFF2: Unable to open material library " + path + "."); return; } @@ -158,7 +158,7 @@ void NFFImporter::LoadNFF2MaterialTable(std::vector& output, // The file should start with the magic sequence "mat" if (!TokenMatch(buffer,"mat",3)) { - DefaultLogger::get()->error("NFF2: Not a valid material library " + path + "."); + ASSIMP_LOG_ERROR_F("NFF2: Not a valid material library ", path, "."); return; } @@ -174,7 +174,7 @@ void NFFImporter::LoadNFF2MaterialTable(std::vector& output, // 'version' defines the version of the file format if (TokenMatch(sz,"version",7)) { - DefaultLogger::get()->info("NFF (Sense8) material library file format: " + std::string(sz)); + ASSIMP_LOG_INFO_F("NFF (Sense8) material library file format: ", std::string(sz)); } // 'matdef' starts a new material in the file else if (TokenMatch(sz,"matdef",6)) @@ -192,8 +192,7 @@ void NFFImporter::LoadNFF2MaterialTable(std::vector& output, { if (!curShader) { - DefaultLogger::get()->error(std::string("NFF2 material library: Found element ") + - sz + "but there is no active material"); + ASSIMP_LOG_ERROR_F("NFF2 material library: Found element ", sz, "but there is no active material"); continue; } } @@ -308,7 +307,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, SkipSpaces(line,&sz); if (TokenMatch(sz,"version",7)) { - DefaultLogger::get()->info("NFF (Sense8) file format: " + std::string(sz)); + ASSIMP_LOG_INFO_F("NFF (Sense8) file format: ", sz ); } else if (TokenMatch(sz,"viewpos",7)) { @@ -471,7 +470,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, unsigned int m = ::strtoul10(sz,&sz); if (m >= (unsigned int)tempPositions.size()) { - DefaultLogger::get()->error("NFF2: Vertex index overflow"); + ASSIMP_LOG_ERROR("NFF2: Vertex index overflow"); m= 0; } // mesh.vertices.push_back (tempPositions[idx]); @@ -577,7 +576,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, matIdx = ::strtoul10(sz,&sz); if (matIdx >= materialTable.size()) { - DefaultLogger::get()->error("NFF2: Material index overflow."); + ASSIMP_LOG_ERROR("NFF2: Material index overflow."); matIdx = 0; } @@ -750,7 +749,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, { if(!GetNextLine(buffer,line)) { - DefaultLogger::get()->error("NFF: Unexpected EOF was encountered. Patch definition incomplete"); + ASSIMP_LOG_ERROR("NFF: Unexpected EOF was encountered. Patch definition incomplete"); continue; } @@ -943,7 +942,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, if(!GetNextLine(buffer,line)) { - DefaultLogger::get()->error("NFF: Unexpected end of file (cone definition not complete)"); + ASSIMP_LOG_ERROR("NFF: Unexpected end of file (cone definition not complete)"); break; } sz = line; @@ -955,7 +954,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, if(!GetNextLine(buffer,line)) { - DefaultLogger::get()->error("NFF: Unexpected end of file (cone definition not complete)"); + ASSIMP_LOG_ERROR("NFF: Unexpected end of file (cone definition not complete)"); break; } sz = line; @@ -971,7 +970,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, float f; if (( f = currentMesh.dir.Length()) < 10e-3f ) { - DefaultLogger::get()->error("NFF: Cone height is close to zero"); + ASSIMP_LOG_ERROR("NFF: Cone height is close to zero"); continue; } currentMesh.dir /= f; // normalize @@ -1029,18 +1028,20 @@ void NFFImporter::InternReadFile( const std::string& pFile, // 'pb' - bezier patch. Not supported yet else if (TokenMatch(sz,"pb",2)) { - DefaultLogger::get()->error("NFF: Encountered unsupported ID: bezier patch"); + ASSIMP_LOG_ERROR("NFF: Encountered unsupported ID: bezier patch"); } // 'pn' - NURBS. Not supported yet else if (TokenMatch(sz,"pn",2) || TokenMatch(sz,"pnn",3)) { - DefaultLogger::get()->error("NFF: Encountered unsupported ID: NURBS"); + ASSIMP_LOG_ERROR("NFF: Encountered unsupported ID: NURBS"); } // '' - comment else if ('#' == line[0]) { const char* sz;SkipSpaces(&line[1],&sz); - if (!IsLineEnd(*sz))DefaultLogger::get()->info(sz); + if (!IsLineEnd(*sz)) { + ASSIMP_LOG_INFO(sz); + } } } } diff --git a/code/OFFLoader.cpp b/code/OFFLoader.cpp index d99ba55a2..81f9c9916 100644 --- a/code/OFFLoader.cpp +++ b/code/OFFLoader.cpp @@ -157,7 +157,7 @@ void OFFImporter::InternReadFile( const std::string& pFile, { if(!GetNextLine(buffer,line)) { - DefaultLogger::get()->error("OFF: The number of verts in the header is incorrect"); + ASSIMP_LOG_ERROR("OFF: The number of verts in the header is incorrect"); break; } aiVector3D& v = tempPositions[i]; @@ -175,14 +175,14 @@ void OFFImporter::InternReadFile( const std::string& pFile, { if(!GetNextLine(buffer,line)) { - DefaultLogger::get()->error("OFF: The number of faces in the header is incorrect"); + ASSIMP_LOG_ERROR("OFF: The number of faces in the header is incorrect"); break; } sz = line;SkipSpaces(&sz); faces->mNumIndices = strtoul10(sz,&sz); if(!(faces->mNumIndices) || faces->mNumIndices > 9) { - DefaultLogger::get()->error("OFF: Faces with zero indices aren't allowed"); + ASSIMP_LOG_ERROR("OFF: Faces with zero indices aren't allowed"); --mesh->mNumFaces; continue; } @@ -217,7 +217,7 @@ void OFFImporter::InternReadFile( const std::string& pFile, idx = strtoul10(sz,&sz); if ((idx) >= numVertices) { - DefaultLogger::get()->error("OFF: Vertex index is out of range"); + ASSIMP_LOG_ERROR("OFF: Vertex index is out of range"); idx = numVertices-1; } faces->mIndices[m] = p++; diff --git a/code/ObjFileImporter.cpp b/code/ObjFileImporter.cpp index bce94ebbb..dd0733caa 100644 --- a/code/ObjFileImporter.cpp +++ b/code/ObjFileImporter.cpp @@ -557,7 +557,7 @@ void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pSc const unsigned int numMaterials = (unsigned int) pModel->m_MaterialLib.size(); pScene->mNumMaterials = 0; if ( pModel->m_MaterialLib.empty() ) { - DefaultLogger::get()->debug("OBJ: no materials specified"); + ASSIMP_LOG_DEBUG("OBJ: no materials specified"); return; } @@ -591,7 +591,7 @@ void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pSc break; default: sm = aiShadingMode_Gouraud; - DefaultLogger::get()->error("OBJ: unexpected illumination model (0-2 recognized)"); + ASSIMP_LOG_ERROR("OBJ: unexpected illumination model (0-2 recognized)"); } mat->AddProperty( &sm, 1, AI_MATKEY_SHADING_MODEL); diff --git a/code/ObjFileMtlImporter.cpp b/code/ObjFileMtlImporter.cpp index 584b3115c..8f7588819 100644 --- a/code/ObjFileMtlImporter.cpp +++ b/code/ObjFileMtlImporter.cpp @@ -366,7 +366,7 @@ void ObjFileMtlImporter::getTexture() { out = & m_pModel->m_pCurrentMaterial->textureSpecularity; clampIndex = ObjFile::Material::TextureSpecularityType; } else { - DefaultLogger::get()->error("OBJ/MTL: Encountered unknown texture type"); + ASSIMP_LOG_ERROR("OBJ/MTL: Encountered unknown texture type"); return; } diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index 004778259..7630127fa 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -426,7 +426,7 @@ void ObjFileParser::getFace( aiPrimitiveType type ) { if ( *m_DataIt =='/' ) { if (type == aiPrimitiveType_POINT) { - DefaultLogger::get()->error("Obj: Separator unexpected in point statement"); + ASSIMP_LOG_ERROR("Obj: Separator unexpected in point statement"); } if (iPos == 0) { //if there are no texture coordinates in the file, but normals @@ -486,7 +486,7 @@ void ObjFileParser::getFace( aiPrimitiveType type ) { } if ( face->m_vertices.empty() ) { - DefaultLogger::get()->error("Obj: Ignoring empty face"); + ASSIMP_LOG_ERROR("Obj: Ignoring empty face"); // skip line and clean up m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); delete face; @@ -556,7 +556,7 @@ void ObjFileParser::getMaterialDesc() { // This may be the case if the material library is missing. We don't want to lose all // materials if that happens, so create a new named material instead of discarding it // completely. - DefaultLogger::get()->error("OBJ: failed to locate material " + strName + ", creating new material"); + ASSIMP_LOG_ERROR("OBJ: failed to locate material " + strName + ", creating new material"); m_pModel->m_pCurrentMaterial = new ObjFile::Material(); m_pModel->m_pCurrentMaterial->MaterialName.Set(strName); m_pModel->m_MaterialLib.push_back(strName); @@ -620,12 +620,12 @@ void ObjFileParser::getMaterialLib() { IOStream *pFile = m_pIO->Open( absName ); if ( nullptr == pFile ) { - DefaultLogger::get()->error("OBJ: Unable to locate material file " + strMatName); + ASSIMP_LOG_ERROR("OBJ: Unable to locate material file " + strMatName); std::string strMatFallbackName = m_originalObjFileName.substr(0, m_originalObjFileName.length() - 3) + "mtl"; - DefaultLogger::get()->info("OBJ: Opening fallback material file " + strMatFallbackName); + ASSIMP_LOG_INFO("OBJ: Opening fallback material file " + strMatFallbackName); pFile = m_pIO->Open(strMatFallbackName); if (!pFile) { - DefaultLogger::get()->error("OBJ: Unable to locate fallback material file " + strMatFallbackName); + ASSIMP_LOG_ERROR("OBJ: Unable to locate fallback material file " + strMatFallbackName); m_DataIt = skipLine(m_DataIt, m_DataItEnd, m_uiLine); return; } @@ -817,7 +817,7 @@ void ObjFileParser::createMesh( const std::string &meshName ) } else { - DefaultLogger::get()->error("OBJ: No object detected to attach a new mesh instance."); + ASSIMP_LOG_ERROR("OBJ: No object detected to attach a new mesh instance."); } } @@ -851,7 +851,7 @@ bool ObjFileParser::needsNewMesh( const std::string &materialName ) void ObjFileParser::reportErrorTokenInFace() { m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); - DefaultLogger::get()->error("OBJ: Not supported token in face description detected"); + ASSIMP_LOG_ERROR("OBJ: Not supported token in face description detected"); } // ------------------------------------------------------------------- diff --git a/code/OgreBinarySerializer.cpp b/code/OgreBinarySerializer.cpp index 88fe02057..8948844d0 100644 --- a/code/OgreBinarySerializer.cpp +++ b/code/OgreBinarySerializer.cpp @@ -176,7 +176,7 @@ uint16_t OgreBinarySerializer::ReadHeader(bool readLen) #if (OGRE_BINARY_SERIALIZER_DEBUG == 1) if (id != HEADER_CHUNK_ID) { - DefaultLogger::get()->debug(Formatter::format() << (assetMode == AM_Mesh + ASSIMP_LOG_DEBUG(Formatter::format() << (assetMode == AM_Mesh ? MeshHeaderToString(static_cast(id)) : SkeletonHeaderToString(static_cast(id)))); } #endif @@ -192,7 +192,7 @@ void OgreBinarySerializer::RollbackHeader() void OgreBinarySerializer::SkipBytes(size_t numBytes) { #if (OGRE_BINARY_SERIALIZER_DEBUG == 1) - DefaultLogger::get()->debug(Formatter::format() << "Skipping " << numBytes << " bytes"); + ASSIMP_LOG_DEBUG_F( "Skipping ", numBytes, " bytes"); #endif m_reader->IncPtr(numBytes); @@ -237,8 +237,8 @@ void OgreBinarySerializer::ReadMesh(Mesh *mesh) { mesh->hasSkeletalAnimations = Read(); - DefaultLogger::get()->debug("Reading Mesh"); - DefaultLogger::get()->debug(Formatter::format() << " - Skeletal animations: " << (mesh->hasSkeletalAnimations ? "true" : "false")); + ASSIMP_LOG_DEBUG("Reading Mesh"); + ASSIMP_LOG_DEBUG_F( " - Skeletal animations: ", mesh->hasSkeletalAnimations ? "true" : "false" ); if (!AtEnd()) { @@ -420,9 +420,9 @@ void OgreBinarySerializer::ReadSubMesh(Mesh *mesh) submesh->indexData->faceCount = static_cast(submesh->indexData->count / 3); submesh->indexData->is32bit = Read(); - DefaultLogger::get()->debug(Formatter::format() << "Reading SubMesh " << mesh->subMeshes.size()); - DefaultLogger::get()->debug(Formatter::format() << " - Material: '" << submesh->materialRef << "'"); - DefaultLogger::get()->debug(Formatter::format() << " - Uses shared geometry: " << (submesh->usesSharedVertexData ? "true" : "false")); + ASSIMP_LOG_DEBUG_F( "Reading SubMesh ", mesh->subMeshes.size()); + ASSIMP_LOG_DEBUG_F( " - Material: '", submesh->materialRef, "'"); + ASSIMP_LOG_DEBUG_F( " - Uses shared geometry: ", submesh->usesSharedVertexData ? "true" : "false" ); // Index buffer if (submesh->indexData->count > 0) @@ -431,9 +431,9 @@ void OgreBinarySerializer::ReadSubMesh(Mesh *mesh) uint8_t *indexBuffer = ReadBytes(numBytes); submesh->indexData->buffer = MemoryStreamPtr(new Assimp::MemoryIOStream(indexBuffer, numBytes, true)); - DefaultLogger::get()->debug(Formatter::format() << " - " << submesh->indexData->faceCount - << " faces from " << submesh->indexData->count << (submesh->indexData->is32bit ? " 32bit" : " 16bit") - << " indexes of " << numBytes << " bytes"); + ASSIMP_LOG_DEBUG_F( " - ", submesh->indexData->faceCount, + " faces from ", submesh->indexData->count, (submesh->indexData->is32bit ? " 32bit" : " 16bit"), + " indexes of ", numBytes, " bytes"); } // Vertex buffer if not referencing the shared geometry @@ -549,7 +549,7 @@ void OgreBinarySerializer::ReadSubMeshNames(Mesh *mesh) } submesh->name = ReadLine(); - DefaultLogger::get()->debug(Formatter::format() << " - SubMesh " << submesh->index << " name '" << submesh->name << "'"); + ASSIMP_LOG_DEBUG_F( " - SubMesh ", submesh->index, " name '", submesh->name, "'"); if (!AtEnd()) id = ReadHeader(); @@ -563,7 +563,7 @@ void OgreBinarySerializer::ReadGeometry(VertexData *dest) { dest->count = Read(); - DefaultLogger::get()->debug(Formatter::format() << " - Reading geometry of " << dest->count << " vertices"); + ASSIMP_LOG_DEBUG_F( " - Reading geometry of ", dest->count, " vertices"); if (!AtEnd()) { @@ -620,8 +620,8 @@ void OgreBinarySerializer::ReadGeometryVertexElement(VertexData *dest) element.offset = Read(); element.index = Read(); - DefaultLogger::get()->debug(Formatter::format() << " - Vertex element " << element.SemanticToString() << " of type " - << element.TypeToString() << " index=" << element.index << " source=" << element.source); + ASSIMP_LOG_DEBUG_F( " - Vertex element ", element.SemanticToString(), " of type ", + element.TypeToString(), " index=", element.index, " source=", element.source); dest->vertexElements.push_back(element); } @@ -642,7 +642,7 @@ void OgreBinarySerializer::ReadGeometryVertexBuffer(VertexData *dest) uint8_t *vertexBuffer = ReadBytes(numBytes); dest->vertexBindings[bindIndex] = MemoryStreamPtr(new Assimp::MemoryIOStream(vertexBuffer, numBytes, true)); - DefaultLogger::get()->debug(Formatter::format() << " - Read vertex buffer for source " << bindIndex << " of " << numBytes << " bytes"); + ASSIMP_LOG_DEBUG_F( " - Read vertex buffer for source ", bindIndex, " of ", numBytes, " bytes"); } void OgreBinarySerializer::ReadEdgeList(Mesh * /*mesh*/) @@ -892,13 +892,13 @@ MemoryStreamReaderPtr OgreBinarySerializer::OpenReader(Assimp::IOSystem *pIOHand { if (!EndsWith(filename, ".skeleton", false)) { - DefaultLogger::get()->error("Imported Mesh is referencing to unsupported '" + filename + "' skeleton file."); + ASSIMP_LOG_ERROR_F("Imported Mesh is referencing to unsupported '", filename, "' skeleton file."); return MemoryStreamReaderPtr(); } if (!pIOHandler->Exists(filename)) { - DefaultLogger::get()->error("Failed to find skeleton file '" + filename + "' that is referenced by imported Mesh."); + ASSIMP_LOG_ERROR_F("Failed to find skeleton file '", filename, "' that is referenced by imported Mesh."); return MemoryStreamReaderPtr(); } @@ -925,7 +925,7 @@ void OgreBinarySerializer::ReadSkeleton(Skeleton *skeleton) << " Supported versions: " << SKELETON_VERSION_1_8 << " and " << SKELETON_VERSION_1_1); } - DefaultLogger::get()->debug("Reading Skeleton"); + ASSIMP_LOG_DEBUG("Reading Skeleton"); bool firstBone = true; bool firstAnim = true; @@ -944,7 +944,7 @@ void OgreBinarySerializer::ReadSkeleton(Skeleton *skeleton) { if (firstBone) { - DefaultLogger::get()->debug(" - Bones"); + ASSIMP_LOG_DEBUG(" - Bones"); firstBone = false; } @@ -960,7 +960,7 @@ void OgreBinarySerializer::ReadSkeleton(Skeleton *skeleton) { if (firstAnim) { - DefaultLogger::get()->debug(" - Animations"); + ASSIMP_LOG_DEBUG(" - Animations"); firstAnim = false; } @@ -1003,7 +1003,7 @@ void OgreBinarySerializer::ReadBone(Skeleton *skeleton) throw DeadlyImportError(Formatter::format() << "Ogre Skeleton bone indexes not contiguous. Error at bone index " << bone->id); } - DefaultLogger::get()->debug(Formatter::format() << " " << bone->id << " " << bone->name); + ASSIMP_LOG_DEBUG_F( " ", bone->id, " ", bone->name); skeleton->bones.push_back(bone); } @@ -1053,7 +1053,7 @@ void OgreBinarySerializer::ReadSkeletonAnimation(Skeleton *skeleton) skeleton->animations.push_back(anim); - DefaultLogger::get()->debug(Formatter::format() << " " << anim->name << " (" << anim->length << " sec, " << anim->tracks.size() << " tracks)"); + ASSIMP_LOG_DEBUG_F( " ", anim->name, " (", anim->length, " sec, ", anim->tracks.size(), " tracks)"); } void OgreBinarySerializer::ReadSkeletonAnimationTrack(Skeleton * /*skeleton*/, Animation *dest) diff --git a/code/OgreMaterial.cpp b/code/OgreMaterial.cpp index f0fb515d8..ceca04da1 100644 --- a/code/OgreMaterial.cpp +++ b/code/OgreMaterial.cpp @@ -175,18 +175,18 @@ aiMaterial* OgreImporter::ReadMaterial(const std::string &pFile, Assimp::IOSyste if (materialFile) { break; } - DefaultLogger::get()->debug(Formatter::format() << "Source file for material '" << materialName << "' " << potentialFiles[i] << " does not exist"); + ASSIMP_LOG_DEBUG_F( "Source file for material '", materialName, "' ", potentialFiles[i], " does not exist"); } if (!materialFile) { - DefaultLogger::get()->error(Formatter::format() << "Failed to find source file for material '" << materialName << "'"); + ASSIMP_LOG_ERROR_F( "Failed to find source file for material '", materialName, "'"); return 0; } std::unique_ptr stream(materialFile); if (stream->FileSize() == 0) { - ASSIMP_LOG_WARN(Formatter::format() << "Source file for material '" << materialName << "' is empty (size is 0 bytes)"); + ASSIMP_LOG_WARN_F( "Source file for material '", materialName, "' is empty (size is 0 bytes)"); return 0; } @@ -201,7 +201,7 @@ aiMaterial* OgreImporter::ReadMaterial(const std::string &pFile, Assimp::IOSyste ss << &data[0]; } - DefaultLogger::get()->debug("Reading material '" + materialName + "'"); + ASSIMP_LOG_DEBUG_F("Reading material '", materialName, "'"); aiMaterial *material = new aiMaterial(); m_textures.clear(); @@ -234,7 +234,6 @@ aiMaterial* OgreImporter::ReadMaterial(const std::string &pFile, Assimp::IOSyste ss >> linePart; if (linePart != materialName) { - //DefaultLogger::get()->debug(Formatter::format() << "Found material '" << linePart << "' that does not match at index " << ss.tellg()); ss >> linePart; continue; } @@ -242,11 +241,11 @@ aiMaterial* OgreImporter::ReadMaterial(const std::string &pFile, Assimp::IOSyste NextAfterNewLine(ss, linePart); if (linePart != partBlockStart) { - DefaultLogger::get()->error(Formatter::format() << "Invalid material: block start missing near index " << ss.tellg()); + ASSIMP_LOG_ERROR_F( "Invalid material: block start missing near index ", ss.tellg()); return material; } - DefaultLogger::get()->debug("material '" + materialName + "'"); + ASSIMP_LOG_DEBUG_F("material '", materialName, "'"); while(linePart != partBlockEnd) { @@ -350,11 +349,11 @@ bool OgreImporter::ReadTechnique(const std::string &techniqueName, stringstream if (linePart != partBlockStart) { - DefaultLogger::get()->error(Formatter::format() << "Invalid material: Technique block start missing near index " << ss.tellg()); + ASSIMP_LOG_ERROR_F( "Invalid material: Technique block start missing near index ", ss.tellg()); return false; } - DefaultLogger::get()->debug(" technique '" + techniqueName + "'"); + ASSIMP_LOG_DEBUG_F(" technique '", techniqueName, "'"); const string partPass = "pass"; @@ -386,11 +385,11 @@ bool OgreImporter::ReadPass(const std::string &passName, stringstream &ss, aiMat if (linePart != partBlockStart) { - DefaultLogger::get()->error(Formatter::format() << "Invalid material: Pass block start missing near index " << ss.tellg()); + ASSIMP_LOG_ERROR_F( "Invalid material: Pass block start missing near index ", ss.tellg()); return false; } - DefaultLogger::get()->debug(" pass '" + passName + "'"); + ASSIMP_LOG_DEBUG_F(" pass '", passName, "'"); const string partAmbient = "ambient"; const string partDiffuse = "diffuse"; @@ -417,7 +416,7 @@ bool OgreImporter::ReadPass(const std::string &passName, stringstream &ss, aiMat ss >> r >> g >> b; const aiColor3D color(r, g, b); - DefaultLogger::get()->debug(Formatter::format() << " " << linePart << " " << r << " " << g << " " << b); + ASSIMP_LOG_DEBUG_F( " ", linePart, " ", r, " ", g, " ", b); if (linePart == partAmbient) { @@ -452,11 +451,11 @@ bool OgreImporter::ReadTextureUnit(const std::string &textureUnitName, stringstr if (linePart != partBlockStart) { - DefaultLogger::get()->error(Formatter::format() << "Invalid material: Texture unit block start missing near index " << ss.tellg()); + ASSIMP_LOG_ERROR_F( "Invalid material: Texture unit block start missing near index ", ss.tellg()); return false; } - DefaultLogger::get()->debug(" texture_unit '" + textureUnitName + "'"); + ASSIMP_LOG_DEBUG_F(" texture_unit '", textureUnitName, "'"); const string partTexture = "texture"; const string partTextCoordSet = "tex_coord_set"; @@ -491,7 +490,7 @@ bool OgreImporter::ReadTextureUnit(const std::string &textureUnitName, stringstr if (posSuffix != string::npos && posUnderscore != string::npos && posSuffix > posUnderscore) { string identifier = Ogre::ToLower(textureRef.substr(posUnderscore, posSuffix - posUnderscore)); - DefaultLogger::get()->debug(Formatter::format() << "Detecting texture type from filename postfix '" << identifier << "'"); + ASSIMP_LOG_DEBUG_F( "Detecting texture type from filename postfix '", identifier, "'"); if (identifier == "_n" || identifier == "_nrm" || identifier == "_nrml" || identifier == "_normal" || identifier == "_normals" || identifier == "_normalmap") { @@ -581,8 +580,8 @@ bool OgreImporter::ReadTextureUnit(const std::string &textureUnitName, stringstr unsigned int textureTypeIndex = m_textures[textureType]; m_textures[textureType]++; - DefaultLogger::get()->debug(Formatter::format() << " texture '" << textureRef << "' type " << textureType - << " index " << textureTypeIndex << " UV " << uvCoord); + ASSIMP_LOG_DEBUG_F( " texture '", textureRef, "' type ", textureType, + " index ", textureTypeIndex, " UV ", uvCoord); aiString assimpTextureRef(textureRef); material->AddProperty(&assimpTextureRef, AI_MATKEY_TEXTURE(textureType, textureTypeIndex)); diff --git a/code/OgreXmlSerializer.cpp b/code/OgreXmlSerializer.cpp index 12b2bcbd9..5805a528d 100644 --- a/code/OgreXmlSerializer.cpp +++ b/code/OgreXmlSerializer.cpp @@ -190,7 +190,7 @@ std::string &OgreXmlSerializer::NextNode() CurrentNodeName(true); #if (OGRE_XML_SERIALIZER_DEBUG == 1) - DefaultLogger::get()->debug("<" + m_currentNodeName + ">"); + ASSIMP_LOG_DEBUG"<" + m_currentNodeName + ">"); #endif return m_currentNodeName; } @@ -210,7 +210,7 @@ std::string OgreXmlSerializer::CurrentNodeName(bool forceRead) std::string &OgreXmlSerializer::SkipCurrentNode() { #if (OGRE_XML_SERIALIZER_DEBUG == 1) - DefaultLogger::get()->debug("Skipping node <" + m_currentNodeName + ">"); + ASSIMP_LOG_DEBUG("Skipping node <" + m_currentNodeName + ">"); #endif for(;;) { @@ -317,7 +317,7 @@ void OgreXmlSerializer::ReadMesh(MeshXml *mesh) { throw DeadlyImportError("Root node is <" + m_currentNodeName + "> expecting "); } - DefaultLogger::get()->debug("Reading Mesh"); + ASSIMP_LOG_DEBUG("Reading Mesh"); NextNode(); @@ -351,7 +351,7 @@ void OgreXmlSerializer::ReadMesh(MeshXml *mesh) { else if (m_currentNodeName == nnSkeletonLink) { mesh->skeletonRef = ReadAttribute("name"); - DefaultLogger::get()->debug("Read skeleton link " + mesh->skeletonRef); + ASSIMP_LOG_DEBUG_F("Read skeleton link ", mesh->skeletonRef); NextNode(); } // Assimp incompatible/ignored nodes @@ -363,7 +363,7 @@ void OgreXmlSerializer::ReadMesh(MeshXml *mesh) { void OgreXmlSerializer::ReadGeometry(VertexDataXml *dest) { dest->count = ReadAttribute("vertexcount"); - DefaultLogger::get()->debug(Formatter::format() << " - Reading geometry of " << dest->count << " vertices"); + ASSIMP_LOG_DEBUG_F( " - Reading geometry of ", dest->count, " vertices"); NextNode(); while(m_currentNodeName == nnVertexBuffer) { @@ -385,22 +385,22 @@ void OgreXmlSerializer::ReadGeometryVertexBuffer(VertexDataXml *dest) if (positions) { - DefaultLogger::get()->debug(" - Contains positions"); + ASSIMP_LOG_DEBUG(" - Contains positions"); dest->positions.reserve(dest->count); } if (normals) { - DefaultLogger::get()->debug(" - Contains normals"); + ASSIMP_LOG_DEBUG(" - Contains normals"); dest->normals.reserve(dest->count); } if (tangents) { - DefaultLogger::get()->debug(" - Contains tangents"); + ASSIMP_LOG_DEBUG(" - Contains tangents"); dest->tangents.reserve(dest->count); } if (uvs > 0) { - DefaultLogger::get()->debug(Formatter::format() << " - Contains " << uvs << " texture coords"); + ASSIMP_LOG_DEBUG_F( " - Contains ", uvs, " texture coords"); dest->uvs.resize(uvs); for(size_t i=0, len=dest->uvs.size(); iuvs[i].reserve(dest->count); @@ -508,7 +508,7 @@ void OgreXmlSerializer::ReadGeometryVertexBuffer(VertexDataXml *dest) } } if (warn) { - DefaultLogger::get()->warn("Vertex buffer attribute read not implemented for element: " + m_currentNodeName); + ASSIMP_LOG_WARN_F("Vertex buffer attribute read not implemented for element: ", m_currentNodeName); } } @@ -554,9 +554,9 @@ void OgreXmlSerializer::ReadSubMesh(MeshXml *mesh) submesh->usesSharedVertexData = ReadAttribute(anUseSharedVertices); } - DefaultLogger::get()->debug(Formatter::format() << "Reading SubMesh " << mesh->subMeshes.size()); - DefaultLogger::get()->debug(Formatter::format() << " - Material: '" << submesh->materialRef << "'"); - DefaultLogger::get()->debug(Formatter::format() << " - Uses shared geometry: " << (submesh->usesSharedVertexData ? "true" : "false")); + ASSIMP_LOG_DEBUG_F( "Reading SubMesh ", mesh->subMeshes.size()); + ASSIMP_LOG_DEBUG_F( " - Material: '", submesh->materialRef, "'"); + ASSIMP_LOG_DEBUG_F( " - Uses shared geometry: ", (submesh->usesSharedVertexData ? "true" : "false")); // TODO: maybe we have always just 1 faces and 1 geometry and always in this order. this loop will only work correct, when the order // of faces and geometry changed, and not if we have more than one of one @@ -587,7 +587,7 @@ void OgreXmlSerializer::ReadSubMesh(MeshXml *mesh) /// @todo Support quads if Ogre even supports them in XML (I'm not sure but I doubt it) if (!quadWarned && HasAttribute(anV4)) { - DefaultLogger::get()->warn("Submesh has quads with , only triangles are supported at the moment!"); + ASSIMP_LOG_WARN("Submesh has quads with , only triangles are supported at the moment!"); quadWarned = true; } @@ -597,31 +597,25 @@ void OgreXmlSerializer::ReadSubMesh(MeshXml *mesh) NextNode(); } - if (submesh->indexData->faces.size() == submesh->indexData->faceCount) - { - DefaultLogger::get()->debug(Formatter::format() << " - Faces " << submesh->indexData->faceCount); - } - else - { + if (submesh->indexData->faces.size() == submesh->indexData->faceCount) { + ASSIMP_LOG_DEBUG_F( " - Faces ", submesh->indexData->faceCount); + } else { throw DeadlyImportError(Formatter::format() << "Read only " << submesh->indexData->faces.size() << " faces when should have read " << submesh->indexData->faceCount); } - } - else if (m_currentNodeName == nnGeometry) - { + } else if (m_currentNodeName == nnGeometry) { if (submesh->usesSharedVertexData) { throw DeadlyImportError("Found in when use shared geometry is true. Invalid mesh file."); } submesh->vertexData = new VertexDataXml(); ReadGeometry(submesh->vertexData); - } - else if (m_currentNodeName == nnBoneAssignments) - { + } else if (m_currentNodeName == nnBoneAssignments) { ReadBoneAssignments(submesh->vertexData); } // Assimp incompatible/ignored nodes - else + else { SkipCurrentNode(); + } } submesh->index = static_cast(mesh->subMeshes.size()); @@ -676,7 +670,7 @@ void OgreXmlSerializer::ReadBoneAssignments(VertexDataXml *dest) } } - DefaultLogger::get()->debug(Formatter::format() << " - " << dest->boneAssignments.size() << " bone assignments"); + ASSIMP_LOG_DEBUG_F( " - ", dest->boneAssignments.size(), " bone assignments"); } // Skeleton @@ -731,13 +725,13 @@ XmlReaderPtr OgreXmlSerializer::OpenReader(Assimp::IOSystem *pIOHandler, const s { if (!EndsWith(filename, ".skeleton.xml", false)) { - DefaultLogger::get()->error("Imported Mesh is referencing to unsupported '" + filename + "' skeleton file."); + ASSIMP_LOG_ERROR_F("Imported Mesh is referencing to unsupported '", filename, "' skeleton file."); return XmlReaderPtr(); } if (!pIOHandler->Exists(filename)) { - DefaultLogger::get()->error("Failed to find skeleton file '" + filename + "' that is referenced by imported Mesh."); + ASSIMP_LOG_ERROR_F("Failed to find skeleton file '", filename, "' that is referenced by imported Mesh."); return XmlReaderPtr(); } @@ -760,7 +754,7 @@ void OgreXmlSerializer::ReadSkeleton(Skeleton *skeleton) throw DeadlyImportError("Root node is <" + m_currentNodeName + "> expecting "); } - DefaultLogger::get()->debug("Reading Skeleton"); + ASSIMP_LOG_DEBUG("Reading Skeleton"); // Optional blend mode from root node if (HasAttribute("blendmode")) { @@ -793,7 +787,7 @@ void OgreXmlSerializer::ReadAnimations(Skeleton *skeleton) throw DeadlyImportError("Cannot read for a Skeleton without bones"); } - DefaultLogger::get()->debug(" - Animations"); + ASSIMP_LOG_DEBUG(" - Animations"); NextNode(); while(m_currentNodeName == nnAnimation) @@ -809,7 +803,7 @@ void OgreXmlSerializer::ReadAnimations(Skeleton *skeleton) ReadAnimationTracks(anim); skeleton->animations.push_back(anim); - DefaultLogger::get()->debug(Formatter::format() << " " << anim->name << " (" << anim->length << " sec, " << anim->tracks.size() << " tracks)"); + ASSIMP_LOG_DEBUG_F( " ", anim->name, " (", anim->length, " sec, ", anim->tracks.size(), " tracks)"); } } @@ -867,7 +861,7 @@ void OgreXmlSerializer::ReadAnimationKeyFrames(Animation *anim, VertexAnimationT { axis.x = 1.0f; if (angle != 0) { - DefaultLogger::get()->warn("Found invalid a key frame with a zero rotation axis in animation: " + anim->name); + ASSIMP_LOG_WARN_F("Found invalid a key frame with a zero rotation axis in animation: ", anim->name); } } keyframe.rotation = aiQuaternion(axis, angle); @@ -925,7 +919,7 @@ static bool BoneCompare(Bone *a, Bone *b) void OgreXmlSerializer::ReadBones(Skeleton *skeleton) { - DefaultLogger::get()->debug(" - Bones"); + ASSIMP_LOG_DEBUG(" - Bones"); NextNode(); while(m_currentNodeName == nnBone) @@ -994,7 +988,7 @@ void OgreXmlSerializer::ReadBones(Skeleton *skeleton) for (size_t i=0, len=skeleton->bones.size(); ibones[i]; - DefaultLogger::get()->debug(Formatter::format() << " " << b->id << " " << b->name); + ASSIMP_LOG_DEBUG_F( " ", b->id, " ", b->name); if (b->id != static_cast(i)) { throw DeadlyImportError(Formatter::format() << "Bone ids are not in sequence starting from 0. Missing index " << i); diff --git a/code/OpenGEXImporter.cpp b/code/OpenGEXImporter.cpp index 652ba0f98..9966c1f34 100644 --- a/code/OpenGEXImporter.cpp +++ b/code/OpenGEXImporter.cpp @@ -708,7 +708,7 @@ void OpenGEXImporter::handleMeshNode( ODDLParser::DDLNode *node, aiScene *pScene } else if ( "quads" == propKey ) { m_currentMesh->mPrimitiveTypes |= aiPrimitiveType_POLYGON; } else { - DefaultLogger::get()->warn( propKey + " is not supported primitive type." ); + ASSIMP_LOG_WARN_F( propKey, " is not supported primitive type." ); } } } @@ -1213,12 +1213,11 @@ void OpenGEXImporter::resolveReferences() { if ( nullptr != m_currentMesh ) { unsigned int matIdx = static_cast< unsigned int >( m_material2refMap[ name ] ); if ( m_currentMesh->mMaterialIndex != 0 ) { - DefaultLogger::get()->warn( "Override of material reference in current mesh by material reference." ); + ASSIMP_LOG_WARN( "Override of material reference in current mesh by material reference." ); } m_currentMesh->mMaterialIndex = matIdx; } else { - DefaultLogger::get()->warn( "Cannot resolve material reference, because no current mesh is there." ); - + ASSIMP_LOG_WARN( "Cannot resolve material reference, because no current mesh is there." ); } } } diff --git a/code/OptimizeGraph.cpp b/code/OptimizeGraph.cpp index 7835c3f01..59a764d5c 100644 --- a/code/OptimizeGraph.cpp +++ b/code/OptimizeGraph.cpp @@ -242,7 +242,7 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode* nd, std::list& no // ------------------------------------------------------------------------------------------------ // Execute the post-processing step on the given scene void OptimizeGraphProcess::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("OptimizeGraphProcess begin"); + ASSIMP_LOG_DEBUG("OptimizeGraphProcess begin"); nodes_in = nodes_out = count_merged = 0; mScene = pScene; @@ -329,12 +329,10 @@ void OptimizeGraphProcess::Execute( aiScene* pScene) { pScene->mRootNode->mParent = NULL; if (!DefaultLogger::isNullLogger()) { if ( nodes_in != nodes_out) { - - char buf[512]; - ::ai_snprintf(buf,512,"OptimizeGraphProcess finished; Input nodes: %u, Output nodes: %u",nodes_in,nodes_out); - DefaultLogger::get()->info(buf); + ASSIMP_LOG_INFO_F("OptimizeGraphProcess finished; Input nodes: ", nodes_in, ", Output nodes: ", nodes_out); + } else { + ASSIMP_LOG_DEBUG("OptimizeGraphProcess finished"); } - else DefaultLogger::get()->debug("OptimizeGraphProcess finished"); } meshes.clear(); locked.clear(); diff --git a/code/OptimizeMeshes.cpp b/code/OptimizeMeshes.cpp index f586cc316..25575b049 100644 --- a/code/OptimizeMeshes.cpp +++ b/code/OptimizeMeshes.cpp @@ -107,11 +107,11 @@ void OptimizeMeshesProcess::Execute( aiScene* pScene) { const unsigned int num_old = pScene->mNumMeshes; if (num_old <= 1) { - DefaultLogger::get()->debug("Skipping OptimizeMeshesProcess"); + ASSIMP_LOG_DEBUG("Skipping OptimizeMeshesProcess"); return; } - DefaultLogger::get()->debug("OptimizeMeshesProcess begin"); + ASSIMP_LOG_DEBUG("OptimizeMeshesProcess begin"); mScene = pScene; // need to clear persistent members from previous runs @@ -151,11 +151,9 @@ void OptimizeMeshesProcess::Execute( aiScene* pScene) std::copy(output.begin(),output.end(),mScene->mMeshes); if (output.size() != num_old) { - char tmp[512]; - ::ai_snprintf(tmp,512,"OptimizeMeshesProcess finished. Input meshes: %u, Output meshes: %u",num_old,pScene->mNumMeshes); - DefaultLogger::get()->info(tmp); + ASSIMP_LOG_DEBUG_F("OptimizeMeshesProcess finished. Input meshes: ", num_old, ", Output meshes: ", pScene->mNumMeshes); } else { - DefaultLogger::get()->debug( "OptimizeMeshesProcess finished" ); + ASSIMP_LOG_DEBUG( "OptimizeMeshesProcess finished" ); } } diff --git a/code/PlyParser.cpp b/code/PlyParser.cpp index b6bd60f9f..b51b6ac71 100644 --- a/code/PlyParser.cpp +++ b/code/PlyParser.cpp @@ -97,7 +97,7 @@ PLY::EDataType PLY::Property::ParseDataType(std::vector &buffer) { } if (PLY::EDT_INVALID == eOut) { - DefaultLogger::get()->info("Found unknown data type in PLY file. This is OK"); + ASSIMP_LOG_INFO("Found unknown data type in PLY file. This is OK"); } return eOut; @@ -229,7 +229,7 @@ PLY::ESemantic PLY::Property::ParseSemantic(std::vector &buffer) { eOut = PLY::EST_ZNormal; } else { - DefaultLogger::get()->info("Found unknown property semantic in file. This is ok"); + ASSIMP_LOG_INFO("Found unknown property semantic in file. This is ok"); PLY::DOM::SkipLine(buffer); } return eOut; @@ -295,7 +295,7 @@ bool PLY::Property::ParseProperty(std::vector &buffer, PLY::Property* pOut if (PLY::EST_INVALID == pOut->Semantic) { - DefaultLogger::get()->info("Found unknown semantic in PLY file. This is OK"); + ASSIMP_LOG_INFO("Found unknown semantic in PLY file. This is OK"); std::string(&buffer[0], &buffer[0] + strlen(&buffer[0])); } @@ -514,7 +514,7 @@ bool PLY::DOM::SkipComments(std::vector &buffer) // ------------------------------------------------------------------------------------------------ bool PLY::DOM::ParseHeader(IOStreamBuffer &streamBuffer, std::vector &buffer, bool isBinary) { - DefaultLogger::get()->debug("PLY::DOM::ParseHeader() begin"); + ASSIMP_LOG_DEBUG("PLY::DOM::ParseHeader() begin"); // parse all elements while (!buffer.empty()) @@ -543,14 +543,14 @@ bool PLY::DOM::ParseHeader(IOStreamBuffer &streamBuffer, std::vector if (!isBinary) // it would occur an error, if binary data start with values as space or line end. SkipSpacesAndLineEnd(buffer); - DefaultLogger::get()->debug("PLY::DOM::ParseHeader() succeeded"); + ASSIMP_LOG_DEBUG("PLY::DOM::ParseHeader() succeeded"); return true; } // ------------------------------------------------------------------------------------------------ bool PLY::DOM::ParseElementInstanceLists(IOStreamBuffer &streamBuffer, std::vector &buffer, PLYImporter* loader) { - DefaultLogger::get()->debug("PLY::DOM::ParseElementInstanceLists() begin"); + ASSIMP_LOG_DEBUG("PLY::DOM::ParseElementInstanceLists() begin"); alElementData.resize(alElements.size()); std::vector::const_iterator i = alElements.begin(); @@ -571,7 +571,7 @@ bool PLY::DOM::ParseElementInstanceLists(IOStreamBuffer &streamBuffer, std } } - DefaultLogger::get()->debug("PLY::DOM::ParseElementInstanceLists() succeeded"); + ASSIMP_LOG_DEBUG("PLY::DOM::ParseElementInstanceLists() succeeded"); return true; } @@ -582,7 +582,7 @@ bool PLY::DOM::ParseElementInstanceListsBinary(IOStreamBuffer &streamBuffe PLYImporter* loader, bool p_bBE) { - DefaultLogger::get()->debug("PLY::DOM::ParseElementInstanceListsBinary() begin"); + ASSIMP_LOG_DEBUG("PLY::DOM::ParseElementInstanceListsBinary() begin"); alElementData.resize(alElements.size()); std::vector::const_iterator i = alElements.begin(); @@ -602,7 +602,7 @@ bool PLY::DOM::ParseElementInstanceListsBinary(IOStreamBuffer &streamBuffe } } - DefaultLogger::get()->debug("PLY::DOM::ParseElementInstanceListsBinary() succeeded"); + ASSIMP_LOG_DEBUG("PLY::DOM::ParseElementInstanceListsBinary() succeeded"); return true; } @@ -615,11 +615,11 @@ bool PLY::DOM::ParseInstanceBinary(IOStreamBuffer &streamBuffer, DOM* p_pc std::vector buffer; streamBuffer.getNextLine(buffer); - DefaultLogger::get()->debug("PLY::DOM::ParseInstanceBinary() begin"); + ASSIMP_LOG_DEBUG("PLY::DOM::ParseInstanceBinary() begin"); if (!p_pcOut->ParseHeader(streamBuffer, buffer, true)) { - DefaultLogger::get()->debug("PLY::DOM::ParseInstanceBinary() failure"); + ASSIMP_LOG_DEBUG("PLY::DOM::ParseInstanceBinary() failure"); return false; } @@ -628,10 +628,10 @@ bool PLY::DOM::ParseInstanceBinary(IOStreamBuffer &streamBuffer, DOM* p_pc const char* pCur = (char*)&buffer[0]; if (!p_pcOut->ParseElementInstanceListsBinary(streamBuffer, buffer, pCur, bufferSize, loader, p_bBE)) { - DefaultLogger::get()->debug("PLY::DOM::ParseInstanceBinary() failure"); + ASSIMP_LOG_DEBUG("PLY::DOM::ParseInstanceBinary() failure"); return false; } - DefaultLogger::get()->debug("PLY::DOM::ParseInstanceBinary() succeeded"); + ASSIMP_LOG_DEBUG("PLY::DOM::ParseInstanceBinary() succeeded"); return true; } @@ -644,11 +644,11 @@ bool PLY::DOM::ParseInstance(IOStreamBuffer &streamBuffer, DOM* p_pcOut, P std::vector buffer; streamBuffer.getNextLine(buffer); - DefaultLogger::get()->debug("PLY::DOM::ParseInstance() begin"); + ASSIMP_LOG_DEBUG("PLY::DOM::ParseInstance() begin"); if (!p_pcOut->ParseHeader(streamBuffer, buffer, false)) { - DefaultLogger::get()->debug("PLY::DOM::ParseInstance() failure"); + ASSIMP_LOG_DEBUG("PLY::DOM::ParseInstance() failure"); return false; } @@ -656,10 +656,10 @@ bool PLY::DOM::ParseInstance(IOStreamBuffer &streamBuffer, DOM* p_pcOut, P streamBuffer.getNextLine(buffer); if (!p_pcOut->ParseElementInstanceLists(streamBuffer, buffer, loader)) { - DefaultLogger::get()->debug("PLY::DOM::ParseInstance() failure"); + ASSIMP_LOG_DEBUG("PLY::DOM::ParseInstance() failure"); return false; } - DefaultLogger::get()->debug("PLY::DOM::ParseInstance() succeeded"); + ASSIMP_LOG_DEBUG("PLY::DOM::ParseInstance() succeeded"); return true; } diff --git a/code/PretransformVertices.cpp b/code/PretransformVertices.cpp index cc5c669e4..0623f00ef 100644 --- a/code/PretransformVertices.cpp +++ b/code/PretransformVertices.cpp @@ -391,7 +391,7 @@ void PretransformVertices::BuildWCSMeshes(std::vector& out, aiMesh** in } if (node->mMeshes[i] < numIn) { // Worst case. Need to operate on a full copy of the mesh - DefaultLogger::get()->info("PretransformVertices: Copying mesh due to mismatching transforms"); + ASSIMP_LOG_INFO("PretransformVertices: Copying mesh due to mismatching transforms"); aiMesh* ntz; const unsigned int tmp = mesh->mNumBones; // @@ -441,7 +441,7 @@ void PretransformVertices::BuildMeshRefCountArray(aiNode* nd, unsigned int * ref // Executes the post processing step on the given imported data. void PretransformVertices::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("PretransformVerticesProcess begin"); + ASSIMP_LOG_DEBUG("PretransformVerticesProcess begin"); // Return immediately if we have no meshes if (!pScene->mNumMeshes) @@ -713,22 +713,12 @@ void PretransformVertices::Execute( aiScene* pScene) } // print statistics - if (!DefaultLogger::isNullLogger()) - { - char buffer[4096]; + if (!DefaultLogger::isNullLogger()) { + ASSIMP_LOG_DEBUG("PretransformVerticesProcess finished"); - DefaultLogger::get()->debug("PretransformVerticesProcess finished"); - - ::ai_snprintf(buffer,4096,"Removed %u nodes and %u animation channels (%u output nodes)", - iOldNodes,iOldAnimationChannels,CountNodes(pScene->mRootNode)); - DefaultLogger::get()->info(buffer); - - ai_snprintf(buffer, 4096,"Kept %u lights and %u cameras", - pScene->mNumLights,pScene->mNumCameras); - DefaultLogger::get()->info(buffer); - - ai_snprintf(buffer, 4096,"Moved %u meshes to WCS (number of output meshes: %u)", - iOldMeshes,pScene->mNumMeshes); - DefaultLogger::get()->info(buffer); + ASSIMP_LOG_INFO_F("Removed ", iOldNodes, " nodes and ", iOldAnimationChannels, " animation channels (", + CountNodes(pScene->mRootNode) ," output nodes)" ); + ASSIMP_LOG_INFO_F("Kept ", pScene->mNumLights, " lights and ", pScene->mNumCameras, " cameras." ); + ASSIMP_LOG_INFO_F("Moved ", iOldMeshes, " meshes to WCS (number of output meshes: ", pScene->mNumMeshes, ")"); } } diff --git a/code/ProcessHelper.cpp b/code/ProcessHelper.cpp index d6f8cd165..7f3e4ba72 100644 --- a/code/ProcessHelper.cpp +++ b/code/ProcessHelper.cpp @@ -62,7 +62,7 @@ void ConvertListToStrings(const std::string& in, std::list& out) while (*s != '\'') { ++s; if (*s == '\0') { - DefaultLogger::get()->error("ConvertListToString: String list is ill-formatted"); + ASSIMP_LOG_ERROR("ConvertListToString: String list is ill-formatted"); return; } } diff --git a/code/ProcessHelper.h b/code/ProcessHelper.h index 5ef3707e8..c668b946f 100644 --- a/code/ProcessHelper.h +++ b/code/ProcessHelper.h @@ -348,7 +348,7 @@ class ComputeSpatialSortProcess : public BaseProcess void Execute( aiScene* pScene) { typedef std::pair _Type; - DefaultLogger::get()->debug("Generate spatially-sorted vertex cache"); + ASSIMP_LOG_DEBUG("Generate spatially-sorted vertex cache"); std::vector<_Type>* p = new std::vector<_Type>(pScene->mNumMeshes); std::vector<_Type>::iterator it = p->begin(); diff --git a/code/Q3DLoader.cpp b/code/Q3DLoader.cpp index ebb80d537..f1165dc2c 100644 --- a/code/Q3DLoader.cpp +++ b/code/Q3DLoader.cpp @@ -125,7 +125,7 @@ void Q3DImporter::InternReadFile( const std::string& pFile, } // Print the file format version - DefaultLogger::get()->info("Quick3D File format version: " + + ASSIMP_LOG_INFO_F("Quick3D File format version: ", std::string(&((const char*)stream.GetPtr())[8],2)); // ... an store it @@ -413,7 +413,7 @@ outer: // If we have no materials loaded - generate a default mat if (materials.empty()) { - DefaultLogger::get()->info("Quick3D: No material found, generating one"); + ASSIMP_LOG_INFO("Quick3D: No material found, generating one"); materials.push_back(Material()); materials.back().diffuse = fgColor ; } diff --git a/code/RawLoader.cpp b/code/RawLoader.cpp index 0c149a1f6..1bc508759 100644 --- a/code/RawLoader.cpp +++ b/code/RawLoader.cpp @@ -160,7 +160,7 @@ void RAWImporter::InternReadFile( const std::string& pFile, } if (num != 12 && num != 9) { - DefaultLogger::get()->error("A line may have either 9 or 12 floats and an optional texture"); + ASSIMP_LOG_ERROR("A line may have either 9 or 12 floats and an optional texture"); continue; } diff --git a/code/RemoveRedundantMaterials.cpp b/code/RemoveRedundantMaterials.cpp index 683fb7fdd..7194d3c8e 100644 --- a/code/RemoveRedundantMaterials.cpp +++ b/code/RemoveRedundantMaterials.cpp @@ -87,7 +87,7 @@ void RemoveRedundantMatsProcess::SetupProperties(const Importer* pImp) // Executes the post processing step on the given imported data. void RemoveRedundantMatsProcess::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("RemoveRedundantMatsProcess begin"); + ASSIMP_LOG_DEBUG("RemoveRedundantMatsProcess begin"); unsigned int redundantRemoved = 0, unreferencedRemoved = 0; if (pScene->mNumMaterials) @@ -122,7 +122,7 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene) // Keep this material even if no mesh references it abReferenced[i] = true; - DefaultLogger::get()->debug(std::string("Found positive match in exclusion list: \'") + name.data + "\'"); + ASSIMP_LOG_DEBUG_F( "Found positive match in exclusion list: \'", name.data, "\'"); } } } @@ -211,13 +211,11 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene) } if (redundantRemoved == 0 && unreferencedRemoved == 0) { - DefaultLogger::get()->debug("RemoveRedundantMatsProcess finished "); + ASSIMP_LOG_DEBUG("RemoveRedundantMatsProcess finished "); } else { - char szBuffer[128]; // should be sufficiently large - ::ai_snprintf(szBuffer,128,"RemoveRedundantMatsProcess finished. Removed %u redundant and %u unused materials.", - redundantRemoved,unreferencedRemoved); - DefaultLogger::get()->info(szBuffer); + ASSIMP_LOG_INFO_F("RemoveRedundantMatsProcess finished. Removed ", redundantRemoved, " redundant and ", + unreferencedRemoved, " unused materials."); } } diff --git a/code/RemoveVCProcess.cpp b/code/RemoveVCProcess.cpp index ddb0023cc..81249eab2 100644 --- a/code/RemoveVCProcess.cpp +++ b/code/RemoveVCProcess.cpp @@ -145,7 +145,7 @@ bool UpdateNodeGraph(aiNode* node,std::list& childsOfParent,bool root) // Executes the post processing step on the given imported data. void RemoveVCProcess::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("RemoveVCProcess begin"); + ASSIMP_LOG_DEBUG("RemoveVCProcess begin"); bool bHas = false; //,bMasked = false; mScene = pScene; @@ -224,15 +224,18 @@ void RemoveVCProcess::Execute( aiScene* pScene) if (!pScene->mNumMeshes || !pScene->mNumMaterials) { pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE; - DefaultLogger::get()->debug("Setting AI_SCENE_FLAGS_INCOMPLETE flag"); + ASSIMP_LOG_DEBUG("Setting AI_SCENE_FLAGS_INCOMPLETE flag"); // If we have no meshes anymore we should also clear another flag ... if (!pScene->mNumMeshes) pScene->mFlags &= ~AI_SCENE_FLAGS_NON_VERBOSE_FORMAT; } - if (bHas)DefaultLogger::get()->info("RemoveVCProcess finished. Data structure cleanup has been done."); - else DefaultLogger::get()->debug("RemoveVCProcess finished. Nothing to be done ..."); + if (bHas) { + ASSIMP_LOG_INFO("RemoveVCProcess finished. Data structure cleanup has been done."); + } else { + ASSIMP_LOG_DEBUG("RemoveVCProcess finished. Nothing to be done ..."); + } } // ------------------------------------------------------------------------------------------------ diff --git a/code/SIBImporter.cpp b/code/SIBImporter.cpp index 5c8c717b5..7a69dd175 100644 --- a/code/SIBImporter.cpp +++ b/code/SIBImporter.cpp @@ -150,7 +150,7 @@ static SIBChunk ReadChunk(StreamReaderLE* stream) chunk.Tag = stream->GetU4(); chunk.Size = stream->GetU4(); if (chunk.Size > stream->GetRemainingSizeToLimit()) - DefaultLogger::get()->error("SIB: Chunk overflow"); + ASSIMP_LOG_ERROR("SIB: Chunk overflow"); ByteSwap::Swap4(&chunk.Tag); return chunk; } @@ -589,7 +589,7 @@ static void ReadShape(SIB* sib, StreamReaderLE* stream) if (mtl >= meshes.size()) { - DefaultLogger::get()->error("SIB: Face material index is invalid."); + ASSIMP_LOG_ERROR("SIB: Face material index is invalid."); mtl = 0; } diff --git a/code/SMDLoader.cpp b/code/SMDLoader.cpp index 4f9ed5c1c..dc6706934 100644 --- a/code/SMDLoader.cpp +++ b/code/SMDLoader.cpp @@ -286,7 +286,7 @@ void SMDImporter::CreateOutputMeshes() if (UINT_MAX == (*iFace).iTexture)aaiFaces[(*iFace).iTexture].push_back( 0 ); else if ((*iFace).iTexture >= aszTextures.size()) { - DefaultLogger::get()->error("[SMD/VTA] Material index overflow in face"); + ASSIMP_LOG_INFO("[SMD/VTA] Material index overflow in face"); aaiFaces[(*iFace).iTexture].push_back((unsigned int)aszTextures.size()-1); } else aaiFaces[(*iFace).iTexture].push_back(iNum); @@ -366,7 +366,7 @@ void SMDImporter::CreateOutputMeshes() if (pairval.first >= asBones.size() || pairval.first == face.avVertices[iVert].iParentNode) { - DefaultLogger::get()->error("[SMD/VTA] Bone index overflow. " + ASSIMP_LOG_ERROR("[SMD/VTA] Bone index overflow. " "The bone index will be ignored, the weight will be assigned " "to the vertex' parent node"); continue; @@ -387,7 +387,7 @@ void SMDImporter::CreateOutputMeshes() { if (face.avVertices[iVert].iParentNode >= asBones.size()) { - DefaultLogger::get()->error("[SMD/VTA] Bone index overflow. " + ASSIMP_LOG_ERROR("[SMD/VTA] Bone index overflow. " "The index of the vertex parent bone is invalid. " "The remaining weights will be normalized to 1.0"); @@ -953,7 +953,7 @@ void SMDImporter::ParseSkeletonElement(const char* szCurrent, unsigned int iBone = 0; if(!ParseUnsignedInt(szCurrent,&szCurrent,iBone)) { - DefaultLogger::get()->error("Unexpected EOF/EOL while parsing bone index"); + ASSIMP_LOG_ERROR("Unexpected EOF/EOL while parsing bone index"); SMDI_PARSE_RETURN; } if (iBone >= asBones.size()) diff --git a/code/STEPFile.h b/code/STEPFile.h index d789faac2..492150658 100644 --- a/code/STEPFile.h +++ b/code/STEPFile.h @@ -776,10 +776,10 @@ namespace STEP { // XXX is this really how the EXPRESS notation ([?:3],[1:3]) is intended? if (max_cnt && inp->GetSize() > max_cnt) { - DefaultLogger::get()->warn("too many aggregate elements"); + ASSIMP_LOG_WARN("too many aggregate elements"); } else if (inp->GetSize() < min_cnt) { - DefaultLogger::get()->warn("too few aggregate elements"); + ASSIMP_LOG_WARN("too few aggregate elements"); } out.reserve(inp->GetSize()); diff --git a/code/STLLoader.cpp b/code/STLLoader.cpp index 3a85a5495..46808503d 100644 --- a/code/STLLoader.cpp +++ b/code/STLLoader.cpp @@ -286,14 +286,14 @@ void STLImporter::LoadASCIIFile( aiNode *root ) { if(!SkipSpacesAndLineEnd(&sz)) { // seems we're finished although there was no end marker - DefaultLogger::get()->warn("STL: unexpected EOF. \'endsolid\' keyword was expected"); + ASSIMP_LOG_WARN("STL: unexpected EOF. \'endsolid\' keyword was expected"); break; } // facet normal -0.13 -0.13 -0.98 if (!strncmp(sz,"facet",5) && IsSpaceOrNewLine(*(sz+5)) && *(sz + 5) != '\0') { if (faceVertexCounter != 3) { - DefaultLogger::get()->warn("STL: A new facet begins but the old is not yet complete"); + ASSIMP_LOG_WARN("STL: A new facet begins but the old is not yet complete"); } faceVertexCounter = 0; normalBuffer.push_back(aiVector3D()); @@ -302,7 +302,7 @@ void STLImporter::LoadASCIIFile( aiNode *root ) { sz += 6; SkipSpaces(&sz); if (strncmp(sz,"normal",6)) { - DefaultLogger::get()->warn("STL: a facet normal vector was expected but not found"); + ASSIMP_LOG_WARN("STL: a facet normal vector was expected but not found"); } else { if (sz[6] == '\0') { throw DeadlyImportError("STL: unexpected EOF while parsing facet"); @@ -319,7 +319,7 @@ void STLImporter::LoadASCIIFile( aiNode *root ) { } } else if (!strncmp(sz,"vertex",6) && ::IsSpaceOrNewLine(*(sz+6))) { // vertex 1.50000 1.50000 0.00000 if (faceVertexCounter >= 3) { - DefaultLogger::get()->error("STL: a facet with more than 3 vertices has been found"); + ASSIMP_LOG_ERROR("STL: a facet with more than 3 vertices has been found"); ++sz; } else { if (sz[6] == '\0') { @@ -418,7 +418,7 @@ bool STLImporter::LoadBinaryFile() // read the default vertex color for facets bIsMaterialise = true; - DefaultLogger::get()->info("STL: Taking code path for Materialise files"); + ASSIMP_LOG_INFO("STL: Taking code path for Materialise files"); const ai_real invByte = (ai_real)1.0 / ( ai_real )255.0; clrColorDefault.r = (*sz2++) * invByte; clrColorDefault.g = (*sz2++) * invByte; @@ -500,7 +500,7 @@ bool STLImporter::LoadBinaryFile() *pMesh->mColors[0]++ = this->clrColorDefault; pMesh->mColors[0] -= pMesh->mNumVertices; - DefaultLogger::get()->info("STL: Mesh has vertex colors"); + ASSIMP_LOG_INFO("STL: Mesh has vertex colors"); } aiColor4D* clr = &pMesh->mColors[0][i*3]; clr->a = 1.0; diff --git a/code/SortByPTypeProcess.cpp b/code/SortByPTypeProcess.cpp index 8d6be695d..ee18585e2 100644 --- a/code/SortByPTypeProcess.cpp +++ b/code/SortByPTypeProcess.cpp @@ -137,11 +137,11 @@ void SortByPTypeProcess::Execute( aiScene* pScene) { if (!pScene->mNumMeshes) { - DefaultLogger::get()->debug("SortByPTypeProcess skipped, there are no meshes"); + ASSIMP_LOG_DEBUG("SortByPTypeProcess skipped, there are no meshes"); return; } - DefaultLogger::get()->debug("SortByPTypeProcess begin"); + ASSIMP_LOG_DEBUG("SortByPTypeProcess begin"); unsigned int aiNumMeshesPerPType[4] = {0,0,0,0}; @@ -404,8 +404,8 @@ void SortByPTypeProcess::Execute( aiScene* pScene) 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"); + ASSIMP_LOG_INFO(buffer); + ASSIMP_LOG_DEBUG("SortByPTypeProcess finished"); } } diff --git a/code/SplitLargeMeshes.cpp b/code/SplitLargeMeshes.cpp index f24ddd205..28b655fa4 100644 --- a/code/SplitLargeMeshes.cpp +++ b/code/SplitLargeMeshes.cpp @@ -78,7 +78,7 @@ void SplitLargeMeshesProcess_Triangle::Execute( aiScene* pScene) { if (0xffffffff == this->LIMIT)return; - DefaultLogger::get()->debug("SplitLargeMeshesProcess_Triangle begin"); + ASSIMP_LOG_DEBUG("SplitLargeMeshesProcess_Triangle begin"); std::vector > avList; for( unsigned int a = 0; a < pScene->mNumMeshes; a++) @@ -96,10 +96,11 @@ void SplitLargeMeshesProcess_Triangle::Execute( aiScene* pScene) // now we need to update all nodes this->UpdateNode(pScene->mRootNode,avList); - DefaultLogger::get()->info("SplitLargeMeshesProcess_Triangle finished. Meshes have been split"); + ASSIMP_LOG_INFO("SplitLargeMeshesProcess_Triangle finished. Meshes have been split"); + } + else { + ASSIMP_LOG_DEBUG("SplitLargeMeshesProcess_Triangle finished. There was nothing to do"); } - else DefaultLogger::get()->debug("SplitLargeMeshesProcess_Triangle finished. There was nothing to do"); - return; } // ------------------------------------------------------------------------------------------------ @@ -154,7 +155,7 @@ void SplitLargeMeshesProcess_Triangle::SplitMesh( { if (pMesh->mNumFaces > SplitLargeMeshesProcess_Triangle::LIMIT) { - DefaultLogger::get()->info("Mesh exceeds the triangle limit. It will be split ..."); + ASSIMP_LOG_INFO("Mesh exceeds the triangle limit. It will be split ..."); // we need to split this mesh into sub meshes // determine the size of a submesh @@ -378,7 +379,7 @@ void SplitLargeMeshesProcess_Vertex::Execute( aiScene* pScene) if (0xffffffff == this->LIMIT)return; - DefaultLogger::get()->debug("SplitLargeMeshesProcess_Vertex begin"); + ASSIMP_LOG_DEBUG("SplitLargeMeshesProcess_Vertex begin"); for( unsigned int a = 0; a < pScene->mNumMeshes; a++) this->SplitMesh(a, pScene->mMeshes[a],avList); @@ -394,10 +395,10 @@ void SplitLargeMeshesProcess_Vertex::Execute( aiScene* pScene) // now we need to update all nodes SplitLargeMeshesProcess_Triangle::UpdateNode(pScene->mRootNode,avList); - DefaultLogger::get()->info("SplitLargeMeshesProcess_Vertex finished. Meshes have been split"); + ASSIMP_LOG_INFO("SplitLargeMeshesProcess_Vertex finished. Meshes have been split"); + } else { + ASSIMP_LOG_DEBUG("SplitLargeMeshesProcess_Vertex finished. There was nothing to do"); } - else DefaultLogger::get()->debug("SplitLargeMeshesProcess_Vertex finished. There was nothing to do"); - return; } // ------------------------------------------------------------------------------------------------ diff --git a/code/Subdivision.cpp b/code/Subdivision.cpp index ced560764..2f2f09596 100644 --- a/code/Subdivision.cpp +++ b/code/Subdivision.cpp @@ -342,11 +342,8 @@ void CatmullClarkSubdivider::InternSubdivide ( // Report the number of bad edges. bad edges are referenced by less than two // faces in the mesh. They occur at outer model boundaries in non-closed // shapes. - char tmp[512]; - ai_snprintf(tmp, 512, "Catmull-Clark Subdivider: got %u bad edges touching only one face (totally %u edges). ", - bad_cnt,static_cast(edges.size())); - - DASSIMP_LOG_DEBUG(tmp); + ASSIMP_LOG_DEBUG_F("Catmull-Clark Subdivider: got ", bad_cnt, " bad edges touching only one face (totally ", + static_cast(edges.size()), " edges). "); }} // --------------------------------------------------------------------- diff --git a/code/TerragenLoader.cpp b/code/TerragenLoader.cpp index 0f5f4cb9d..0eb22cef6 100644 --- a/code/TerragenLoader.cpp +++ b/code/TerragenLoader.cpp @@ -192,7 +192,7 @@ void TerragenImporter::InternReadFile( const std::string& pFile, { mode = reader.GetI1(); if (0 != mode) - DefaultLogger::get()->error("TER: Unsupported mapping mode, a flat terrain is returned"); + ASSIMP_LOG_ERROR("TER: Unsupported mapping mode, a flat terrain is returned"); } // actual terrain data else if (!::strncmp(head,AI_TERR_CHUNK_ALTW,4)) diff --git a/code/TextureTransform.cpp b/code/TextureTransform.cpp index 62bbadd08..a21835b13 100644 --- a/code/TextureTransform.cpp +++ b/code/TextureTransform.cpp @@ -105,12 +105,10 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info) if (info.mRotation) { float out = info.mRotation; - if ((rounded = (int)(info.mRotation / (float)AI_MATH_TWO_PI))) + if ((rounded = static_cast((info.mRotation / static_cast(AI_MATH_TWO_PI))))) { - out -= rounded*(float)AI_MATH_PI; - - ai_snprintf(szTemp, 512, "Texture coordinate rotation %f can be simplified to %f",info.mRotation,out); - DefaultLogger::get()->info(szTemp); + out -= rounded * static_cast(AI_MATH_PI); + ASSIMP_LOG_INFO_F("Texture coordinate rotation ", info.mRotation, " can be simplified to ", out); } // Next step - convert negative rotation angles to positives @@ -150,7 +148,7 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info) out = 1.f; } if (szTemp[0]) { - DefaultLogger::get()->info(szTemp); + ASSIMP_LOG_INFO(szTemp); info.mTranslation.x = out; } } @@ -183,7 +181,7 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info) out = 1.f; } if (szTemp[0]) { - DefaultLogger::get()->info(szTemp); + ASSIMP_LOG_INFO(szTemp); info.mTranslation.y = out; } } @@ -221,7 +219,7 @@ inline const char* MappingModeToChar(aiTextureMapMode map) // ------------------------------------------------------------------------------------------------ void TextureTransformStep::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("TransformUVCoordsProcess begin"); + ASSIMP_LOG_DEBUG("TransformUVCoordsProcess begin"); /* We build a per-mesh list of texture transformations we'll need @@ -416,7 +414,7 @@ void TextureTransformStep::Execute( aiScene* pScene) ++it2; if ((*it2).lockedPos != AI_TT_UV_IDX_LOCK_NONE) { - DefaultLogger::get()->error("Channel mismatch, can't compute all transformations properly [design bug]"); + ASSIMP_LOG_ERROR("Channel mismatch, can't compute all transformations properly [design bug]"); continue; } @@ -449,10 +447,8 @@ void TextureTransformStep::Execute( aiScene* pScene) if (size > AI_MAX_NUMBER_OF_TEXTURECOORDS) { if (!DefaultLogger::isNullLogger()) { - ::ai_snprintf(buffer,1024,"%u UV channels required but just %u available", - static_cast(trafo.size()),AI_MAX_NUMBER_OF_TEXTURECOORDS); - - DefaultLogger::get()->error(buffer); + ASSIMP_LOG_ERROR_F(static_cast(trafo.size()), " UV channels required but just ", + AI_MAX_NUMBER_OF_TEXTURECOORDS, " available"); } size = AI_MAX_NUMBER_OF_TEXTURECOORDS; } @@ -487,7 +483,7 @@ void TextureTransformStep::Execute( aiScene* pScene) MappingModeToChar ((*it).mapU), MappingModeToChar ((*it).mapV)); - DefaultLogger::get()->info(buffer); + ASSIMP_LOG_INFO(buffer); } // Check whether we need a new buffer here @@ -560,12 +556,10 @@ void TextureTransformStep::Execute( aiScene* pScene) if (!DefaultLogger::isNullLogger()) { if (transformedChannels) { - ::ai_snprintf(buffer,1024,"TransformUVCoordsProcess end: %u output channels (in: %u, modified: %u)", - outChannels,inChannels,transformedChannels); - - DefaultLogger::get()->info(buffer); + ASSIMP_LOG_INFO_F("TransformUVCoordsProcess end: ", outChannels, " output channels (in: ", inChannels, ", modified: ", transformedChannels,")"); + } else { + ASSIMP_LOG_DEBUG("TransformUVCoordsProcess finished"); } - else DefaultLogger::get()->debug("TransformUVCoordsProcess finished"); } } diff --git a/code/TriangulateProcess.cpp b/code/TriangulateProcess.cpp index 25d92c470..cc8b05c47 100644 --- a/code/TriangulateProcess.cpp +++ b/code/TriangulateProcess.cpp @@ -100,7 +100,7 @@ bool TriangulateProcess::IsActive( unsigned int pFlags) const // Executes the post processing step on the given imported data. void TriangulateProcess::Execute( aiScene* pScene) { - DefaultLogger::get()->debug("TriangulateProcess begin"); + ASSIMP_LOG_DEBUG("TriangulateProcess begin"); bool bHas = false; for( unsigned int a = 0; a < pScene->mNumMeshes; a++) @@ -110,13 +110,12 @@ void TriangulateProcess::Execute( aiScene* pScene) } } if ( bHas ) { - DefaultLogger::get()->info( "TriangulateProcess finished. All polygons have been triangulated." ); + ASSIMP_LOG_INFO( "TriangulateProcess finished. All polygons have been triangulated." ); } else { - DefaultLogger::get()->debug( "TriangulateProcess finished. There was nothing to be done." ); + ASSIMP_LOG_DEBUG( "TriangulateProcess finished. There was nothing to be done." ); } } - // ------------------------------------------------------------------------------------------------ // Triangulates the given mesh. bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) @@ -410,7 +409,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) // Instead we're continuing with the standard tri-fanning algorithm which we'd // use if we had only convex polygons. That's life. - DefaultLogger::get()->error("Failed to triangulate polygon (no ear found). Probably not a simple polygon?"); + ASSIMP_LOG_ERROR("Failed to triangulate polygon (no ear found). Probably not a simple polygon?"); #ifdef AI_BUILD_TRIANGULATE_DEBUG_POLYS fprintf(fout,"critical error here, no ear found! "); @@ -488,7 +487,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) // drop dumb 0-area triangles if (std::fabs(GetArea2D(temp_verts[i[0]],temp_verts[i[1]],temp_verts[i[2]])) < 1e-5f) { - DefaultLogger::get()->debug("Dropping triangle with area 0"); + ASSIMP_LOG_DEBUG("Dropping triangle with area 0"); --curOut; delete[] f->mIndices; diff --git a/code/ValidateDataStructure.cpp b/code/ValidateDataStructure.cpp index 20b348763..51e04b96b 100644 --- a/code/ValidateDataStructure.cpp +++ b/code/ValidateDataStructure.cpp @@ -206,7 +206,7 @@ inline void ValidateDSProcess::DoValidationWithNameCheck(T** array, void ValidateDSProcess::Execute( aiScene* pScene) { this->mScene = pScene; - DefaultLogger::get()->debug("ValidateDataStructureProcess begin"); + ASSIMP_LOG_DEBUG("ValidateDataStructureProcess begin"); // validate the node graph of the scene Validate(pScene->mRootNode); @@ -273,7 +273,7 @@ void ValidateDSProcess::Execute( aiScene* pScene) } // if (!has)ReportError("The aiScene data structure is empty"); - DefaultLogger::get()->debug("ValidateDataStructureProcess end"); + ASSIMP_LOG_DEBUG("ValidateDataStructureProcess end"); } // ------------------------------------------------------------------------------------------------ diff --git a/code/XFileImporter.cpp b/code/XFileImporter.cpp index fd28fbb79..94b38e303 100644 --- a/code/XFileImporter.cpp +++ b/code/XFileImporter.cpp @@ -587,7 +587,7 @@ void XFileImporter::ConvertMaterials( aiScene* pScene, std::vectorwarn( format() << "Could not resolve global material reference \"" << oldMat.mName << "\"" ); + ASSIMP_LOG_WARN_F( "Could not resolve global material reference \"", oldMat.mName, "\"" ); oldMat.sceneIndex = 0; } diff --git a/code/XFileParser.cpp b/code/XFileParser.cpp index 4dd2c990b..0988edaff 100644 --- a/code/XFileParser.cpp +++ b/code/XFileParser.cpp @@ -255,7 +255,7 @@ XFileParser::XFileParser( const std::vector& pBuffer) // FIXME: we don't need the compressed data anymore, could release // it already for better memory usage. Consider breaking const-co. - DefaultLogger::get()->info("Successfully decompressed MSZIP-compressed file"); + ASSIMP_LOG_INFO("Successfully decompressed MSZIP-compressed file"); #endif // !! ASSIMP_BUILD_NO_COMPRESSED_X } else @@ -322,11 +322,11 @@ void XFileParser::ParseFile() if( objectName == "}") { // whatever? - DefaultLogger::get()->warn("} found in dataObject"); + ASSIMP_LOG_WARN("} found in dataObject"); } else { // unknown format - DefaultLogger::get()->warn("Unknown data object in animation of .x file"); + ASSIMP_LOG_WARN("Unknown data object in animation of .x file"); ParseUnknownDataObject(); } } @@ -422,7 +422,7 @@ void XFileParser::ParseDataObjectFrame( Node* pParent) ParseDataObjectMesh( mesh); } else { - DefaultLogger::get()->warn("Unknown data object in frame in x file"); + ASSIMP_LOG_WARN("Unknown data object in frame in x file"); ParseUnknownDataObject(); } } @@ -509,7 +509,7 @@ void XFileParser::ParseDataObjectMesh( Mesh* pMesh) ParseDataObjectSkinWeights( pMesh); else { - DefaultLogger::get()->warn("Unknown data object in mesh in x file"); + ASSIMP_LOG_WARN("Unknown data object in mesh in x file"); ParseUnknownDataObject(); } } @@ -719,7 +719,7 @@ void XFileParser::ParseDataObjectMeshMaterialList( Mesh* pMesh) // ignore } else { - DefaultLogger::get()->warn("Unknown data object in material list in x file"); + ASSIMP_LOG_WARN("Unknown data object in material list in x file"); ParseUnknownDataObject(); } } @@ -767,7 +767,7 @@ void XFileParser::ParseDataObjectMaterial( Material* pMaterial) pMaterial->mTextures.push_back( TexEntry( texname, true)); } else { - DefaultLogger::get()->warn("Unknown data object in material in x file"); + ASSIMP_LOG_WARN("Unknown data object in material in x file"); ParseUnknownDataObject(); } } @@ -805,7 +805,7 @@ void XFileParser::ParseDataObjectAnimationSet() ParseDataObjectAnimation( anim); else { - DefaultLogger::get()->warn("Unknown data object in animation set in x file"); + ASSIMP_LOG_WARN("Unknown data object in animation set in x file"); ParseUnknownDataObject(); } } @@ -842,7 +842,7 @@ void XFileParser::ParseDataObjectAnimation( Animation* pAnim) CheckForClosingBrace(); } else { - DefaultLogger::get()->warn("Unknown data object in animation in x file"); + ASSIMP_LOG_WARN("Unknown data object in animation in x file"); ParseUnknownDataObject(); } } @@ -950,7 +950,7 @@ void XFileParser::ParseDataObjectTextureFilename( std::string& pName) // FIX: some files (e.g. AnimationTest.x) have "" as texture file name if (!pName.length()) { - DefaultLogger::get()->warn("Length of texture file name is zero. Skipping this texture."); + ASSIMP_LOG_WARN("Length of texture file name is zero. Skipping this texture."); } // some exporters write double backslash paths out. We simply replace them if we find them diff --git a/include/assimp/LogAux.h b/include/assimp/LogAux.h index b8aa2e2d2..cf6d50014 100644 --- a/include/assimp/LogAux.h +++ b/include/assimp/LogAux.h @@ -64,28 +64,28 @@ public: // ------------------------------------------------------------------------------------------------ static void LogWarn(const Formatter::format& message) { if (!DefaultLogger::isNullLogger()) { - DefaultLogger::get()->warn(Prefix()+(std::string)message); + ASSIMP_LOG_WARN(Prefix()+(std::string)message); } } // ------------------------------------------------------------------------------------------------ static void LogError(const Formatter::format& message) { if (!DefaultLogger::isNullLogger()) { - DefaultLogger::get()->error(Prefix()+(std::string)message); + ASSIMP_LOG_ERROR(Prefix()+(std::string)message); } } // ------------------------------------------------------------------------------------------------ static void LogInfo(const Formatter::format& message) { if (!DefaultLogger::isNullLogger()) { - DefaultLogger::get()->info(Prefix()+(std::string)message); + ASSIMP_LOG_INFO(Prefix()+(std::string)message); } } // ------------------------------------------------------------------------------------------------ static void LogDebug(const Formatter::format& message) { if (!DefaultLogger::isNullLogger()) { - DefaultLogger::get()->debug(Prefix()+(std::string)message); + ASSIMP_LOG_DEBUG(Prefix()+(std::string)message); } } @@ -126,6 +126,6 @@ private: static const char* Prefix(); }; - } // ! Assimp + #endif From 3d79472172c9e4bacbfdb0a54fb2b034bc552247 Mon Sep 17 00:00:00 2001 From: kimkulling Date: Thu, 26 Apr 2018 14:36:59 +0200 Subject: [PATCH 05/11] fix the build. --- code/BaseImporter.cpp | 2 +- code/DefaultIOSystem.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/BaseImporter.cpp b/code/BaseImporter.cpp index fa9f70603..78979d078 100644 --- a/code/BaseImporter.cpp +++ b/code/BaseImporter.cpp @@ -595,7 +595,7 @@ void BatchLoader::LoadAll() if (!DefaultLogger::isNullLogger()) { ASSIMP_LOG_INFO("%%% BEGIN EXTERNAL FILE %%%"); - ASSIMP_LOG_INFO("File: ", (*it).file); + ASSIMP_LOG_INFO_F("File: ", (*it).file); } m_data->pImporter->ReadFile((*it).file,pp); (*it).scene = m_data->pImporter->GetOrphanedScene(); diff --git a/code/DefaultIOSystem.cpp b/code/DefaultIOSystem.cpp index ec0de6e3a..3afaf69e0 100644 --- a/code/DefaultIOSystem.cpp +++ b/code/DefaultIOSystem.cpp @@ -189,7 +189,7 @@ inline static void MakeAbsolutePath (const char* in, char* _out) if(!ret) { // preserve the input path, maybe someone else is able to fix // the path before it is accessed (e.g. our file system filter) - ASSIMP_LOG_WARN("Invalid path: ", std::string(in)); + ASSIMP_LOG_WARN_F("Invalid path: ", std::string(in)); strcpy(_out,in); } #endif From 75c7b15b5541cc5c2c94b32c249d083d0a335a1b Mon Sep 17 00:00:00 2001 From: kimkulling Date: Thu, 26 Apr 2018 15:05:49 +0200 Subject: [PATCH 06/11] Fix c++11 usage. --- code/MDLMaterialLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/MDLMaterialLoader.cpp b/code/MDLMaterialLoader.cpp index e80d3b560..2c21b188b 100644 --- a/code/MDLMaterialLoader.cpp +++ b/code/MDLMaterialLoader.cpp @@ -75,7 +75,7 @@ void MDLImporter::SearchPalette(const unsigned char** pszColorMap) { if (pcStream->FileSize() >= 768) { - constexpr size_t len = 256 * 3; + size_t len = 256 * 3; unsigned char* colorMap = new unsigned char[len]; szColorMap = colorMap; pcStream->Read(colorMap, len,1); From a5e14db19b0bfbaa59bd7ad6ded65ab7acb3dd8d Mon Sep 17 00:00:00 2001 From: kimkulling Date: Thu, 26 Apr 2018 15:41:31 +0200 Subject: [PATCH 07/11] fix invaid macro usage. --- code/DXFLoader.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/code/DXFLoader.cpp b/code/DXFLoader.cpp index 7d8b6eca2..c77d13a7e 100644 --- a/code/DXFLoader.cpp +++ b/code/DXFLoader.cpp @@ -373,7 +373,7 @@ void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& bloc // first check if the referenced blocks exists ... const DXF::BlockMap::const_iterator it = blocks_by_name.find(insert.name); if (it == blocks_by_name.end()) { - ASSIMP_LOG_ERROR("DXF: Failed to resolve block reference: ", insert.name,"; skipping" ); + ASSIMP_LOG_ERROR_F("DXF: Failed to resolve block reference: ", insert.name,"; skipping" ); continue; } @@ -406,7 +406,6 @@ void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& bloc } } - // ------------------------------------------------------------------------------------------------ void DXFImporter::GenerateMaterials(aiScene* pScene, DXF::FileData& /*output*/) { @@ -433,7 +432,6 @@ void DXFImporter::GenerateMaterials(aiScene* pScene, DXF::FileData& /*output*/) pScene->mMaterials[0] = pcMat; } - // ------------------------------------------------------------------------------------------------ void DXFImporter::GenerateHierarchy(aiScene* pScene, DXF::FileData& /*output*/) { @@ -444,9 +442,7 @@ void DXFImporter::GenerateHierarchy(aiScene* pScene, DXF::FileData& /*output*/) if (1 == pScene->mNumMeshes) { pScene->mRootNode->mMeshes = new unsigned int[ pScene->mRootNode->mNumMeshes = 1 ]; pScene->mRootNode->mMeshes[0] = 0; - } - else - { + } else { pScene->mRootNode->mChildren = new aiNode*[ pScene->mRootNode->mNumChildren = pScene->mNumMeshes ]; for (unsigned int m = 0; m < pScene->mRootNode->mNumChildren;++m) { aiNode* p = pScene->mRootNode->mChildren[m] = new aiNode(); From c299755721f06d93d6305b6ad10514b362ed1a0c Mon Sep 17 00:00:00 2001 From: kimkulling Date: Thu, 26 Apr 2018 16:13:57 +0200 Subject: [PATCH 08/11] DXF: fix macro issues. --- code/DXFLoader.cpp | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/code/DXFLoader.cpp b/code/DXFLoader.cpp index c77d13a7e..90270bbd7 100644 --- a/code/DXFLoader.cpp +++ b/code/DXFLoader.cpp @@ -241,7 +241,7 @@ void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output) } } - ASSIMP_LOG_DEBUG("DXF: Unexpanded polycount is ", icount, ", vertex count is ", vcount); + ASSIMP_LOG_DEBUG_F("DXF: Unexpanded polycount is ", icount, ", vertex count is ", vcount); } if (! output.blocks.size() ) { @@ -457,22 +457,17 @@ void DXFImporter::GenerateHierarchy(aiScene* pScene, DXF::FileData& /*output*/) // ------------------------------------------------------------------------------------------------ -void DXFImporter::SkipSection(DXF::LineReader& reader) -{ +void DXFImporter::SkipSection(DXF::LineReader& reader) { for( ;!reader.End() && !reader.Is(0,"ENDSEC"); reader++); } - // ------------------------------------------------------------------------------------------------ -void DXFImporter::ParseHeader(DXF::LineReader& reader, DXF::FileData& /*output*/) -{ +void DXFImporter::ParseHeader(DXF::LineReader& reader, DXF::FileData& ) { for( ;!reader.End() && !reader.Is(0,"ENDSEC"); reader++); } - // ------------------------------------------------------------------------------------------------ -void DXFImporter::ParseBlocks(DXF::LineReader& reader, DXF::FileData& output) -{ +void DXFImporter::ParseBlocks(DXF::LineReader& reader, DXF::FileData& output) { while( !reader.End() && !reader.Is(0,"ENDSEC")) { if (reader.Is(0,"BLOCK")) { ParseBlock(++reader,output); @@ -481,15 +476,11 @@ void DXFImporter::ParseBlocks(DXF::LineReader& reader, DXF::FileData& output) ++reader; } - ASSIMP_LOG_DEBUG((Formatter::format("DXF: got "), - output.blocks.size()," entries in BLOCKS" - )); + ASSIMP_LOG_DEBUG_F("DXF: got ", output.blocks.size()," entries in BLOCKS" ); } - // ------------------------------------------------------------------------------------------------ -void DXFImporter::ParseBlock(DXF::LineReader& reader, DXF::FileData& output) -{ +void DXFImporter::ParseBlock(DXF::LineReader& reader, DXF::FileData& output) { // push a new block onto the stack. output.blocks.push_back( DXF::Block() ); DXF::Block& block = output.blocks.back(); @@ -533,7 +524,6 @@ void DXFImporter::ParseBlock(DXF::LineReader& reader, DXF::FileData& output) } } - // ------------------------------------------------------------------------------------------------ void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output) { @@ -563,19 +553,16 @@ void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output) ++reader; } - ASSIMP_LOG_DEBUG((Formatter::format("DXF: got "), - block.lines.size()," polylines and ", block.insertions.size() ," inserted blocks in ENTITIES" - )); + ASSIMP_LOG_DEBUG_F( "DXF: got ", block.lines.size()," polylines and ", block.insertions.size(), + " inserted blocks in ENTITIES" ); } - void DXFImporter::ParseInsertion(DXF::LineReader& reader, DXF::FileData& output) { output.blocks.back().insertions.push_back( DXF::InsertBlock() ); DXF::InsertBlock& bl = output.blocks.back().insertions.back(); while( !reader.End() && !reader.Is(0)) { - switch(reader.GroupCode()) { // name of referenced block @@ -620,8 +607,7 @@ void DXFImporter::ParseInsertion(DXF::LineReader& reader, DXF::FileData& output) #define DXF_POLYLINE_FLAG_POLYFACEMESH 0x40 // ------------------------------------------------------------------------------------------------ -void DXFImporter::ParsePolyLine(DXF::LineReader& reader, DXF::FileData& output) -{ +void DXFImporter::ParsePolyLine(DXF::LineReader& reader, DXF::FileData& output) { output.blocks.back().lines.push_back( std::shared_ptr( new DXF::PolyLine() ) ); DXF::PolyLine& line = *output.blocks.back().lines.back(); @@ -788,8 +774,7 @@ void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& li } line.indices.push_back(indices[i]-1); } - } - else { + } else { line.positions.push_back(out); line.colors.push_back(clr); } @@ -915,4 +900,3 @@ void DXFImporter::Parse3DFace(DXF::LineReader& reader, DXF::FileData& output) } #endif // !! ASSIMP_BUILD_NO_DXF_IMPORTER - From 8626b185fbe38a8a539addf90cbb3a8b1b9d4c16 Mon Sep 17 00:00:00 2001 From: kimkulling Date: Thu, 26 Apr 2018 16:38:42 +0200 Subject: [PATCH 09/11] Fix misused log macros + compiler warnings. --- code/ColladaLoader.cpp | 30 +++++++++++++++--------------- code/DefaultIOSystem.cpp | 2 +- code/FBXExporter.cpp | 8 ++++---- code/MD3Loader.cpp | 2 +- tools/assimp_view/assimp_view.rc | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index a26df1898..45dd52710 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -472,7 +472,7 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll if( !srcMesh) { - ASSIMP_LOG_WARN( "Collada: Unable to find geometry for ID \"", mid.mMeshOrController, "\". Skipping." ); + ASSIMP_LOG_WARN_F( "Collada: Unable to find geometry for ID \"", mid.mMeshOrController, "\". Skipping." ); continue; } } else @@ -875,7 +875,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada:: if( bnode) bone->mName.Set( FindNameForNode( bnode)); else - ASSIMP_LOG_WARN( "ColladaLoader::CreateMesh(): could not find corresponding node for joint \"", bone->mName.data, "\"." ); + ASSIMP_LOG_WARN_F( "ColladaLoader::CreateMesh(): could not find corresponding node for joint \"", bone->mName.data, "\"." ); // and insert bone dstMesh->mBones[boneCount++] = bone; @@ -1176,9 +1176,8 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars else if( subElement == "Z") entry.mSubElement = 2; else - ASSIMP_LOG_WARN( "Unknown anim subelement <", subElement, ">. Ignoring" ); - } else - { + ASSIMP_LOG_WARN_F( "Unknown anim subelement <", subElement, ">. Ignoring" ); + } else { // no subelement following, transformId is remaining string entry.mTransformId = srcChannel.mTarget.substr( slashPos+1); } @@ -1658,9 +1657,10 @@ void ColladaLoader::FillMaterials( const ColladaParser& pParser, aiScene* /*pSce } // add textures, if given - if( !effect.mTexAmbient.mName.empty()) - /* It is merely a lightmap */ - AddTexture( mat, pParser, effect, effect.mTexAmbient, aiTextureType_LIGHTMAP); + if (!effect.mTexAmbient.mName.empty()) { + // It is merely a light-map + AddTexture(mat, pParser, effect, effect.mTexAmbient, aiTextureType_LIGHTMAP); + } if( !effect.mTexEmissive.mName.empty()) AddTexture( mat, pParser, effect, effect.mTexEmissive, aiTextureType_EMISSIVE); @@ -1688,8 +1688,8 @@ void ColladaLoader::BuildMaterials( ColladaParser& pParser, aiScene* /*pScene*/) { newMats.reserve(pParser.mMaterialLibrary.size()); - for( ColladaParser::MaterialLibrary::const_iterator matIt = pParser.mMaterialLibrary.begin(); matIt != pParser.mMaterialLibrary.end(); ++matIt) - { + for( ColladaParser::MaterialLibrary::const_iterator matIt = pParser.mMaterialLibrary.begin(); + matIt != pParser.mMaterialLibrary.end(); ++matIt) { const Collada::Material& material = matIt->second; // a material is only a reference to an effect ColladaParser::EffectLibrary::iterator effIt = pParser.mEffectLibrary.find( material.mEffect); @@ -1808,7 +1808,7 @@ void ColladaLoader::ConvertPath (aiString& ss) { // TODO: collada spec, p 22. Handle URI correctly. // For the moment we're just stripping the file:// away to make it work. - // Windoes doesn't seem to be able to find stuff like + // Windows doesn't seem to be able to find stuff like // 'file://..\LWO\LWO2\MappingModes\earthSpherical.jpg' if (0 == strncmp(ss.data,"file://",7)) { @@ -1822,7 +1822,7 @@ void ColladaLoader::ConvertPath (aiString& ss) if( ss.data[0] == '/' && isalpha( ss.data[1]) && ss.data[2] == ':' ) { ss.length--; - memmove( ss.data, ss.data+1, ss.length); + ::memmove( ss.data, ss.data+1, ss.length); ss.data[ss.length] = 0; } @@ -1872,9 +1872,9 @@ const std::string& ColladaLoader::ReadString( const Collada::Accessor& pAccessor void ColladaLoader::CollectNodes( const aiNode* pNode, std::vector& poNodes) const { poNodes.push_back( pNode); - - for( size_t a = 0; a < pNode->mNumChildren; ++a) - CollectNodes( pNode->mChildren[a], poNodes); + for (size_t a = 0; a < pNode->mNumChildren; ++a) { + CollectNodes(pNode->mChildren[a], poNodes); + } } // ------------------------------------------------------------------------------------------------ diff --git a/code/DefaultIOSystem.cpp b/code/DefaultIOSystem.cpp index 3afaf69e0..fee9c3e7f 100644 --- a/code/DefaultIOSystem.cpp +++ b/code/DefaultIOSystem.cpp @@ -179,7 +179,7 @@ inline static void MakeAbsolutePath (const char* in, char* _out) if (!ret) { // preserve the input path, maybe someone else is able to fix // the path before it is accessed (e.g. our file system filter) - ASSIMP_LOG_WARN("Invalid path: ", std::string(in)); + ASSIMP_LOG_WARN_F("Invalid path: ", std::string(in)); strcpy(_out, in); } } diff --git a/code/FBXExporter.cpp b/code/FBXExporter.cpp index 4945ec5dc..52c69161a 100644 --- a/code/FBXExporter.cpp +++ b/code/FBXExporter.cpp @@ -71,7 +71,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // https://code.blender.org/2013/08/fbx-binary-file-format-specification/ // https://wiki.blender.org/index.php/User:Mont29/Foundation/FBX_File_Structure -const double DEG = 57.29577951308232087679815481; // degrees per radian +const ai_real DEG = ai_real( 57.29577951308232087679815481 ); // degrees per radian // some constants that we'll use for writing metadata namespace FBX { @@ -980,9 +980,9 @@ aiMatrix4x4 get_world_transform(const aiNode* node, const aiScene* scene) int64_t to_ktime(double ticks, const aiAnimation* anim) { if (anim->mTicksPerSecond <= 0) { - return ticks * FBX::SECOND; + return static_cast(ticks) * FBX::SECOND; } - return (ticks / anim->mTicksPerSecond) * FBX::SECOND; + return (static_cast(ticks) / static_cast(anim->mTicksPerSecond)) * FBX::SECOND; } void FBXExporter::WriteObjects () @@ -2440,7 +2440,7 @@ void FBXExporter::WriteAnimationCurve( // TODO: keyattr flags and data (STUB for now) n.AddChild("KeyAttrFlags", std::vector{0}); n.AddChild("KeyAttrDataFloat", std::vector{0,0,0,0}); - ai_assert(times.size() <= std::numeric_limits::max()); + ai_assert(static_cast(times.size()) <= std::numeric_limits::max()); n.AddChild( "KeyAttrRefCount", std::vector{static_cast(times.size())} diff --git a/code/MD3Loader.cpp b/code/MD3Loader.cpp index 4e0b24acb..d12f2d5fd 100644 --- a/code/MD3Loader.cpp +++ b/code/MD3Loader.cpp @@ -1037,7 +1037,7 @@ void MD3Importer::InternReadFile( const std::string& pFile, if (!DefaultLogger::isNullLogger()) { for (std::list< Q3Shader::SkinData::TextureEntry>::const_iterator it = skins.textures.begin();it != skins.textures.end(); ++it) { if (!(*it).resolved) { - ASSIMP_LOG_ERROR("MD3: Failed to match skin ", (*it).first, " to surface ", (*it).second); + ASSIMP_LOG_ERROR_F("MD3: Failed to match skin ", (*it).first, " to surface ", (*it).second); } } } diff --git a/tools/assimp_view/assimp_view.rc b/tools/assimp_view/assimp_view.rc index aebb1e2d9..093b860fc 100644 --- a/tools/assimp_view/assimp_view.rc +++ b/tools/assimp_view/assimp_view.rc @@ -189,7 +189,7 @@ BEGIN LTEXT "Angle limit (in degrees):",IDC_STATIC,13,10,76,8 LTEXT "The angle limit defines the maximum angle that may be between two adjacent face normals that they're smoothed together.",IDC_STATIC,13,31,253,19 CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,113,278,1 - LTEXT "This setting is also used during import, but it can be overridden by single model importers to match the original look of a model as closely as possible. Examples include 3DS, ASE and LWO, all of them relying on smoothing groups and their own angle limits. ",IDC_STATIC,13,51,254,33 + LTEXT "Also used during import, but can be overridden by single model importers to match the original look of a model as close as possible. Examples includes 3DS, ASE and LWO, all of them relying on smoothing groups and their own angle limits. ",IDC_STATIC,13,51,254,33 LTEXT "NOTE: New settings don't take effect immediately, use 'Smooth Normals' or 'Reload' to update the model.",IDC_STATIC,14,118,254,22 CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,90,277,1 END From 6a311210e77aa285079463f72d9dfca726a70c11 Mon Sep 17 00:00:00 2001 From: kimkulling Date: Thu, 26 Apr 2018 17:01:22 +0200 Subject: [PATCH 10/11] fix another bug of misusage of the log macros. --- code/COBLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/COBLoader.cpp b/code/COBLoader.cpp index 1d4ee2464..d6692f7d2 100644 --- a/code/COBLoader.cpp +++ b/code/COBLoader.cpp @@ -837,7 +837,7 @@ void COBImporter::ReadBitM_Ascii(Scene& /*out*/, LineSplitter& splitter, const C const unsigned int head = strtoul10((++splitter)[1]); if (head != sizeof(Bitmap::BitmapHeader)) { - ASSIMP_LOG_WARN_F("Unexpected ThumbNailHdrSize, skipping this chunk"); + ASSIMP_LOG_WARN("Unexpected ThumbNailHdrSize, skipping this chunk"); return; } From b877b3e10ea5533496b82ff0db7ef42255b05714 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 26 Apr 2018 22:01:41 +0200 Subject: [PATCH 11/11] use correct log macro. --- code/COBLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/COBLoader.cpp b/code/COBLoader.cpp index d6692f7d2..a9784fbec 100644 --- a/code/COBLoader.cpp +++ b/code/COBLoader.cpp @@ -777,7 +777,7 @@ void COBImporter::ReadPolH_Ascii(Scene& out, LineSplitter& splitter, const Chunk for(unsigned int cur = 0; cur < cnt && ++splitter ;++cur) { if (splitter.match_start("Hole")) { - ASSIMP_LOG_WARN_F( "Skipping unsupported `Hole` line" ); + ASSIMP_LOG_WARN( "Skipping unsupported `Hole` line" ); continue; }