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; }