From a0b3df6dbd0ca6b8a8fd20e7919e9b4e84f21c2d Mon Sep 17 00:00:00 2001 From: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com> Date: Tue, 28 Nov 2023 16:13:54 -0500 Subject: [PATCH] Fix target names not being imported on some gLTF2 models --- code/AssetLib/glTF2/glTF2Asset.inl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/code/AssetLib/glTF2/glTF2Asset.inl b/code/AssetLib/glTF2/glTF2Asset.inl index 53ffdaf312..5781a4be6e 100644 --- a/code/AssetLib/glTF2/glTF2Asset.inl +++ b/code/AssetLib/glTF2/glTF2Asset.inl @@ -1552,6 +1552,22 @@ inline void Mesh::Read(Value &pJSON_Object, Asset &pAsset_Root) { } } } + + if(this->targetNames.empty()) + { + Value *curExtras = FindObject(primitive, "extras"); + if (nullptr != curExtras) { + if (Value *curTargetNames = FindArray(*curExtras, "targetNames")) { + this->targetNames.resize(curTargetNames->Size()); + for (unsigned int j = 0; j < curTargetNames->Size(); ++j) { + Value &targetNameValue = (*curTargetNames)[j]; + if (targetNameValue.IsString()) { + this->targetNames[j] = targetNameValue.GetString(); + } + } + } + } + } } }