From 988acd00f10e5334ea2903b0ef7b0df2b6529f9b Mon Sep 17 00:00:00 2001 From: Alexis Breust Date: Fri, 5 Jan 2018 10:08:17 +0100 Subject: [PATCH 1/4] Using relative buffers URI --- code/glTF2AssetWriter.inl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/glTF2AssetWriter.inl b/code/glTF2AssetWriter.inl index 6b1a50887..2f9b8cb68 100644 --- a/code/glTF2AssetWriter.inl +++ b/code/glTF2AssetWriter.inl @@ -156,7 +156,10 @@ namespace glTF2 { inline void Write(Value& obj, Buffer& b, AssetWriter& w) { obj.AddMember("byteLength", static_cast(b.byteLength), w.mAl); - obj.AddMember("uri", Value(b.GetURI(), w.mAl).Move(), w.mAl); + + const auto uri = b.GetURI(); + const auto relativeUri = uri.substr(uri.find_last_of("/\\") + 1u); + obj.AddMember("uri", Value(relativeUri, w.mAl).Move(), w.mAl); } inline void Write(Value& obj, BufferView& bv, AssetWriter& w) From ce5b78f6c0d62441d4dca28cc8e53db58088cda3 Mon Sep 17 00:00:00 2001 From: Robert Spencer Date: Sat, 6 Jan 2018 15:17:03 +0200 Subject: [PATCH 2/4] Remove check for 'assimp' in name of directories to be searched for library in python port --- port/PyAssimp/pyassimp/helper.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/port/PyAssimp/pyassimp/helper.py b/port/PyAssimp/pyassimp/helper.py index 85bb53add..7d9282745 100644 --- a/port/PyAssimp/pyassimp/helper.py +++ b/port/PyAssimp/pyassimp/helper.py @@ -51,11 +51,8 @@ if os.name=='posix': elif os.name=='nt': ext_whitelist.append('.dll') path_dirs = os.environ['PATH'].split(';') - for dir_candidate in path_dirs: - if 'assimp' in dir_candidate.lower(): - additional_dirs.append(dir_candidate) + additional_dirs.extend(path_dirs) -#print(additional_dirs) def vec2tuple(x): """ Converts a VECTOR3D to a Tuple """ return (x.x, x.y, x.z) From f149a2641b947ebb4d1b5bb33b9f74904c30215a Mon Sep 17 00:00:00 2001 From: Robert Spencer Date: Sat, 6 Jan 2018 15:17:56 +0200 Subject: [PATCH 3/4] Add compiled python files to the ignore list --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 12cd76a87..2a3b68a50 100644 --- a/.gitignore +++ b/.gitignore @@ -60,6 +60,7 @@ test/gtest/src/gtest-stamp/Debug/gtest-build *.lib test/gtest/src/gtest-stamp/Debug/ tools/assimp_view/assimp_viewer.vcxproj.user +*.pyc # Unix editor backups *~ From 01081765ad391a26fc129960e5ab7493bcaeb1f9 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 6 Jan 2018 18:03:27 +0100 Subject: [PATCH 4/4] closes https://github.com/assimp/assimp/issues/1638: use memcpy instead of dynamic_cast. --- code/FBXBinaryTokenizer.cpp | 35 ++++++++++++++--------------------- include/assimp/types.h | 3 +-- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/code/FBXBinaryTokenizer.cpp b/code/FBXBinaryTokenizer.cpp index cc2e734fc..5884125a2 100644 --- a/code/FBXBinaryTokenizer.cpp +++ b/code/FBXBinaryTokenizer.cpp @@ -129,30 +129,26 @@ AI_WONT_RETURN void TokenizeError(const std::string& message, unsigned int offse // ------------------------------------------------------------------------------------------------ -uint32_t Offset(const char* begin, const char* cursor) -{ +uint32_t Offset(const char* begin, const char* cursor) { ai_assert(begin <= cursor); + return static_cast(cursor - begin); } - // ------------------------------------------------------------------------------------------------ -void TokenizeError(const std::string& message, const char* begin, const char* cursor) -{ +void TokenizeError(const std::string& message, const char* begin, const char* cursor) { TokenizeError(message, Offset(begin, cursor)); } - // ------------------------------------------------------------------------------------------------ -uint32_t ReadWord(const char* input, const char*& cursor, const char* end) -{ +uint32_t ReadWord(const char* input, const char*& cursor, const char* end) { const size_t k_to_read = sizeof( uint32_t ); if(Offset(cursor, end) < k_to_read ) { TokenizeError("cannot ReadWord, out of bounds",input, cursor); } uint32_t word; - memcpy(&word, cursor, 4); + ::memcpy(&word, cursor, 4); AI_SWAP4(word); cursor += k_to_read; @@ -167,7 +163,8 @@ uint64_t ReadDoubleWord(const char* input, const char*& cursor, const char* end) TokenizeError("cannot ReadDoubleWord, out of bounds",input, cursor); } - uint64_t dword = *reinterpret_cast(cursor); + uint64_t dword /*= *reinterpret_cast(cursor)*/; + ::memcpy( &dword, cursor, sizeof( uint64_t ) ); AI_SWAP8(dword); cursor += k_to_read; @@ -176,24 +173,21 @@ uint64_t ReadDoubleWord(const char* input, const char*& cursor, const char* end) } // ------------------------------------------------------------------------------------------------ -uint8_t ReadByte(const char* input, const char*& cursor, const char* end) -{ +uint8_t ReadByte(const char* input, const char*& cursor, const char* end) { if(Offset(cursor, end) < sizeof( uint8_t ) ) { TokenizeError("cannot ReadByte, out of bounds",input, cursor); } - uint8_t word = *reinterpret_cast(cursor); + uint8_t word;/* = *reinterpret_cast< const uint8_t* >( cursor )*/ + ::memcpy( &word, cursor, sizeof( uint8_t ) ); ++cursor; return word; } - // ------------------------------------------------------------------------------------------------ -unsigned int ReadString(const char*& sbegin_out, const char*& send_out, const char* input, const char*& cursor, const char* end, - bool long_length = false, - bool allow_null = false) -{ +unsigned int ReadString(const char*& sbegin_out, const char*& send_out, const char* input, + const char*& cursor, const char* end, bool long_length = false, bool allow_null = false) { const uint32_t len_len = long_length ? 4 : 1; if(Offset(cursor, end) < len_len) { TokenizeError("cannot ReadString, out of bounds reading length",input, cursor); @@ -222,8 +216,7 @@ unsigned int ReadString(const char*& sbegin_out, const char*& send_out, const ch } // ------------------------------------------------------------------------------------------------ -void ReadData(const char*& sbegin_out, const char*& send_out, const char* input, const char*& cursor, const char* end) -{ +void ReadData(const char*& sbegin_out, const char*& send_out, const char* input, const char*& cursor, const char* end) { if(Offset(cursor, end) < 1) { TokenizeError("cannot ReadData, out of bounds reading length",input, cursor); } @@ -422,7 +415,7 @@ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor, return true; } -} +} // anonymous namespace // ------------------------------------------------------------------------------------------------ // TODO: Test FBX Binary files newer than the 7500 version to check if the 64 bits address behaviour is consistent diff --git a/include/assimp/types.h b/include/assimp/types.h index 0012a0bba..e7bec2f85 100644 --- a/include/assimp/types.h +++ b/include/assimp/types.h @@ -110,8 +110,7 @@ extern "C" { /** Maximum dimension for strings, ASSIMP strings are zero terminated. */ #ifdef __cplusplus -static -const size_t MAXLEN = 1024; + static const size_t MAXLEN = 1024; #else # define MAXLEN 1024 #endif