From 02560471681f2a4eeb9937305e52eae710e1513c Mon Sep 17 00:00:00 2001 From: Marco Feuerstein Date: Thu, 22 Jun 2023 14:04:21 +0200 Subject: [PATCH] Extend token search flag from alpha to graph. This way we can fix Blender exported files being wrongly detected as obj files. --- code/Common/BaseImporter.cpp | 7 ++++--- include/assimp/BaseImporter.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/code/Common/BaseImporter.cpp b/code/Common/BaseImporter.cpp index 87b385268..8f8e41d39 100644 --- a/code/Common/BaseImporter.cpp +++ b/code/Common/BaseImporter.cpp @@ -158,7 +158,7 @@ void BaseImporter::GetExtensionList(std::set &extensions) { std::size_t numTokens, unsigned int searchBytes /* = 200 */, bool tokensSol /* false */, - bool noAlphaBeforeTokens /* false */) { + bool noGraphBeforeTokens /* false */) { ai_assert(nullptr != tokens); ai_assert(0 != numTokens); ai_assert(0 != searchBytes); @@ -207,8 +207,9 @@ void BaseImporter::GetExtensionList(std::set &extensions) { continue; } // We need to make sure that we didn't accidentally identify the end of another token as our token, - // e.g. in a previous version the "gltf " present in some gltf files was detected as "f " - if (noAlphaBeforeTokens && (r != buffer && isalpha(static_cast(r[-1])))) { + // e.g. in a previous version the "gltf " present in some gltf files was detected as "f ", or a + // Blender-exported glb file containing "Khronos glTF Blender I/O " was detected as "o " + if (noGraphBeforeTokens && (r != buffer && isgraph(static_cast(r[-1])))) { continue; } // We got a match, either we don't care where it is, or it happens to diff --git a/include/assimp/BaseImporter.h b/include/assimp/BaseImporter.h index 06b87f1e1..42b537b91 100644 --- a/include/assimp/BaseImporter.h +++ b/include/assimp/BaseImporter.h @@ -259,7 +259,7 @@ public: // static utilities std::size_t numTokens, unsigned int searchBytes = 200, bool tokensSol = false, - bool noAlphaBeforeTokens = false); + bool noGraphBeforeTokens = false); // ------------------------------------------------------------------- /** @brief Check whether a file has a specific file extension