Merge pull request #53140 from V-Sekai/gltf_naming_fix

This commit is contained in:
Rémi Verschelde 2021-09-28 08:40:54 +02:00 committed by GitHub
commit dbe0e4613a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -598,9 +598,9 @@ Error GLTFDocument::_parse_scenes(Ref<GLTFState> state) {
} }
if (s.has("name") && !String(s["name"]).empty() && !((String)s["name"]).begins_with("Scene")) { if (s.has("name") && !String(s["name"]).empty() && !((String)s["name"]).begins_with("Scene")) {
state->scene_name = _gen_unique_name(state, s["name"]); state->scene_name = s["name"];
} else { } else {
state->scene_name = _gen_unique_name(state, state->filename); state->scene_name = state->filename;
} }
} }
@ -4960,6 +4960,9 @@ void GLTFDocument::_assign_scene_names(Ref<GLTFState> state) {
n->set_name(_gen_unique_name(state, n->get_name())); n->set_name(_gen_unique_name(state, n->get_name()));
} }
// Assign a unique name to the scene last to avoid naming conflicts with the root
state->scene_name = _gen_unique_name(state, state->scene_name);
} }
BoneAttachment *GLTFDocument::_generate_bone_attachment(Ref<GLTFState> state, Skeleton *skeleton, const GLTFNodeIndex node_index, const GLTFNodeIndex bone_index) { BoneAttachment *GLTFDocument::_generate_bone_attachment(Ref<GLTFState> state, Skeleton *skeleton, const GLTFNodeIndex node_index, const GLTFNodeIndex bone_index) {