From 1e828cb8bb18218735a8a5fa00f18ba2c544f7bd Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Fri, 14 Feb 2020 15:57:06 +0100 Subject: [PATCH 1/4] pkg-config: fix include path --- assimp.pc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assimp.pc.in b/assimp.pc.in index c659e19f2..02cf59dc4 100644 --- a/assimp.pc.in +++ b/assimp.pc.in @@ -1,7 +1,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=@CMAKE_INSTALL_PREFIX@/ libdir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_LIB_INSTALL_DIR@ -includedir=@CMAKE_INSTALL_PREFIX@/../include/@ASSIMP_INCLUDE_INSTALL_DIR@ +includedir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_INCLUDE_INSTALL_DIR@ Name: @CMAKE_PROJECT_NAME@ Description: Import various well-known 3D model formats in an uniform manner. From f28b087d163e0f027e027e6d634d4e42d55b727d Mon Sep 17 00:00:00 2001 From: iamAdrianIusca Date: Fri, 21 Feb 2020 20:17:38 +0200 Subject: [PATCH 2/4] small improvements in the CMakeLists.txt file If ASSIMP_NO_EXPORT is not defined: - don't add the macro for the exporters - don't include the files for all the exporter - don't display any messages about what exporters are enabled or not --- code/CMakeLists.txt | 232 +++++++++++++++++++++----------------------- 1 file changed, 113 insertions(+), 119 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 91f099c02..1d4586494 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -252,35 +252,39 @@ MACRO(ADD_ASSIMP_IMPORTER name) ENDIF() ENDMACRO() -# if this variable is set to TRUE, the user can manually disable exporters by setting -# ASSIMP_BUILD_XXX_EXPORTER to FALSE for each exporter -# if this variable is set to FALSE, the user can manually enable exporters by setting -# ASSIMP_BUILD_XXX_EXPORTER to TRUE for each exporter -OPTION(ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT "default value of all ASSIMP_BUILD_XXX_EXPORTER values" TRUE) +if (NOT ASSIMP_NO_EXPORT) -# macro to add the CMake Option ADD_ASSIMP_IMPORTER_ which enables compile of loader -# this way selective loaders can be compiled (reduces filesize + compile time) -MACRO(ADD_ASSIMP_EXPORTER name) - IF (ASSIMP_NO_EXPORT) - set(ASSIMP_EXPORTER_ENABLED FALSE) - ELSEIF (ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT) - set(ASSIMP_EXPORTER_ENABLED TRUE) - IF (DEFINED ASSIMP_BUILD_${name}_EXPORTER AND NOT ASSIMP_BUILD_${name}_EXPORTER) + # if this variable is set to TRUE, the user can manually disable exporters by setting + # ASSIMP_BUILD_XXX_EXPORTER to FALSE for each exporter + # if this variable is set to FALSE, the user can manually enable exporters by setting + # ASSIMP_BUILD_XXX_EXPORTER to TRUE for each exporter + OPTION(ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT "default value of all ASSIMP_BUILD_XXX_EXPORTER values" TRUE) + + # macro to add the CMake Option ADD_ASSIMP_IMPORTER_ which enables compile of loader + # this way selective loaders can be compiled (reduces filesize + compile time) + MACRO(ADD_ASSIMP_EXPORTER name) + IF (ASSIMP_NO_EXPORT) set(ASSIMP_EXPORTER_ENABLED FALSE) + ELSEIF (ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT) + set(ASSIMP_EXPORTER_ENABLED TRUE) + IF (DEFINED ASSIMP_BUILD_${name}_EXPORTER AND NOT ASSIMP_BUILD_${name}_EXPORTER) + set(ASSIMP_EXPORTER_ENABLED FALSE) + ENDIF () + ELSE () + set(ASSIMP_EXPORTER_ENABLED ${ASSIMP_BUILD_${name}_EXPORTER}) ENDIF () - ELSE () - set(ASSIMP_EXPORTER_ENABLED ${ASSIMP_BUILD_${name}_EXPORTER}) - ENDIF () - IF (ASSIMP_EXPORTER_ENABLED) - SET(ASSIMP_EXPORTERS_ENABLED "${ASSIMP_EXPORTERS_ENABLED} ${name}") - LIST(APPEND ASSIMP_EXPORTER_SRCS ${ARGN}) - SOURCE_GROUP(${name}_EXPORTER FILES ${ARGN}) - ELSE() - SET(ASSIMP_EXPORTERS_DISABLED "${ASSIMP_EXPORTERS_DISABLED} ${name}") - add_definitions(-DASSIMP_BUILD_NO_${name}_EXPORTER) - ENDIF() -ENDMACRO() + IF (ASSIMP_EXPORTER_ENABLED) + SET(ASSIMP_EXPORTERS_ENABLED "${ASSIMP_EXPORTERS_ENABLED} ${name}") + LIST(APPEND ASSIMP_EXPORTER_SRCS ${ARGN}) + SOURCE_GROUP(${name}_EXPORTER FILES ${ARGN}) + ELSE() + SET(ASSIMP_EXPORTERS_DISABLED "${ASSIMP_EXPORTERS_DISABLED} ${name}") + add_definitions(-DASSIMP_BUILD_NO_${name}_EXPORTER) + ENDIF() + ENDMACRO() + +endif() SET(ASSIMP_LOADER_SRCS "") SET(ASSIMP_IMPORTERS_ENABLED "") # list of enabled importers @@ -307,11 +311,6 @@ ADD_ASSIMP_IMPORTER( 3DS 3DS/3DSLoader.h ) -ADD_ASSIMP_EXPORTER( 3DS - 3DS/3DSExporter.h - 3DS/3DSExporter.cpp -) - ADD_ASSIMP_IMPORTER( AC AC/ACLoader.cpp AC/ACLoader.h @@ -329,20 +328,6 @@ ADD_ASSIMP_IMPORTER( ASSBIN Assbin/AssbinLoader.cpp ) -ADD_ASSIMP_EXPORTER( ASSBIN - Assbin/AssbinExporter.h - Assbin/AssbinExporter.cpp - Assbin/AssbinFileWriter.h - Assbin/AssbinFileWriter.cpp -) - -ADD_ASSIMP_EXPORTER( ASSXML - Assxml/AssxmlExporter.h - Assxml/AssxmlExporter.cpp - Assxml/AssxmlFileWriter.h - Assxml/AssxmlFileWriter.cpp -) - ADD_ASSIMP_IMPORTER( B3D B3D/B3DImporter.cpp B3D/B3DImporter.h @@ -362,11 +347,6 @@ ADD_ASSIMP_IMPORTER( COLLADA Collada/ColladaParser.h ) -ADD_ASSIMP_EXPORTER( COLLADA - Collada/ColladaExporter.h - Collada/ColladaExporter.cpp -) - ADD_ASSIMP_IMPORTER( DXF DXF/DXFLoader.cpp DXF/DXFLoader.h @@ -423,11 +403,6 @@ ADD_ASSIMP_IMPORTER( M3D M3D/m3d.h ) -ADD_ASSIMP_EXPORTER( M3D - M3D/M3DExporter.h - M3D/M3DExporter.cpp -) - ADD_ASSIMP_IMPORTER( MD2 MD2/MD2FileData.h MD2/MD2Loader.cpp @@ -505,11 +480,6 @@ ADD_ASSIMP_IMPORTER( OBJ Obj/ObjTools.h ) -ADD_ASSIMP_EXPORTER( OBJ - Obj/ObjExporter.h - Obj/ObjExporter.cpp -) - ADD_ASSIMP_IMPORTER( OGRE Ogre/OgreImporter.h Ogre/OgreStructs.h @@ -529,11 +499,6 @@ ADD_ASSIMP_IMPORTER( OPENGEX OpenGEX/OpenGEXStructs.h ) -ADD_ASSIMP_EXPORTER( OPENGEX - OpenGEX/OpenGEXExporter.cpp - OpenGEX/OpenGEXExporter.h -) - ADD_ASSIMP_IMPORTER( PLY Ply/PlyLoader.cpp Ply/PlyLoader.h @@ -541,11 +506,6 @@ ADD_ASSIMP_IMPORTER( PLY Ply/PlyParser.h ) -ADD_ASSIMP_EXPORTER( PLY - Ply/PlyExporter.cpp - Ply/PlyExporter.h -) - ADD_ASSIMP_IMPORTER( MS3D MS3D/MS3DLoader.cpp MS3D/MS3DLoader.h @@ -635,14 +595,86 @@ ADD_ASSIMP_IMPORTER( FBX FBX/FBXCommon.h ) -ADD_ASSIMP_EXPORTER( FBX - FBX/FBXExporter.h - FBX/FBXExporter.cpp - FBX/FBXExportNode.h - FBX/FBXExportNode.cpp - FBX/FBXExportProperty.h - FBX/FBXExportProperty.cpp -) +if (NOT ASSIMP_NO_EXPORT) + + ADD_ASSIMP_EXPORTER( OBJ + Obj/ObjExporter.h + Obj/ObjExporter.cpp) + + ADD_ASSIMP_EXPORTER( OPENGEX + OpenGEX/OpenGEXExporter.cpp + OpenGEX/OpenGEXExporter.h) + + ADD_ASSIMP_EXPORTER( PLY + Ply/PlyExporter.cpp + Ply/PlyExporter.h) + + ADD_ASSIMP_EXPORTER( 3DS + 3DS/3DSExporter.h + 3DS/3DSExporter.cpp) + + ADD_ASSIMP_EXPORTER( ASSBIN + Assbin/AssbinExporter.h + Assbin/AssbinExporter.cpp + Assbin/AssbinFileWriter.h + Assbin/AssbinFileWriter.cpp) + + ADD_ASSIMP_EXPORTER( ASSXML + Assxml/AssxmlExporter.h + Assxml/AssxmlExporter.cpp + Assxml/AssxmlFileWriter.h + Assxml/AssxmlFileWriter.cpp) + + ADD_ASSIMP_EXPORTER(M3D + M3D/M3DExporter.h + M3D/M3DExporter.cpp) + + ADD_ASSIMP_EXPORTER(COLLADA + Collada/ColladaExporter.h + Collada/ColladaExporter.cpp) + + ADD_ASSIMP_EXPORTER( FBX + FBX/FBXExporter.h + FBX/FBXExporter.cpp + FBX/FBXExportNode.h + FBX/FBXExportNode.cpp + FBX/FBXExportProperty.h + FBX/FBXExportProperty.cpp) + + ADD_ASSIMP_EXPORTER( STL + STL/STLExporter.h + STL/STLExporter.cpp) + + ADD_ASSIMP_EXPORTER( X + X/XFileExporter.h + X/XFileExporter.cpp) + + ADD_ASSIMP_EXPORTER( X3D + X3D/X3DExporter.cpp + X3D/X3DExporter.hpp) + + ADD_ASSIMP_EXPORTER( GLTF + glTF/glTFExporter.h + glTF/glTFExporter.cpp + glTF2/glTF2Exporter.h + glTF2/glTF2Exporter.cpp) + + ADD_ASSIMP_EXPORTER( 3MF + 3MF/D3MFExporter.h + 3MF/D3MFExporter.cpp) + + ADD_ASSIMP_EXPORTER( ASSJSON + Assjson/cencode.c + Assjson/cencode.h + Assjson/json_exporter.cpp + Assjson/mesh_splitter.cpp + Assjson/mesh_splitter.h) + + ADD_ASSIMP_EXPORTER( STEP + Step/StepExporter.h + Step/StepExporter.cpp) + +endif() SET( PostProcessing_SRCS PostProcessing/CalcTangentsProcess.cpp @@ -744,11 +776,6 @@ ADD_ASSIMP_IMPORTER( STL STL/STLLoader.h ) -ADD_ASSIMP_EXPORTER( STL - STL/STLExporter.h - STL/STLExporter.cpp -) - ADD_ASSIMP_IMPORTER( TERRAGEN Terragen/TerragenLoader.cpp Terragen/TerragenLoader.h @@ -767,11 +794,6 @@ ADD_ASSIMP_IMPORTER( X X/XFileParser.h ) -ADD_ASSIMP_EXPORTER( X - X/XFileExporter.h - X/XFileExporter.cpp -) - ADD_ASSIMP_IMPORTER( X3D X3D/X3DImporter.cpp X3D/X3DImporter.hpp @@ -792,11 +814,6 @@ ADD_ASSIMP_IMPORTER( X3D X3D/X3DVocabulary.cpp ) -ADD_ASSIMP_EXPORTER( X3D - X3D/X3DExporter.cpp - X3D/X3DExporter.hpp -) - ADD_ASSIMP_IMPORTER( GLTF glTF/glTFCommon.h glTF/glTFCommon.cpp @@ -814,13 +831,6 @@ ADD_ASSIMP_IMPORTER( GLTF glTF2/glTF2Importer.h ) -ADD_ASSIMP_EXPORTER( GLTF - glTF/glTFExporter.h - glTF/glTFExporter.cpp - glTF2/glTF2Exporter.h - glTF2/glTF2Exporter.cpp -) - ADD_ASSIMP_IMPORTER( 3MF 3MF/D3MFImporter.h 3MF/D3MFImporter.cpp @@ -829,11 +839,6 @@ ADD_ASSIMP_IMPORTER( 3MF 3MF/3MFXmlTags.h ) -ADD_ASSIMP_EXPORTER( 3MF - 3MF/D3MFExporter.h - 3MF/D3MFExporter.cpp -) - ADD_ASSIMP_IMPORTER( MMD MMD/MMDCpp14.h MMD/MMDImporter.cpp @@ -844,14 +849,6 @@ ADD_ASSIMP_IMPORTER( MMD MMD/MMDVmdParser.h ) -ADD_ASSIMP_EXPORTER( ASSJSON - Assjson/cencode.c - Assjson/cencode.h - Assjson/json_exporter.cpp - Assjson/mesh_splitter.cpp - Assjson/mesh_splitter.h -) - # Workaround for issue #2406 - force problematic large file to be optimized to prevent string table overflow error # Used -Os instead of -O2 as previous issues had mentioned, since -Os is roughly speaking -O2, excluding any # optimizations that take up extra space. Given that the issue is a string table overflowing, -Os seemed appropriate @@ -874,11 +871,6 @@ ADD_ASSIMP_IMPORTER( STEP Importer/StepFile/StepReaderGen.h ) -ADD_ASSIMP_EXPORTER( STEP - Step/StepExporter.h - Step/StepExporter.cpp -) - if ((NOT ASSIMP_NO_EXPORT) OR (NOT ASSIMP_EXPORTERS_ENABLED STREQUAL "")) SET( Exporter_SRCS Common/Exporter.cpp @@ -1088,8 +1080,10 @@ ENDIF(NOT HUNTER_ENABLED) MESSAGE(STATUS "Enabled importer formats:${ASSIMP_IMPORTERS_ENABLED}") MESSAGE(STATUS "Disabled importer formats:${ASSIMP_IMPORTERS_DISABLED}") -MESSAGE(STATUS "Enabled exporter formats:${ASSIMP_EXPORTERS_ENABLED}") -MESSAGE(STATUS "Disabled exporter formats:${ASSIMP_EXPORTERS_DISABLED}") +if (NOT ASSIMP_NO_EXPORT) + MESSAGE(STATUS "Enabled exporter formats:${ASSIMP_EXPORTERS_ENABLED}") + MESSAGE(STATUS "Disabled exporter formats:${ASSIMP_EXPORTERS_DISABLED}") +endif() SOURCE_GROUP( include\\assimp FILES ${PUBLIC_HEADERS} ) From 22311883ce2aca0477f764bb300541f02834645f Mon Sep 17 00:00:00 2001 From: Sebastian Matusik Date: Fri, 28 Feb 2020 18:39:40 -0800 Subject: [PATCH 3/4] Fix for #3037 [FATAL] SplitByBoneCountProcess::SplitMesh goes into infinite loop --- code/Common/SplitByBoneCountProcess.cpp | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/code/Common/SplitByBoneCountProcess.cpp b/code/Common/SplitByBoneCountProcess.cpp index b472cb359..e8e216478 100644 --- a/code/Common/SplitByBoneCountProcess.cpp +++ b/code/Common/SplitByBoneCountProcess.cpp @@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include using namespace Assimp; using namespace Assimp::Formatter; @@ -94,7 +95,10 @@ void SplitByBoneCountProcess::Execute( aiScene* pScene) bool isNecessary = false; for( unsigned int a = 0; a < pScene->mNumMeshes; ++a) if( pScene->mMeshes[a]->mNumBones > mMaxBoneCount ) + { isNecessary = true; + break; + } if( !isNecessary ) { @@ -155,7 +159,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormNumBones <= mMaxBoneCount ) + { return; + } // necessary optimisation: build a list of all affecting bones for each vertex // TODO: (thom) maybe add a custom allocator here to avoid allocating tens of thousands of small arrays @@ -165,7 +171,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormBones[a]; for( unsigned int b = 0; b < bone->mNumWeights; ++b) + { vertexBones[ bone->mWeights[b].mVertexId ].push_back( BoneWeight( a, bone->mWeights[b].mWeight)); + } } unsigned int numFacesHandled = 0; @@ -189,7 +197,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormFaces[a]; // check every vertex if its bones would still fit into the current submesh @@ -201,17 +211,27 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector mMaxBoneCount) + { + throw DeadlyImportError("SplitByBoneCountProcess: Single face requires more bones than specified max bone count!"); + } // leave out the face if the new bones required for this face don't fit the bone count limit anymore if( numBones + newBonesAtCurrentFace.size() > mMaxBoneCount ) + { continue; + } // mark all new bones as necessary while( !newBonesAtCurrentFace.empty() ) @@ -219,7 +239,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormName.length > 0 ) + { newMesh->mName.Set( format() << pMesh->mName.data << "_sub" << poNewMeshes.size()); + } newMesh->mMaterialIndex = pMesh->mMaterialIndex; newMesh->mPrimitiveTypes = pMesh->mPrimitiveTypes; poNewMeshes.push_back( newMesh); @@ -247,7 +271,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormNumFaces = static_cast(subMeshFaces.size()); newMesh->mVertices = new aiVector3D[newMesh->mNumVertices]; if( pMesh->HasNormals() ) + { newMesh->mNormals = new aiVector3D[newMesh->mNumVertices]; + } if( pMesh->HasTangentsAndBitangents() ) { newMesh->mTangents = new aiVector3D[newMesh->mNumVertices]; @@ -256,13 +282,17 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectorHasTextureCoords( a) ) + { newMesh->mTextureCoords[a] = new aiVector3D[newMesh->mNumVertices]; + } newMesh->mNumUVComponents[a] = pMesh->mNumUVComponents[a]; } for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a ) { if( pMesh->HasVertexColors( a) ) + { newMesh->mColors[a] = new aiColor4D[newMesh->mNumVertices]; + } } // and copy over the data, generating faces with linear indices along the way @@ -285,7 +315,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormVertices[nvi] = pMesh->mVertices[srcIndex]; if( pMesh->HasNormals() ) + { newMesh->mNormals[nvi] = pMesh->mNormals[srcIndex]; + } if( pMesh->HasTangentsAndBitangents() ) { newMesh->mTangents[nvi] = pMesh->mTangents[srcIndex]; @@ -294,12 +326,16 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectorHasTextureCoords( c) ) + { newMesh->mTextureCoords[c][nvi] = pMesh->mTextureCoords[c][srcIndex]; + } } for( unsigned int c = 0; c < AI_MAX_NUMBER_OF_COLOR_SETS; ++c ) { if( pMesh->HasVertexColors( c) ) + { newMesh->mColors[c][nvi] = pMesh->mColors[c][srcIndex]; + } } nvi++; @@ -316,7 +352,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormNumBones; ++a ) { if( !isBoneUsed[a] ) + { continue; + } // create the new bone const aiBone* srcBone = pMesh->mBones[a]; @@ -340,7 +378,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector::max() ) + { newMesh->mBones[newBoneIndex]->mNumWeights++; + } } } From 496fcd35c19b8ae4521487ad6d498d5476f69cfa Mon Sep 17 00:00:00 2001 From: Sebastian Matusik Date: Fri, 28 Feb 2020 19:17:53 -0800 Subject: [PATCH 4/4] Trimmed trailing whitespaces --- code/Common/SplitByBoneCountProcess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Common/SplitByBoneCountProcess.cpp b/code/Common/SplitByBoneCountProcess.cpp index e8e216478..ab7a1fe00 100644 --- a/code/Common/SplitByBoneCountProcess.cpp +++ b/code/Common/SplitByBoneCountProcess.cpp @@ -224,7 +224,7 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector mMaxBoneCount) - { + { throw DeadlyImportError("SplitByBoneCountProcess: Single face requires more bones than specified max bone count!"); } // leave out the face if the new bones required for this face don't fit the bone count limit anymore