Merge pull request #19544 from RandomShaper/gltf-shapes-names

Import morph target names from glTF
This commit is contained in:
Rémi Verschelde 2018-06-15 09:33:44 +02:00 committed by GitHub
commit f2cd1e0c15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -863,6 +863,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
ERR_FAIL_COND_V(!d.has("primitives"), ERR_PARSE_ERROR); ERR_FAIL_COND_V(!d.has("primitives"), ERR_PARSE_ERROR);
Array primitives = d["primitives"]; Array primitives = d["primitives"];
Dictionary extras = d.has("extras") ? (Dictionary)d["extras"] : Dictionary();
for (int j = 0; j < primitives.size(); j++) { for (int j = 0; j < primitives.size(); j++) {
@ -1000,8 +1001,10 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
Array targets = p["targets"]; Array targets = p["targets"];
if (j == 0) { if (j == 0) {
Array target_names = extras.has("targetNames") ? (Array)extras["targetNames"] : Array();
for (int k = 0; k < targets.size(); k++) { 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);
} }
} }