From 7e140ff912419a81aa3b0f5725f53d849e5c92e4 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Fri, 10 Jan 2020 13:50:16 +0200 Subject: [PATCH 01/48] Add MD2 importer unit tests --- test/CMakeLists.txt | 1 + test/unit/ImportExport/utMD2Importer.cpp | 87 ++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 test/unit/ImportExport/utMD2Importer.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2429ab25d..321aeea70 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -128,6 +128,7 @@ SET( IMPORTERS unit/ImportExport/utOFFImportExport.cpp unit/ImportExport/utNFFImportExport.cpp unit/ImportExport/utXGLImportExport.cpp + unit/ImportExport/utMD2Importer.cpp unit/ImportExport/utMDLImporter.cpp unit/ImportExport/MDL/MDLHL1TestFiles.h unit/ImportExport/MDL/utMDLImporter_HL1_ImportSettings.cpp diff --git a/test/unit/ImportExport/utMD2Importer.cpp b/test/unit/ImportExport/utMD2Importer.cpp new file mode 100644 index 000000000..9bafd881c --- /dev/null +++ b/test/unit/ImportExport/utMD2Importer.cpp @@ -0,0 +1,87 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2020, assimp team + + + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--------------------------------------------------------------------------- +*/ + +#include "UnitTestPCH.h" + +#include +#include +#include + + +using namespace Assimp; + + + +TEST(utMD2Importer, importFaerie) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MD2/faerie.md2", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utMD2Importer, importSydney) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MD2/sydney.md2", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utMD2Importer, importDolphin) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD2/dolphin.md2", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utMD2Importer, importFlag) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD2/flag.md2", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utMD2Importer, importHorse) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD2/horse.md2", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} From 122667b2b218a57085056d41d28af392f6555776 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 15 Jan 2020 10:36:30 +0100 Subject: [PATCH 02/48] Update .travis.yml Set depth to 1 because we do not need the history. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8fe39d59c..79ccf5b1a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,9 @@ env: - secure: "lZ7pHQvl5dpZWzBQAaIMf0wqrvtcZ4wiZKeIZjf83TEsflW8+z0uTpIuN30ZV6Glth/Sq1OhLnTP5+N57fZU/1ebA5twHdvP4bS5CIUUg71/CXQZNl36xeaqvxsG/xRrdpKOsPdjAOsQ9KPTQulsX43XDLS7CasMiLvYOpqKcPc=" - PV=r8e PLATF=linux-x86_64 NDK_HOME=${TRAVIS_BUILD_DIR}/android-ndk-${PV} PATH=${PATH}:${NDK_HOME} +git: + depth: 1 + matrix: include: - os: linux From babf9eac0f53e3e6a7533d028f594aad6715c204 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 15 Jan 2020 10:39:48 +0100 Subject: [PATCH 03/48] Update appveyor.yml Enable git clone --depth 1 --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index fa0a125f0..9aeac7832 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,8 @@ # clone directory clone_folder: c:\projects\assimp +clone_depth: 1 + # branches to build branches: # whitelist From d6e9a15b1540c2550bafe3a90de292ca7161f7e7 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 15 Jan 2020 13:23:13 +0200 Subject: [PATCH 04/48] Add MD5 importer unit tests --- test/CMakeLists.txt | 1 + test/unit/ImportExport/utMD5Importer.cpp | 80 ++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 test/unit/ImportExport/utMD5Importer.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 321aeea70..3d382490c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -129,6 +129,7 @@ SET( IMPORTERS unit/ImportExport/utNFFImportExport.cpp unit/ImportExport/utXGLImportExport.cpp unit/ImportExport/utMD2Importer.cpp + unit/ImportExport/utMD5Importer.cpp unit/ImportExport/utMDLImporter.cpp unit/ImportExport/MDL/MDLHL1TestFiles.h unit/ImportExport/MDL/utMDLImporter_HL1_ImportSettings.cpp diff --git a/test/unit/ImportExport/utMD5Importer.cpp b/test/unit/ImportExport/utMD5Importer.cpp new file mode 100644 index 000000000..941d20e9d --- /dev/null +++ b/test/unit/ImportExport/utMD5Importer.cpp @@ -0,0 +1,80 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2020, assimp team + + + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--------------------------------------------------------------------------- +*/ + +#include "UnitTestPCH.h" + +#include +#include +#include + + +using namespace Assimp; + + + +TEST(utMD5Importer, importEmpty) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MD5/invalid/empty.md5mesh", aiProcess_ValidateDataStructure); + ASSERT_EQ(nullptr, scene); +} + + +TEST(utMD5Importer, importSimpleCube) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MD5/SimpleCube.md5mesh", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utMD5Importer, importBoarMan) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD5/BoarMan.md5mesh", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utMD5Importer, importBob) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD5/Bob.md5mesh", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} From a50b94dd63dd63d5759dfc79751f9f1ea3226b18 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 15 Jan 2020 14:10:09 +0200 Subject: [PATCH 05/48] Revert test model dwarf.cob to working version --- test/models/COB/dwarf.cob | Bin 962911 -> 962915 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/models/COB/dwarf.cob b/test/models/COB/dwarf.cob index 718d0c786e9ff18237c991370c30027362079425..1e6e1ddd700a52770fc311cbd0a71cbf920cfba1 100644 GIT binary patch delta 109 zcmccr$m;PUtA-ZF7N!>F7M3ln-a?GL?cPGHK+Fcj>_E)1-CKxrl@A*)mlFd6%k+t7 xc!j4=IKw-seSSPA5OZyxAJ3g#!N@xus7F7M3ln-a^xPZ*VKM=LxX_F&hxG12M<;JR!~wpXoJccvrPA ejOPSmuI&rsxw9+UfvUIj-r&jmvK=V-{0RW!Y9LYo From 26a80bb0197b48ad4dd5b4478bdd1e6bf25f5474 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 15 Jan 2020 14:15:29 +0200 Subject: [PATCH 06/48] Refactor COB import test to not use a class --- test/unit/ImportExport/utCOBImportExport.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/test/unit/ImportExport/utCOBImportExport.cpp b/test/unit/ImportExport/utCOBImportExport.cpp index d80757e53..3147dc143 100644 --- a/test/unit/ImportExport/utCOBImportExport.cpp +++ b/test/unit/ImportExport/utCOBImportExport.cpp @@ -43,22 +43,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "UnitTestPCH.h" #include "SceneDiffer.h" -#include "AbstractImportExportBase.h" #include #include using namespace Assimp; -class utCOBImportExport : public AbstractImportExportBase { -public: - virtual bool importerTest() { - Assimp::Importer importer; - const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/molecule.cob", aiProcess_ValidateDataStructure); - return nullptr != scene; - } -}; -TEST_F(utCOBImportExport, importAMFFromFileTest) { - EXPECT_TRUE(importerTest()); +TEST(utCOBImporter, importMolecule) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/molecule.cob", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); } + + From 542b1f768858db91875680218e7ebdca3b9c969f Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 15 Jan 2020 14:34:25 +0200 Subject: [PATCH 07/48] Add more COB importer unit tests --- test/unit/ImportExport/utCOBImportExport.cpp | 51 ++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/test/unit/ImportExport/utCOBImportExport.cpp b/test/unit/ImportExport/utCOBImportExport.cpp index 3147dc143..c01487c84 100644 --- a/test/unit/ImportExport/utCOBImportExport.cpp +++ b/test/unit/ImportExport/utCOBImportExport.cpp @@ -50,6 +50,31 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; +TEST(utCOBImporter, importDwarfASCII) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/dwarf_ascii.cob", aiProcess_ValidateDataStructure); + // FIXME: this is wrong, it should succeed + // change to ASSERT_NE after it's been fixed + ASSERT_EQ(nullptr, scene); +} + + +TEST(utCOBImporter, importDwarf) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/dwarf.cob", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utCOBImporter, importMoleculeASCII) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/molecule_ascii.cob", aiProcess_ValidateDataStructure); + // FIXME: this is wrong, it should succeed + // change to ASSERT_NE after it's been fixed + ASSERT_EQ(nullptr, scene); +} + + TEST(utCOBImporter, importMolecule) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/molecule.cob", aiProcess_ValidateDataStructure); @@ -57,3 +82,29 @@ TEST(utCOBImporter, importMolecule) { } +TEST(utCOBImporter, importSpider43ASCII) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/spider_4_3_ascii.cob", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utCOBImporter, importSpider43) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/spider_4_3.cob", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utCOBImporter, importSpider66ASCII) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/spider_6_6_ascii.cob", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utCOBImporter, importSpider66) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/spider_6_6.cob", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} From 23e4dd8ae5d06a9a3681ccc0b93396b56bbddee9 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 15 Jan 2020 14:11:40 +0100 Subject: [PATCH 08/48] Update appveyor.yml Use cmake for build. --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 9aeac7832..4e1df941a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -54,9 +54,11 @@ cache: - bin\.mtime_cache before_build: + - echo NUMBER_OF_PROCESSORS=%NUMBER_OF_PROCESSORS% - ruby scripts\AppVeyor\mtime_cache -g scripts\AppVeyor\cacheglobs.txt -c bin\.mtime_cache\cache.json build: + - cmake --build . --use-stderr --target Release -- -j%NUMBER_OF_PROCESSORS% parallel: true project: Assimp.sln From 9867bdd9841188396c848233d98f12998f7b5929 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 15 Jan 2020 15:08:35 +0100 Subject: [PATCH 09/48] Update appveyor.yml Fix the build script. --- appveyor.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 4e1df941a..a5f2fd111 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -59,8 +59,6 @@ before_build: build: - cmake --build . --use-stderr --target Release -- -j%NUMBER_OF_PROCESSORS% - parallel: true - project: Assimp.sln after_build: - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" ( From f7ca69c07efbd0a021bb9870d78ad40d9be96b57 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 15 Jan 2020 15:53:24 +0100 Subject: [PATCH 10/48] Update appveyor.yml Next try --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index a5f2fd111..aadb90da3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -58,7 +58,7 @@ before_build: - ruby scripts\AppVeyor\mtime_cache -g scripts\AppVeyor\cacheglobs.txt -c bin\.mtime_cache\cache.json build: - - cmake --build . --use-stderr --target Release -- -j%NUMBER_OF_PROCESSORS% + - cmake --build . --target Release -j%NUMBER_OF_PROCESSORS% after_build: - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" ( From ce087fe6e20100bb3b98b061b6d7ad424ee61e9d Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 15 Jan 2020 16:03:39 +0100 Subject: [PATCH 11/48] Update appveyor.yml Fix the build --- appveyor.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index aadb90da3..857ddd849 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -58,7 +58,8 @@ before_build: - ruby scripts\AppVeyor\mtime_cache -g scripts\AppVeyor\cacheglobs.txt -c bin\.mtime_cache\cache.json build: - - cmake --build . --target Release -j%NUMBER_OF_PROCESSORS% + parallel: true + project: Assimp.sln after_build: - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" ( From 1cae51615f81f11cd4283c3e5792a7c226815111 Mon Sep 17 00:00:00 2001 From: "Hui.Du" Date: Thu, 16 Jan 2020 11:49:00 +1300 Subject: [PATCH 12/48] Fix: gltf exporting memory leak --- code/glTF/glTFAsset.inl | 4 +++- code/glTF/glTFExporter.cpp | 9 ++++----- code/glTF/glTFExporter.h | 2 +- code/glTF2/glTF2Asset.inl | 7 +++++-- code/glTF2/glTF2Exporter.cpp | 6 ++---- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/code/glTF/glTFAsset.inl b/code/glTF/glTFAsset.inl index 500d49fcb..f93f195bb 100644 --- a/code/glTF/glTFAsset.inl +++ b/code/glTF/glTFAsset.inl @@ -688,7 +688,9 @@ inline void Image::SetData(uint8_t* data, size_t length, Asset& r) bufferView->byteOffset = b->AppendData(data, length); } else { // text file: will be stored as a data uri - this->mData.reset(data); + uint8_t *temp = new uint8_t[length]; + memcpy(temp, data, length); + this->mData.reset(temp); this->mDataLength = length; } } diff --git a/code/glTF/glTFExporter.cpp b/code/glTF/glTFExporter.cpp index cf8ef974a..4772c7dc6 100644 --- a/code/glTF/glTFExporter.cpp +++ b/code/glTF/glTFExporter.cpp @@ -100,17 +100,16 @@ glTFExporter::glTFExporter(const char* filename, IOSystem* pIOSystem, const aiSc { aiScene* sceneCopy_tmp; SceneCombiner::CopyScene(&sceneCopy_tmp, pScene); - aiScene *sceneCopy(sceneCopy_tmp); SplitLargeMeshesProcess_Triangle tri_splitter; tri_splitter.SetLimit(0xffff); - tri_splitter.Execute(sceneCopy); + tri_splitter.Execute(sceneCopy_tmp); SplitLargeMeshesProcess_Vertex vert_splitter; vert_splitter.SetLimit(0xffff); - vert_splitter.Execute(sceneCopy); + vert_splitter.Execute(sceneCopy_tmp); - mScene = sceneCopy; + mScene.reset(sceneCopy_tmp); mAsset.reset( new glTF::Asset( pIOSystem ) ); @@ -877,7 +876,7 @@ void glTFExporter::ExportMetadata() // Copyright aiString copyright_str; - if (mScene->mMetaData->Get(AI_METADATA_SOURCE_COPYRIGHT, copyright_str)) { + if (mScene->mMetaData != nullptr && mScene->mMetaData->Get(AI_METADATA_SOURCE_COPYRIGHT, copyright_str)) { asset.copyright = copyright_str.C_Str(); } } diff --git a/code/glTF/glTFExporter.h b/code/glTF/glTFExporter.h index d6c2e7f04..ffa2ce42e 100644 --- a/code/glTF/glTFExporter.h +++ b/code/glTF/glTFExporter.h @@ -90,7 +90,7 @@ namespace Assimp const char* mFilename; IOSystem* mIOSystem; - const aiScene* mScene; + std::shared_ptr mScene; const ExportProperties* mProperties; std::map mTexturesByPath; diff --git a/code/glTF2/glTF2Asset.inl b/code/glTF2/glTF2Asset.inl index e55857be1..3db37c72b 100644 --- a/code/glTF2/glTF2Asset.inl +++ b/code/glTF2/glTF2Asset.inl @@ -752,6 +752,7 @@ inline uint8_t* Image::StealData() return mData.release(); } +// Never take over the ownership of data whenever binary or not inline void Image::SetData(uint8_t* data, size_t length, Asset& r) { Ref b = r.GetBodyBuffer(); @@ -764,8 +765,10 @@ inline void Image::SetData(uint8_t* data, size_t length, Asset& r) bufferView->byteOffset = b->AppendData(data, length); } else { // text file: will be stored as a data uri - this->mData.reset(data); - this->mDataLength = length; + uint8_t *temp = new uint8_t[length]; + memcpy(temp, data, length); + this->mData.reset(temp); + this->mDataLength = length; } } diff --git a/code/glTF2/glTF2Exporter.cpp b/code/glTF2/glTF2Exporter.cpp index d7b16ab04..ee40694f9 100644 --- a/code/glTF2/glTF2Exporter.cpp +++ b/code/glTF2/glTF2Exporter.cpp @@ -352,10 +352,8 @@ void glTF2Exporter::GetMatTex(const aiMaterial* mat, Ref& texture, aiTe if (path[0] == '*') { // embedded aiTexture* tex = mScene->mTextures[atoi(&path[1])]; - // copy data since lifetime control is handed over to the asset - uint8_t* data = new uint8_t[tex->mWidth]; - memcpy(data, tex->pcData, tex->mWidth); - texture->source->SetData(data, tex->mWidth, *mAsset); + // The asset has its own buffer, see Image::SetData + texture->source->SetData(reinterpret_cast (tex->pcData), tex->mWidth, *mAsset); if (tex->achFormatHint[0]) { std::string mimeType = "image/"; From 08110be9f742b3167ff9bd6906b35e59d3595b4a Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Thu, 16 Jan 2020 13:41:01 +0200 Subject: [PATCH 13/48] Revert BoxTextured.glb to working version --- .../BoxTextured-glTF-Binary/BoxTextured.glb | Bin 4695 -> 4696 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/models/glTF2/BoxTextured-glTF-Binary/BoxTextured.glb b/test/models/glTF2/BoxTextured-glTF-Binary/BoxTextured.glb index 19b5546b04f56818f70f8bf809863ec8853b72f1..03cd2acf941a0838722aa3e7243d33a8f459c22e 100644 GIT binary patch delta 14 Vcmcbvazkaq4Gu=$%{MseIRP+R1+f4C delta 12 Tcmcbia$RM^4UWw>IqEq9DEtMa From 2a366388c2f9326c5f8f515dd21251ef19ef9212 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Thu, 16 Jan 2020 13:55:34 +0200 Subject: [PATCH 14/48] Revert Wuson.ms3d to working version --- test/models/MS3D/Wuson.ms3d | Bin 330211 -> 330213 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/models/MS3D/Wuson.ms3d b/test/models/MS3D/Wuson.ms3d index e78cbaa58e0ded211393ecea424f8b8e6ade237f..2fc79ac82666277998e21202ce5914e971c93561 100644 GIT binary patch delta 33 ocmaDnS>)+tk%kt=7N!>FEi6}h70$Z73Z&0WVi7L~0PANB8~^|S delta 29 lcmaDlS>*9#k%kt=7N!>FEi6}hwqNaG`N6vV+$0w9asbB|4FdoG From 89e622060b02a5911bdabcb64afdd8a20c16c0e8 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Thu, 16 Jan 2020 14:02:04 +0200 Subject: [PATCH 15/48] Preserve more exceptions in Half-Life MDL loader --- code/MDL/HalfLife/HL1MDLLoader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/MDL/HalfLife/HL1MDLLoader.cpp b/code/MDL/HalfLife/HL1MDLLoader.cpp index 785183950..90a1479a3 100644 --- a/code/MDL/HalfLife/HL1MDLLoader.cpp +++ b/code/MDL/HalfLife/HL1MDLLoader.cpp @@ -175,9 +175,9 @@ void HL1MDLLoader::load_file() { release_resources(); - } catch (const std::exception &e) { + } catch (...) { release_resources(); - throw e; + throw; } } From 715337aa0b95936b11fe622f9e658427c3814c07 Mon Sep 17 00:00:00 2001 From: Matthias Moulin Date: Thu, 16 Jan 2020 18:21:28 +0100 Subject: [PATCH 16/48] Suppressed MSVC++ warning C4244 'return': conversion from '__int64' to 'int', possible loss of data --- code/Assjson/cencode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/Assjson/cencode.c b/code/Assjson/cencode.c index db99e7efa..bd302100b 100644 --- a/code/Assjson/cencode.c +++ b/code/Assjson/cencode.c @@ -42,7 +42,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, { state_in->result = result; state_in->step = step_A; - return codechar - code_out; + return (int)(codechar - code_out); } fragment = *plainchar++; result = (fragment & 0x0fc) >> 2; @@ -53,7 +53,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, { state_in->result = result; state_in->step = step_B; - return codechar - code_out; + return (int)(codechar - code_out); } fragment = *plainchar++; result |= (fragment & 0x0f0) >> 4; @@ -64,7 +64,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, { state_in->result = result; state_in->step = step_C; - return codechar - code_out; + return (int)(codechar - code_out); } fragment = *plainchar++; result |= (fragment & 0x0c0) >> 6; @@ -81,7 +81,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, } } /* control should not reach here */ - return codechar - code_out; + return (int)(codechar - code_out); } int base64_encode_blockend(char* code_out, base64_encodestate* state_in) @@ -104,6 +104,6 @@ int base64_encode_blockend(char* code_out, base64_encodestate* state_in) } *codechar++ = '\n'; - return codechar - code_out; + return (int)(codechar - code_out); } From e0e9ec720bc0eae2f5ed620d920a52cd046d84df Mon Sep 17 00:00:00 2001 From: Matthias Moulin Date: Thu, 16 Jan 2020 18:24:06 +0100 Subject: [PATCH 17/48] Suppressed MSVC++ warning C4267 '=': conversion from 'size_t' to 'ai_uint32', possible loss of data --- code/CSM/CSMLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/CSM/CSMLoader.cpp b/code/CSM/CSMLoader.cpp index 9dbb38467..7fea06727 100644 --- a/code/CSM/CSMLoader.cpp +++ b/code/CSM/CSMLoader.cpp @@ -178,7 +178,7 @@ void CSMImporter::InternReadFile( const std::string& pFile, *ot++ = *buffer++; *ot = '\0'; - nda->mNodeName.length = (size_t)(ot-nda->mNodeName.data); + nda->mNodeName.length = (ai_uint32)(ot-nda->mNodeName.data); } anim->mNumChannels = static_cast(anims_temp.size()); From fb5a30efd09cd6a9735673ac75493141d1f78dd6 Mon Sep 17 00:00:00 2001 From: Matthias Moulin Date: Thu, 16 Jan 2020 18:25:37 +0100 Subject: [PATCH 18/48] Suppressed MSVC++ warning C4267 '=': conversion from 'size_t' to 'ai_uint32', possible loss of data --- code/MDL/MDLLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/MDL/MDLLoader.cpp b/code/MDL/MDLLoader.cpp index 027c03cbd..57a6bda95 100644 --- a/code/MDL/MDLLoader.cpp +++ b/code/MDL/MDLLoader.cpp @@ -1575,7 +1575,7 @@ void MDLImporter::InternReadFile_3DGS_MDL7( ) const size_t maxSize(buffersize - (i*AI_MDL7_MAX_GROUPNAMESIZE)); pcNode->mName.length = ai_snprintf(szBuffer, maxSize, "Group_%u", p); } else { - pcNode->mName.length = ::strlen(szBuffer); + pcNode->mName.length = (ai_uint32)::strlen(szBuffer); } ::strncpy(pcNode->mName.data,szBuffer,MAXLEN-1); ++p; From 3ab21c926c29bab9bef8ff3bc8c01d08e72ffd4e Mon Sep 17 00:00:00 2001 From: Matthias Moulin Date: Thu, 16 Jan 2020 18:27:00 +0100 Subject: [PATCH 19/48] Suppressed MSVC++ warning C4267 '=': conversion from 'size_t' to 'ai_uint32', possible loss of data --- code/MDL/MDLMaterialLoader.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/MDL/MDLMaterialLoader.cpp b/code/MDL/MDLMaterialLoader.cpp index 0a196761f..79b57128a 100644 --- a/code/MDL/MDLMaterialLoader.cpp +++ b/code/MDL/MDLMaterialLoader.cpp @@ -541,7 +541,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( size_t iLen2 = iLen+1; iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2; memcpy(szFile.data,(const char*)szCurrent,iLen2); - szFile.length = iLen; + szFile.length = (ai_uint32)iLen; szCurrent += iLen2; @@ -710,7 +710,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( aiString szFile; const size_t iLen = strlen((const char*)szCurrent); ::memcpy(szFile.data,(const char*)szCurrent,iLen+1); - szFile.length = iLen; + szFile.length = (ai_uint32)iLen; pcMatOut->AddProperty(&szFile,AI_MATKEY_TEXTURE_DIFFUSE(0)); @@ -831,7 +831,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( aiString szFile; ::memcpy(szFile.data,pcSkin->texture_name,sizeof(pcSkin->texture_name)); szFile.data[sizeof(pcSkin->texture_name)] = '\0'; - szFile.length = ::strlen(szFile.data); + szFile.length = (ai_uint32)::strlen(szFile.data); pcMatOut->AddProperty(&szFile,AI_MATKEY_NAME); } From 91ecad5da8ae31deceed17fe07ec8646a49babba Mon Sep 17 00:00:00 2001 From: Matthias Moulin Date: Thu, 16 Jan 2020 18:28:04 +0100 Subject: [PATCH 20/48] Suppressed MSVC++ warning C4267 '=': conversion from 'size_t' to 'ai_uint32', possible loss of data --- code/Material/MaterialSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Material/MaterialSystem.cpp b/code/Material/MaterialSystem.cpp index aa3df9ac2..befdb43d2 100644 --- a/code/Material/MaterialSystem.cpp +++ b/code/Material/MaterialSystem.cpp @@ -504,7 +504,7 @@ aiReturn aiMaterial::AddBinaryProperty (const void* pInput, pcNew->mData = new char[pSizeInBytes]; memcpy (pcNew->mData,pInput,pSizeInBytes); - pcNew->mKey.length = ::strlen(pKey); + pcNew->mKey.length = (ai_uint32)::strlen(pKey); ai_assert ( MAXLEN > pcNew->mKey.length); strcpy( pcNew->mKey.data, pKey ); From 633a37512f5faf60616d8450282e9dcdd991a581 Mon Sep 17 00:00:00 2001 From: Matthias Moulin Date: Thu, 16 Jan 2020 18:28:45 +0100 Subject: [PATCH 21/48] Suppressed MSVC++ warning C4267 '=': conversion from 'size_t' to 'ai_uint32', possible loss of data --- code/Q3BSP/Q3BSPFileImporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Q3BSP/Q3BSPFileImporter.cpp b/code/Q3BSP/Q3BSPFileImporter.cpp index 4add00a07..a492cc92a 100644 --- a/code/Q3BSP/Q3BSPFileImporter.cpp +++ b/code/Q3BSP/Q3BSPFileImporter.cpp @@ -616,7 +616,7 @@ bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *model // We'll leave it up to the user to figure out which extension the file has. aiString name; strncpy( name.data, pTexture->strName, sizeof name.data ); - name.length = strlen( name.data ); + name.length = (ai_uint32)strlen( name.data ); pMatHelper->AddProperty( &name, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) ); } } From 784a05651b175f7e8ae957d0fa269a915ec97947 Mon Sep 17 00:00:00 2001 From: Matthias Moulin Date: Thu, 16 Jan 2020 18:29:30 +0100 Subject: [PATCH 22/48] Suppressed MSVC++ warning C4267 '=': conversion from 'size_t' to 'ai_uint32', possible loss of data --- code/SMD/SMDLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/SMD/SMDLoader.cpp b/code/SMD/SMDLoader.cpp index 7eb6b18d1..aa1f26cc8 100644 --- a/code/SMD/SMDLoader.cpp +++ b/code/SMD/SMDLoader.cpp @@ -616,7 +616,7 @@ void SMDImporter::CreateOutputMaterials() { if (aszTextures[iMat].length()) { ::strncpy(szName.data, aszTextures[iMat].c_str(),MAXLEN-1); - szName.length = aszTextures[iMat].length(); + szName.length = (ai_uint32)aszTextures[iMat].length(); pcMat->AddProperty(&szName,AI_MATKEY_TEXTURE_DIFFUSE(0)); } } From bdc10aa336a11344fd76919b8f3c640f571f57be Mon Sep 17 00:00:00 2001 From: Matthias Moulin Date: Thu, 16 Jan 2020 18:30:11 +0100 Subject: [PATCH 23/48] Suppressed MSVC++ warning C4267 '=': conversion from 'size_t' to 'ai_uint32', possible loss of data --- code/Unreal/UnrealLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Unreal/UnrealLoader.cpp b/code/Unreal/UnrealLoader.cpp index 0bd4650d0..00b6b812d 100644 --- a/code/Unreal/UnrealLoader.cpp +++ b/code/Unreal/UnrealLoader.cpp @@ -403,7 +403,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile, // set color and name mat->AddProperty(&color,1,AI_MATKEY_COLOR_DIFFUSE); - s.length = ::strlen(s.data); + s.length = (ai_uint32)::strlen(s.data); mat->AddProperty(&s,AI_MATKEY_NAME); // set texture, if any From 986c18501a16dd05a1789cd71e5197e648e96053 Mon Sep 17 00:00:00 2001 From: Matthias Moulin Date: Thu, 16 Jan 2020 18:31:44 +0100 Subject: [PATCH 24/48] Suppressed MSVC++ warning C4267 '=': conversion from 'size_t' to 'ai_uint32', possible loss of data --- code/X/XFileImporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/X/XFileImporter.cpp b/code/X/XFileImporter.cpp index be7256d5c..122033b08 100644 --- a/code/X/XFileImporter.cpp +++ b/code/X/XFileImporter.cpp @@ -211,7 +211,7 @@ aiNode* XFileImporter::CreateNodes( aiScene* pScene, aiNode* pParent, const XFil // create node aiNode* node = new aiNode; - node->mName.length = pNode->mName.length(); + node->mName.length = (ai_uint32)pNode->mName.length(); node->mParent = pParent; memcpy( node->mName.data, pNode->mName.c_str(), pNode->mName.length()); node->mName.data[node->mName.length] = 0; From 25a11ac10168c74a53495ff31691079f555dc757 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 17 Jan 2020 13:33:50 +0100 Subject: [PATCH 25/48] Update appveyor.yml Try to enable parallel build. --- appveyor.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 857ddd849..61ec49f8f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -57,9 +57,8 @@ before_build: - echo NUMBER_OF_PROCESSORS=%NUMBER_OF_PROCESSORS% - ruby scripts\AppVeyor\mtime_cache -g scripts\AppVeyor\cacheglobs.txt -c bin\.mtime_cache\cache.json -build: - parallel: true - project: Assimp.sln +build_script: + cmake --build . -- /maxcpucount:2 after_build: - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" ( From 6970e70dbb48e82f0a0c4a1569706ae518d95ae0 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Fri, 17 Jan 2020 08:27:52 -0500 Subject: [PATCH 26/48] [MDL] Updated header to use when checking file size. (Redone) This is needed since it's possible to have an MDL sequence group file that has a size less than the Quake 1 MDL header. --- code/MDL/MDLLoader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/MDL/MDLLoader.cpp b/code/MDL/MDLLoader.cpp index 57a6bda95..eb629d35a 100644 --- a/code/MDL/MDLLoader.cpp +++ b/code/MDL/MDLLoader.cpp @@ -179,9 +179,9 @@ void MDLImporter::InternReadFile( const std::string& pFile, } // This should work for all other types of MDL files, too ... - // the quake header is one of the smallest, afaik + // the HL1 sequence group header is one of the smallest, afaik iFileSize = (unsigned int)file->FileSize(); - if( iFileSize < sizeof(MDL::Header)) { + if( iFileSize < sizeof(MDL::HalfLife::SequenceHeader_HL1)) { throw DeadlyImportError( "MDL File is too small."); } From cc40963e1a9a4734180246096ca2f81a80e15c24 Mon Sep 17 00:00:00 2001 From: Matthias Moulin Date: Fri, 17 Jan 2020 16:07:50 +0100 Subject: [PATCH 27/48] Removed name of unreferenced local variable in catch block --- code/FBX/FBXConverter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/FBX/FBXConverter.cpp b/code/FBX/FBXConverter.cpp index 5b34868ba..d672afe56 100644 --- a/code/FBX/FBXConverter.cpp +++ b/code/FBX/FBXConverter.cpp @@ -1564,7 +1564,7 @@ namespace Assimp { bone_map.clear(); } - catch (std::exception&e) { + catch (std::exception&) { std::for_each(bones.begin(), bones.end(), Util::delete_fun()); throw; } From d2e4d47908a5d1535493cc3106377adab393ab3c Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 17 Jan 2020 19:32:59 +0100 Subject: [PATCH 28/48] Update appveyor.yml fix build folder --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 61ec49f8f..299f42df6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -58,7 +58,7 @@ before_build: - ruby scripts\AppVeyor\mtime_cache -g scripts\AppVeyor\cacheglobs.txt -c bin\.mtime_cache\cache.json build_script: - cmake --build . -- /maxcpucount:2 + cmake --build . --config Release -- /maxcpucount:2 after_build: - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" ( From 247667233dac4ce9d164f1a876f1ad32390f8e12 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Sat, 18 Jan 2020 14:58:19 -0500 Subject: [PATCH 29/48] Fixed memory leak in MDLLoader.cpp If one of the MDL importer implementations throw an exception, the memory allocated at mBuffer may never be freed. This fix should prevent further memory leaks. --- code/MDL/MDLLoader.cpp | 167 ++++++++++++++++++++++------------------- 1 file changed, 89 insertions(+), 78 deletions(-) diff --git a/code/MDL/MDLLoader.cpp b/code/MDL/MDLLoader.cpp index eb629d35a..78dc9d77f 100644 --- a/code/MDL/MDLLoader.cpp +++ b/code/MDL/MDLLoader.cpp @@ -184,88 +184,99 @@ void MDLImporter::InternReadFile( const std::string& pFile, if( iFileSize < sizeof(MDL::HalfLife::SequenceHeader_HL1)) { throw DeadlyImportError( "MDL File is too small."); } - - // Allocate storage and copy the contents of the file to a memory buffer - mBuffer =new unsigned char[iFileSize+1]; - file->Read( (void*)mBuffer, 1, iFileSize); - - // Append a binary zero to the end of the buffer. - // this is just for safety that string parsing routines - // find the end of the buffer ... - mBuffer[iFileSize] = '\0'; - const uint32_t iMagicWord = *((uint32_t*)mBuffer); - - // Determine the file subtype and call the appropriate member function - - // Original Quake1 format - if (AI_MDL_MAGIC_NUMBER_BE == iMagicWord || AI_MDL_MAGIC_NUMBER_LE == iMagicWord) { - ASSIMP_LOG_DEBUG("MDL subtype: Quake 1, magic word is IDPO"); - iGSFileVersion = 0; - InternReadFile_Quake1(); - } - // GameStudio A MDL2 format - used by some test models that come with 3DGS - else if (AI_MDL_MAGIC_NUMBER_BE_GS3 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS3 == iMagicWord) { - ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A2, magic word is MDL2"); - iGSFileVersion = 2; - InternReadFile_Quake1(); - } - // GameStudio A4 MDL3 format - else if (AI_MDL_MAGIC_NUMBER_BE_GS4 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS4 == iMagicWord) { - ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A4, magic word is MDL3"); - iGSFileVersion = 3; - InternReadFile_3DGS_MDL345(); - } - // GameStudio A5+ MDL4 format - else if (AI_MDL_MAGIC_NUMBER_BE_GS5a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS5a == iMagicWord) { - ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A4, magic word is MDL4"); - iGSFileVersion = 4; - InternReadFile_3DGS_MDL345(); - } - // GameStudio A5+ MDL5 format - else if (AI_MDL_MAGIC_NUMBER_BE_GS5b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS5b == iMagicWord) { - ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A5, magic word is MDL5"); - iGSFileVersion = 5; - InternReadFile_3DGS_MDL345(); - } - // GameStudio A7 MDL7 format - else if (AI_MDL_MAGIC_NUMBER_BE_GS7 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS7 == iMagicWord) { - ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A7, magic word is MDL7"); - iGSFileVersion = 7; - InternReadFile_3DGS_MDL7(); - } - // IDST/IDSQ Format (CS:S/HL^2, etc ...) - else if (AI_MDL_MAGIC_NUMBER_BE_HL2a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2a == iMagicWord || - AI_MDL_MAGIC_NUMBER_BE_HL2b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2b == iMagicWord) - { - iGSFileVersion = 0; - - HalfLife::HalfLifeMDLBaseHeader *pHeader = (HalfLife::HalfLifeMDLBaseHeader *)mBuffer; - if (pHeader->version == AI_MDL_HL1_VERSION) - { - ASSIMP_LOG_DEBUG("MDL subtype: Half-Life 1/Goldsrc Engine, magic word is IDST/IDSQ"); - InternReadFile_HL1(pFile, iMagicWord); + + // delete the file buffer and cleanup. + auto DeleteBufferAndCleanup = [&]() { + if (mBuffer) { + delete mBuffer; + mBuffer = nullptr; } - else - { - ASSIMP_LOG_DEBUG("MDL subtype: Source(tm) Engine, magic word is IDST/IDSQ"); - InternReadFile_HL2(); + AI_DEBUG_INVALIDATE_PTR(pIOHandler); + AI_DEBUG_INVALIDATE_PTR(pScene); + }; + + try { + // Allocate storage and copy the contents of the file to a memory buffer + mBuffer = new unsigned char[iFileSize+1]; + file->Read( (void*)mBuffer, 1, iFileSize); + + // Append a binary zero to the end of the buffer. + // this is just for safety that string parsing routines + // find the end of the buffer ... + mBuffer[iFileSize] = '\0'; + const uint32_t iMagicWord = *((uint32_t*)mBuffer); + + // Determine the file subtype and call the appropriate member function + + // Original Quake1 format + if (AI_MDL_MAGIC_NUMBER_BE == iMagicWord || AI_MDL_MAGIC_NUMBER_LE == iMagicWord) { + ASSIMP_LOG_DEBUG("MDL subtype: Quake 1, magic word is IDPO"); + iGSFileVersion = 0; + InternReadFile_Quake1(); } - } - else { - // print the magic word to the log file - throw DeadlyImportError( "Unknown MDL subformat " + pFile + - ". Magic word (" + std::string((char*)&iMagicWord,4) + ") is not known"); - } + // GameStudio A MDL2 format - used by some test models that come with 3DGS + else if (AI_MDL_MAGIC_NUMBER_BE_GS3 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS3 == iMagicWord) { + ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A2, magic word is MDL2"); + iGSFileVersion = 2; + InternReadFile_Quake1(); + } + // GameStudio A4 MDL3 format + else if (AI_MDL_MAGIC_NUMBER_BE_GS4 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS4 == iMagicWord) { + ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A4, magic word is MDL3"); + iGSFileVersion = 3; + InternReadFile_3DGS_MDL345(); + } + // GameStudio A5+ MDL4 format + else if (AI_MDL_MAGIC_NUMBER_BE_GS5a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS5a == iMagicWord) { + ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A4, magic word is MDL4"); + iGSFileVersion = 4; + InternReadFile_3DGS_MDL345(); + } + // GameStudio A5+ MDL5 format + else if (AI_MDL_MAGIC_NUMBER_BE_GS5b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS5b == iMagicWord) { + ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A5, magic word is MDL5"); + iGSFileVersion = 5; + InternReadFile_3DGS_MDL345(); + } + // GameStudio A7 MDL7 format + else if (AI_MDL_MAGIC_NUMBER_BE_GS7 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS7 == iMagicWord) { + ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A7, magic word is MDL7"); + iGSFileVersion = 7; + InternReadFile_3DGS_MDL7(); + } + // IDST/IDSQ Format (CS:S/HL^2, etc ...) + else if (AI_MDL_MAGIC_NUMBER_BE_HL2a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2a == iMagicWord || + AI_MDL_MAGIC_NUMBER_BE_HL2b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2b == iMagicWord) + { + iGSFileVersion = 0; - // Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system - pScene->mRootNode->mTransformation = aiMatrix4x4(1.f,0.f,0.f,0.f, - 0.f,0.f,1.f,0.f,0.f,-1.f,0.f,0.f,0.f,0.f,0.f,1.f); + HalfLife::HalfLifeMDLBaseHeader *pHeader = (HalfLife::HalfLifeMDLBaseHeader *)mBuffer; + if (pHeader->version == AI_MDL_HL1_VERSION) + { + ASSIMP_LOG_DEBUG("MDL subtype: Half-Life 1/Goldsrc Engine, magic word is IDST/IDSQ"); + InternReadFile_HL1(pFile, iMagicWord); + } + else + { + ASSIMP_LOG_DEBUG("MDL subtype: Source(tm) Engine, magic word is IDST/IDSQ"); + InternReadFile_HL2(); + } + } + else { + // print the magic word to the log file + throw DeadlyImportError( "Unknown MDL subformat " + pFile + + ". Magic word (" + std::string((char*)&iMagicWord,4) + ") is not known"); + } - // delete the file buffer and cleanup - delete [] mBuffer; - mBuffer= nullptr; - AI_DEBUG_INVALIDATE_PTR(pIOHandler); - AI_DEBUG_INVALIDATE_PTR(pScene); + // Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system + pScene->mRootNode->mTransformation = aiMatrix4x4(1.f,0.f,0.f,0.f, + 0.f,0.f,1.f,0.f,0.f,-1.f,0.f,0.f,0.f,0.f,0.f,1.f); + + DeleteBufferAndCleanup(); + } catch(...) { + DeleteBufferAndCleanup(); + throw; + } } // ------------------------------------------------------------------------------------------------ From b74562f8a08ab889e10b5f37cfac3b957cce52f8 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Sat, 18 Jan 2020 15:16:03 -0500 Subject: [PATCH 30/48] Fixed delete operator. --- code/MDL/MDLLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/MDL/MDLLoader.cpp b/code/MDL/MDLLoader.cpp index 78dc9d77f..0c80abfc3 100644 --- a/code/MDL/MDLLoader.cpp +++ b/code/MDL/MDLLoader.cpp @@ -188,7 +188,7 @@ void MDLImporter::InternReadFile( const std::string& pFile, // delete the file buffer and cleanup. auto DeleteBufferAndCleanup = [&]() { if (mBuffer) { - delete mBuffer; + delete [] mBuffer; mBuffer = nullptr; } AI_DEBUG_INVALIDATE_PTR(pIOHandler); From 0c228806f707ff640d4df0cc85ee9f667b44cdef Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Fri, 17 Jan 2020 14:17:26 +0200 Subject: [PATCH 31/48] Add all shipped .blend files to unit tests --- test/unit/utBlenderImportExport.cpp | 172 ++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) diff --git a/test/unit/utBlenderImportExport.cpp b/test/unit/utBlenderImportExport.cpp index b2d268497..f6d557e0c 100644 --- a/test/unit/utBlenderImportExport.cpp +++ b/test/unit/utBlenderImportExport.cpp @@ -60,3 +60,175 @@ public: TEST_F( utBlenderImporterExporter, importBlenFromFileTest ) { EXPECT_TRUE( importerTest() ); } + + +TEST( utBlenderImporter, import4cubes ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/4Cubes4Mats_248.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, import269_regress1 ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/blender_269_regress1.blend", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST( utBlenderImporter, importBlenderDefault248 ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_248.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, importBlenderDefault250 ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_250.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, importBlenderDefault250Compressed ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_250_Compressed.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, importBlenderDefault262 ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_262.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, importBlenderDefault269 ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_269.blend", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST( utBlenderImporter, importBlenderDefault271 ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_271.blend", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST( utBlenderImporter, importCubeHierarchy_248 ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/CubeHierarchy_248.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, importHuman ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/HUMAN.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, importMirroredCube_252 ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/MirroredCube_252.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, importNoisyTexturedCube_VoronoiGlob_248 ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/NoisyTexturedCube_VoronoiGlob_248.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, importSmoothVsSolidCube_248 ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/SmoothVsSolidCube_248.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, importSuzanne_248 ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/Suzanne_248.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, importSuzanneSubdiv_252 ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/SuzanneSubdiv_252.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, importTexturedCube_ImageGlob_248 ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedCube_ImageGlob_248.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, importTexturedPlane_ImageUv_248 ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedPlane_ImageUv_248.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, importTexturedPlane_ImageUvPacked_248 ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedPlane_ImageUvPacked_248.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, importTorusLightsCams_250_compressed ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TorusLightsCams_250_compressed.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, import_yxa_1 ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/yxa_1.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, importBob ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/BLEND/Bob.blend", aiProcess_ValidateDataStructure); + // FIXME: this is probably not right, loading this should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST( utBlenderImporter, importFleurOptonl ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/BLEND/fleurOptonl.blend", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} From 6e4b2086591d0e0a9d576f948b53875693bc30a2 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Mon, 20 Jan 2020 14:14:17 +0200 Subject: [PATCH 32/48] Revert QuickDraw--Chasis.lwo to working version --- .../LWO2/LWSReferences/QuickDraw--Chasis.lwo | Bin 90970 -> 90974 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/models-nonbsd/LWO/LWO2/LWSReferences/QuickDraw--Chasis.lwo b/test/models-nonbsd/LWO/LWO2/LWSReferences/QuickDraw--Chasis.lwo index d8fbd397b4e6dd429ae315f36796ecb83a3a73c4..056ad233cf161cb125c1b9a63ff83f36082dc171 100644 GIT binary patch delta 36 qcmcb0jP>3z)(uv77 Date: Mon, 20 Jan 2020 14:22:18 +0200 Subject: [PATCH 33/48] Revert broken FBX models to working versions --- .../models-nonbsd/FBX/2013_BINARY/Granate.fbx | Bin 42991 -> 42992 bytes test/models-nonbsd/FBX/2013_BINARY/duck.fbx | Bin 960527 -> 960528 bytes test/models-nonbsd/FBX/2013_BINARY/jeep1.fbx | Bin 155791 -> 155792 bytes .../FBX/2013_BINARY/kwxport_test_vcolors.fbx | Bin 616062 -> 617536 bytes .../FBX/2013_BINARY/mar_rifle.fbx | Bin 247144 -> 247184 bytes .../models-nonbsd/FBX/2013_BINARY/pyramob.fbx | Bin 846765 -> 846768 bytes 6 files changed, 0 insertions(+), 0 deletions(-) diff --git a/test/models-nonbsd/FBX/2013_BINARY/Granate.fbx b/test/models-nonbsd/FBX/2013_BINARY/Granate.fbx index d1efbf2f677a05e363af9978a4739b06a70bf17e..1e25c223b568063a24adc00e05b7a49731b7d7ca 100644 GIT binary patch delta 16 YcmaEVp6SDRrVWoh7DT^6-+kpfSGXXI(5VHU=D-g2*F*^`*05K;Ja{)0o5c2>r@AfH+ H`Knm}bpRhK delta 69 zcmbPm!K(j)Rl^p>DT~{uE@lK`CLm@8Viq7~1!6WJW(Q&pAm#*OE+FOxVjdvo-9B|O HUo{H=XgVJ% diff --git a/test/models-nonbsd/FBX/2013_BINARY/jeep1.fbx b/test/models-nonbsd/FBX/2013_BINARY/jeep1.fbx index 33607b99382b3eda2d49cb789e105f1c34148be9..8d35f7f1699bda436ff419d105b1d73bf505f74f 100644 GIT binary patch delta 21 dcmeA_$T{I4XG06)7N!k$jJ(@7*fHH#1OQ%R2oeAQ delta 19 bcmbPmkhA|FXG06)7N!k$+c(-V-B$zvQ%(p4 diff --git a/test/models-nonbsd/FBX/2013_BINARY/kwxport_test_vcolors.fbx b/test/models-nonbsd/FBX/2013_BINARY/kwxport_test_vcolors.fbx index 686d273eca798d6e6d5f7caecaae2b04892f904d..f3cd463e224fb95f53aea9d1d79a012a2c8998d3 100644 GIT binary patch delta 8515 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 diff --git a/test/models-nonbsd/FBX/2013_BINARY/mar_rifle.fbx b/test/models-nonbsd/FBX/2013_BINARY/mar_rifle.fbx index 5e5d05118919368ac32b5e2b18981cc61e8b4ff2..96431196c9dc045ba7ac208e25800199fcfca6f4 100644 GIT binary patch delta 293 zcmaFS#Xq5&e}hCUBkyL3SfL~qUM_Cl%{u!(Gcoc`PJAJ<+4ztWH&8D0thfY3F7GKw zZgb)bL3>8t?M3R0mo(Wynz*=lw|fLKss{o^^A|B5=VjvM-EOvl(WDM2kfq18pNE;3 zi($IqT1KhK4(y!U{j8Z*+W>V6@o@0-ZvR)##1jNm$aRY8A}bp&FUZ90ch58Z0ot|w z<|QU>W+46KDw8({P>P3#gNK`gi-(hoce>R*CR0Y<>G}7VQo-)qe(fGp4wD#Akq|Gx zq>!krm^2Vc2#E>u^7Bp)d&pD>H0bz4rglvr?Z?f0iw8(+NHA+N0_k8$W=^1m(_^HW Qm4T-5@NRFEW`4dB0HuLSS^xk5 delta 228 zcmbQx&Hti{e}hEqX31EgBqlEI&HDR4Gi_ErWX8QY>a4f~NTl>BP$ct(p#Ao0b;e7Y zEL_}NT-!qe8Px-~*DPW@&b!@p1EWdZ_9{K5{XEQE42+WvHI=rk;7sV(#rdB0P%M0o1-3sQ>@~ delta 64 zcmdmR-FWSF Date: Mon, 20 Jan 2020 14:27:06 +0200 Subject: [PATCH 34/48] Revert broken HMP test model to working version --- .../models-nonbsd/HMP/terrain_withtexture.hmp | Bin 605686 -> 605688 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/models-nonbsd/HMP/terrain_withtexture.hmp b/test/models-nonbsd/HMP/terrain_withtexture.hmp index aa4a2e129cc6d15cd11466ddf885607a2c23515b..b78b32917e9c483665ea637cea0c9ac121301b0e 100644 GIT binary patch delta 49 zcmezNTjj@Zm4+6^Elk{>7E`H&fiS%8=oh}nRceY@vFjy delta 45 vcmezITjkqtm4+6^Elk{>w)1>qvU}g|{g4@mS%8=oh}nRceY^KVj Date: Mon, 20 Jan 2020 14:30:51 +0200 Subject: [PATCH 35/48] Revert broken 3DS test model to working version --- test/models-nonbsd/3DS/pyramob.3DS | Bin 693758 -> 693769 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/models-nonbsd/3DS/pyramob.3DS b/test/models-nonbsd/3DS/pyramob.3DS index f4f5af4f3487724d718a0e147adeb5dd0d4a3c5c..c880bdf43aa5c41c923916b42e24a74da1d36fb6 100644 GIT binary patch delta 145 zcmeyjTB~!7RznM83sVbo3rh>@7B&qpc3v)a1`aOX>AGHQs=B;ff?PsC0X{A+E>0lL z&&3U7u`>v8@c>!u41!#|Ko&cL5KxwPdyN-cpE}S0UZ4rQ)A@_o+_`}qP9T?`mz%de hzK9Ko*@2j2dwdb6jx8ha_U`qZKUjfu^H$F42LK}y8^{0v delta 104 zcmeBNqxEmKRznM83sVbo3rh>@7B&qpRxWl14zB6?UTmt>MQlLK4#XVWGm1EMY`0Hc&-sIOd*4>h>IVQd Cvm0{& From e876afeaab2791ff908388288939626ff292016a Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Mon, 20 Jan 2020 14:33:18 +0200 Subject: [PATCH 36/48] Revert broken XGL test model to working version --- test/models/XGL/Spider_ascii.zgl | Bin 59944 -> 59945 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/models/XGL/Spider_ascii.zgl b/test/models/XGL/Spider_ascii.zgl index 218322dc66e2fa7ed208fa087caa7ec28a9c99fa..3816eae879e58b5aa4e77d95087a98027e0d2dd4 100644 GIT binary patch delta 16 YcmZ2+g?Z%_<_&eJjJ%ucQdhMA06`T8WdHyG delta 14 WcmZ2^g?Ysl<_&eJo9k0owEzG&p$Aw1 From 808a0a54129e8e091bfc33bad0d5f4375000bd0a Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Mon, 20 Jan 2020 14:41:25 +0200 Subject: [PATCH 37/48] Revert broken STL test model to working version --- test/models/STL/3DSMaxExport.STL | Bin 100083 -> 100084 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/models/STL/3DSMaxExport.STL b/test/models/STL/3DSMaxExport.STL index d420fd6e7ab7d46d06d4577f621c1730e7b6e5ad..2576dbb7b2883bdd1058d272320dc482bd486023 100644 GIT binary patch delta 16 Ycmey|%l4(0ZA0m5M&8Y(tLtt907UKx7ytkO delta 14 Wcmey;%l5gKZA0nm&1I|WZUX>1 Date: Mon, 20 Jan 2020 14:42:25 +0200 Subject: [PATCH 38/48] Revert broken terragen model to working version --- test/models/TER/RealisticTerrain_Large.ter | Bin 526412 -> 526424 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/models/TER/RealisticTerrain_Large.ter b/test/models/TER/RealisticTerrain_Large.ter index d8613d1c54ada137aa8233807638f65c19af1625..f51986ac8c34f4a46c738712813e2ac08afd17a9 100644 GIT binary patch delta 109 zcmX>zLE**(g$=*fGV*TzwRU*}Bk%TwdW<~*OuW3?b?X^#c>x93PcibvGxD~JYBFsX z)ntB>4HWx1g*j#)kPZ!I(d7oxO>r#M`9L*)&$4X)dzO{&IFQXfm2ErsRQB{dpnMTC H$1N5Bsr)7v delta 85 zcmV-b0IL7kkRZ&EAh7zav-_>5fVZPA0gO<$F@FKtO1BKk0S;e>8z};}8z}?iYqpgG rT)wwmQv@vww~Jl`dvAva&IGpy&IJy~hZdCvw-%KLXKuHC0|?p#ZAK#3 From 1eeecb7ca74f23a05e6c1564200aff67076cf9d7 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Mon, 20 Jan 2020 15:30:49 +0200 Subject: [PATCH 39/48] Revert broken Q3D test models to working versions --- test/models/Q3D/WusonOrange.q3o | Bin 144224 -> 144230 bytes test/models/Q3D/WusonOrange.q3s | Bin 144430 -> 144436 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/test/models/Q3D/WusonOrange.q3o b/test/models/Q3D/WusonOrange.q3o index 9f99fd0e46db161b404364b8532937898a467940..78394d799c6b3c548bf5c19aaafba78cf1be991f 100644 GIT binary patch delta 75 zcmaFxjN{oej)pCa&NiaFTnr5SKr8^IL44lrp*D=gEV3Xr9}ovaaVSU*hy_9P_D2qk Gb)NthV+^4H delta 69 zcmaF%jN`#Gj)pCa&Nf0^3=I50EC8i})blT?`Na delta 69 zcmdn;f@9qaj)pCa&Nf0^3=I50EC8i})bR From 8619ff55b6d29176f4113fec3baf02ec0552947a Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 13:05:02 +0200 Subject: [PATCH 40/48] Revert broken .X test model to working version --- test/models/X/fromtruespace_bin32.x | Bin 372304 -> 372321 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/models/X/fromtruespace_bin32.x b/test/models/X/fromtruespace_bin32.x index d09fc15644985294205d1788cef888662e778bbd..0333a1a5d072709641d097e3c595d436b47a4caf 100644 GIT binary patch delta 258 zcmca`N9^Gpu?>B`jJ%usd`nI;@=m{A!Q3s%%f-OJ1;oq@3=H`|dLj_>ZeJkIn9d^! zlAFxQz%U7jLGpZ1KJRon6~=T`kTghY0#q8r2eHk8G)OtfSl;%UHsB`oBMrBPELPV!Q3s(#lXM?#LNr~4EaEMA`owHtYl8-5eKp+b22bY z0%DLXACy0xv5h%h3CICSOn^!Pxge%FkOrv*nb^KTg%OCEwr@~jHVC1EWk8FVzT0kZ JIl^-HB><5~EMfov From 963d47574808d5b618e3875c544708666aa209b1 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 13:42:12 +0200 Subject: [PATCH 41/48] Add MD3 importer unit tests --- test/CMakeLists.txt | 1 + test/unit/ImportExport/utMD3Importer.cpp | 73 ++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 test/unit/ImportExport/utMD3Importer.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3d382490c..f5e87b2b6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -129,6 +129,7 @@ SET( IMPORTERS unit/ImportExport/utNFFImportExport.cpp unit/ImportExport/utXGLImportExport.cpp unit/ImportExport/utMD2Importer.cpp + unit/ImportExport/utMD3Importer.cpp unit/ImportExport/utMD5Importer.cpp unit/ImportExport/utMDLImporter.cpp unit/ImportExport/MDL/MDLHL1TestFiles.h diff --git a/test/unit/ImportExport/utMD3Importer.cpp b/test/unit/ImportExport/utMD3Importer.cpp new file mode 100644 index 000000000..212fb6338 --- /dev/null +++ b/test/unit/ImportExport/utMD3Importer.cpp @@ -0,0 +1,73 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2020, assimp team + + + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--------------------------------------------------------------------------- +*/ + +#include "UnitTestPCH.h" + +#include +#include +#include + + +using namespace Assimp; + + + +TEST(utMD3Importer, importWatercan) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD3/watercan.md3", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utMD3Importer, importWatercan_dmg) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD3/watercan_dmg.md3", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utMD3Importer, importEuropean_fnt_v2) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD3/q3root/models/mapobjects/kt_kubalwagon/european_fnt_v2.md3", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} From 2875f7fd5f04a5d541b481b867c1de1f636aa961 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 13:45:40 +0200 Subject: [PATCH 42/48] Refactor XGL unit test --- test/unit/ImportExport/utXGLImportExport.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/test/unit/ImportExport/utXGLImportExport.cpp b/test/unit/ImportExport/utXGLImportExport.cpp index 89e780e20..8f5c4bdfe 100644 --- a/test/unit/ImportExport/utXGLImportExport.cpp +++ b/test/unit/ImportExport/utXGLImportExport.cpp @@ -42,22 +42,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "UnitTestPCH.h" -#include "AbstractImportExportBase.h" #include #include + using namespace Assimp; -class utXGLImportExport : public AbstractImportExportBase { -public: - virtual bool importerTest() { - Assimp::Importer importer; - const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sample_official.xgl", 0); - return true; - return nullptr != scene; - } -}; -TEST_F(utXGLImportExport, importXGLFromFileTest) { - EXPECT_TRUE(importerTest()); +TEST(utXGLImporter, importSample_official) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sample_official.xgl", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); } + From 69284bdef931dc8134be93a0a629b10fcff7115a Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 13:50:11 +0200 Subject: [PATCH 43/48] Add more XGL unit tests --- test/unit/ImportExport/utXGLImportExport.cpp | 48 ++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/test/unit/ImportExport/utXGLImportExport.cpp b/test/unit/ImportExport/utXGLImportExport.cpp index 8f5c4bdfe..4cace2904 100644 --- a/test/unit/ImportExport/utXGLImportExport.cpp +++ b/test/unit/ImportExport/utXGLImportExport.cpp @@ -49,9 +49,57 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; +TEST(utXGLImporter, importBCN_Epileptic) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/BCN_Epileptic.zgl", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXGLImporter, importCubesWithAlpha) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/cubes_with_alpha.zgl", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + TEST(utXGLImporter, importSample_official) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sample_official.xgl", aiProcess_ValidateDataStructure); ASSERT_NE(nullptr, scene); } + +TEST(utXGLImporter, importSample_official_asxml) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sample_official_asxml.xml", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXGLImporter, importSphereWithMatGloss) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sphere_with_mat_gloss_10pc.zgl", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXGLImporter, importSpiderASCII) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/Spider_ascii.zgl", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXGLImporter, importWuson) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/Wuson.zgl", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXGLImporter, importWusonDXF) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/wuson_dxf.zgl", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} From 461f9923a7a70425d21f51f6903758034254d572 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 14:09:29 +0200 Subject: [PATCH 44/48] Refactor 3D import unit test --- test/unit/ut3DImportExport.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/test/unit/ut3DImportExport.cpp b/test/unit/ut3DImportExport.cpp index a3a3197cc..2d42d2829 100644 --- a/test/unit/ut3DImportExport.cpp +++ b/test/unit/ut3DImportExport.cpp @@ -42,23 +42,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "UnitTestPCH.h" -#include "SceneDiffer.h" -#include "AbstractImportExportBase.h" #include #include + using namespace Assimp; -class ut3DImportExport : public AbstractImportExportBase { -public: - virtual bool importerTest() { - Assimp::Importer importer; - const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/3D/box_a.3d", aiProcess_ValidateDataStructure ); - return nullptr != scene; - } -}; -TEST_F( ut3DImportExport, import3DFromFileTest ) { - EXPECT_TRUE( importerTest() ); +TEST(ut3DImportExport, importBoxA) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3D/box_a.3d", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); } From 0b776f16cb19c68655e5a135b0300cf190a51ffb Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 14:22:29 +0200 Subject: [PATCH 45/48] Add more 3D unit tests --- test/unit/ut3DImportExport.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/unit/ut3DImportExport.cpp b/test/unit/ut3DImportExport.cpp index 2d42d2829..922d8c747 100644 --- a/test/unit/ut3DImportExport.cpp +++ b/test/unit/ut3DImportExport.cpp @@ -55,3 +55,17 @@ TEST(ut3DImportExport, importBoxA) { const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3D/box_a.3d", aiProcess_ValidateDataStructure); ASSERT_NE(nullptr, scene); } + + +TEST(ut3DImportExport, importBoxD) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3D/box_d.3d", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(ut3DImportExport, importBoxUC) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3D/box.uc", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} From c407892c9c3f20ab292a79b0cc4c31c292167fca Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 14:43:20 +0200 Subject: [PATCH 46/48] Refactor AC unit test --- test/unit/utACImportExport.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/test/unit/utACImportExport.cpp b/test/unit/utACImportExport.cpp index 192de16a0..4bac8bd3b 100644 --- a/test/unit/utACImportExport.cpp +++ b/test/unit/utACImportExport.cpp @@ -42,23 +42,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "UnitTestPCH.h" -#include "SceneDiffer.h" -#include "AbstractImportExportBase.h" #include #include + using namespace Assimp; -class utACImportExport : public AbstractImportExportBase { -public: - virtual bool importerTest() { - Assimp::Importer importer; - const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/AC/Wuson.ac", aiProcess_ValidateDataStructure ); - return nullptr != scene; - } -}; -TEST_F( utACImportExport, importACFromFileTest ) { - EXPECT_TRUE( importerTest() ); +TEST(utACImportExport, importWuson) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/Wuson.ac", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); } + + From d4d19b7062dd1f3d20dd58e3cc76322b09feb9cf Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 14:48:37 +0200 Subject: [PATCH 47/48] Add more AC unit tests --- test/unit/utACImportExport.cpp | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/test/unit/utACImportExport.cpp b/test/unit/utACImportExport.cpp index 4bac8bd3b..8a685056d 100644 --- a/test/unit/utACImportExport.cpp +++ b/test/unit/utACImportExport.cpp @@ -50,6 +50,63 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; +TEST(utACImportExport, importClosedLine) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/closedLine.ac", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utACImportExport, importNoSurfaces) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/nosurfaces.ac", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utACImportExport, importOpenLine) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/openLine.ac", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utACImportExport, importSampleSubdiv) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/sample_subdiv.ac", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utACImportExport, importSphereWithLight) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/SphereWithLight.ac", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utACImportExport, importSphereWithLightUTF16) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/SphereWithLight_UTF16LE.ac", aiProcess_ValidateDataStructure); + // FIXME: this is probably wrong, loading the file should succeed + ASSERT_EQ(nullptr, scene); +} + + +TEST(utACImportExport, importSphereWithLightUTF8BOM) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/SphereWithLight_UTF8BOM.ac", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utACImportExport, importSphereWithLightUvScaling4X) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/SphereWithLightUvScaling4X.ac", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + TEST(utACImportExport, importWuson) { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/Wuson.ac", aiProcess_ValidateDataStructure); @@ -57,3 +114,9 @@ TEST(utACImportExport, importWuson) { } +TEST(utACImportExport, testFormatDetection) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/TestFormatDetection", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + From c2a74c61f40bbf0ea2a9464103fc746f3b039e8b Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 14:56:31 +0200 Subject: [PATCH 48/48] Add more X unit tests --- test/unit/utXImporterExporter.cpp | 77 +++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/test/unit/utXImporterExporter.cpp b/test/unit/utXImporterExporter.cpp index 53e156bcc..15e19cf01 100644 --- a/test/unit/utXImporterExporter.cpp +++ b/test/unit/utXImporterExporter.cpp @@ -67,3 +67,80 @@ TEST_F( utXImporterExporter, heap_overflow_in_tokenizer ) { Assimp::Importer importer; EXPECT_NO_THROW( importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/X/OV_GetNextToken", 0 ) ); } + + +TEST(utXImporter, importAnimTest) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/anim_test.x", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXImporter, importBCNEpileptic) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/BCN_Epileptic.X", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXImporter, importFromTrueSpaceBin32) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/fromtruespace_bin32.x", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXImporter, import_kwxport_test_cubewithvcolors) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/kwxport_test_cubewithvcolors.x", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXImporter, importTestCubeBinary) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test_cube_binary.x", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXImporter, importTestCubeCompressed) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test_cube_compressed.x", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXImporter, importTestCubeText) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test_cube_text.x", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXImporter, importTestWuson) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/Testwuson.X", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +TEST(utXImporter, TestFormatDetection) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/TestFormatDetection", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +#if 0 // FIXME: disabled because it leaks memory + + +TEST(utXImporter, importDwarf) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/X/dwarf.x", aiProcess_ValidateDataStructure); + ASSERT_NE(nullptr, scene); +} + + +#endif // 0 +