diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-17 09:17:54 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-17 09:17:54 +0200 |
commit | b1b4d5b6d1212c6a8dc40d9f082efb4f3f655ef5 (patch) | |
tree | 19538016df597d11aaa58f9d52ec12f7348f400c /scene/3d | |
parent | 36496c5c6da0b0a9fade9476e89888f598810ebc (diff) | |
parent | 2b3cf2451f1dae92d98b7ba05c895d31f6ad3bcb (diff) | |
download | redot-engine-b1b4d5b6d1212c6a8dc40d9f082efb4f3f655ef5.tar.gz |
Merge pull request #97007 from TokageItLab/fix-sync-physical-bone
Fix syncing PhysicalBone internal poses individually
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/physical_bone_simulator_3d.cpp | 8 | ||||
-rw-r--r-- | scene/3d/physical_bone_simulator_3d.h | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/scene/3d/physical_bone_simulator_3d.cpp b/scene/3d/physical_bone_simulator_3d.cpp index 510d887c83..8874c9cfc6 100644 --- a/scene/3d/physical_bone_simulator_3d.cpp +++ b/scene/3d/physical_bone_simulator_3d.cpp @@ -73,10 +73,15 @@ void PhysicalBoneSimulator3D::_pose_updated() { } ERR_FAIL_COND(skeleton->get_bone_count() != bones.size()); 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) { if (!Engine::get_singleton()->is_editor_hint()) { _reset_physical_bones_state(); @@ -363,6 +368,7 @@ void PhysicalBoneSimulator3D::_process_modification() { continue; } if (bones[i].physical_bone->is_simulating_physics() == false) { + _bone_pose_updated(skeleton, i); bones[i].physical_bone->reset_to_rest_position(); } else if (simulating) { skeleton->set_bone_global_pose(i, bones[i].global_pose); diff --git a/scene/3d/physical_bone_simulator_3d.h b/scene/3d/physical_bone_simulator_3d.h index ddc9cd569a..24136be2b8 100644 --- a/scene/3d/physical_bone_simulator_3d.h +++ b/scene/3d/physical_bone_simulator_3d.h @@ -73,6 +73,7 @@ protected: void _bone_list_changed(); void _pose_updated(); + void _bone_pose_updated(Skeleton3D *skeleton, int p_bone_id); virtual void _process_modification() override; |