From 233198baefa8be47bbea4235d438e337c8eda0f2 Mon Sep 17 00:00:00 2001 From: Bengt Rosenberger Date: Fri, 22 Jul 2022 01:04:05 +0200 Subject: [PATCH] Fixed extras presence check in gltf2 import. --- code/AssetLib/glTF2/glTF2Exporter.cpp | 6 ++---- code/AssetLib/glTF2/glTF2Importer.cpp | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/code/AssetLib/glTF2/glTF2Exporter.cpp b/code/AssetLib/glTF2/glTF2Exporter.cpp index f8b1995d9..d3c88e479 100644 --- a/code/AssetLib/glTF2/glTF2Exporter.cpp +++ b/code/AssetLib/glTF2/glTF2Exporter.cpp @@ -486,7 +486,7 @@ inline void ExportNodeExtras(const aiMetadataEntry &metadataEntry, aiString name } inline void ExportNodeExtras(const aiMetadata *metadata, Extras &extras) { - if (metadata == nullptr) { + if (metadata == nullptr || metadata->mNumProperties == 0) { return; } @@ -1406,9 +1406,7 @@ unsigned int glTF2Exporter::ExportNode(const aiNode *n, Ref &parent) { node->parent = parent; node->name = name; - if (n->mMetaData != nullptr && n->mMetaData->mNumProperties > 0) { - ExportNodeExtras(n->mMetaData, node->extras); - } + ExportNodeExtras(n->mMetaData, node->extras); if (!n->mTransformation.IsIdentity()) { if (mScene->mNumAnimations > 0 || (mProperties && mProperties->HasPropertyBool("GLTF2_NODE_IN_TRS"))) { diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp index a14e6ad6f..e88cd0f08 100644 --- a/code/AssetLib/glTF2/glTF2Importer.cpp +++ b/code/AssetLib/glTF2/glTF2Importer.cpp @@ -1081,7 +1081,7 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector & } } - if (node.customExtensions || !node.extras.HasExtras()) { + if (node.customExtensions || node.extras.HasExtras()) { ainode->mMetaData = new aiMetadata; if (node.customExtensions) { ParseExtensions(ainode->mMetaData, node.customExtensions);