From affa85a36bbd329c8792b553f64188c1d3a58188 Mon Sep 17 00:00:00 2001 From: hgdagon Date: Wed, 25 May 2022 07:59:01 -0700 Subject: [PATCH 1/9] Fix GNUC check on Windows --- code/Common/DefaultIOStream.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/Common/DefaultIOStream.cpp b/code/Common/DefaultIOStream.cpp index 17fc44f9a..bbc3b2080 100644 --- a/code/Common/DefaultIOStream.cpp +++ b/code/Common/DefaultIOStream.cpp @@ -63,7 +63,7 @@ inline int select_fseek(FILE *file, int64_t offset, int origin) { -#if defined _WIN64 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601) +#if defined _WIN32 && !defined __GNUC__ && __MSVCRT_VERSION__ >= 0x0601 template <> inline size_t select_ftell<8>(FILE *file) { return (size_t)::_ftelli64(file); @@ -74,7 +74,7 @@ inline int select_fseek<8>(FILE *file, int64_t offset, int origin) { return ::_fseeki64(file, offset, origin); } -#endif // #if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601) +#endif // #if defined _WIN32 && !defined __GNUC__ && __MSVCRT_VERSION__ >= 0x0601 } // namespace @@ -149,7 +149,7 @@ size_t DefaultIOStream::FileSize() const { // // See here for details: // https://www.securecoding.cert.org/confluence/display/seccode/FIO19-C.+Do+not+use+fseek()+and+ftell()+to+compute+the+size+of+a+regular+file -#if defined _WIN64 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601) +#if defined _WIN32 && !defined __GNUC__ && __MSVCRT_VERSION__ >= 0x0601 struct __stat64 fileStat; //using fileno + fstat avoids having to handle the filename int err = _fstat64(_fileno(mFile), &fileStat); From efbcdccac99a66d513731a2f5af65211c734cfe7 Mon Sep 17 00:00:00 2001 From: hgdagon Date: Wed, 25 May 2022 09:18:42 -0700 Subject: [PATCH 2/9] Fix GNUC check on Windows (2nd attempt) --- code/Common/DefaultIOStream.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/Common/DefaultIOStream.cpp b/code/Common/DefaultIOStream.cpp index bbc3b2080..d5d584689 100644 --- a/code/Common/DefaultIOStream.cpp +++ b/code/Common/DefaultIOStream.cpp @@ -63,7 +63,7 @@ inline int select_fseek(FILE *file, int64_t offset, int origin) { -#if defined _WIN32 && !defined __GNUC__ && __MSVCRT_VERSION__ >= 0x0601 +#if defined _WIN32 && (!defined __GNUC__ || !defined __CLANG__ && __MSVCRT_VERSION__ >= 0x0601) template <> inline size_t select_ftell<8>(FILE *file) { return (size_t)::_ftelli64(file); @@ -74,7 +74,7 @@ inline int select_fseek<8>(FILE *file, int64_t offset, int origin) { return ::_fseeki64(file, offset, origin); } -#endif // #if defined _WIN32 && !defined __GNUC__ && __MSVCRT_VERSION__ >= 0x0601 +#endif } // namespace @@ -149,7 +149,7 @@ size_t DefaultIOStream::FileSize() const { // // See here for details: // https://www.securecoding.cert.org/confluence/display/seccode/FIO19-C.+Do+not+use+fseek()+and+ftell()+to+compute+the+size+of+a+regular+file -#if defined _WIN32 && !defined __GNUC__ && __MSVCRT_VERSION__ >= 0x0601 +#if defined _WIN32 && (!defined __GNUC__ || !defined __CLANG__ && __MSVCRT_VERSION__ >= 0x0601) struct __stat64 fileStat; //using fileno + fstat avoids having to handle the filename int err = _fstat64(_fileno(mFile), &fileStat); From bca5650578fd693f25bca7bc683a0c0c7484ab38 Mon Sep 17 00:00:00 2001 From: Gargaj Date: Sat, 18 Jun 2022 23:11:24 +0200 Subject: [PATCH 3/9] fix windows 32 bit builds --- code/Common/DefaultIOStream.cpp | 7 +++++++ code/PostProcessing/EmbedTexturesProcess.cpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/code/Common/DefaultIOStream.cpp b/code/Common/DefaultIOStream.cpp index 17fc44f9a..201d68fdf 100644 --- a/code/Common/DefaultIOStream.cpp +++ b/code/Common/DefaultIOStream.cpp @@ -156,6 +156,13 @@ size_t DefaultIOStream::FileSize() const { if (0 != err) return 0; mCachedSize = (size_t)(fileStat.st_size); +#elif defined _WIN32 + struct _stat32 fileStat; + //using fileno + fstat avoids having to handle the filename + int err = _fstat32(_fileno(mFile), &fileStat); + if (0 != err) + return 0; + mCachedSize = (size_t)(fileStat.st_size); #elif defined __GNUC__ || defined __APPLE__ || defined __MACH__ || defined __FreeBSD__ struct stat fileStat; int err = stat(mFilename.c_str(), &fileStat); diff --git a/code/PostProcessing/EmbedTexturesProcess.cpp b/code/PostProcessing/EmbedTexturesProcess.cpp index 2f80c908e..7ac4ddd4e 100644 --- a/code/PostProcessing/EmbedTexturesProcess.cpp +++ b/code/PostProcessing/EmbedTexturesProcess.cpp @@ -128,7 +128,7 @@ bool EmbedTexturesProcess::addTexture(aiScene *pScene, const std::string &path) aiTexel* imageContent = new aiTexel[ 1ul + static_cast( imageSize ) / sizeof(aiTexel)]; pFile->Seek(0, aiOrigin_SET); - pFile->Read(reinterpret_cast(imageContent), imageSize, 1); + pFile->Read(reinterpret_cast(imageContent), static_cast(imageSize), 1); mIOHandler->Close(pFile); // Enlarging the textures table From 2de95c77a4a90b7dfc681d3859ed23b1a795f3f8 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Jun 2022 17:48:06 +0200 Subject: [PATCH 4/9] Update name of package - closes https://github.com/assimp/assimp/issues/4594 --- Build.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Build.md b/Build.md index d6abe7b67..f48f50495 100644 --- a/Build.md +++ b/Build.md @@ -14,7 +14,8 @@ The assimp port in vcpkg is kept up to date by Microsoft team members and commun ## Install on Ubuntu You can install the Asset-Importer-Lib via apt: ``` -sudo apt-get install assimp +sudp apt-get update +sudo apt-get install libassimp-dev ``` ## Install pyassimp From d3c820161434d5b39fb0e505bcdd7eb94d4f5950 Mon Sep 17 00:00:00 2001 From: kimmi Date: Tue, 28 Jun 2022 20:31:03 +0200 Subject: [PATCH 5/9] Fix token match string checks. --- code/AssetLib/OpenGEX/OpenGEXImporter.cpp | 50 ++++++++++------------- code/AssetLib/OpenGEX/OpenGEXImporter.h | 11 ++--- 2 files changed, 24 insertions(+), 37 deletions(-) diff --git a/code/AssetLib/OpenGEX/OpenGEXImporter.cpp b/code/AssetLib/OpenGEX/OpenGEXImporter.cpp index c8e47933d..2883f9612 100644 --- a/code/AssetLib/OpenGEX/OpenGEXImporter.cpp +++ b/code/AssetLib/OpenGEX/OpenGEXImporter.cpp @@ -151,45 +151,46 @@ namespace Grammar { } static TokenType matchTokenType(const char *tokenType) { - if (MetricType == tokenType) { + const size_t len = std::strlen(tokenType); + if (0 == strncmp(MetricType, tokenType, len)) { return MetricToken; - } else if (NameType == tokenType) { + } else if (0 == strncmp(NameType, tokenType, len)) { return NameToken; - } else if (ObjectRefType == tokenType) { + } else if (0 == strncmp(ObjectRefType, tokenType, len)) { return ObjectRefToken; - } else if (MaterialRefType == tokenType) { + } else if (0 == strncmp(MaterialRefType, tokenType, len)) { return MaterialRefToken; - } else if (MetricKeyType == tokenType) { + } else if (0 == strncmp(MetricKeyType, tokenType, len)) { return MetricKeyToken; - } else if (GeometryNodeType == tokenType) { + } else if (0 == strncmp(GeometryNodeType, tokenType, len)) { return GeometryNodeToken; - } else if (CameraNodeType == tokenType) { + } else if (0 == strncmp(CameraNodeType, tokenType, len)) { return CameraNodeToken; - } else if (LightNodeType == tokenType) { + } else if (0 == strncmp(LightNodeType, tokenType, len)) { return LightNodeToken; - } else if (GeometryObjectType == tokenType) { + } else if (0 == strncmp(GeometryObjectType, tokenType, len)) { return GeometryObjectToken; - } else if (CameraObjectType == tokenType) { + } else if (0 == strncmp(CameraObjectType, tokenType, len)) { return CameraObjectToken; - } else if (LightObjectType == tokenType) { + } else if (0 == strncmp(LightObjectType, tokenType, len)) { return LightObjectToken; - } else if (TransformType == tokenType) { + } else if (0 == strncmp(TransformType, tokenType, len)) { return TransformToken; - } else if (MeshType == tokenType) { + } else if (0 == strncmp(MeshType, tokenType, len)) { return MeshToken; - } else if (VertexArrayType == tokenType) { + } else if (0 == strncmp(VertexArrayType, tokenType, len)) { return VertexArrayToken; - } else if (IndexArrayType == tokenType) { + } else if (0 == strncmp(IndexArrayType, tokenType, len)) { return IndexArrayToken; - } else if (MaterialType == tokenType) { + } else if (0 == strncmp(MaterialType, tokenType, len)) { return MaterialToken; - } else if (ColorType == tokenType) { + } else if (0 == strncmp(ColorType, tokenType, len)) { return ColorToken; - } else if (ParamType == tokenType) { + } else if (0 == strncmp(ParamType, tokenType, len)) { return ParamToken; - } else if (TextureType == tokenType) { + } else if (0 == strncmp(TextureType, tokenType, len)) { return TextureToken; - } else if (AttenType == tokenType) { + } else if (0 == strncmp(AttenType, tokenType, len)) { return AttenToken; } @@ -256,11 +257,6 @@ OpenGEXImporter::RefInfo::RefInfo(aiNode *node, Type type, std::vector m_Names; RefInfo( aiNode *node, Type type, std::vector &names ); - ~RefInfo(); + ~RefInfo() = default; RefInfo( const RefInfo & ) = delete; RefInfo &operator = ( const RefInfo & ) = delete; From 3d692c72ba12cd97485bdd561089a12587517bb3 Mon Sep 17 00:00:00 2001 From: kimmi Date: Tue, 28 Jun 2022 20:31:55 +0200 Subject: [PATCH 6/9] Fix name of test --- test/unit/utOpenGEXImportExport.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/unit/utOpenGEXImportExport.cpp b/test/unit/utOpenGEXImportExport.cpp index a7b682063..2388366b5 100644 --- a/test/unit/utOpenGEXImportExport.cpp +++ b/test/unit/utOpenGEXImportExport.cpp @@ -40,6 +40,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "AbstractImportExportBase.h" + +#include #include "UnitTestPCH.h" #include @@ -51,11 +53,12 @@ public: bool importerTest() override { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OpenGEX/Example.ogex", 0); + printf("Number of meshes = %d\n", scene->mNumMeshes); return nullptr != scene; } }; -TEST_F(utOpenGEXImportExport, importLWSFromFileTest) { +TEST_F(utOpenGEXImportExport, importOpenGexFromFileTest) { EXPECT_TRUE(importerTest()); } From f76be1a6310c73c453b7b56394ac0040677fb120 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Jun 2022 20:38:36 +0200 Subject: [PATCH 7/9] Replace debug code by a real test --- test/unit/utOpenGEXImportExport.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/utOpenGEXImportExport.cpp b/test/unit/utOpenGEXImportExport.cpp index 2388366b5..ed22a6fb7 100644 --- a/test/unit/utOpenGEXImportExport.cpp +++ b/test/unit/utOpenGEXImportExport.cpp @@ -53,7 +53,7 @@ public: bool importerTest() override { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OpenGEX/Example.ogex", 0); - printf("Number of meshes = %d\n", scene->mNumMeshes); + EXPECT_EQ(1u, scene->mNumMeshes); return nullptr != scene; } }; From eee6269cd15b717a6ba6389636e463f03f0c1549 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 29 Jun 2022 11:15:29 +0200 Subject: [PATCH 8/9] Diable build for tools per default - closes https://github.com/assimp/assimp/issues/4593 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2aa66421c..a4f711528 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,7 +90,7 @@ OPTION( ASSIMP_BUILD_ZLIB ) OPTION( ASSIMP_BUILD_ASSIMP_TOOLS "If the supplementary tools for Assimp are built in addition to the library." - ON + OFF ) OPTION ( ASSIMP_BUILD_SAMPLES "If the official samples are built as well (needs Glut)." From 55625d1af52ac89cf71a17af57c33128bd323fb3 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 30 Jun 2022 20:58:34 +0200 Subject: [PATCH 9/9] Use mingw.include --- code/res/assimp.rc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/res/assimp.rc b/code/res/assimp.rc index c36d812f8..fd10935f6 100644 --- a/code/res/assimp.rc +++ b/code/res/assimp.rc @@ -1,5 +1,9 @@ #include "revision.h" +#ifdef __GNUC__ +#include "winresrc.h" +#else #include "winres.h" +#endif LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL #pragma code_page(1252)