Fix bug in aiMetadata constructor that overwrites an array of one of aiString, aiVector3D, or aiMetadata with the first entry

aiMetadata copy constructor calls aiMetadata::Get on the copied from aiMetadata using the const aiString &key version. When
this is called on the metadata of an array type, this overwrites all entries with the first entry. This is due to the key
of all entries in an array being the name of the array. ie, in a glTF2 file with an extension:
"Extension" : [
	"Value1",
	"Value2",
	"Value3"
]
the aiMetadata struct for the "Extension" entry will have 3 entries with key/value pairs as:
"Extension"/"Value1"
"Extension"/"Value2"
"Extension"/"Value3"
So when the copy constructor calls the key based aiMetadata::Get, it will find "Value1" for all three entries.

This change simply replaces the key based aiMetadata::Get with the index based aiMetadata::Get
pull/3922/head
Evangel 2021-05-26 18:36:56 +10:00
parent 6f24e873b3
commit 5468dd667e
1 changed files with 3 additions and 3 deletions

View File

@ -202,17 +202,17 @@ struct aiMetadata {
} break;
case AI_AISTRING: {
aiString v;
rhs.Get<aiString>(mKeys[i], v);
rhs.Get<aiString>(i, v);
mValues[i].mData = new aiString(v);
} break;
case AI_AIVECTOR3D: {
aiVector3D v;
rhs.Get<aiVector3D>(mKeys[i], v);
rhs.Get<aiVector3D>(i, v);
mValues[i].mData = new aiVector3D(v);
} break;
case AI_AIMETADATA: {
aiMetadata v;
rhs.Get<aiMetadata>(mKeys[i], v);
rhs.Get<aiMetadata>(i, v);
mValues[i].mData = new aiMetadata(v);
} break;
#ifndef SWIG