Fix syncing PhysicalBone internal poses individually

(cherry picked from commit 2b3cf2451f)
This commit is contained in:
Silc Lizard (Tokage) Renew 2024-09-15 01:41:39 +09:00 committed by Rémi Verschelde
parent 15129c044e
commit 7b32e96f3d
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 8 additions and 1 deletions

View File

@ -73,10 +73,15 @@ void PhysicalBoneSimulator3D::_pose_updated() {
} }
ERR_FAIL_COND(skeleton->get_bone_count() != bones.size()); ERR_FAIL_COND(skeleton->get_bone_count() != bones.size());
for (int i = 0; i < skeleton->get_bone_count(); i++) { for (int i = 0; i < skeleton->get_bone_count(); i++) {
bones.write[i].global_pose = skeleton->get_bone_global_pose(i); _bone_pose_updated(skeleton, i);
} }
} }
void PhysicalBoneSimulator3D::_bone_pose_updated(Skeleton3D *p_skeleton, int p_bone_id) {
ERR_FAIL_INDEX(p_bone_id, bones.size());
bones.write[p_bone_id].global_pose = p_skeleton->get_bone_global_pose(p_bone_id);
}
void PhysicalBoneSimulator3D::_set_active(bool p_active) { void PhysicalBoneSimulator3D::_set_active(bool p_active) {
if (!Engine::get_singleton()->is_editor_hint()) { if (!Engine::get_singleton()->is_editor_hint()) {
_reset_physical_bones_state(); _reset_physical_bones_state();
@ -363,6 +368,7 @@ void PhysicalBoneSimulator3D::_process_modification() {
continue; continue;
} }
if (bones[i].physical_bone->is_simulating_physics() == false) { if (bones[i].physical_bone->is_simulating_physics() == false) {
_bone_pose_updated(skeleton, i);
bones[i].physical_bone->reset_to_rest_position(); bones[i].physical_bone->reset_to_rest_position();
} else if (simulating) { } else if (simulating) {
skeleton->set_bone_global_pose(i, bones[i].global_pose); skeleton->set_bone_global_pose(i, bones[i].global_pose);

View File

@ -73,6 +73,7 @@ protected:
void _bone_list_changed(); void _bone_list_changed();
void _pose_updated(); void _pose_updated();
void _bone_pose_updated(Skeleton3D *skeleton, int p_bone_id);
virtual void _process_modification() override; virtual void _process_modification() override;