Fixed extras presence check in gltf2 import.

pull/4658/head
Bengt Rosenberger 2022-07-22 01:04:05 +02:00
parent 99c3104588
commit 233198baef
2 changed files with 3 additions and 5 deletions

View File

@ -486,7 +486,7 @@ inline void ExportNodeExtras(const aiMetadataEntry &metadataEntry, aiString name
} }
inline void ExportNodeExtras(const aiMetadata *metadata, Extras &extras) { inline void ExportNodeExtras(const aiMetadata *metadata, Extras &extras) {
if (metadata == nullptr) { if (metadata == nullptr || metadata->mNumProperties == 0) {
return; return;
} }
@ -1406,9 +1406,7 @@ unsigned int glTF2Exporter::ExportNode(const aiNode *n, Ref<Node> &parent) {
node->parent = parent; node->parent = parent;
node->name = name; 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 (!n->mTransformation.IsIdentity()) {
if (mScene->mNumAnimations > 0 || (mProperties && mProperties->HasPropertyBool("GLTF2_NODE_IN_TRS"))) { if (mScene->mNumAnimations > 0 || (mProperties && mProperties->HasPropertyBool("GLTF2_NODE_IN_TRS"))) {

View File

@ -1081,7 +1081,7 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector<unsigned int> &
} }
} }
if (node.customExtensions || !node.extras.HasExtras()) { if (node.customExtensions || node.extras.HasExtras()) {
ainode->mMetaData = new aiMetadata; ainode->mMetaData = new aiMetadata;
if (node.customExtensions) { if (node.customExtensions) {
ParseExtensions(ainode->mMetaData, node.customExtensions); ParseExtensions(ainode->mMetaData, node.customExtensions);