From 856547be238fded2396eaf82e7c7d9502836bb22 Mon Sep 17 00:00:00 2001 From: Garux Date: Mon, 5 Apr 2021 17:06:49 +0300 Subject: [PATCH 1/9] Fix Q1 MDL group frame loading, e.g. Q1 progs/flame2.mdl --- code/AssetLib/MDL/MDLFileData.h | 4 +++- code/AssetLib/MDL/MDLLoader.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/MDL/MDLFileData.h b/code/AssetLib/MDL/MDLFileData.h index bbb6f7728..872cee7f8 100644 --- a/code/AssetLib/MDL/MDLFileData.h +++ b/code/AssetLib/MDL/MDLFileData.h @@ -696,6 +696,8 @@ struct GroupFrame //! 0 = simple frame, !0 = group frame int32_t type; + int32_t numframes; + //! Minimum vertex for all single frames Vertex min; @@ -703,7 +705,7 @@ struct GroupFrame Vertex max; //! Time for all single frames - float *time; + float time; // float[numframes] //! List of single frames SimpleFrame *frames; diff --git a/code/AssetLib/MDL/MDLLoader.cpp b/code/AssetLib/MDL/MDLLoader.cpp index a4286a716..b5010a37f 100644 --- a/code/AssetLib/MDL/MDLLoader.cpp +++ b/code/AssetLib/MDL/MDLLoader.cpp @@ -428,7 +428,7 @@ void MDLImporter::InternReadFile_Quake1() { } else { // get the first frame in the group BE_NCONST MDL::GroupFrame *pcFrames2 = (BE_NCONST MDL::GroupFrame *)pcFrames; - pcFirstFrame = &(pcFrames2->frames[0]); + pcFirstFrame = (MDL::SimpleFrame *)( &pcFrames2->time + pcFrames2->numframes ); } BE_NCONST MDL::Vertex *pcVertices = (BE_NCONST MDL::Vertex *)((pcFirstFrame->name) + sizeof(pcFirstFrame->name)); VALIDATE_FILE_SIZE((const unsigned char *)(pcVertices + pcHeader->num_verts)); From c776924adf904cc1cb6cd4121394cb5d538a2c13 Mon Sep 17 00:00:00 2001 From: Garux Date: Sun, 30 May 2021 11:45:50 +0300 Subject: [PATCH 2/9] fix -Waddress-of-packed-member --- code/AssetLib/MDL/MDLFileData.h | 4 ++-- code/AssetLib/MDL/MDLLoader.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/code/AssetLib/MDL/MDLFileData.h b/code/AssetLib/MDL/MDLFileData.h index 872cee7f8..473a06989 100644 --- a/code/AssetLib/MDL/MDLFileData.h +++ b/code/AssetLib/MDL/MDLFileData.h @@ -704,8 +704,8 @@ struct GroupFrame //! Maximum vertex for all single frames Vertex max; - //! Time for all single frames - float time; // float[numframes] + //! List of times for all single frames + float *times; //! List of single frames SimpleFrame *frames; diff --git a/code/AssetLib/MDL/MDLLoader.cpp b/code/AssetLib/MDL/MDLLoader.cpp index b5010a37f..0f84111af 100644 --- a/code/AssetLib/MDL/MDLLoader.cpp +++ b/code/AssetLib/MDL/MDLLoader.cpp @@ -427,8 +427,9 @@ void MDLImporter::InternReadFile_Quake1() { pcFirstFrame = (MDL::SimpleFrame *)&pcFrames->frame; } else { // get the first frame in the group - BE_NCONST MDL::GroupFrame *pcFrames2 = (BE_NCONST MDL::GroupFrame *)pcFrames; - pcFirstFrame = (MDL::SimpleFrame *)( &pcFrames2->time + pcFrames2->numframes ); + BE_NCONST MDL::GroupFrame *pcFrames2 = (BE_NCONST MDL::GroupFrame *)szCurrent; + pcFirstFrame = (MDL::SimpleFrame *)( szCurrent + sizeof(MDL::GroupFrame::type) + sizeof(MDL::GroupFrame::numframes) + + sizeof(MDL::GroupFrame::min) + sizeof(MDL::GroupFrame::max) + sizeof(*MDL::GroupFrame::times) * pcFrames2->numframes ); } BE_NCONST MDL::Vertex *pcVertices = (BE_NCONST MDL::Vertex *)((pcFirstFrame->name) + sizeof(pcFirstFrame->name)); VALIDATE_FILE_SIZE((const unsigned char *)(pcVertices + pcHeader->num_verts)); From 93edbe883f0e89cdd207d18f85ccaa0544ae1c6d Mon Sep 17 00:00:00 2001 From: Hill Ma Date: Fri, 10 Sep 2021 11:00:21 -0700 Subject: [PATCH 3/9] Use Safe Constants Idioms for ObjFileParser::DEFAULT_MATERIAL. Reference: "A static Class Member" in https://abseil.io/tips/140 --- code/AssetLib/Obj/ObjFileParser.cpp | 3 +-- code/AssetLib/Obj/ObjFileParser.h | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code/AssetLib/Obj/ObjFileParser.cpp b/code/AssetLib/Obj/ObjFileParser.cpp index 767805c10..2e998a815 100644 --- a/code/AssetLib/Obj/ObjFileParser.cpp +++ b/code/AssetLib/Obj/ObjFileParser.cpp @@ -47,7 +47,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #include #include #include @@ -56,7 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { -const std::string ObjFileParser::DEFAULT_MATERIAL = AI_DEFAULT_MATERIAL_NAME; +constexpr char ObjFileParser::DEFAULT_MATERIAL[]; ObjFileParser::ObjFileParser() : m_DataIt(), diff --git a/code/AssetLib/Obj/ObjFileParser.h b/code/AssetLib/Obj/ObjFileParser.h index 5d7ce065a..05a3b8046 100644 --- a/code/AssetLib/Obj/ObjFileParser.h +++ b/code/AssetLib/Obj/ObjFileParser.h @@ -42,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define OBJ_FILEPARSER_H_INC #include +#include #include #include #include @@ -141,7 +142,7 @@ private: // because the class contains pointer to allocated memory /// Default material name - static const std::string DEFAULT_MATERIAL; + static constexpr char DEFAULT_MATERIAL[] = AI_DEFAULT_MATERIAL_NAME; //! Iterator to current position in buffer DataArrayIt m_DataIt; //! Iterator to end position of buffer From 5895c0c22cc88763c016de821d2da2da7f4fd5dd Mon Sep 17 00:00:00 2001 From: Krishty Date: Sat, 11 Sep 2021 23:23:05 +0200 Subject: [PATCH 4/9] more const in format detection BaseImporter::SearchFileHeaderForToken() expected a pointer to a non-const token list. This was probably an oversight, as nobody would realistically expect the function to change the list. Furthermore, it prevented token lists from being compiled to read-only memory, in some cases even causing the compiler to generate thread-safe initialization. The list is now const and all callers declare their token lists static const, thus compiling them to read-only memory. --- code/AssetLib/AMF/AMFImporter.cpp | 2 +- code/AssetLib/ASE/ASELoader.cpp | 2 +- code/AssetLib/BVH/BVHLoader.cpp | 2 +- code/AssetLib/Blender/BlenderLoader.cpp | 4 ++-- code/AssetLib/COB/COBLoader.cpp | 2 +- code/AssetLib/CSM/CSMLoader.cpp | 2 +- code/AssetLib/Collada/ColladaLoader.cpp | 2 +- code/AssetLib/DXF/DXFLoader.cpp | 4 ++-- code/AssetLib/FBX/FBXImporter.cpp | 2 +- code/AssetLib/IFC/IFCLoader.cpp | 5 ++--- code/AssetLib/Irr/IRRLoader.cpp | 2 +- code/AssetLib/Irr/IRRMeshLoader.cpp | 2 +- code/AssetLib/MD5/MD5Loader.cpp | 2 +- code/AssetLib/MMD/MMDImporter.cpp | 4 ++-- code/AssetLib/MS3D/MS3DLoader.cpp | 2 +- code/AssetLib/NDO/NDOLoader.cpp | 2 +- code/AssetLib/OFF/OFFLoader.cpp | 2 +- code/AssetLib/Ogre/OgreImporter.cpp | 2 +- code/AssetLib/OpenGEX/OpenGEXImporter.cpp | 4 ++-- code/AssetLib/Ply/PlyLoader.cpp | 2 +- code/AssetLib/Q3D/Q3DLoader.cpp | 2 +- code/AssetLib/STL/STLLoader.cpp | 2 +- code/AssetLib/Terragen/TerragenLoader.cpp | 2 +- code/AssetLib/XGL/XGLLoader.cpp | 2 +- code/Common/BaseImporter.cpp | 2 +- include/assimp/BaseImporter.h | 2 +- 26 files changed, 31 insertions(+), 32 deletions(-) diff --git a/code/AssetLib/AMF/AMFImporter.cpp b/code/AssetLib/AMF/AMFImporter.cpp index 88a38b827..9a9ab94ca 100644 --- a/code/AssetLib/AMF/AMFImporter.cpp +++ b/code/AssetLib/AMF/AMFImporter.cpp @@ -511,7 +511,7 @@ bool AMFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool p } if (extension.empty() || pCheckSig) { - const char *tokens[] = { "" }; + static const char * const tokens[] = { "" }; return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1); } else { /// @todo Read and validate first header chunk? diff --git a/code/AssetLib/OpenGEX/OpenGEXImporter.cpp b/code/AssetLib/OpenGEX/OpenGEXImporter.cpp index 05507944e..0f224ea28 100644 --- a/code/AssetLib/OpenGEX/OpenGEXImporter.cpp +++ b/code/AssetLib/OpenGEX/OpenGEXImporter.cpp @@ -299,8 +299,8 @@ bool OpenGEXImporter::CanRead(const std::string &file, IOSystem *pIOHandler, boo if (!checkSig) { canRead = SimpleExtensionCheck(file, "ogex"); } else { - static const char *token[] = { "Metric", "GeometryNode", "VertexArray (attrib", "IndexArray" }; - canRead = BaseImporter::SearchFileHeaderForToken(pIOHandler, file, token, 4); + static const char * const token[] = { "Metric", "GeometryNode", "VertexArray (attrib", "IndexArray" }; + canRead = SearchFileHeaderForToken(pIOHandler, file, token, 4); } return canRead; diff --git a/code/AssetLib/Ply/PlyLoader.cpp b/code/AssetLib/Ply/PlyLoader.cpp index 93d48bcbf..b58ef1ef2 100644 --- a/code/AssetLib/Ply/PlyLoader.cpp +++ b/code/AssetLib/Ply/PlyLoader.cpp @@ -111,7 +111,7 @@ bool PLYImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c if (!pIOHandler) { return true; } - static const char *tokens[] = { + static const char * const tokens[] = { "ply" }; return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1); diff --git a/code/AssetLib/Q3D/Q3DLoader.cpp b/code/AssetLib/Q3D/Q3DLoader.cpp index f81026547..fe8541a5d 100644 --- a/code/AssetLib/Q3D/Q3DLoader.cpp +++ b/code/AssetLib/Q3D/Q3DLoader.cpp @@ -92,7 +92,7 @@ bool Q3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c else if (!extension.length() || checkSig) { if (!pIOHandler) return true; - const char *tokens[] = { "quick3Do", "quick3Ds" }; + static const char * const tokens[] = { "quick3Do", "quick3Ds" }; return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 2); } return false; diff --git a/code/AssetLib/STL/STLLoader.cpp b/code/AssetLib/STL/STLLoader.cpp index 8cfe63e0d..4d23b93e2 100644 --- a/code/AssetLib/STL/STLLoader.cpp +++ b/code/AssetLib/STL/STLLoader.cpp @@ -150,7 +150,7 @@ bool STLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c if (!pIOHandler) { return true; } - const char *tokens[] = { "STL", "solid" }; + static const char * const tokens[] = { "STL", "solid" }; return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 2); } diff --git a/code/AssetLib/Terragen/TerragenLoader.cpp b/code/AssetLib/Terragen/TerragenLoader.cpp index e0bdbf026..9a6e7fa24 100644 --- a/code/AssetLib/Terragen/TerragenLoader.cpp +++ b/code/AssetLib/Terragen/TerragenLoader.cpp @@ -93,7 +93,7 @@ bool TerragenImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, b return true; } - const char *tokens[] = { "terragen" }; + static const char * const tokens[] = { "terragen" }; return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1); } diff --git a/code/AssetLib/XGL/XGLLoader.cpp b/code/AssetLib/XGL/XGLLoader.cpp index bbfa31829..c3341af5e 100644 --- a/code/AssetLib/XGL/XGLLoader.cpp +++ b/code/AssetLib/XGL/XGLLoader.cpp @@ -118,7 +118,7 @@ bool XGLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c } else if (extension == "xml" || checkSig) { ai_assert(pIOHandler != NULL); - const char *tokens[] = { "", "", "" }; + static const char * const tokens[] = { "", "", "" }; return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 3); } return false; diff --git a/code/Common/BaseImporter.cpp b/code/Common/BaseImporter.cpp index 0f41e9e65..fa6cac938 100644 --- a/code/Common/BaseImporter.cpp +++ b/code/Common/BaseImporter.cpp @@ -155,7 +155,7 @@ void BaseImporter::GetExtensionList(std::set &extensions) { // ------------------------------------------------------------------------------------------------ /*static*/ bool BaseImporter::SearchFileHeaderForToken(IOSystem *pIOHandler, const std::string &pFile, - const char **tokens, + const char * const *tokens, unsigned int numTokens, unsigned int searchBytes /* = 200 */, bool tokensSol /* false */, diff --git a/include/assimp/BaseImporter.h b/include/assimp/BaseImporter.h index 54b5daac1..656e0f165 100644 --- a/include/assimp/BaseImporter.h +++ b/include/assimp/BaseImporter.h @@ -259,7 +259,7 @@ public: // static utilities static bool SearchFileHeaderForToken( IOSystem *pIOSystem, const std::string &file, - const char **tokens, + const char * const *tokens, unsigned int numTokens, unsigned int searchBytes = 200, bool tokensSol = false, From fb5b5e9d40b15b7f502e5c7cd99521d9b5e21eba Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 21 Sep 2021 11:06:18 +0200 Subject: [PATCH 5/9] Fix possible nullptr dereferencing in material parsing * Return 0.0f for empty buffer * closes https://github.com/assimp/assimp/issues/3442 --- code/AssetLib/Obj/ObjFileMtlImporter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/AssetLib/Obj/ObjFileMtlImporter.cpp b/code/AssetLib/Obj/ObjFileMtlImporter.cpp index 94e57c26b..6a81fb082 100644 --- a/code/AssetLib/Obj/ObjFileMtlImporter.cpp +++ b/code/AssetLib/Obj/ObjFileMtlImporter.cpp @@ -232,6 +232,12 @@ void ObjFileMtlImporter::getIlluminationModel(int &illum_model) { // Loads a single float value. void ObjFileMtlImporter::getFloatValue(ai_real &value) { m_DataIt = CopyNextWord(m_DataIt, m_DataItEnd, &m_buffer[0], BUFFERSIZE); + size_t len = std::strlen(&m_buffer[0]); + if (0 == len) { + value = 0.0f; + return; + } + value = (ai_real)fast_atof(&m_buffer[0]); } From 95263b2e54325d7f3e307b689830ee9b40462cbf Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 21 Sep 2021 11:34:58 +0200 Subject: [PATCH 6/9] Update ObjTools.h --- code/AssetLib/Obj/ObjTools.h | 119 ++++++++++++++++++++--------------- 1 file changed, 70 insertions(+), 49 deletions(-) diff --git a/code/AssetLib/Obj/ObjTools.h b/code/AssetLib/Obj/ObjTools.h index 61efb98b2..9e57a1c84 100644 --- a/code/AssetLib/Obj/ObjTools.h +++ b/code/AssetLib/Obj/ObjTools.h @@ -2,7 +2,7 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2020, assimp team +Copyright (c) 2006-2021, assimp team All rights reserved. @@ -51,57 +51,62 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { -/** @brief Returns true, if the last entry of the buffer is reached. - * @param it Iterator of current position. - * @param end Iterator with end of buffer. +/** + * @brief Returns true, if the last entry of the buffer is reached. + * @param[in] it Iterator of current position. + * @param[in] end Iterator with end of buffer. * @return true, if the end of the buffer is reached. */ template inline bool isEndOfBuffer(char_t it, char_t end) { if (it == end) { return true; - } else { - --end; } + --end; + return (it == end); } -/** @brief Returns next word separated by a space - * @param pBuffer Pointer to data buffer - * @param pEnd Pointer to end of buffer +/** + * @brief Returns next word separated by a space + * @param[in] pBuffer Pointer to data buffer + * @param[in] pEnd Pointer to end of buffer * @return Pointer to next space */ template inline Char_T getNextWord(Char_T pBuffer, Char_T pEnd) { while (!isEndOfBuffer(pBuffer, pEnd)) { if (!IsSpaceOrNewLine(*pBuffer) || IsLineEnd(*pBuffer)) { - //if ( *pBuffer != '\\' ) break; } - pBuffer++; + ++pBuffer; } + return pBuffer; } -/** @brief Returns pointer a next token - * @param pBuffer Pointer to data buffer - * @param pEnd Pointer to end of buffer +/** + * @brief Returns pointer a next token + * @param[in] pBuffer Pointer to data buffer + * @param[in] pEnd Pointer to end of buffer * @return Pointer to next token */ template inline Char_T getNextToken(Char_T pBuffer, Char_T pEnd) { while (!isEndOfBuffer(pBuffer, pEnd)) { - if (IsSpaceOrNewLine(*pBuffer)) + if (IsSpaceOrNewLine(*pBuffer)) { break; - pBuffer++; + } + ++pBuffer; } return getNextWord(pBuffer, pEnd); } -/** @brief Skips a line - * @param it Iterator set to current position - * @param end Iterator set to end of scratch buffer for readout - * @param uiLine Current line number in format +/** + * @brief Skips a line + * @param[in] it Iterator set to current position + * @param[in] end Iterator set to end of scratch buffer for readout + * @param[out] uiLine Current line number in format * @return Current-iterator with new position */ template @@ -122,11 +127,12 @@ inline char_t skipLine(char_t it, char_t end, unsigned int &uiLine) { return it; } -/** @brief Get a name from the current line. Preserve space in the middle, +/** + * @brief Get a name from the current line. Preserve space in the middle, * but trim it at the end. - * @param it set to current position - * @param end set to end of scratch buffer for readout - * @param name Separated name + * @param[in] it set to current position + * @param[in] end set to end of scratch buffer for readout + * @param[out] name Separated name * @return Current-iterator with new position */ template @@ -150,15 +156,16 @@ inline char_t getName(char_t it, char_t end, std::string &name) { ++it; } std::string strName(pStart, &(*it)); - if (strName.empty()) - return it; - else + if (!strName.empty()) { name = strName; + } + return it; } -/** @brief Get a name from the current line. Do not preserve space +/** + * @brief Get a name from the current line. Do not preserve space * in the middle, but trim it at the end. * @param it set to current position * @param end set to end of scratch buffer for readout @@ -188,19 +195,19 @@ inline char_t getNameNoSpace(char_t it, char_t end, std::string &name) { ++it; } std::string strName(pStart, &(*it)); - if (strName.empty()) - return it; - else + if (!strName.empty()) { name = strName; - + } + return it; } -/** @brief Get next word from given line - * @param it set to current position - * @param end set to end of scratch buffer for readout - * @param pBuffer Buffer for next word - * @param length Buffer length +/** + * @brief Get next word from given line + * @param[in] it set to current position + * @param[in] end set to end of scratch buffer for readout + * @param[in] pBuffer Buffer for next word + * @param[in] length Buffer length * @return Current-iterator with new position */ template @@ -209,19 +216,21 @@ inline char_t CopyNextWord(char_t it, char_t end, char *pBuffer, size_t length) it = getNextWord(it, end); while (!IsSpaceOrNewLine(*it) && !isEndOfBuffer(it, end)) { pBuffer[index] = *it; - index++; - if (index == length - 1) + ++index; + if (index == length - 1) { break; + } ++it; } pBuffer[index] = '\0'; return it; } -/** @brief Get next float from given line - * @param it set to current position - * @param end set to end of scratch buffer for readout - * @param value Separated float value. +/** + * @brief Get next float from given line + * @param[in] it set to current position + * @param[in] end set to end of scratch buffer for readout + * @param[out] value Separated float value. * @return Current-iterator with new position */ template @@ -234,21 +243,33 @@ inline char_t getFloat(char_t it, char_t end, ai_real &value) { return it; } - +/** + * @brief Will remove white-spaces for a string. + * @param[in] str The string to clean + * @return The trimmed string. + */ template -string_type trim_whitespaces(string_type str) { - while (!str.empty() && IsSpace(str[0])) +inline string_type trim_whitespaces(string_type str) { + while (!str.empty() && IsSpace(str[0])) { str.erase(0); - while (!str.empty() && IsSpace(str[str.length() - 1])) + } + while (!str.empty() && IsSpace(str[str.length() - 1])) { str.erase(str.length() - 1); + } return str; } +/** + * @brief Checks for a line-end. + * @param[in] it Current iterator in string. + * @param[in] end End of the string. + * @return The trimmed string. + */ template bool hasLineEnd(T it, T end) { - bool hasLineEnd(false); + bool hasLineEnd = false; while (!isEndOfBuffer(it, end)) { - it++; + ++it; if (IsLineEnd(it)) { hasLineEnd = true; break; From ac6b8988df29c24d1aee61e7754337f588f22427 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 1 Oct 2021 14:24:40 +0200 Subject: [PATCH 7/9] Add support for normal maps, the classic way - get compiant to tinyobjloader and other importers - closes https://github.com/assimp/assimp/issues/3726 --- code/AssetLib/Obj/ObjFileMtlImporter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/Obj/ObjFileMtlImporter.cpp b/code/AssetLib/Obj/ObjFileMtlImporter.cpp index 6a81fb082..548401d01 100644 --- a/code/AssetLib/Obj/ObjFileMtlImporter.cpp +++ b/code/AssetLib/Obj/ObjFileMtlImporter.cpp @@ -61,7 +61,8 @@ static const std::string EmissiveTexture1 = "map_emissive"; static const std::string EmissiveTexture2 = "map_Ke"; static const std::string BumpTexture1 = "map_bump"; static const std::string BumpTexture2 = "bump"; -static const std::string NormalTexture = "map_Kn"; +static const std::string NormalTextureV1 = "map_Kn"; +static const std::string NormalTextureV2 = "norm"; static const std::string ReflectionTexture = "refl"; static const std::string DisplacementTexture1 = "map_disp"; static const std::string DisplacementTexture2 = "disp"; @@ -321,7 +322,7 @@ void ObjFileMtlImporter::getTexture() { // Bump texture out = &m_pModel->m_pCurrentMaterial->textureBump; clampIndex = ObjFile::Material::TextureBumpType; - } else if (!ASSIMP_strincmp(pPtr, NormalTexture.c_str(), static_cast(NormalTexture.size()))) { + } else if (!ASSIMP_strincmp(pPtr, NormalTextureV1.c_str(), static_cast(NormalTextureV1.size())) || !ASSIMP_strincmp(pPtr, NormalTextureV2.c_str(), static_cast(NormalTextureV2.size()))) { // Normal map out = &m_pModel->m_pCurrentMaterial->textureNormal; clampIndex = ObjFile::Material::TextureNormalType; From ae951fbef99707705eadbaceaf8fb51f3bd770b3 Mon Sep 17 00:00:00 2001 From: Davide Pizzolotto Date: Sun, 3 Oct 2021 00:36:40 +0200 Subject: [PATCH 8/9] Fix aiString length in aiProcess_EmbedTextures --- code/PostProcessing/EmbedTexturesProcess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/PostProcessing/EmbedTexturesProcess.cpp b/code/PostProcessing/EmbedTexturesProcess.cpp index d7720de98..0c1207cff 100644 --- a/code/PostProcessing/EmbedTexturesProcess.cpp +++ b/code/PostProcessing/EmbedTexturesProcess.cpp @@ -89,7 +89,7 @@ void EmbedTexturesProcess::Execute(aiScene* pScene) { // Indeed embed if (addTexture(pScene, path.data)) { auto embeddedTextureId = pScene->mNumTextures - 1u; - ::ai_snprintf(path.data, 1024, "*%u", embeddedTextureId); + path.length = ::ai_snprintf(path.data, 1024, "*%u", embeddedTextureId); material->AddProperty(&path, AI_MATKEY_TEXTURE(tt, texId)); embeddedTexturesCount++; } From a01a5b4e3a12baac929c11dff7962fdb24b1b772 Mon Sep 17 00:00:00 2001 From: Lassi Helynranta Date: Sat, 9 Oct 2021 20:02:52 +0300 Subject: [PATCH 9/9] Added missing include --- code/Common/ImporterRegistry.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/Common/ImporterRegistry.cpp b/code/Common/ImporterRegistry.cpp index 5df096166..77a365844 100644 --- a/code/Common/ImporterRegistry.cpp +++ b/code/Common/ImporterRegistry.cpp @@ -46,6 +46,7 @@ directly (unless you are adding new loaders), instead use the corresponding preprocessor flag to selectively disable formats. */ +#include #include #include #include