Fix child bones of the physical bone aren't modified

This commit is contained in:
Silc Lizard (Tokage) Renew 2024-06-09 18:00:36 +09:00
parent 5241d30bfa
commit 05c0d22afc
1 changed files with 18 additions and 0 deletions

View File

@ -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++) {
@ -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());
}
*/
}
}