From 384db8686e84fe95afe417fd341fc259f528649d Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 27 Nov 2023 21:22:40 +0100 Subject: [PATCH 01/22] Update FBXConverter.cpp - Temporary fix bind pose storage in offset matrix - Will close https://github.com/assimp/assimp/issues/5132 --- code/AssetLib/FBX/FBXConverter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp index 3538e84a8..1245f1f19 100644 --- a/code/AssetLib/FBX/FBXConverter.cpp +++ b/code/AssetLib/FBX/FBXConverter.cpp @@ -1621,16 +1621,16 @@ void FBXConverter::ConvertCluster(std::vector &local_mesh_bones, const bone = new aiBone(); bone->mName = bone_name; - bone->mOffsetMatrix = cluster->Transform(); + //bone->mOffsetMatrix = cluster->Transform(); // store local transform link for post processing - /* + bone->mOffsetMatrix = cluster->TransformLink(); bone->mOffsetMatrix.Inverse(); aiMatrix4x4 matrix = (aiMatrix4x4)absolute_transform; bone->mOffsetMatrix = bone->mOffsetMatrix * matrix; // * mesh_offset - */ + // // Now calculate the aiVertexWeights // From 01f2549abe70fe390f6c169b7f3de5ba4ab48e9f Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Nov 2023 15:59:06 +0100 Subject: [PATCH 02/22] Fix the build --- code/AssetLib/FBX/FBXConverter.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp index 1245f1f19..bd97db76d 100644 --- a/code/AssetLib/FBX/FBXConverter.cpp +++ b/code/AssetLib/FBX/FBXConverter.cpp @@ -55,9 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include - #include - #include #include #include @@ -1604,7 +1602,7 @@ void FBXConverter::ConvertWeights(aiMesh *out, const MeshGeometry &geo, const ai void FBXConverter::ConvertCluster(std::vector &local_mesh_bones, const Cluster *cluster, std::vector &out_indices, std::vector &index_out_indices, - std::vector &count_out_indices, const aiMatrix4x4 & /* absolute_transform*/, + std::vector &count_out_indices, const aiMatrix4x4 &absolute_transform, aiNode *) { ai_assert(cluster != nullptr); // make sure cluster valid @@ -1627,7 +1625,7 @@ void FBXConverter::ConvertCluster(std::vector &local_mesh_bones, const bone->mOffsetMatrix = cluster->TransformLink(); bone->mOffsetMatrix.Inverse(); - aiMatrix4x4 matrix = (aiMatrix4x4)absolute_transform; + const aiMatrix4x4 matrix = (aiMatrix4x4)absolute_transform; bone->mOffsetMatrix = bone->mOffsetMatrix * matrix; // * mesh_offset From 85f64c913145f63a394d0907ab65a45511e19bcc Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Nov 2023 20:56:43 +0100 Subject: [PATCH 03/22] Use correct time scaling --- code/AssetLib/FBX/FBXExporter.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/code/AssetLib/FBX/FBXExporter.cpp b/code/AssetLib/FBX/FBXExporter.cpp index 2ea505618..28299544a 100644 --- a/code/AssetLib/FBX/FBXExporter.cpp +++ b/code/AssetLib/FBX/FBXExporter.cpp @@ -1061,14 +1061,14 @@ aiMatrix4x4 get_world_transform(const aiNode* node, const aiScene* scene) return transform; } -int64_t to_ktime(double ticks, const aiAnimation* anim) { +inline int64_t to_ktime(double ticks, const aiAnimation* anim) { if (anim->mTicksPerSecond <= 0) { return static_cast(ticks) * FBX::SECOND; } - return (static_cast(ticks) / static_cast(anim->mTicksPerSecond)) * FBX::SECOND; + return (static_cast(ticks / anim->mTicksPerSecond)) * FBX::SECOND; } -int64_t to_ktime(double time) { +inline int64_t to_ktime(double time) { return (static_cast(time * FBX::SECOND)); } @@ -2413,7 +2413,7 @@ void FBXExporter::WriteObjects () // position/translation for (size_t ki = 0; ki < na->mNumPositionKeys; ++ki) { const aiVectorKey& k = na->mPositionKeys[ki]; - times.push_back(to_ktime(k.mTime)); + times.push_back(to_ktime(k.mTime, anim)); xval.push_back(k.mValue.x); yval.push_back(k.mValue.y); zval.push_back(k.mValue.z); @@ -2427,7 +2427,7 @@ void FBXExporter::WriteObjects () times.clear(); xval.clear(); yval.clear(); zval.clear(); for (size_t ki = 0; ki < na->mNumRotationKeys; ++ki) { const aiQuatKey& k = na->mRotationKeys[ki]; - times.push_back(to_ktime(k.mTime)); + times.push_back(to_ktime(k.mTime, anim)); // TODO: aiQuaternion method to convert to Euler... aiMatrix4x4 m(k.mValue.GetMatrix()); aiVector3D qs, qr, qt; @@ -2445,7 +2445,7 @@ void FBXExporter::WriteObjects () times.clear(); xval.clear(); yval.clear(); zval.clear(); for (size_t ki = 0; ki < na->mNumScalingKeys; ++ki) { const aiVectorKey& k = na->mScalingKeys[ki]; - times.push_back(to_ktime(k.mTime)); + times.push_back(to_ktime(k.mTime, anim)); xval.push_back(k.mValue.x); yval.push_back(k.mValue.y); zval.push_back(k.mValue.z); From 6f70e220e4f8f975ee931ebb0884da49c33159f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Mon, 6 Nov 2023 11:09:22 +0100 Subject: [PATCH 04/22] always include "utf8.h" (instead of contrib/.../utf8.h) --- code/AssetLib/MMD/MMDPmxParser.cpp | 6 +----- code/AssetLib/SIB/SIBImporter.cpp | 6 +----- code/AssetLib/STEPParser/STEPFileEncoding.cpp | 6 +----- code/Common/BaseImporter.cpp | 6 +----- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/code/AssetLib/MMD/MMDPmxParser.cpp b/code/AssetLib/MMD/MMDPmxParser.cpp index 42e835c66..6b04f02e9 100644 --- a/code/AssetLib/MMD/MMDPmxParser.cpp +++ b/code/AssetLib/MMD/MMDPmxParser.cpp @@ -42,11 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include "MMDPmxParser.h" #include -#ifdef ASSIMP_USE_HUNTER -# include -#else -# include "../contrib/utf8cpp/source/utf8.h" -#endif +#include "utf8.h" #include namespace pmx diff --git a/code/AssetLib/SIB/SIBImporter.cpp b/code/AssetLib/SIB/SIBImporter.cpp index 26b1c5227..840f74b7d 100644 --- a/code/AssetLib/SIB/SIBImporter.cpp +++ b/code/AssetLib/SIB/SIBImporter.cpp @@ -56,11 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#ifdef ASSIMP_USE_HUNTER -#include -#else -#include "../contrib/utf8cpp/source/utf8.h" -#endif +#include "utf8.h" #include #include #include diff --git a/code/AssetLib/STEPParser/STEPFileEncoding.cpp b/code/AssetLib/STEPParser/STEPFileEncoding.cpp index d4456e674..92eb4f284 100644 --- a/code/AssetLib/STEPParser/STEPFileEncoding.cpp +++ b/code/AssetLib/STEPParser/STEPFileEncoding.cpp @@ -45,11 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "STEPFileEncoding.h" #include -#ifdef ASSIMP_USE_HUNTER -# include -#else -# include -#endif +#include "utf8.h" #include diff --git a/code/Common/BaseImporter.cpp b/code/Common/BaseImporter.cpp index a169c8a10..9ef69a8e6 100644 --- a/code/Common/BaseImporter.cpp +++ b/code/Common/BaseImporter.cpp @@ -357,11 +357,7 @@ std::string BaseImporter::GetExtension(const std::string &pFile) { return false; } -#ifdef ASSIMP_USE_HUNTER -#include -#else -#include "../contrib/utf8cpp/source/utf8.h" -#endif +#include "utf8.h" // ------------------------------------------------------------------------------------------------ // Convert to UTF8 data From bfdd154d14b3f653cbcb9494876236e34c7e39ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Mon, 6 Nov 2023 13:32:35 +0100 Subject: [PATCH 05/22] Always include "zlib.h" (rather than .../contrib/zlib/zlib.h) The path to the vendored zlib is set by the build-system, so there's no need to add additional preprocessor magic --- code/AssetLib/Assbin/AssbinFileWriter.cpp | 6 +----- code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp | 6 +----- code/Common/Compression.h | 6 +----- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/code/AssetLib/Assbin/AssbinFileWriter.cpp b/code/AssetLib/Assbin/AssbinFileWriter.cpp index e9d857a84..782595bc1 100644 --- a/code/AssetLib/Assbin/AssbinFileWriter.cpp +++ b/code/AssetLib/Assbin/AssbinFileWriter.cpp @@ -50,11 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef ASSIMP_BUILD_NO_OWN_ZLIB -#include -#else -#include "../contrib/zlib/zlib.h" -#endif +#include "zlib.h" #include diff --git a/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp b/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp index 30b1bf053..3c56775e8 100644 --- a/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp +++ b/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp @@ -48,11 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#ifdef ASSIMP_BUILD_NO_OWN_ZLIB -#include -#else -#include "../contrib/zlib/zlib.h" -#endif +#include "zlib.h" #include #include diff --git a/code/Common/Compression.h b/code/Common/Compression.h index 13a79af3f..cfedc7409 100644 --- a/code/Common/Compression.h +++ b/code/Common/Compression.h @@ -41,11 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once -#ifdef ASSIMP_BUILD_NO_OWN_ZLIB -# include -#else -# include "../contrib/zlib/zlib.h" -#endif +#include "zlib.h" #include #include // size_t From 6f715edfa091c4bcd6fc5e468d446a5b71139b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Mon, 6 Nov 2023 13:32:54 +0100 Subject: [PATCH 06/22] Drop disabled zlib.h inclusion stubs --- code/AssetLib/FBX/FBXParser.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/code/AssetLib/FBX/FBXParser.cpp b/code/AssetLib/FBX/FBXParser.cpp index 955e811cb..7baa7ed39 100644 --- a/code/AssetLib/FBX/FBXParser.cpp +++ b/code/AssetLib/FBX/FBXParser.cpp @@ -45,12 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_FBX_IMPORTER -//#ifdef ASSIMP_BUILD_NO_OWN_ZLIB #include "Common/Compression.h" -//# include -//#else -//# include "../contrib/zlib/zlib.h" -//#endif #include "FBXTokenizer.h" #include "FBXParser.h" From a63a6011c5db6e55ab60eb8554b505b437ba2594 Mon Sep 17 00:00:00 2001 From: ccn Date: Sun, 5 Nov 2023 22:20:16 -0500 Subject: [PATCH 07/22] Update Build.md Add more details about the default build. --- Build.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Build.md b/Build.md index 957031b5f..9440a0073 100644 --- a/Build.md +++ b/Build.md @@ -43,6 +43,7 @@ cd assimp cmake CMakeLists.txt cmake --build . ``` +Note that by default this builds a shared library into the `bin` directory. If you want to build it as a static library see the build options at the bottom of this file. ### Build instructions for Windows with Visual-Studio From f701d702e4363a48688412c1e376437497f06111 Mon Sep 17 00:00:00 2001 From: Maksim Kostin Date: Mon, 13 Nov 2023 11:27:44 +0300 Subject: [PATCH 08/22] Fix buffer overflow in FBX::Util::DecodeBase64() --- code/AssetLib/FBX/FBXUtil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/FBX/FBXUtil.cpp b/code/AssetLib/FBX/FBXUtil.cpp index ac465d6e9..e2903c536 100644 --- a/code/AssetLib/FBX/FBXUtil.cpp +++ b/code/AssetLib/FBX/FBXUtil.cpp @@ -155,7 +155,7 @@ size_t DecodeBase64(const char* in, size_t inLength, uint8_t* out, size_t maxOut const size_t realLength = inLength - size_t(in[inLength - 1] == '=') - size_t(in[inLength - 2] == '='); size_t dst_offset = 0; int val = 0, valb = -8; - for (size_t src_offset = 0; src_offset < realLength; ++src_offset) + for (size_t src_offset = 0; src_offset < realLength && dst_offset < maxOutLength; ++src_offset) { const uint8_t table_value = Util::DecodeBase64(in[src_offset]); if (table_value == 255) From e765862d2493b4ed6408cea8c4e50b5df56f8fb6 Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Mon, 27 Nov 2023 13:11:23 -0800 Subject: [PATCH 09/22] Readme.md: correct 2 errors in section headers --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 94f938970..a1f707a95 100644 --- a/Readme.md +++ b/Readme.md @@ -15,10 +15,10 @@ Open Asset Import Library is a library to load various 3d file formats into a sh APIs are provided for C and C++. There are various bindings to other languages (C#, Java, Python, Delphi, D). Assimp also runs on Android and iOS. Additionally, assimp features various __mesh post-processing tools__: normals and tangent space generation, triangulation, vertex cache locality optimization, removal of degenerate primitives and duplicate vertices, sorting by primitive type, merging of redundant materials and many more. -### Latest Doc's ### +### Documentation ### Please check the latest documents at [Asset-Importer-Lib-Doc](https://assimp-docs.readthedocs.io/en/latest/). -### Prebuild binaries ### +### Pre-built binaries ### Please check our [Itchi Projectspace](https://kimkulling.itch.io/the-asset-importer-lib) If you want to check our Model-Database, use the following repo: https://github.com/assimp/assimp-mdb From d311fa95c61fe8177b14c9b04453190efd9d83cf Mon Sep 17 00:00:00 2001 From: Maksim Kostin Date: Mon, 13 Nov 2023 12:06:56 +0300 Subject: [PATCH 10/22] Fix double free in Video::~Video() --- code/AssetLib/FBX/FBXMaterial.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/AssetLib/FBX/FBXMaterial.cpp b/code/AssetLib/FBX/FBXMaterial.cpp index 2f575a511..bcb9bc42a 100644 --- a/code/AssetLib/FBX/FBXMaterial.cpp +++ b/code/AssetLib/FBX/FBXMaterial.cpp @@ -367,7 +367,9 @@ Video::Video(uint64_t id, const Element &element, const Document &doc, const std } Video::~Video() { - delete[] content; + if (contentLength > 0) { + delete[] content; + } } } //!FBX From 769e82ce5e9ad064e6792e84a0178d032b7039cc Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Sat, 18 Nov 2023 14:21:58 -0800 Subject: [PATCH 11/22] FBXMeshGeometry: solve issue #5116 using patch provided by darktjm --- code/AssetLib/FBX/FBXMeshGeometry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/FBX/FBXMeshGeometry.cpp b/code/AssetLib/FBX/FBXMeshGeometry.cpp index fcbaac169..8c6499a91 100644 --- a/code/AssetLib/FBX/FBXMeshGeometry.cpp +++ b/code/AssetLib/FBX/FBXMeshGeometry.cpp @@ -467,9 +467,9 @@ void ResolveVertexDataArray(std::vector& data_out, const Scope& source, std::vector uvIndices; ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName)); - if (uvIndices.size() != vertex_count) { + if (uvIndices.size() != mapping_offsets.size()) { FBXImporter::LogError("length of input data unexpected for ByVertice mapping: ", - uvIndices.size(), ", expected ", vertex_count); + uvIndices.size(), ", expected ", mapping_offsets.size()); return; } From a0b3df6dbd0ca6b8a8fd20e7919e9b4e84f21c2d Mon Sep 17 00:00:00 2001 From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com> Date: Tue, 28 Nov 2023 16:13:54 -0500 Subject: [PATCH 12/22] Fix target names not being imported on some gLTF2 models --- code/AssetLib/glTF2/glTF2Asset.inl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/code/AssetLib/glTF2/glTF2Asset.inl b/code/AssetLib/glTF2/glTF2Asset.inl index 53ffdaf31..5781a4be6 100644 --- a/code/AssetLib/glTF2/glTF2Asset.inl +++ b/code/AssetLib/glTF2/glTF2Asset.inl @@ -1552,6 +1552,22 @@ inline void Mesh::Read(Value &pJSON_Object, Asset &pAsset_Root) { } } } + + if(this->targetNames.empty()) + { + Value *curExtras = FindObject(primitive, "extras"); + if (nullptr != curExtras) { + if (Value *curTargetNames = FindArray(*curExtras, "targetNames")) { + this->targetNames.resize(curTargetNames->Size()); + for (unsigned int j = 0; j < curTargetNames->Size(); ++j) { + Value &targetNameValue = (*curTargetNames)[j]; + if (targetNameValue.IsString()) { + this->targetNames[j] = targetNameValue.GetString(); + } + } + } + } + } } } From 213d73ebc6a0ab64b880bf144aefa2c2f6092cb6 Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Thu, 23 Nov 2023 12:08:01 -0800 Subject: [PATCH 13/22] correct grammar/typographic errors in comments (8 files) --- code/AssetLib/3DS/3DSConverter.cpp | 2 +- code/AssetLib/3DS/3DSLoader.cpp | 2 +- code/AssetLib/ASE/ASELoader.cpp | 2 +- code/AssetLib/Blender/BlenderScene.cpp | 2 +- code/AssetLib/Collada/ColladaParser.cpp | 2 +- code/AssetLib/FBX/FBXConverter.cpp | 2 +- code/AssetLib/FBX/FBXDeformer.cpp | 2 +- tools/assimp_view/assimp_view.cpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/code/AssetLib/3DS/3DSConverter.cpp b/code/AssetLib/3DS/3DSConverter.cpp index b99e9f798..6d3f09cb7 100644 --- a/code/AssetLib/3DS/3DSConverter.cpp +++ b/code/AssetLib/3DS/3DSConverter.cpp @@ -593,7 +593,7 @@ void Discreet3DSImporter::AddNodeToGraph(aiScene *pcSOut, aiNode *pcOut, // Cameras or lights define their transformation in their parent node and in the // corresponding light or camera chunks. However, we read and process the latter - // to to be able to return valid cameras/lights even if no scenegraph is given. + // to be able to return valid cameras/lights even if no scenegraph is given. for (unsigned int n = 0; n < pcSOut->mNumCameras; ++n) { if (pcSOut->mCameras[n]->mName == pcOut->mName) { pcSOut->mCameras[n]->mLookAt = aiVector3D(0.f, 0.f, 1.f); diff --git a/code/AssetLib/3DS/3DSLoader.cpp b/code/AssetLib/3DS/3DSLoader.cpp index a2dcc32ac..a406ea1d2 100644 --- a/code/AssetLib/3DS/3DSLoader.cpp +++ b/code/AssetLib/3DS/3DSLoader.cpp @@ -365,7 +365,7 @@ void Discreet3DSImporter::ParseChunk(const char *name, unsigned int num) { // IMPLEMENTATION NOTE; // Cameras or lights define their transformation in their parent node and in the // corresponding light or camera chunks. However, we read and process the latter - // to to be able to return valid cameras/lights even if no scenegraph is given. + // to be able to return valid cameras/lights even if no scenegraph is given. // get chunk type switch (chunk.Flag) { diff --git a/code/AssetLib/ASE/ASELoader.cpp b/code/AssetLib/ASE/ASELoader.cpp index 94e213fb3..f98316661 100644 --- a/code/AssetLib/ASE/ASELoader.cpp +++ b/code/AssetLib/ASE/ASELoader.cpp @@ -904,7 +904,7 @@ void ASEImporter::ConvertMeshes(ASE::Mesh &mesh, std::vector &avOutMes ASSIMP_LOG_WARN("Material index is out of range"); } - // If the material the mesh is assigned to is consisting of submeshes, split it + // If the material the mesh is assigned to consists of submeshes, split it if (!mParser->m_vMaterials[mesh.iMaterialIndex].avSubMaterials.empty()) { std::vector vSubMaterials = mParser->m_vMaterials[mesh.iMaterialIndex].avSubMaterials; diff --git a/code/AssetLib/Blender/BlenderScene.cpp b/code/AssetLib/Blender/BlenderScene.cpp index a2e4c30f2..e25dc450b 100644 --- a/code/AssetLib/Blender/BlenderScene.cpp +++ b/code/AssetLib/Blender/BlenderScene.cpp @@ -297,7 +297,7 @@ void Structure ::Convert( const FileDatabase &db) const { // note: as per https://github.com/assimp/assimp/issues/128, // reading the Object linked list recursively is prone to stack overflow. - // This structure converter is therefore an hand-written exception that + // This structure converter is therefore a hand-written exception that // does it iteratively. const int initial_pos = db.reader->GetCurrentPos(); diff --git a/code/AssetLib/Collada/ColladaParser.cpp b/code/AssetLib/Collada/ColladaParser.cpp index 7ccb22fec..42a8d6052 100644 --- a/code/AssetLib/Collada/ColladaParser.cpp +++ b/code/AssetLib/Collada/ColladaParser.cpp @@ -1867,7 +1867,7 @@ size_t ColladaParser::ReadPrimitives(XmlNode &node, Mesh &pMesh, std::vector and tags this function will create wrong uv coordinates. -///It's not clear from COLLADA documentation is this allowed or not. For now only exporter fixed to avoid such behavior +///It's not clear from COLLADA documentation whether this is allowed or not. For now only exporter fixed to avoid such behavior void ColladaParser::CopyVertex(size_t currentVertex, size_t numOffsets, size_t numPoints, size_t perVertexOffset, Mesh &pMesh, std::vector &pPerIndexChannels, size_t currentPrimitive, const std::vector &indices) { // calculate the base offset of the vertex whose attributes we ant to copy diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp index bd97db76d..62ada774f 100644 --- a/code/AssetLib/FBX/FBXConverter.cpp +++ b/code/AssetLib/FBX/FBXConverter.cpp @@ -1204,7 +1204,7 @@ unsigned int FBXConverter::ConvertMeshSingleMaterial(const MeshGeometry &mesh, c const auto &curNormals = shapeGeometry->GetNormals(); const auto &curIndices = shapeGeometry->GetIndices(); //losing channel name if using shapeGeometry->Name() - // if blendShapeChannel Name is empty or don't have a ".", add geoMetryName; + // if blendShapeChannel Name is empty or doesn't have a ".", add geoMetryName; auto aniName = FixAnimMeshName(blendShapeChannel->Name()); auto geoMetryName = FixAnimMeshName(shapeGeometry->Name()); if (aniName.empty()) { diff --git a/code/AssetLib/FBX/FBXDeformer.cpp b/code/AssetLib/FBX/FBXDeformer.cpp index 1aab55ea9..8f944527a 100644 --- a/code/AssetLib/FBX/FBXDeformer.cpp +++ b/code/AssetLib/FBX/FBXDeformer.cpp @@ -84,7 +84,7 @@ Cluster::Cluster(uint64_t id, const Element& element, const Document& doc, const transform = ReadMatrix(Transform); transformLink = ReadMatrix(TransformLink); - // it is actually possible that there be Deformer's with no weights + // it is actually possible that there are Deformer's with no weights if (!!Indexes != !!Weights) { DOMError("either Indexes or Weights are missing from Cluster",&element); } diff --git a/tools/assimp_view/assimp_view.cpp b/tools/assimp_view/assimp_view.cpp index e00c6e39d..8f2d131d2 100644 --- a/tools/assimp_view/assimp_view.cpp +++ b/tools/assimp_view/assimp_view.cpp @@ -291,7 +291,7 @@ int LoadAsset() { //------------------------------------------------------------------------------- // Delete the loaded asset -// The function does nothing is no asset is loaded +// The function does nothing if no asset is loaded //------------------------------------------------------------------------------- int DeleteAsset(void) { if (!g_pcAsset) { From a72289b327ec1e1db02e14eb89ef1254e5435a76 Mon Sep 17 00:00:00 2001 From: Alexey Medvedev Date: Sat, 25 Nov 2023 16:13:42 -0800 Subject: [PATCH 14/22] glTF KHR_materials_specular fixes --- code/AssetLib/glTF2/glTF2Asset.h | 2 +- code/AssetLib/glTF2/glTF2Asset.inl | 2 +- code/AssetLib/glTF2/glTF2Exporter.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/AssetLib/glTF2/glTF2Asset.h b/code/AssetLib/glTF2/glTF2Asset.h index 3ae40f07e..8d500b156 100644 --- a/code/AssetLib/glTF2/glTF2Asset.h +++ b/code/AssetLib/glTF2/glTF2Asset.h @@ -720,7 +720,7 @@ const vec4 defaultBaseColor = { 1, 1, 1, 1 }; const vec3 defaultEmissiveFactor = { 0, 0, 0 }; const vec4 defaultDiffuseFactor = { 1, 1, 1, 1 }; const vec3 defaultSpecularFactor = { 1, 1, 1 }; -const vec3 defaultSpecularColorFactor = { 0, 0, 0 }; +const vec3 defaultSpecularColorFactor = { 1, 1, 1 }; const vec3 defaultSheenFactor = { 0, 0, 0 }; const vec3 defaultAttenuationColor = { 1, 1, 1 }; diff --git a/code/AssetLib/glTF2/glTF2Asset.inl b/code/AssetLib/glTF2/glTF2Asset.inl index 5781a4be6..61964d1b4 100644 --- a/code/AssetLib/glTF2/glTF2Asset.inl +++ b/code/AssetLib/glTF2/glTF2Asset.inl @@ -1392,7 +1392,7 @@ inline void PbrSpecularGlossiness::SetDefaults() { inline void MaterialSpecular::SetDefaults() { //KHR_materials_specular properties SetVector(specularColorFactor, defaultSpecularColorFactor); - specularFactor = 0.f; + specularFactor = 1.f; } inline void MaterialSheen::SetDefaults() { diff --git a/code/AssetLib/glTF2/glTF2Exporter.cpp b/code/AssetLib/glTF2/glTF2Exporter.cpp index 18a6ae2f4..836e15f9f 100644 --- a/code/AssetLib/glTF2/glTF2Exporter.cpp +++ b/code/AssetLib/glTF2/glTF2Exporter.cpp @@ -730,8 +730,8 @@ bool glTF2Exporter::GetMatSpecular(const aiMaterial &mat, glTF2::MaterialSpecula } else if (colorFactorIsZero) { specular.specularColorFactor[0] = specular.specularColorFactor[1] = specular.specularColorFactor[2] = 1.0f; } - GetMatTex(mat, specular.specularColorTexture, aiTextureType_SPECULAR); - GetMatTex(mat, specular.specularTexture, aiTextureType_SPECULAR); + GetMatTex(mat, specular.specularTexture, aiTextureType_SPECULAR, 0); + GetMatTex(mat, specular.specularColorTexture, aiTextureType_SPECULAR, 1); return true; } From dc399f73432e0a5849ae12f0ef0fba74ba465c5d Mon Sep 17 00:00:00 2001 From: Alexey Medvedev Date: Sat, 25 Nov 2023 16:14:36 -0800 Subject: [PATCH 15/22] glTF KHR_materials_specular fixes --- code/AssetLib/glTF2/glTF2Importer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp index 4bdbe39f1..e89baaf0d 100644 --- a/code/AssetLib/glTF2/glTF2Importer.cpp +++ b/code/AssetLib/glTF2/glTF2Importer.cpp @@ -288,8 +288,8 @@ static aiMaterial *ImportMaterial(std::vector &embeddedTexIdxs, Asset &r, M if (std::memcmp(specular.specularColorFactor, defaultSpecularColorFactor, sizeof(glTFCommon::vec3)) != 0 || specular.specularFactor != 0.0f) { SetMaterialColorProperty(r, specular.specularColorFactor, aimat, AI_MATKEY_COLOR_SPECULAR); aimat->AddProperty(&specular.specularFactor, 1, AI_MATKEY_SPECULAR_FACTOR); - SetMaterialTextureProperty(embeddedTexIdxs, r, specular.specularTexture, aimat, aiTextureType_SPECULAR); - SetMaterialTextureProperty(embeddedTexIdxs, r, specular.specularColorTexture, aimat, aiTextureType_SPECULAR); + SetMaterialTextureProperty(embeddedTexIdxs, r, specular.specularTexture, aimat, aiTextureType_SPECULAR, 0); + SetMaterialTextureProperty(embeddedTexIdxs, r, specular.specularColorTexture, aimat, aiTextureType_SPECULAR, 1); } } // pbrSpecularGlossiness From 762ad8e9b7d8749c17dedd3e0b9a32b933949e8f Mon Sep 17 00:00:00 2001 From: Alexey Medvedev Date: Sat, 25 Nov 2023 16:30:55 -0800 Subject: [PATCH 16/22] glTF KHR_materials_specular fixes --- code/AssetLib/glTF2/glTF2AssetWriter.inl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/glTF2/glTF2AssetWriter.inl b/code/AssetLib/glTF2/glTF2AssetWriter.inl index 30f2580a2..bfd9135d3 100644 --- a/code/AssetLib/glTF2/glTF2AssetWriter.inl +++ b/code/AssetLib/glTF2/glTF2AssetWriter.inl @@ -426,13 +426,14 @@ namespace glTF2 { if (specular.specularFactor != 0.0f) { WriteFloat(materialSpecular, specular.specularFactor, "specularFactor", w.mAl); - WriteTex(materialSpecular, specular.specularTexture, "specularTexture", w.mAl); } if (specular.specularColorFactor[0] != defaultSpecularColorFactor[0] && specular.specularColorFactor[1] != defaultSpecularColorFactor[1] && specular.specularColorFactor[2] != defaultSpecularColorFactor[2]) { WriteVec(materialSpecular, specular.specularColorFactor, "specularColorFactor", w.mAl); - WriteTex(materialSpecular, specular.specularColorTexture, "specularColorTexture", w.mAl); } + WriteTex(materialSpecular, specular.specularTexture, "specularTexture", w.mAl); + WriteTex(materialSpecular, specular.specularColorTexture, "specularColorTexture", w.mAl); + if (!materialSpecular.ObjectEmpty()) { exts.AddMember("KHR_materials_specular", materialSpecular, w.mAl); } From 88084a67fcb50eafd564096997cde25f4513abb0 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 20 Dec 2023 19:47:29 +0100 Subject: [PATCH 17/22] Disable Hunter --- .github/workflows/ccpp.yml | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 2c5ca438b..3859c04db 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - name: [ubuntu-latest-g++, macos-latest-clang++, windows-latest-cl.exe, ubuntu-latest-clang++, ubuntu-gcc-hunter, macos-clang-hunter, windows-msvc-hunter] + name: [ubuntu-latest-g++, macos-latest-clang++, windows-latest-cl.exe, ubuntu-latest-clang++] # For Windows msvc, for Linux and macOS let's use the clang compiler, use gcc for Linux. include: - name: windows-latest-cl.exe @@ -35,15 +35,6 @@ jobs: os: ubuntu-latest cxx: g++ cc: gcc - - name: ubuntu-gcc-hunter - os: ubuntu-latest - toolchain: ninja-gcc-cxx17-fpic - - name: macos-clang-hunter - os: macos-latest - toolchain: ninja-clang-cxx17-fpic - - name: windows-msvc-hunter - os: windows-latest - toolchain: ninja-vs-win64-cxx17 steps: - uses: actions/checkout@v4 @@ -55,25 +46,11 @@ jobs: - uses: ilammy/msvc-dev-cmd@v1 - name: Set Compiler Environment - if: "!endsWith(matrix.name, 'hunter')" uses: lukka/set-shell-env@v1 with: CXX: ${{ matrix.cxx }} CC: ${{ matrix.cc }} - - name: Set Compiler Environment for Hunter on Windows - if: startsWith(matrix.name, 'windows') && endsWith(matrix.name, 'hunter') - uses: lukka/set-shell-env@v1 - with: - VS160COMNTOOLS: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools - - - name: Checkout Hunter toolchains - if: endsWith(matrix.name, 'hunter') - uses: actions/checkout@v4 - with: - repository: cpp-pm/polly - path: cmake/polly - - name: Cache DX SDK id: dxcache if: contains(matrix.name, 'windows') From 4034df8b6e7e08efa70d3e645f161b4e2a303bf4 Mon Sep 17 00:00:00 2001 From: Alexander Wagner Date: Thu, 21 Sep 2023 14:26:41 +0200 Subject: [PATCH 18/22] - removed unused include --- include/assimp/types.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/assimp/types.h b/include/assimp/types.h index 42aa0f9eb..9f4edfe0f 100644 --- a/include/assimp/types.h +++ b/include/assimp/types.h @@ -73,6 +73,12 @@ typedef uint32_t ai_uint32; #ifdef __cplusplus +//#ifdef ASSIMP_USE_HUNTER +//# include +//#else +//# include "../contrib/utf8cpp/source/utf8.h" +//#endif + #include #include // for std::nothrow_t #include // for aiString::Set(const std::string&) From e86f1acb9b11e317fe81124cbd38972da04f98d7 Mon Sep 17 00:00:00 2001 From: Alexander Wagner Date: Mon, 27 Nov 2023 20:02:39 +0100 Subject: [PATCH 19/22] - fixed q3bsp issue --- code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp b/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp index 3c56775e8..a82f29cf1 100644 --- a/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp +++ b/code/AssetLib/Q3BSP/Q3BSPFileImporter.cpp @@ -395,7 +395,10 @@ void Q3BSPFileImporter::createTriangleTopology(const Q3BSP::Q3BSPModel *pModel, m_pCurrentFace->mIndices = new unsigned int[3]; m_pCurrentFace->mIndices[idx] = vertIdx; } - } + } else { + m_pCurrentFace->mIndices[idx] = vertIdx; + } + pMesh->mVertices[vertIdx].Set(pVertex->vPosition.x, pVertex->vPosition.y, pVertex->vPosition.z); pMesh->mNormals[vertIdx].Set(pVertex->vNormal.x, pVertex->vNormal.y, pVertex->vNormal.z); From d03ab3ef276e4ee8fe4705100c3d1516eea338fc Mon Sep 17 00:00:00 2001 From: Alexander Wagner Date: Wed, 29 Nov 2023 20:28:45 +0100 Subject: [PATCH 20/22] - fixed Exist function on Linux --- code/Common/DefaultIOSystem.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/code/Common/DefaultIOSystem.cpp b/code/Common/DefaultIOSystem.cpp index b28910c70..1bda76e50 100644 --- a/code/Common/DefaultIOSystem.cpp +++ b/code/Common/DefaultIOSystem.cpp @@ -99,12 +99,12 @@ bool DefaultIOSystem::Exists(const char *pFile) const { return false; } #else - FILE *file = ::fopen(pFile, "rb"); - if (!file) { + struct stat statbuf; + stat(pFile, &statbuf); + // test for a regular file + if (!S_ISREG(statbuf.st_mode)){ return false; } - - ::fclose(file); #endif return true; @@ -116,6 +116,7 @@ IOStream *DefaultIOSystem::Open(const char *strFile, const char *strMode) { ai_assert(strFile != nullptr); ai_assert(strMode != nullptr); FILE *file; + #ifdef _WIN32 std::wstring name = Utf8ToWide(strFile); if (name.empty()) { @@ -126,6 +127,7 @@ IOStream *DefaultIOSystem::Open(const char *strFile, const char *strMode) { #else file = ::fopen(strFile, strMode); #endif + if (!file) { return nullptr; } From 3ce8a58d41ceb5c71628c7ccd2907c09b7a09b33 Mon Sep 17 00:00:00 2001 From: Marka Ragnos Date: Sat, 9 Dec 2023 19:01:04 +0100 Subject: [PATCH 21/22] Update DefaultIOSystem.cpp Added missing whitespace --- code/Common/DefaultIOSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Common/DefaultIOSystem.cpp b/code/Common/DefaultIOSystem.cpp index 1bda76e50..a72627154 100644 --- a/code/Common/DefaultIOSystem.cpp +++ b/code/Common/DefaultIOSystem.cpp @@ -102,7 +102,7 @@ bool DefaultIOSystem::Exists(const char *pFile) const { struct stat statbuf; stat(pFile, &statbuf); // test for a regular file - if (!S_ISREG(statbuf.st_mode)){ + if (!S_ISREG(statbuf.st_mode)) { return false; } #endif From df33d33e8f9004adcaa6f3c1ad8e03800dca0c9a Mon Sep 17 00:00:00 2001 From: Alexander Wagner Date: Mon, 18 Dec 2023 10:46:48 +0100 Subject: [PATCH 22/22] - removed commented code --- include/assimp/types.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/include/assimp/types.h b/include/assimp/types.h index 9f4edfe0f..42aa0f9eb 100644 --- a/include/assimp/types.h +++ b/include/assimp/types.h @@ -73,12 +73,6 @@ typedef uint32_t ai_uint32; #ifdef __cplusplus -//#ifdef ASSIMP_USE_HUNTER -//# include -//#else -//# include "../contrib/utf8cpp/source/utf8.h" -//#endif - #include #include // for std::nothrow_t #include // for aiString::Set(const std::string&)