From 793284a766e33a0cad7d1af3e6ad95df07ac826b Mon Sep 17 00:00:00 2001 From: Krishty Date: Mon, 16 Jan 2023 08:42:50 +0100 Subject: [PATCH 1/5] Fix Build Without ArmaturePopulate Post Process Step This post process step introduced new attributes into `aiSkeletonBone`. Said attributes are only defined with the process enabled, i.e. when the `ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS` macro has not been defined. Some code, however, accessed the variables unconditionally, leading to build failures if `ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS` was defined. This commit adds the missing checks. --- code/AssetLib/FBX/FBXConverter.cpp | 2 ++ include/assimp/mesh.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp index 75d28fbdf..b989e8730 100644 --- a/code/AssetLib/FBX/FBXConverter.cpp +++ b/code/AssetLib/FBX/FBXConverter.cpp @@ -1455,7 +1455,9 @@ static void copyBoneToSkeletonBone(aiMesh *mesh, aiBone *bone, aiSkeletonBone *s skeletonBone->mWeights = bone->mWeights; skeletonBone->mOffsetMatrix = bone->mOffsetMatrix; skeletonBone->mMeshId = mesh; +#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS skeletonBone->mNode = bone->mNode; +#endif skeletonBone->mParent = -1; } diff --git a/include/assimp/mesh.h b/include/assimp/mesh.h index 363627464..b0179e179 100644 --- a/include/assimp/mesh.h +++ b/include/assimp/mesh.h @@ -988,8 +988,10 @@ struct aiSkeletonBone { #ifdef __cplusplus aiSkeletonBone() : mParent(-1), +#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS mArmature(nullptr), mNode(nullptr), +#endif mNumnWeights(0), mMeshId(nullptr), mWeights(nullptr), From 72b178b9fc6825adc1607afdfed4c8cdae10f615 Mon Sep 17 00:00:00 2001 From: AdamCichocki Date: Mon, 23 Jan 2023 14:51:02 +0100 Subject: [PATCH 2/5] Optimized usedVertexIndices by using bitmask instead of unordered_set --- code/PostProcessing/JoinVerticesProcess.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/code/PostProcessing/JoinVerticesProcess.cpp b/code/PostProcessing/JoinVerticesProcess.cpp index 0423ab5c2..30831eed0 100644 --- a/code/PostProcessing/JoinVerticesProcess.cpp +++ b/code/PostProcessing/JoinVerticesProcess.cpp @@ -264,12 +264,13 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) { // We should care only about used vertices, not all of them // (this can happen due to original file vertices buffer being used by // multiple meshes) - std::unordered_set usedVertexIndices; - usedVertexIndices.reserve(pMesh->mNumVertices); - for( unsigned int a = 0; a < pMesh->mNumFaces; a++) { + std::vector usedVertexIndicesMask; + usedVertexIndicesMask.resize((pMesh->mNumVertices + 31) / 32, 0); + for (unsigned int a = 0; a < pMesh->mNumFaces; a++) { aiFace& face = pMesh->mFaces[a]; - for( unsigned int b = 0; b < face.mNumIndices; b++) { - usedVertexIndices.insert(face.mIndices[b]); + for (unsigned int b = 0; b < face.mNumIndices; b++) { + const unsigned int currIndex = face.mIndices[b]; + usedVertexIndicesMask[currIndex / 32] |= 1u << (currIndex % 32); } } @@ -335,7 +336,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) { int newIndex = 0; for( unsigned int a = 0; a < pMesh->mNumVertices; a++) { // if the vertex is unused Do nothing - if (usedVertexIndices.find(a) == usedVertexIndices.end()) { + if (0 == (usedVertexIndicesMask[a / 32] & (1u << (a % 32)))) { continue; } // collect the vertex data From 5ed09b7ab6fde84099a095c4ffcef055c9d715a5 Mon Sep 17 00:00:00 2001 From: AdamCichocki Date: Mon, 23 Jan 2023 16:39:06 +0100 Subject: [PATCH 3/5] usedVertexIndicesMask is now based on vector instead of vector --- code/PostProcessing/JoinVerticesProcess.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/code/PostProcessing/JoinVerticesProcess.cpp b/code/PostProcessing/JoinVerticesProcess.cpp index 30831eed0..3bf96afeb 100644 --- a/code/PostProcessing/JoinVerticesProcess.cpp +++ b/code/PostProcessing/JoinVerticesProcess.cpp @@ -264,13 +264,12 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) { // We should care only about used vertices, not all of them // (this can happen due to original file vertices buffer being used by // multiple meshes) - std::vector usedVertexIndicesMask; - usedVertexIndicesMask.resize((pMesh->mNumVertices + 31) / 32, 0); + std::vector usedVertexIndicesMask; + usedVertexIndicesMask.resize(pMesh->mNumVertices, false); for (unsigned int a = 0; a < pMesh->mNumFaces; a++) { aiFace& face = pMesh->mFaces[a]; for (unsigned int b = 0; b < face.mNumIndices; b++) { - const unsigned int currIndex = face.mIndices[b]; - usedVertexIndicesMask[currIndex / 32] |= 1u << (currIndex % 32); + usedVertexIndicesMask[face.mIndices[b]] = true; } } @@ -336,7 +335,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) { int newIndex = 0; for( unsigned int a = 0; a < pMesh->mNumVertices; a++) { // if the vertex is unused Do nothing - if (0 == (usedVertexIndicesMask[a / 32] & (1u << (a % 32)))) { + if (!usedVertexIndicesMask[a]) { continue; } // collect the vertex data From 5c286b8c134997aebb31060548f8e4e59e8598aa Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 31 Jan 2023 20:12:07 +0100 Subject: [PATCH 4/5] Fix: Remove deprecated dependency. --- port/iOS/build.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/port/iOS/build.sh b/port/iOS/build.sh index 335b450d1..1248eb641 100755 --- a/port/iOS/build.sh +++ b/port/iOS/build.sh @@ -190,11 +190,9 @@ if [[ "$DEPLOY_FAT" -eq 1 ]]; then if [[ "$BUILD_TYPE" =~ "Debug" ]]; then make_fat_static_or_shared_binary 'libassimpd' - make_fat_static_binary 'libIrrXMLd' make_fat_static_binary 'libzlibstaticd' else make_fat_static_or_shared_binary 'libassimp' - make_fat_static_binary 'libIrrXML' make_fat_static_binary 'libzlibstatic' fi From 47303c2d28967ffb36d31df7db6a04c9f5917eda Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 31 Jan 2023 20:41:18 +0100 Subject: [PATCH 5/5] Fix:Remove deprecated features from iOS build. --- port/iOS/build.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/port/iOS/build.sh b/port/iOS/build.sh index 1248eb641..099bd8b0f 100755 --- a/port/iOS/build.sh +++ b/port/iOS/build.sh @@ -76,7 +76,7 @@ build_arch() rm CMakeCache.txt - CMAKE_CLI_INPUT="-DCMAKE_C_COMPILER=$CMAKE_C_COMPILER -DCMAKE_CXX_COMPILER=$CMAKE_CXX_COMPILER -DCMAKE_TOOLCHAIN_FILE=./port/iOS/IPHONEOS_$(echo $1 | tr '[:lower:]' '[:upper:]')_TOOLCHAIN.cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_BOOST_WORKAROUND=ON -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS" + CMAKE_CLI_INPUT="-DCMAKE_C_COMPILER=$CMAKE_C_COMPILER -DCMAKE_CXX_COMPILER=$CMAKE_CXX_COMPILER -DCMAKE_TOOLCHAIN_FILE=./port/iOS/IPHONEOS_$(echo $1 | tr '[:lower:]' '[:upper:]')_TOOLCHAIN.cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS" echo "[!] Running CMake with -G 'Unix Makefiles' $CMAKE_CLI_INPUT" @@ -190,10 +190,8 @@ if [[ "$DEPLOY_FAT" -eq 1 ]]; then if [[ "$BUILD_TYPE" =~ "Debug" ]]; then make_fat_static_or_shared_binary 'libassimpd' - make_fat_static_binary 'libzlibstaticd' else make_fat_static_or_shared_binary 'libassimp' - make_fat_static_binary 'libzlibstatic' fi echo "[!] Done! The fat binaries can be found at $BUILD_DIR"