From 662ace7016bac6c5462e71c1e49ab8c0be2dfd49 Mon Sep 17 00:00:00 2001 From: "K. S. Ernest (iFire) Lee" Date: Mon, 7 Oct 2024 09:28:57 -0700 Subject: [PATCH] Assign the correct bone rest transform to nodes with matrix in GLTF --- modules/gltf/gltf_document.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 992075e980e7..b0fcf2b9bc9e 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -601,8 +601,10 @@ Error GLTFDocument::_parse_nodes(Ref p_state) { if (n.has("skin")) { node->skin = n["skin"]; } + Transform3D godot_rest_transform; if (n.has("matrix")) { node->transform = _arr_to_xform(n["matrix"]); + godot_rest_transform = node->transform; } else { if (n.has("translation")) { node->set_position(_arr_to_vec3(n["translation"])); @@ -613,12 +615,10 @@ Error GLTFDocument::_parse_nodes(Ref p_state) { if (n.has("scale")) { node->set_scale(_arr_to_vec3(n["scale"])); } - - Transform3D godot_rest_transform; godot_rest_transform.basis.set_quaternion_scale(node->transform.basis.get_rotation_quaternion(), node->transform.basis.get_scale()); godot_rest_transform.origin = node->transform.origin; - node->set_additional_data("GODOT_rest_transform", godot_rest_transform); } + node->set_additional_data("GODOT_rest_transform", godot_rest_transform); if (n.has("extensions")) { Dictionary extensions = n["extensions"];