Skip to content

Commit

Permalink
Extend token search flag from alpha to graph.
Browse files Browse the repository at this point in the history
This way we can fix Blender exported files being wrongly detected as
obj files.
  • Loading branch information
feuerste committed Jul 5, 2023
1 parent 9a94b26 commit 43360ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions code/Common/BaseImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void BaseImporter::GetExtensionList(std::set<std::string> &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);
Expand Down Expand Up @@ -207,8 +207,9 @@ void BaseImporter::GetExtensionList(std::set<std::string> &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<unsigned char>(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<unsigned char>(r[-1])))) {
continue;
}
// We got a match, either we don't care where it is, or it happens to
Expand Down
2 changes: 1 addition & 1 deletion include/assimp/BaseImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class ASSIMP_API BaseImporter {
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
Expand Down

0 comments on commit 43360ad

Please sign in to comment.