From 437958ef91920bde96ebd8481540406a33aaa947 Mon Sep 17 00:00:00 2001 From: Jackie9527 <80555200+Jackie9527@users.noreply.github.com> Date: Sat, 25 Feb 2023 10:10:35 +0800 Subject: [PATCH 1/8] bugfix fails to check if point in triangle. Signed-off-by: Jackie9527 <80555200+Jackie9527@users.noreply.github.com> --- code/Common/PolyTools.h | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/code/Common/PolyTools.h b/code/Common/PolyTools.h index 9837a2991..a5bd1090b 100644 --- a/code/Common/PolyTools.h +++ b/code/Common/PolyTools.h @@ -74,26 +74,8 @@ inline bool OnLeftSideOfLine2D(const T& p0, const T& p1,const T& p2) { * both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/ template inline bool PointInTriangle2D(const T& p0, const T& p1,const T& p2, const T& pp) { - // Point in triangle test using baryzentric coordinates - const aiVector2D v0 = p1 - p0; - const aiVector2D v1 = p2 - p0; - const aiVector2D v2 = pp - p0; - - double dot00 = v0 * v0; - double dot11 = v1 * v1; - const double dot01 = v0 * v1; - const double dot02 = v0 * v2; - const double dot12 = v1 * v2; - const double denom = dot00 * dot11 - dot01 * dot01; - if (denom == 0.0) { - return false; - } - - const double invDenom = 1.0 / denom; - dot11 = (dot11 * dot02 - dot01 * dot12) * invDenom; - dot00 = (dot00 * dot12 - dot01 * dot02) * invDenom; - - return (dot11 > 0) && (dot00 > 0) && (dot11 + dot00 < 1); + // pp should be left side of the three triangle side, by ccw arrow + return OnLeftSideOfLine2D(p0, p1, pp) && OnLeftSideOfLine2D(p1, p2, pp) && OnLeftSideOfLine2D(p2, p0, pp); } From 94d977354804608d29281a7e3e940b71aa148865 Mon Sep 17 00:00:00 2001 From: FeeshWyvern Date: Mon, 27 Feb 2023 20:02:34 -0800 Subject: [PATCH 2/8] Bug fix: Correctly set the name of the attributes. PR #3940 did not seem to update in Master? --- port/PyAssimp/pyassimp/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/port/PyAssimp/pyassimp/core.py b/port/PyAssimp/pyassimp/core.py index 35ad882b3..37beac886 100644 --- a/port/PyAssimp/pyassimp/core.py +++ b/port/PyAssimp/pyassimp/core.py @@ -211,7 +211,7 @@ def _init(self, target = None, parent = None): else: # starts with 'm' but not iterable - setattr(target, m, obj) + setattr(target, name, obj) logger.debug("Added " + name + " as self." + name + " (type: " + str(type(obj)) + ")") if _is_init_type(obj): From f9fcf33aaa639fbfd386631cb796ac66d01fef94 Mon Sep 17 00:00:00 2001 From: FeeshWyvern Date: Mon, 27 Feb 2023 20:06:05 -0800 Subject: [PATCH 3/8] Bug fix: We should not be accessing `mPrivate` according to structs.Scene and fixes a crash when `mPrivate` points to invalid data. --- port/PyAssimp/pyassimp/core.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/port/PyAssimp/pyassimp/core.py b/port/PyAssimp/pyassimp/core.py index 37beac886..edde8b29a 100644 --- a/port/PyAssimp/pyassimp/core.py +++ b/port/PyAssimp/pyassimp/core.py @@ -115,6 +115,10 @@ def _init(self, target = None, parent = None): if m.startswith("_"): continue + # We should not be accessing `mPrivate` according to structs.Scene. + if m == 'mPrivate': + continue + if m.startswith('mNum'): if 'm' + m[4:] in dirself: continue # will be processed later on From 424f53b4d6055abb582741377f900cbf5b7bdf9a Mon Sep 17 00:00:00 2001 From: Jackie9527 <80555200+Jackie9527@users.noreply.github.com> Date: Sat, 25 Feb 2023 10:08:40 +0800 Subject: [PATCH 4/8] bugfix remove duplicated data. Signed-off-by: Jackie9527 <80555200+Jackie9527@users.noreply.github.com> --- code/AssetLib/FBX/FBXConverter.cpp | 33 ++++++++++++++++----------- code/AssetLib/FBX/FBXDeformer.cpp | 12 ++++++---- code/AssetLib/FBX/FBXDocument.h | 9 ++++---- code/AssetLib/FBX/FBXMeshGeometry.cpp | 7 ++++-- code/AssetLib/FBX/FBXMeshGeometry.h | 9 ++++---- 5 files changed, 43 insertions(+), 27 deletions(-) diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp index d45919e10..e77dd2fc6 100644 --- a/code/AssetLib/FBX/FBXConverter.cpp +++ b/code/AssetLib/FBX/FBXConverter.cpp @@ -1176,15 +1176,23 @@ unsigned int FBXConverter::ConvertMeshSingleMaterial(const MeshGeometry &mesh, c std::vector animMeshes; for (const BlendShape *blendShape : mesh.GetBlendShapes()) { for (const BlendShapeChannel *blendShapeChannel : blendShape->BlendShapeChannels()) { - const std::vector &shapeGeometries = blendShapeChannel->GetShapeGeometries(); - for (size_t i = 0; i < shapeGeometries.size(); i++) { + const auto& shapeGeometries = blendShapeChannel->GetShapeGeometries(); + for (const ShapeGeometry *shapeGeometry : shapeGeometries) { aiAnimMesh *animMesh = aiCreateAnimMesh(out_mesh); - const ShapeGeometry *shapeGeometry = shapeGeometries.at(i); - const std::vector &curVertices = shapeGeometry->GetVertices(); - const std::vector &curNormals = shapeGeometry->GetNormals(); - const std::vector &curIndices = shapeGeometry->GetIndices(); + const auto &curVertices = shapeGeometry->GetVertices(); + const auto &curNormals = shapeGeometry->GetNormals(); + const auto &curIndices = shapeGeometry->GetIndices(); //losing channel name if using shapeGeometry->Name() - animMesh->mName.Set(FixAnimMeshName(blendShapeChannel->Name())); + // if blendShapeChannel Name is empty or don't have a ".", add geoMetryName; + auto aniName = FixAnimMeshName(blendShapeChannel->Name()); + auto geoMetryName = FixAnimMeshName(shapeGeometry->Name()); + if (aniName.empty()) { + aniName = geoMetryName; + } + else if (aniName.find('.') == aniName.npos) { + aniName += "." + geoMetryName; + } + animMesh->mName.Set(aniName); for (size_t j = 0; j < curIndices.size(); j++) { const unsigned int curIndex = curIndices.at(j); aiVector3D vertex = curVertices.at(j); @@ -1406,13 +1414,12 @@ unsigned int FBXConverter::ConvertMeshMultiMaterial(const MeshGeometry &mesh, co std::vector animMeshes; for (const BlendShape *blendShape : mesh.GetBlendShapes()) { for (const BlendShapeChannel *blendShapeChannel : blendShape->BlendShapeChannels()) { - const std::vector &shapeGeometries = blendShapeChannel->GetShapeGeometries(); - for (size_t i = 0; i < shapeGeometries.size(); i++) { + const auto& shapeGeometries = blendShapeChannel->GetShapeGeometries(); + for (const ShapeGeometry *shapeGeometry : shapeGeometries) { aiAnimMesh *animMesh = aiCreateAnimMesh(out_mesh); - const ShapeGeometry *shapeGeometry = shapeGeometries.at(i); - const std::vector &curVertices = shapeGeometry->GetVertices(); - const std::vector &curNormals = shapeGeometry->GetNormals(); - const std::vector &curIndices = shapeGeometry->GetIndices(); + const auto& curVertices = shapeGeometry->GetVertices(); + const auto& curNormals = shapeGeometry->GetNormals(); + const auto& curIndices = shapeGeometry->GetIndices(); animMesh->mName.Set(FixAnimMeshName(shapeGeometry->Name())); for (size_t j = 0; j < curIndices.size(); j++) { unsigned int curIndex = curIndices.at(j); diff --git a/code/AssetLib/FBX/FBXDeformer.cpp b/code/AssetLib/FBX/FBXDeformer.cpp index df134a401..1aab55ea9 100644 --- a/code/AssetLib/FBX/FBXDeformer.cpp +++ b/code/AssetLib/FBX/FBXDeformer.cpp @@ -154,8 +154,10 @@ BlendShape::BlendShape(uint64_t id, const Element& element, const Document& doc, for (const Connection* con : conns) { const BlendShapeChannel* const bspc = ProcessSimpleConnection(*con, false, "BlendShapeChannel -> BlendShape", element); if (bspc) { - blendShapeChannels.push_back(bspc); - continue; + auto pr = blendShapeChannels.insert(bspc); + if (!pr.second) { + FBXImporter::LogWarn("there is the same blendShapeChannel id ", bspc->ID()); + } } } } @@ -179,8 +181,10 @@ BlendShapeChannel::BlendShapeChannel(uint64_t id, const Element& element, const for (const Connection* con : conns) { const ShapeGeometry* const sg = ProcessSimpleConnection(*con, false, "Shape -> BlendShapeChannel", element); if (sg) { - shapeGeometries.push_back(sg); - continue; + auto pr = shapeGeometries.insert(sg); + if (!pr.second) { + FBXImporter::LogWarn("there is the same shapeGeometrie id ", sg->ID()); + } } } } diff --git a/code/AssetLib/FBX/FBXDocument.h b/code/AssetLib/FBX/FBXDocument.h index 8873d65fd..821d4d5cb 100644 --- a/code/AssetLib/FBX/FBXDocument.h +++ b/code/AssetLib/FBX/FBXDocument.h @@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define INCLUDED_AI_FBX_DOCUMENT_H #include +#include #include #include #include "FBXProperties.h" @@ -855,14 +856,14 @@ public: return fullWeights; } - const std::vector& GetShapeGeometries() const { + const std::unordered_set& GetShapeGeometries() const { return shapeGeometries; } private: float percent; WeightArray fullWeights; - std::vector shapeGeometries; + std::unordered_set shapeGeometries; }; /** DOM class for BlendShape deformers */ @@ -872,12 +873,12 @@ public: virtual ~BlendShape(); - const std::vector& BlendShapeChannels() const { + const std::unordered_set& BlendShapeChannels() const { return blendShapeChannels; } private: - std::vector blendShapeChannels; + std::unordered_set blendShapeChannels; }; /** DOM class for skin deformer clusters (aka sub-deformers) */ diff --git a/code/AssetLib/FBX/FBXMeshGeometry.cpp b/code/AssetLib/FBX/FBXMeshGeometry.cpp index ace4ad749..fcbaac169 100644 --- a/code/AssetLib/FBX/FBXMeshGeometry.cpp +++ b/code/AssetLib/FBX/FBXMeshGeometry.cpp @@ -69,13 +69,16 @@ Geometry::Geometry(uint64_t id, const Element& element, const std::string& name, } const BlendShape* const bsp = ProcessSimpleConnection(*con, false, "BlendShape -> Geometry", element); if (bsp) { - blendShapes.push_back(bsp); + auto pr = blendShapes.insert(bsp); + if (!pr.second) { + FBXImporter::LogWarn("there is the same blendShape id ", bsp->ID()); + } } } } // ------------------------------------------------------------------------------------------------ -const std::vector& Geometry::GetBlendShapes() const { +const std::unordered_set& Geometry::GetBlendShapes() const { return blendShapes; } diff --git a/code/AssetLib/FBX/FBXMeshGeometry.h b/code/AssetLib/FBX/FBXMeshGeometry.h index f4a1a2673..3d67ec567 100644 --- a/code/AssetLib/FBX/FBXMeshGeometry.h +++ b/code/AssetLib/FBX/FBXMeshGeometry.h @@ -62,7 +62,7 @@ public: /// @param name The name instance /// @param doc The document instance Geometry( uint64_t id, const Element& element, const std::string& name, const Document& doc ); - + /// @brief The class destructor, default. virtual ~Geometry() = default; @@ -72,11 +72,12 @@ public: /// @brief Get the BlendShape attached to this geometry or nullptr /// @return The blendshape arrays. - const std::vector& GetBlendShapes() const; + const std::unordered_set& GetBlendShapes() const; private: const Skin* skin; - std::vector blendShapes; + std::unordered_set blendShapes; + }; typedef std::vector MatIndexArray; @@ -112,7 +113,7 @@ public: /// @return The binomal vector. const std::vector& GetBinormals() const; - /// @brief Return list of faces - each entry denotes a face and specifies how many vertices it has. + /// @brief Return list of faces - each entry denotes a face and specifies how many vertices it has. /// Vertices are taken from the vertex data arrays in sequential order. /// @return The face indices vector. const std::vector& GetFaceIndexCounts() const; From e2063b3ba6d3bee5b115edc75b00cede072c251a Mon Sep 17 00:00:00 2001 From: Steve M Date: Fri, 17 Mar 2023 22:42:17 -0700 Subject: [PATCH 5/8] Revert to commit 13 May 2014 (08bacc7) Changes were introduced to the binary portion of this file at some point --- test/models/PLY/pond.0.ply | Bin 2171788 -> 2171857 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/models/PLY/pond.0.ply b/test/models/PLY/pond.0.ply index 02b7683cee063655c5b93ade29bc14b3f04e15dd..a45e0322d856bbef01c46b7a5a45a0570fae69be 100644 GIT binary patch delta 600 zcmWmBU1(Ba7zc2U?x^S3d#1~DXFKY!hJv+nyC_;s`h?oDY|NmWE{cL$Y~8hrsLZ-) z6h`e-td%qwG2F(2S7N2mQqWAI#`m{s zsX|*Q!~Vtf!FzT z?p?5ARV8oW`_Zt9M#Jj-Zam8+HI+-6<9ks5w~1RXLi>JhsuO;`$6cs_haYn7n2QdE zxYmO(R^e_}>z?g=mVstBzwCr{XZXrFs9fL|v@l=bH_pS_xVF9x+J9>^X}I)y)#5Su z%|glpm?0$-nvw-Ak8Ca^d>3GJN}zVw_eD6bgNsE$(Tm<=sNn5*%LZjb*206 z>K~clkLUWQO7sLGdYn2Mh^+2=f_%wiV7zd7#2_c&;K?;R-=Z(;G}5fov|>Y+_L!0i zWI?Zq2EFyZpU4UwV&W9`9tn%p-}5dk(zR&ur$p*cHEj5ZY;w5q#b$V7u90)Wvnq-1 zh3gJT1`clVNiVm;Uw5QetqMYhCf-O#apz{GiPJFJVorBM|21=Sb@Z`-nT`c4v!lp* Yoz_d$wHMl~>O-iN{Z?A`Hw};c2fN+ZF8}}l delta 471 zcmV;|0Vw{_$Akfl$Akf}+)T6GOuWsvni>Hpl83{r0k^}f0{nZIz$gPAx8EoOJP3yz zF$0GjF$A|9F$F=Ew_e8uO9q#!%?0V zhsve~x5}mm;6#V3>j$^1>j+~-w+}H1EE%^vN(r$`x9*h*dIYy=nh84yx22*9GEcYI z@d=Mhw`e^I&jGhMKMM6Lw=Qc6@o~2x-3r|cxBln~FW0v&zzY~Nw@32}&C9nHzYOPJ zxBVUs?|Fyqm<_k>m<|gHxA~$D;|{mou@1KJ9>IhY?l}w-HtlK5(~C z#tx~925z+b5 zI=3#79KAA^?ZX^ew@AbsuWGmWE*;BLx5R=SB?E`*g&nu*g&xGEx34Q7d|0 NhctvAw={$xou8R9&XoWF From 48d89622ee436bf30e7bf9e799802e51674c9e2e Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Thu, 9 Mar 2023 13:38:06 +0200 Subject: [PATCH 6/8] Use ASSERT_NE to check that scene has loaded EXPECT_NE tries to continue so it ended up dereferencing null pointers and crashed. --- .../MDL/utMDLImporter_HL1_ImportSettings.cpp | 2 +- .../MDL/utMDLImporter_HL1_Materials.cpp | 16 +++++++-------- .../MDL/utMDLImporter_HL1_Nodes.cpp | 20 +++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/test/unit/ImportExport/MDL/utMDLImporter_HL1_ImportSettings.cpp b/test/unit/ImportExport/MDL/utMDLImporter_HL1_ImportSettings.cpp index 4614066e6..d50c2b35a 100644 --- a/test/unit/ImportExport/MDL/utMDLImporter_HL1_ImportSettings.cpp +++ b/test/unit/ImportExport/MDL/utMDLImporter_HL1_ImportSettings.cpp @@ -190,7 +190,7 @@ private: Assimp::Importer importer; importer.SetPropertyBool(setting_key, setting_value); const aiScene *scene = importer.ReadFile(file_path, aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); + ASSERT_NE(nullptr, scene); func(scene); } diff --git a/test/unit/ImportExport/MDL/utMDLImporter_HL1_Materials.cpp b/test/unit/ImportExport/MDL/utMDLImporter_HL1_Materials.cpp index 2389c0ffc..f733893ca 100644 --- a/test/unit/ImportExport/MDL/utMDLImporter_HL1_Materials.cpp +++ b/test/unit/ImportExport/MDL/utMDLImporter_HL1_Materials.cpp @@ -61,8 +61,8 @@ public: void flatShadeTexture() { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "chrome_sphere.mdl", aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); - EXPECT_NE(nullptr, scene->mMaterials); + ASSERT_NE(nullptr, scene); + ASSERT_NE(nullptr, scene->mMaterials); aiShadingMode shading_mode = aiShadingMode_Flat; scene->mMaterials[0]->Get(AI_MATKEY_SHADING_MODEL, shading_mode); @@ -74,8 +74,8 @@ public: void chromeTexture() { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "chrome_sphere.mdl", aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); - EXPECT_NE(nullptr, scene->mMaterials); + ASSERT_NE(nullptr, scene); + ASSERT_NE(nullptr, scene->mMaterials); int chrome; scene->mMaterials[0]->Get(AI_MDL_HL1_MATKEY_CHROME(aiTextureType_DIFFUSE, 0), chrome); @@ -87,8 +87,8 @@ public: void additiveBlendTexture() { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "blend_additive.mdl", aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); - EXPECT_NE(nullptr, scene->mMaterials); + ASSERT_NE(nullptr, scene); + ASSERT_NE(nullptr, scene->mMaterials); aiBlendMode blend_mode = aiBlendMode_Default; scene->mMaterials[0]->Get(AI_MATKEY_BLEND_FUNC, blend_mode); @@ -101,8 +101,8 @@ public: void textureWithColorMask() { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "alpha_test.mdl", aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); - EXPECT_NE(nullptr, scene->mMaterials); + ASSERT_NE(nullptr, scene); + ASSERT_NE(nullptr, scene->mMaterials); int texture_flags = 0; scene->mMaterials[0]->Get(AI_MATKEY_TEXFLAGS_DIFFUSE(0), texture_flags); diff --git a/test/unit/ImportExport/MDL/utMDLImporter_HL1_Nodes.cpp b/test/unit/ImportExport/MDL/utMDLImporter_HL1_Nodes.cpp index 712f4da11..49ae8a16c 100644 --- a/test/unit/ImportExport/MDL/utMDLImporter_HL1_Nodes.cpp +++ b/test/unit/ImportExport/MDL/utMDLImporter_HL1_Nodes.cpp @@ -136,7 +136,7 @@ public: void emptyBonesNames() { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "unnamed_bones.mdl", aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); + ASSERT_NE(nullptr, scene); const StringVector expected_bones_names = { "Bone", @@ -172,7 +172,7 @@ public: void emptyBodypartsNames() { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "unnamed_bodyparts.mdl", aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); + ASSERT_NE(nullptr, scene); const StringVector expected_bodyparts_names = { "Bodypart", @@ -209,7 +209,7 @@ public: void duplicateBodypartsNames() { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "duplicate_bodyparts.mdl", aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); + ASSERT_NE(nullptr, scene); const StringVector expected_bodyparts_names = { "Bodypart", @@ -254,7 +254,7 @@ public: void duplicateSubModelsNames() { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "duplicate_submodels.mdl", aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); + ASSERT_NE(nullptr, scene); const std::vector expected_bodypart_sub_models_names = { { @@ -272,7 +272,7 @@ public: }; const aiNode *bodyparts_node = scene->mRootNode->FindNode(AI_MDL_HL1_NODE_BODYPARTS); - EXPECT_NE(nullptr, bodyparts_node); + ASSERT_NE(nullptr, bodyparts_node); EXPECT_EQ(3u, bodyparts_node->mNumChildren); StringVector actual_submodels_names; @@ -301,7 +301,7 @@ public: void duplicateSequenceNames() { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "duplicate_sequences.mdl", aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); + ASSERT_NE(nullptr, scene); const StringVector expected_sequence_names = { "idle_1", @@ -337,7 +337,7 @@ public: void emptySequenceNames() { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "unnamed_sequences.mdl", aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); + ASSERT_NE(nullptr, scene); const StringVector expected_sequence_names = { "Sequence", @@ -374,7 +374,7 @@ public: void duplicateSequenceGroupNames() { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "duplicate_sequence_groups/duplicate_sequence_groups.mdl", aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); + ASSERT_NE(nullptr, scene); const StringVector expected_sequence_names = { "default", @@ -412,7 +412,7 @@ public: void emptySequenceGroupNames() { Assimp::Importer importer; const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "unnamed_sequence_groups/unnamed_sequence_groups.mdl", aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); + ASSERT_NE(nullptr, scene); const StringVector expected_sequence_names = { "default", @@ -440,7 +440,7 @@ public: Assimp::Importer importer; const aiScene *scene = importer.ReadFile(MDL_HL1_FILE_MAN, aiProcess_ValidateDataStructure); - EXPECT_NE(nullptr, scene); + ASSERT_NE(nullptr, scene); aiNode *scene_bones_node = scene->mRootNode->FindNode(AI_MDL_HL1_NODE_BONES); From ea3cc378903f698f81a93612f646100e0477c014 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Thu, 9 Mar 2023 14:31:29 +0200 Subject: [PATCH 7/8] Check node parents in ValidateDataStructure --- code/PostProcessing/ValidateDataStructure.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/PostProcessing/ValidateDataStructure.cpp b/code/PostProcessing/ValidateDataStructure.cpp index cae35b895..e31054972 100644 --- a/code/PostProcessing/ValidateDataStructure.cpp +++ b/code/PostProcessing/ValidateDataStructure.cpp @@ -911,7 +911,12 @@ void ValidateDSProcess::Validate(const aiNode *pNode) { nodeName, pNode->mNumChildren); } for (unsigned int i = 0; i < pNode->mNumChildren; ++i) { - Validate(pNode->mChildren[i]); + const aiNode *pChild = pNode->mChildren[i]; + Validate(pChild); + if (pChild->mParent != pNode) { + const char *parentName = (pChild->mParent != nullptr) ? pChild->mParent->mName.C_Str() : "null"; + ReportError("aiNode \"%s\" child %i \"%s\" parent is someone else: \"%s\"", pNode->mName.C_Str(), i, pChild->mName.C_Str(), parentName); + } } } } From 65440f17a1d25a098d1f754a0b8f6fa7fc48303f Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Mon, 20 Mar 2023 15:22:05 +0200 Subject: [PATCH 8/8] Add more ASE model unit tests --- test/unit/utASEImportExport.cpp | 110 ++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/test/unit/utASEImportExport.cpp b/test/unit/utASEImportExport.cpp index 8014cbbc7..af05a2fe5 100644 --- a/test/unit/utASEImportExport.cpp +++ b/test/unit/utASEImportExport.cpp @@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include using namespace Assimp; @@ -63,3 +64,112 @@ public: TEST_F(utASEImportExport, importACFromFileTest) { EXPECT_TRUE(importerTest()); } + + +TEST_F(utASEImportExport, importAnim1) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/anim.ASE", aiProcess_ValidateDataStructure); + + ASSERT_NE(nullptr, scene); +} + + +TEST_F(utASEImportExport, importAnim2) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/anim2.ASE", aiProcess_ValidateDataStructure); + + ASSERT_NE(nullptr, scene); +} + + +TEST_F(utASEImportExport, importCameraRollAnim) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/CameraRollAnim.ase", aiProcess_ValidateDataStructure); + + ASSERT_NE(nullptr, scene); +} + + +TEST_F(utASEImportExport, importMotionCaptureROM) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/MotionCaptureROM.ase", aiProcess_ValidateDataStructure); + + ASSERT_NE(nullptr, scene); +} + + +TEST_F(utASEImportExport, importRotatingCube) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/RotatingCube.ASE", aiProcess_ValidateDataStructure); + + ASSERT_NE(nullptr, scene); +} + + +TEST_F(utASEImportExport, importTargetCameraAnim) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/TargetCameraAnim.ase", aiProcess_ValidateDataStructure); + + ASSERT_NE(nullptr, scene); +} + + +TEST_F(utASEImportExport, importTestFormatDetection) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/TestFormatDetection", aiProcess_ValidateDataStructure); + + ASSERT_NE(nullptr, scene); +} + + +TEST_F(utASEImportExport, importThreeCubesGreen) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/ThreeCubesGreen.ASE", aiProcess_ValidateDataStructure); + + ASSERT_NE(nullptr, scene); + + ::Assimp::Importer importerLE; + const aiScene *sceneLE = importerLE.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/ThreeCubesGreen_UTF16LE.ASE", aiProcess_ValidateDataStructure); + + ASSERT_NE(nullptr, sceneLE); + + ::Assimp::Importer importerBE; + const aiScene *sceneBE = importerBE.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/ThreeCubesGreen_UTF16BE.ASE", aiProcess_ValidateDataStructure); + + ASSERT_NE(nullptr, sceneBE); + + // TODO: these scenes should probably be identical + // verify that is the case and then add tests to check it +} + + +TEST_F(utASEImportExport, importUVTransform_Normal) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/TestUVTransform/UVTransform_Normal.ASE", aiProcess_ValidateDataStructure); + + ASSERT_NE(nullptr, scene); +} + + +TEST_F(utASEImportExport, importUVTransform_ScaleUV1_2_OffsetUV0_0_9_Rotate_72_mirrorU) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/TestUVTransform/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72_mirrorU.ase", aiProcess_ValidateDataStructure); + + ASSERT_NE(nullptr, scene); +} + + +TEST_F(utASEImportExport, importUVTransform_ScaleUV2x) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/TestUVTransform/UVTransform_ScaleUV2x.ASE", aiProcess_ValidateDataStructure); + + ASSERT_NE(nullptr, scene); +} + + +TEST_F(utASEImportExport, importUVTransform_ScaleUV2x_Rotate45) { + ::Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/TestUVTransform/UVTransform_ScaleUV2x_Rotate45.ASE", aiProcess_ValidateDataStructure); + + ASSERT_NE(nullptr, scene); +}