Ensure glTFv2 scene name is unique

Use the provided scene name if extant
Fixes issue #3978
pull/3990/head
RichardTea 2021-07-14 13:39:41 +01:00
parent a08c1c1d67
commit 632b2db97c
1 changed files with 8 additions and 7 deletions

View File

@ -91,12 +91,10 @@ glTF2Exporter::glTF2Exporter(const char* filename, IOSystem* pIOSystem, const ai
const ExportProperties* pProperties, bool isBinary)
: mFilename(filename)
, mIOSystem(pIOSystem)
, mScene(pScene)
, mProperties(pProperties)
, mAsset(new Asset(pIOSystem))
{
mScene = pScene;
mAsset.reset( new Asset( pIOSystem ) );
// Always on as our triangulation process is aware of this type of encoding
mAsset->extensionsUsed.FB_ngon_encoding = true;
@ -1338,8 +1336,11 @@ unsigned int glTF2Exporter::ExportNode(const aiNode* n, Ref<Node>& parent)
void glTF2Exporter::ExportScene()
{
const char* sceneName = "defaultScene";
Ref<Scene> scene = mAsset->scenes.Create(sceneName);
// Use the name of the scene if specified
const std::string sceneName = (mScene->mName.length > 0) ? mScene->mName.C_Str() : "defaultScene";
// Ensure unique
Ref<Scene> scene = mAsset->scenes.Create(mAsset->FindUniqueID(sceneName, ""));
// root node will be the first one exported (idx 0)
if (mAsset->nodes.Size() > 0) {