From 9210ff37f2433e016cb8b83d62f9064ed0428e8d Mon Sep 17 00:00:00 2001 From: thomasbiang Date: Tue, 9 Jul 2019 19:05:45 -0700 Subject: [PATCH] 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?