Skip to content

Commit

Permalink
Orthonormalize PhysicalBone3D transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronfranke committed Jan 31, 2024
1 parent 313f623 commit b015fba
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions scene/3d/physics_body_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2239,11 +2239,14 @@ void PhysicalBone3D::reset_physics_simulation_state() {

void PhysicalBone3D::reset_to_rest_position() {
if (parent_skeleton) {
if (-1 == bone_id) {
set_global_transform(parent_skeleton->get_global_transform() * body_offset);
Transform3D new_transform = parent_skeleton->get_global_transform();
if (bone_id == -1) {
new_transform *= body_offset;
} else {
set_global_transform(parent_skeleton->get_global_transform() * parent_skeleton->get_bone_global_pose(bone_id) * body_offset);
new_transform *= parent_skeleton->get_bone_global_pose(bone_id) * body_offset;
}
new_transform.orthonormalize();
set_global_transform(new_transform);
}
}

Expand Down

0 comments on commit b015fba

Please sign in to comment.