Merge pull request #3990 from RichardTea/gltf_export_id_issue_3978

Ensure glTFv2 scene name is unique
pull/3994/head^2
Kim Kulling 2021-07-21 17:31:58 +02:00 committed by GitHub
commit e9d7ec4ba5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions

View File

@ -88,15 +88,13 @@ namespace Assimp {
} // end of namespace Assimp } // end of namespace Assimp
glTF2Exporter::glTF2Exporter(const char* filename, IOSystem* pIOSystem, const aiScene* pScene, glTF2Exporter::glTF2Exporter(const char* filename, IOSystem* pIOSystem, const aiScene* pScene,
const ExportProperties* pProperties, bool isBinary) const ExportProperties* pProperties, bool isBinary)
: mFilename(filename) : mFilename(filename)
, mIOSystem(pIOSystem) , mIOSystem(pIOSystem)
, mScene(pScene)
, mProperties(pProperties) , 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 // Always on as our triangulation process is aware of this type of encoding
mAsset->extensionsUsed.FB_ngon_encoding = true; mAsset->extensionsUsed.FB_ngon_encoding = true;
@ -1338,8 +1336,11 @@ unsigned int glTF2Exporter::ExportNode(const aiNode* n, Ref<Node>& parent)
void glTF2Exporter::ExportScene() void glTF2Exporter::ExportScene()
{ {
const char* sceneName = "defaultScene"; // Use the name of the scene if specified
Ref<Scene> scene = mAsset->scenes.Create(sceneName); 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) // root node will be the first one exported (idx 0)
if (mAsset->nodes.Size() > 0) { if (mAsset->nodes.Size() > 0) {