From 6b5e0a991401db8f13c3861e59a05cdd186add4a Mon Sep 17 00:00:00 2001 From: thomasbiang Date: Tue, 9 Jul 2019 19:05:45 -0700 Subject: [PATCH 01/18] fix group node being exported as bone node --- code/FBX/FBXExporter.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index dd34e135f..a0a46e09d 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -1617,6 +1617,17 @@ void FBXExporter::WriteObjects () // at the same time we can build a list of all the skeleton nodes, // which will be used later to mark them as type "limbNode". std::unordered_set limbnodes; + + //actual bone nodes in fbx, without parenting-up + std::set setAllBoneNamesInScene; + for(int m = 0; m < mScene->mNumMeshes; ++ m) + { + aiMesh* pMesh = mScene->mMeshes[m]; + for(int b = 0; b < pMesh->mNumBones; ++ b) + setAllBoneNamesInScene.insert(pMesh->mBones[b]->mName.data); + } + aiMatrix4x4 mxTransIdentity; + // and a map of nodes by bone name, as finding them is annoying. std::map node_by_bone; for (size_t mi = 0; mi < mScene->mNumMeshes; ++mi) { @@ -1660,6 +1671,11 @@ void FBXExporter::WriteObjects () if (node_name.find(MAGIC_NODE_TAG) != std::string::npos) { continue; } + //not a bone in scene && no effect in transform + if(setAllBoneNamesInScene.find(node_name)==setAllBoneNamesInScene.end() + && parent->mTransformation == mxTransIdentity) { + continue; + } // otherwise check if this is the root of the skeleton bool end = false; // is the mesh part of this node? From d7773dcfba97b76ca4671b629f8856c0d2693d74 Mon Sep 17 00:00:00 2001 From: thomasbiang Date: Wed, 10 Jul 2019 09:51:20 -0700 Subject: [PATCH 02/18] set->unordered_set;unsigned int for iteration --- code/FBX/FBXExporter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index a0a46e09d..08f4bdbc9 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -1619,11 +1619,11 @@ void FBXExporter::WriteObjects () std::unordered_set limbnodes; //actual bone nodes in fbx, without parenting-up - std::set setAllBoneNamesInScene; - for(int m = 0; m < mScene->mNumMeshes; ++ m) + std::unordered_set setAllBoneNamesInScene; + for(unsigned int m = 0; m < mScene->mNumMeshes; ++ m) { aiMesh* pMesh = mScene->mMeshes[m]; - for(int b = 0; b < pMesh->mNumBones; ++ b) + for(unsigned int b = 0; b < pMesh->mNumBones; ++ b) setAllBoneNamesInScene.insert(pMesh->mBones[b]->mName.data); } aiMatrix4x4 mxTransIdentity; From f703a798f4a66166687a0d5252a6e389bd1d752c Mon Sep 17 00:00:00 2001 From: thomasbiang Date: Wed, 10 Jul 2019 16:27:59 -0700 Subject: [PATCH 03/18] customize error rate for bind pose --- code/FBX/FBXExporter.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index dd34e135f..347025a79 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -68,6 +68,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include //wangyi + // RESOURCES: // https://code.blender.org/2013/08/fbx-binary-file-format-specification/ // https://wiki.blender.org/index.php/User:Mont29/Foundation/FBX_File_Structure @@ -1824,7 +1826,10 @@ void FBXExporter::WriteObjects () // this should be the same as the bone's mOffsetMatrix. // if it's not the same, the skeleton isn't in the bind pose. - const float epsilon = 1e-4f; // some error is to be expected + float epsilon = 1e-4f; // some error is to be expected +#ifdef ASSIMP_CUSTOM_BINDPOSE_ERR + epsilon = ASSIMP_CUSTOM_BINDPOSE_ERR; +#endif bool bone_xform_okay = true; if (b && ! tr.Equal(b->mOffsetMatrix, epsilon)) { not_in_bind_pose.insert(b); From f03f099fa88b078b6197e5bcbdf8defdc136a107 Mon Sep 17 00:00:00 2001 From: thomasbiang Date: Wed, 10 Jul 2019 16:29:50 -0700 Subject: [PATCH 04/18] clean up --- code/FBX/FBXExporter.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index 347025a79..ea1efb777 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -68,8 +68,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include //wangyi - // RESOURCES: // https://code.blender.org/2013/08/fbx-binary-file-format-specification/ // https://wiki.blender.org/index.php/User:Mont29/Foundation/FBX_File_Structure From 259a9bd2af6e7a0ed1d651b2bc0dfdec8d066003 Mon Sep 17 00:00:00 2001 From: thomasbiang Date: Thu, 11 Jul 2019 17:00:47 -0700 Subject: [PATCH 05/18] use ExportProperties to customize bind pose epsilon --- code/FBX/FBXExporter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index ea1efb777..c51e15252 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -67,6 +67,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include // RESOURCES: // https://code.blender.org/2013/08/fbx-binary-file-format-specification/ @@ -1825,9 +1826,9 @@ void FBXExporter::WriteObjects () // this should be the same as the bone's mOffsetMatrix. // if it's not the same, the skeleton isn't in the bind pose. float epsilon = 1e-4f; // some error is to be expected -#ifdef ASSIMP_CUSTOM_BINDPOSE_ERR - epsilon = ASSIMP_CUSTOM_BINDPOSE_ERR; -#endif + float epsilon_custom = mProperties->GetPropertyFloat("BINDPOSE_EPSILON", -1); + if(epsilon_custom > 0) + epsilon = epsilon_custom; bool bone_xform_okay = true; if (b && ! tr.Equal(b->mOffsetMatrix, epsilon)) { not_in_bind_pose.insert(b); From f2731a1b99b6174c1d33b3c6e4146b1ecf72a097 Mon Sep 17 00:00:00 2001 From: thomasbiang Date: Wed, 10 Jul 2019 16:27:59 -0700 Subject: [PATCH 06/18] customize error rate for bind pose --- code/FBX/FBXExporter.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index 08f4bdbc9..f25b4f135 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -68,6 +68,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include //wangyi + // RESOURCES: // https://code.blender.org/2013/08/fbx-binary-file-format-specification/ // https://wiki.blender.org/index.php/User:Mont29/Foundation/FBX_File_Structure @@ -1840,7 +1842,10 @@ void FBXExporter::WriteObjects () // this should be the same as the bone's mOffsetMatrix. // if it's not the same, the skeleton isn't in the bind pose. - const float epsilon = 1e-4f; // some error is to be expected + float epsilon = 1e-4f; // some error is to be expected +#ifdef ASSIMP_CUSTOM_BINDPOSE_ERR + epsilon = ASSIMP_CUSTOM_BINDPOSE_ERR; +#endif bool bone_xform_okay = true; if (b && ! tr.Equal(b->mOffsetMatrix, epsilon)) { not_in_bind_pose.insert(b); From add4d6028b5da6c2a4c1cf4a9261a7a288715262 Mon Sep 17 00:00:00 2001 From: thomasbiang Date: Wed, 10 Jul 2019 16:29:50 -0700 Subject: [PATCH 07/18] clean up --- code/FBX/FBXExporter.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index f25b4f135..5367a8525 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -68,8 +68,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include //wangyi - // RESOURCES: // https://code.blender.org/2013/08/fbx-binary-file-format-specification/ // https://wiki.blender.org/index.php/User:Mont29/Foundation/FBX_File_Structure From 36130f9b86d27a8c8600dc5d163d69d9cbb19fef Mon Sep 17 00:00:00 2001 From: thomasbiang Date: Thu, 11 Jul 2019 17:00:47 -0700 Subject: [PATCH 08/18] use ExportProperties to customize bind pose epsilon --- code/FBX/FBXExporter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index 5367a8525..915b4aca7 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -67,6 +67,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include // RESOURCES: // https://code.blender.org/2013/08/fbx-binary-file-format-specification/ @@ -1841,9 +1842,9 @@ void FBXExporter::WriteObjects () // this should be the same as the bone's mOffsetMatrix. // if it's not the same, the skeleton isn't in the bind pose. float epsilon = 1e-4f; // some error is to be expected -#ifdef ASSIMP_CUSTOM_BINDPOSE_ERR - epsilon = ASSIMP_CUSTOM_BINDPOSE_ERR; -#endif + float epsilon_custom = mProperties->GetPropertyFloat("BINDPOSE_EPSILON", -1); + if(epsilon_custom > 0) + epsilon = epsilon_custom; bool bone_xform_okay = true; if (b && ! tr.Equal(b->mOffsetMatrix, epsilon)) { not_in_bind_pose.insert(b); From f04517004878681e4fac09a60f7876a6df4652f2 Mon Sep 17 00:00:00 2001 From: ywang Date: Mon, 15 Jul 2019 15:52:45 -0700 Subject: [PATCH 09/18] update --- code/FBX/FBXExporter.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index 915b4aca7..dc17fc885 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -67,7 +67,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include // RESOURCES: // https://code.blender.org/2013/08/fbx-binary-file-format-specification/ From 9210ff37f2433e016cb8b83d62f9064ed0428e8d Mon Sep 17 00:00:00 2001 From: thomasbiang Date: Tue, 9 Jul 2019 19:05:45 -0700 Subject: [PATCH 10/18] fix group node being exported as bone node --- code/FBX/FBXExporter.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index dd34e135f..a0a46e09d 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -1617,6 +1617,17 @@ void FBXExporter::WriteObjects () // at the same time we can build a list of all the skeleton nodes, // which will be used later to mark them as type "limbNode". std::unordered_set limbnodes; + + //actual bone nodes in fbx, without parenting-up + std::set setAllBoneNamesInScene; + for(int m = 0; m < mScene->mNumMeshes; ++ m) + { + aiMesh* pMesh = mScene->mMeshes[m]; + for(int b = 0; b < pMesh->mNumBones; ++ b) + setAllBoneNamesInScene.insert(pMesh->mBones[b]->mName.data); + } + aiMatrix4x4 mxTransIdentity; + // and a map of nodes by bone name, as finding them is annoying. std::map node_by_bone; for (size_t mi = 0; mi < mScene->mNumMeshes; ++mi) { @@ -1660,6 +1671,11 @@ void FBXExporter::WriteObjects () if (node_name.find(MAGIC_NODE_TAG) != std::string::npos) { continue; } + //not a bone in scene && no effect in transform + if(setAllBoneNamesInScene.find(node_name)==setAllBoneNamesInScene.end() + && parent->mTransformation == mxTransIdentity) { + continue; + } // otherwise check if this is the root of the skeleton bool end = false; // is the mesh part of this node? From c889699d581f2acbef899120be60104c5b1127cb Mon Sep 17 00:00:00 2001 From: thomasbiang Date: Wed, 10 Jul 2019 09:51:20 -0700 Subject: [PATCH 11/18] set->unordered_set;unsigned int for iteration --- code/FBX/FBXExporter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index a0a46e09d..08f4bdbc9 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -1619,11 +1619,11 @@ void FBXExporter::WriteObjects () std::unordered_set limbnodes; //actual bone nodes in fbx, without parenting-up - std::set setAllBoneNamesInScene; - for(int m = 0; m < mScene->mNumMeshes; ++ m) + std::unordered_set setAllBoneNamesInScene; + for(unsigned int m = 0; m < mScene->mNumMeshes; ++ m) { aiMesh* pMesh = mScene->mMeshes[m]; - for(int b = 0; b < pMesh->mNumBones; ++ b) + for(unsigned int b = 0; b < pMesh->mNumBones; ++ b) setAllBoneNamesInScene.insert(pMesh->mBones[b]->mName.data); } aiMatrix4x4 mxTransIdentity; From cdf60d7423200890b9740715fb0ef1a65f5da6f0 Mon Sep 17 00:00:00 2001 From: thomasbiang Date: Wed, 10 Jul 2019 16:27:59 -0700 Subject: [PATCH 12/18] customize error rate for bind pose --- code/FBX/FBXExporter.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index 08f4bdbc9..f25b4f135 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -68,6 +68,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include //wangyi + // RESOURCES: // https://code.blender.org/2013/08/fbx-binary-file-format-specification/ // https://wiki.blender.org/index.php/User:Mont29/Foundation/FBX_File_Structure @@ -1840,7 +1842,10 @@ void FBXExporter::WriteObjects () // this should be the same as the bone's mOffsetMatrix. // if it's not the same, the skeleton isn't in the bind pose. - const float epsilon = 1e-4f; // some error is to be expected + float epsilon = 1e-4f; // some error is to be expected +#ifdef ASSIMP_CUSTOM_BINDPOSE_ERR + epsilon = ASSIMP_CUSTOM_BINDPOSE_ERR; +#endif bool bone_xform_okay = true; if (b && ! tr.Equal(b->mOffsetMatrix, epsilon)) { not_in_bind_pose.insert(b); From 6e0810d3c1e31f347ea2dff60ef7202bc9c5f802 Mon Sep 17 00:00:00 2001 From: thomasbiang Date: Wed, 10 Jul 2019 16:29:50 -0700 Subject: [PATCH 13/18] clean up --- code/FBX/FBXExporter.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index f25b4f135..5367a8525 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -68,8 +68,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include //wangyi - // RESOURCES: // https://code.blender.org/2013/08/fbx-binary-file-format-specification/ // https://wiki.blender.org/index.php/User:Mont29/Foundation/FBX_File_Structure From 6299c58fae951302e67381921de55994b9125517 Mon Sep 17 00:00:00 2001 From: thomasbiang Date: Thu, 11 Jul 2019 17:00:47 -0700 Subject: [PATCH 14/18] use ExportProperties to customize bind pose epsilon --- code/FBX/FBXExporter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index 5367a8525..915b4aca7 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -67,6 +67,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include // RESOURCES: // https://code.blender.org/2013/08/fbx-binary-file-format-specification/ @@ -1841,9 +1842,9 @@ void FBXExporter::WriteObjects () // this should be the same as the bone's mOffsetMatrix. // if it's not the same, the skeleton isn't in the bind pose. float epsilon = 1e-4f; // some error is to be expected -#ifdef ASSIMP_CUSTOM_BINDPOSE_ERR - epsilon = ASSIMP_CUSTOM_BINDPOSE_ERR; -#endif + float epsilon_custom = mProperties->GetPropertyFloat("BINDPOSE_EPSILON", -1); + if(epsilon_custom > 0) + epsilon = epsilon_custom; bool bone_xform_okay = true; if (b && ! tr.Equal(b->mOffsetMatrix, epsilon)) { not_in_bind_pose.insert(b); From 5121a835b5021a2262e71550fd876688fd9c72ae Mon Sep 17 00:00:00 2001 From: thomasbiang Date: Wed, 10 Jul 2019 16:27:59 -0700 Subject: [PATCH 15/18] customize error rate for bind pose --- code/FBX/FBXExporter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index 915b4aca7..7419f3d15 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -69,6 +69,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include //wangyi + // RESOURCES: // https://code.blender.org/2013/08/fbx-binary-file-format-specification/ // https://wiki.blender.org/index.php/User:Mont29/Foundation/FBX_File_Structure From e3683e49e4476aaba44fe5b9484091413ea35f7f Mon Sep 17 00:00:00 2001 From: thomasbiang Date: Wed, 10 Jul 2019 16:29:50 -0700 Subject: [PATCH 16/18] clean up --- code/FBX/FBXExporter.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index 7419f3d15..915b4aca7 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -69,8 +69,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include //wangyi - // RESOURCES: // https://code.blender.org/2013/08/fbx-binary-file-format-specification/ // https://wiki.blender.org/index.php/User:Mont29/Foundation/FBX_File_Structure From e1e9d92c01e0f38f0da2b02ca4acb409f84eedb2 Mon Sep 17 00:00:00 2001 From: ywang Date: Mon, 15 Jul 2019 15:52:45 -0700 Subject: [PATCH 17/18] update --- code/FBX/FBXExporter.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/code/FBX/FBXExporter.cpp b/code/FBX/FBXExporter.cpp index 915b4aca7..dc17fc885 100644 --- a/code/FBX/FBXExporter.cpp +++ b/code/FBX/FBXExporter.cpp @@ -67,7 +67,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include // RESOURCES: // https://code.blender.org/2013/08/fbx-binary-file-format-specification/ From 78b283135e63707c7847242400be286351a8c9e8 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 21 Jul 2019 13:32:31 +0200 Subject: [PATCH 18/18] Update utIssues.cpp use correct test for floats. --- test/unit/utIssues.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/utIssues.cpp b/test/unit/utIssues.cpp index 6a974d7b9..0e30fa182 100644 --- a/test/unit/utIssues.cpp +++ b/test/unit/utIssues.cpp @@ -74,7 +74,7 @@ TEST_F( utIssues, OpacityBugWhenExporting_727 ) { if ( newScene->mNumMaterials > 0 ) { std::cout << "Desc = " << desc->description << "\n"; EXPECT_EQ( AI_SUCCESS, newScene->mMaterials[ 0 ]->Get( AI_MATKEY_OPACITY, newOpacity ) ); - EXPECT_EQ( opacity, newOpacity ); + EXPECT_FLOAT_EQ( opacity, newOpacity ); } delete scene; }