From 7e140ff912419a81aa3b0f5725f53d849e5c92e4 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Fri, 10 Jan 2020 13:50:16 +0200 Subject: [PATCH 01/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] [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 d2e4d47908a5d1535493cc3106377adab393ab3c Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 17 Jan 2020 19:32:59 +0100 Subject: [PATCH 27/27] 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" (