diff options
author | reduz <reduzio@gmail.com> | 2021-10-13 09:37:40 -0300 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2021-10-13 14:51:29 -0300 |
commit | 2dc823273e8d7d0eb92049c0d687f6a2c247ce13 (patch) | |
tree | 768c9c2f6f4dc005d05afc80200bf6cb5f0013d0 /modules/fbx | |
parent | 004b44e91519626e847c981c9f91ae3c4e36282c (diff) | |
download | redot-engine-2dc823273e8d7d0eb92049c0d687f6a2c247ce13.tar.gz |
Remove REST transform influence in skeleton bones
* Animations and Skeletons are now pose-only.
* Rest transform is kept as reference (when it exists) and for IK
* Improves 3D model compatibility (non uniform transforms will properly work, as well as all animations coming from Autodesk products).
Diffstat (limited to 'modules/fbx')
-rw-r--r-- | modules/fbx/data/fbx_skeleton.cpp | 7 | ||||
-rw-r--r-- | modules/fbx/editor_scene_importer_fbx.cpp | 14 |
2 files changed, 7 insertions, 14 deletions
diff --git a/modules/fbx/data/fbx_skeleton.cpp b/modules/fbx/data/fbx_skeleton.cpp index 3dc163964c..11eed2576f 100644 --- a/modules/fbx/data/fbx_skeleton.cpp +++ b/modules/fbx/data/fbx_skeleton.cpp @@ -104,6 +104,13 @@ void FBXSkeleton::init_skeleton(const ImportState &state) { print_verbose("working on bone: " + itos(bone_index) + " bone name:" + bone->bone_name); skeleton->set_bone_rest(bone->godot_bone_id, get_unscaled_transform(bone->node->pivot_transform->LocalTransform, state.scale)); + { + Transform3D base_xform = bone->node->pivot_transform->LocalTransform; + + skeleton->set_bone_pose_position(bone_index, base_xform.origin); + skeleton->set_bone_pose_rotation(bone_index, base_xform.basis.get_rotation_quaternion()); + skeleton->set_bone_pose_scale(bone_index, base_xform.basis.get_scale()); + } // lookup parent ID if (bone->valid_parent && state.fbx_bone_map.has(bone->parent_bone_id)) { diff --git a/modules/fbx/editor_scene_importer_fbx.cpp b/modules/fbx/editor_scene_importer_fbx.cpp index e90eab522f..879f281292 100644 --- a/modules/fbx/editor_scene_importer_fbx.cpp +++ b/modules/fbx/editor_scene_importer_fbx.cpp @@ -1227,20 +1227,6 @@ Node3D *EditorSceneImporterFBX::_generate_scene( AssetImportAnimation::INTERP_LINEAR); } - // node animations must also include pivots - if (skeleton_bone >= 0) { - Transform3D xform = Transform3D(); - xform.basis.set_quaternion_scale(rot, scale); - xform.origin = pos; - const Transform3D t = bone_rest.affine_inverse() * xform; - - // populate this again - rot = t.basis.get_rotation_quaternion(); - rot.normalize(); - scale = t.basis.get_scale(); - pos = t.origin; - } - if (position_idx >= 0) { animation->position_track_insert_key(position_idx, time, pos); } |