From 13a2f22835cfe4093860de3e3d33782f854a2e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc?= Date: Tue, 14 Jan 2020 16:26:24 +0100 Subject: [PATCH 01/13] Fix Assimp patch version to match the last bug fix release --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23b6f6d61..e14c4aa21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,7 @@ IF(HUNTER_ENABLED) add_definitions(-DASSIMP_USE_HUNTER) ENDIF(HUNTER_ENABLED) -PROJECT( Assimp VERSION 5.0.0 ) +PROJECT( Assimp VERSION 5.0.1 ) # All supported options ############################################### From 963d47574808d5b618e3875c544708666aa209b1 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 21 Jan 2020 13:42:12 +0200 Subject: [PATCH 02/13] 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 03/13] 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 04/13] 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 05/13] 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 06/13] 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 07/13] 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 08/13] 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 09/13] 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 + From 288a638a835ce3727d6c1c939b461e2956b5284d Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 22 Jan 2020 12:19:05 +0200 Subject: [PATCH 10/13] X: Only create animation key arrays if there are some keys --- code/X/XFileImporter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/X/XFileImporter.cpp b/code/X/XFileImporter.cpp index 122033b08..ff4ee1378 100644 --- a/code/X/XFileImporter.cpp +++ b/code/X/XFileImporter.cpp @@ -513,6 +513,7 @@ void XFileImporter::CreateAnimations( aiScene* pScene, const XFile::Scene* pData } else { // separate key sequences for position, rotation, scaling nbone->mNumPositionKeys = (unsigned int)bone->mPosKeys.size(); + if (nbone->mNumPositionKeys != 0) { nbone->mPositionKeys = new aiVectorKey[nbone->mNumPositionKeys]; for( unsigned int c = 0; c < nbone->mNumPositionKeys; ++c ) { aiVector3D pos = bone->mPosKeys[c].mValue; @@ -520,9 +521,11 @@ void XFileImporter::CreateAnimations( aiScene* pScene, const XFile::Scene* pData nbone->mPositionKeys[c].mTime = bone->mPosKeys[c].mTime; nbone->mPositionKeys[c].mValue = pos; } + } // rotation nbone->mNumRotationKeys = (unsigned int)bone->mRotKeys.size(); + if (nbone->mNumRotationKeys != 0) { nbone->mRotationKeys = new aiQuatKey[nbone->mNumRotationKeys]; for( unsigned int c = 0; c < nbone->mNumRotationKeys; ++c ) { aiMatrix3x3 rotmat = bone->mRotKeys[c].mValue.GetMatrix(); @@ -531,12 +534,15 @@ void XFileImporter::CreateAnimations( aiScene* pScene, const XFile::Scene* pData nbone->mRotationKeys[c].mValue = aiQuaternion( rotmat); nbone->mRotationKeys[c].mValue.w *= -1.0f; // needs quat inversion } + } // scaling nbone->mNumScalingKeys = (unsigned int)bone->mScaleKeys.size(); + if (nbone->mNumScalingKeys != 0) { nbone->mScalingKeys = new aiVectorKey[nbone->mNumScalingKeys]; for( unsigned int c = 0; c < nbone->mNumScalingKeys; c++) nbone->mScalingKeys[c] = bone->mScaleKeys[c]; + } // longest lasting key sequence determines duration if( bone->mPosKeys.size() > 0) From aee292e367658c5410d0a61a6ec1a4825c93eff6 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 22 Jan 2020 12:20:34 +0200 Subject: [PATCH 11/13] Whitespace --- code/X/XFileImporter.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/code/X/XFileImporter.cpp b/code/X/XFileImporter.cpp index ff4ee1378..70c6869b3 100644 --- a/code/X/XFileImporter.cpp +++ b/code/X/XFileImporter.cpp @@ -514,34 +514,34 @@ void XFileImporter::CreateAnimations( aiScene* pScene, const XFile::Scene* pData // separate key sequences for position, rotation, scaling nbone->mNumPositionKeys = (unsigned int)bone->mPosKeys.size(); if (nbone->mNumPositionKeys != 0) { - nbone->mPositionKeys = new aiVectorKey[nbone->mNumPositionKeys]; - for( unsigned int c = 0; c < nbone->mNumPositionKeys; ++c ) { - aiVector3D pos = bone->mPosKeys[c].mValue; + nbone->mPositionKeys = new aiVectorKey[nbone->mNumPositionKeys]; + for( unsigned int c = 0; c < nbone->mNumPositionKeys; ++c ) { + aiVector3D pos = bone->mPosKeys[c].mValue; - nbone->mPositionKeys[c].mTime = bone->mPosKeys[c].mTime; - nbone->mPositionKeys[c].mValue = pos; - } + nbone->mPositionKeys[c].mTime = bone->mPosKeys[c].mTime; + nbone->mPositionKeys[c].mValue = pos; + } } // rotation nbone->mNumRotationKeys = (unsigned int)bone->mRotKeys.size(); if (nbone->mNumRotationKeys != 0) { - nbone->mRotationKeys = new aiQuatKey[nbone->mNumRotationKeys]; - for( unsigned int c = 0; c < nbone->mNumRotationKeys; ++c ) { - aiMatrix3x3 rotmat = bone->mRotKeys[c].mValue.GetMatrix(); + nbone->mRotationKeys = new aiQuatKey[nbone->mNumRotationKeys]; + for( unsigned int c = 0; c < nbone->mNumRotationKeys; ++c ) { + aiMatrix3x3 rotmat = bone->mRotKeys[c].mValue.GetMatrix(); - nbone->mRotationKeys[c].mTime = bone->mRotKeys[c].mTime; - nbone->mRotationKeys[c].mValue = aiQuaternion( rotmat); - nbone->mRotationKeys[c].mValue.w *= -1.0f; // needs quat inversion - } + nbone->mRotationKeys[c].mTime = bone->mRotKeys[c].mTime; + nbone->mRotationKeys[c].mValue = aiQuaternion( rotmat); + nbone->mRotationKeys[c].mValue.w *= -1.0f; // needs quat inversion + } } // scaling nbone->mNumScalingKeys = (unsigned int)bone->mScaleKeys.size(); if (nbone->mNumScalingKeys != 0) { - nbone->mScalingKeys = new aiVectorKey[nbone->mNumScalingKeys]; - for( unsigned int c = 0; c < nbone->mNumScalingKeys; c++) - nbone->mScalingKeys[c] = bone->mScaleKeys[c]; + nbone->mScalingKeys = new aiVectorKey[nbone->mNumScalingKeys]; + for( unsigned int c = 0; c < nbone->mNumScalingKeys; c++) + nbone->mScalingKeys[c] = bone->mScaleKeys[c]; } // longest lasting key sequence determines duration From 1edb52c0de4006f7f0383670ef12aacedfd4edeb Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 22 Jan 2020 12:20:49 +0200 Subject: [PATCH 12/13] ScenePreprocessor: Assert some properties about animation channels --- code/Common/ScenePreprocessor.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/code/Common/ScenePreprocessor.cpp b/code/Common/ScenePreprocessor.cpp index 432a3d766..a47053de4 100644 --- a/code/Common/ScenePreprocessor.cpp +++ b/code/Common/ScenePreprocessor.cpp @@ -217,6 +217,7 @@ void ScenePreprocessor::ProcessAnimation (aiAnimation* anim) // No rotation keys? Generate a dummy track if (!channel->mNumRotationKeys) { + ai_assert(!channel->mRotationKeys); channel->mNumRotationKeys = 1; channel->mRotationKeys = new aiQuatKey[1]; aiQuatKey& q = channel->mRotationKeys[0]; @@ -225,10 +226,13 @@ void ScenePreprocessor::ProcessAnimation (aiAnimation* anim) q.mValue = rotation; ASSIMP_LOG_DEBUG("ScenePreprocessor: Dummy rotation track has been generated"); + } else { + ai_assert(channel->mRotationKeys); } // No scaling keys? Generate a dummy track if (!channel->mNumScalingKeys) { + ai_assert(!channel->mScalingKeys); channel->mNumScalingKeys = 1; channel->mScalingKeys = new aiVectorKey[1]; aiVectorKey& q = channel->mScalingKeys[0]; @@ -237,10 +241,13 @@ void ScenePreprocessor::ProcessAnimation (aiAnimation* anim) q.mValue = scaling; ASSIMP_LOG_DEBUG("ScenePreprocessor: Dummy scaling track has been generated"); + } else { + ai_assert(channel->mScalingKeys); } // No position keys? Generate a dummy track if (!channel->mNumPositionKeys) { + ai_assert(!channel->mPositionKeys); channel->mNumPositionKeys = 1; channel->mPositionKeys = new aiVectorKey[1]; aiVectorKey& q = channel->mPositionKeys[0]; @@ -249,6 +256,8 @@ void ScenePreprocessor::ProcessAnimation (aiAnimation* anim) q.mValue = position; ASSIMP_LOG_DEBUG("ScenePreprocessor: Dummy position track has been generated"); + } else { + ai_assert(channel->mPositionKeys); } } } From a74e13d6b27a08f314e701eaca910a3f5e247802 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 22 Jan 2020 12:22:08 +0200 Subject: [PATCH 13/13] Re-enable dwarf.x import test --- test/unit/utXImporterExporter.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/unit/utXImporterExporter.cpp b/test/unit/utXImporterExporter.cpp index 15e19cf01..2c6830978 100644 --- a/test/unit/utXImporterExporter.cpp +++ b/test/unit/utXImporterExporter.cpp @@ -132,15 +132,8 @@ TEST(utXImporter, TestFormatDetection) { } -#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 -