From aadb413fc07dccb8fe5b8fee8704b941f5713816 Mon Sep 17 00:00:00 2001 From: Tommy Date: Wed, 28 Mar 2018 16:09:07 +0200 Subject: [PATCH] Explicit handling of an FBXExportNode edge-case. --- code/FBXExportNode.cpp | 2 +- code/FBXExportNode.h | 3 +++ code/FBXExporter.cpp | 15 +++++---------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/code/FBXExportNode.cpp b/code/FBXExportNode.cpp index 596901989..621e72f09 100644 --- a/code/FBXExportNode.cpp +++ b/code/FBXExportNode.cpp @@ -168,7 +168,7 @@ void FBX::Node::Dump(Assimp::StreamWriterLE &s) DumpChildren(s); // finish, filling in end offset placeholder - End(s, !children.empty()); + End(s, force_has_children || !children.empty()); } void FBX::Node::Begin(Assimp::StreamWriterLE &s) diff --git a/code/FBXExportNode.h b/code/FBXExportNode.h index 2539a9458..58d3d14ee 100644 --- a/code/FBXExportNode.h +++ b/code/FBXExportNode.h @@ -66,6 +66,9 @@ public: // public data members std::vector properties; // node properties std::vector children; // child nodes + // some nodes always pretend they have children... + bool force_has_children = false; + public: // constructors Node() = default; Node(const std::string& n) : name(n) {} diff --git a/code/FBXExporter.cpp b/code/FBXExporter.cpp index 8b633462d..46782cc2e 100644 --- a/code/FBXExporter.cpp +++ b/code/FBXExporter.cpp @@ -419,6 +419,7 @@ void FBXExporter::WriteReferences () // always empty for now. // not really sure what this is for. FBX::Node n("References"); + n.force_has_children = true; n.Dump(outfile); } @@ -1914,11 +1915,8 @@ void FBXExporter::WriteObjects () // this node absurdly always pretends it has children // (in this case it does, but just in case...) - asnode.Begin(outstream); - asnode.DumpProperties(outstream); - asnode.EndProperties(outstream); - asnode.DumpChildren(outstream); - asnode.End(outstream, true); + asnode.force_has_children = true; + asnode.Dump(outstream); // note: animation stacks are not connected to anything } @@ -1932,11 +1930,8 @@ void FBXExporter::WriteObjects () alnode.AddProperties(animlayer_uid, FBX::SEPARATOR + "AnimLayer", ""); // this node absurdly always pretends it has children - alnode.Begin(outstream); - alnode.DumpProperties(outstream); - alnode.EndProperties(outstream); - alnode.DumpChildren(outstream); - alnode.End(outstream, true); + alnode.force_has_children = true; + alnode.Dump(outstream); // connect to the relevant animstack connections.emplace_back(