Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unbound child bones of the PhysicalBone aren't modified #92931

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions scene/3d/physical_bone_simulator_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,20 @@ void PhysicalBoneSimulator3D::_process_modification() {
}
}
} else {
ERR_FAIL_COND(skeleton->get_bone_count() != bones.size());
for (int i = 0; i < skeleton->get_bone_count(); i++) {
if (!bones[i].physical_bone) {
continue;
}
skeleton->set_bone_global_pose(i, bones[i].global_pose);
}

// TODO:
// The above method is performance heavy and needs to be improved.
// Ideally, the processing of set_bone_global_pose within Skeleton3D should be improved,
// but the workaround available now is to convert the global pose to a local pose on the SkeletonModifier side.
// However, the follow method needs recursive processing for deformations within PhysicalBoneSimulator3D to account for update order.
/*
ERR_FAIL_COND(skeleton->get_bone_count() != bones.size());
LocalVector<Transform3D> local_poses;
for (int i = 0; i < skeleton->get_bone_count(); i++) {
Expand All @@ -376,10 +390,14 @@ void PhysicalBoneSimulator3D::_process_modification() {
local_poses.push_back(pt.affine_inverse() * bones[i].global_pose);
}
for (int i = 0; i < skeleton->get_bone_count(); i++) {
if (!bones[i].physical_bone) {
continue;
}
skeleton->set_bone_pose_position(i, local_poses[i].origin);
skeleton->set_bone_pose_rotation(i, local_poses[i].basis.get_rotation_quaternion());
skeleton->set_bone_pose_scale(i, local_poses[i].basis.get_scale());
}
*/
}
}

Expand Down
Loading