summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-06-15 09:33:44 +0200
committerGitHub <noreply@github.com>2018-06-15 09:33:44 +0200
commitf2cd1e0c15855f3b7b7ede5c1db95cc4d61ac10c (patch)
treea36e7c35b8abf8ae9fad55fada32a8d30c9fcd7f
parent4bfa8fabb7ff098836b23c7f52e6dc273cd2e183 (diff)
parent4810eae03bfe94efb896c5d36e50aeb073370602 (diff)
Merge pull request #19544 from RandomShaper/gltf-shapes-names
Import morph target names from glTF
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index f4be6e8d59..07a4cf5884 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -863,6 +863,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
ERR_FAIL_COND_V(!d.has("primitives"), ERR_PARSE_ERROR);
Array primitives = d["primitives"];
+ Dictionary extras = d.has("extras") ? (Dictionary)d["extras"] : Dictionary();
for (int j = 0; j < primitives.size(); j++) {
@@ -1000,8 +1001,10 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
Array targets = p["targets"];
if (j == 0) {
+ Array target_names = extras.has("targetNames") ? (Array)extras["targetNames"] : Array();
for (int k = 0; k < targets.size(); k++) {
- mesh.mesh->add_blend_shape(String("morph_") + itos(k));
+ String name = k < target_names.size() ? (String)target_names[k] : String("morph_") + itos(k);
+ mesh.mesh->add_blend_shape(name);
}
}