diff options
author | Silc Lizard (Tokage) Renew <61938263+TokageItLab@users.noreply.github.com> | 2024-06-23 16:05:04 +0900 |
---|---|---|
committer | Silc Lizard (Tokage) Renew <61938263+TokageItLab@users.noreply.github.com> | 2024-06-25 18:54:59 +0900 |
commit | 793f3832e5e85bdf7b95acf4761d3c2c05db3df9 (patch) | |
tree | fde881959603215f0c1d294e4ab1fc0ba65e3356 /scene/3d/physics | |
parent | 6b281c0c07b07f2142b1fc8a6b3158091a9b124c (diff) | |
download | redot-engine-793f3832e5e85bdf7b95acf4761d3c2c05db3df9.tar.gz |
Rework migration of animate_physical_bones to compatibility
Diffstat (limited to 'scene/3d/physics')
-rw-r--r-- | scene/3d/physics/physical_bone_3d.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/scene/3d/physics/physical_bone_3d.cpp b/scene/3d/physics/physical_bone_3d.cpp index c290f16c0d..294690a89a 100644 --- a/scene/3d/physics/physical_bone_3d.cpp +++ b/scene/3d/physics/physical_bone_3d.cpp @@ -764,7 +764,7 @@ void PhysicalBone3D::_notification(int p_what) { case NOTIFICATION_EXIT_TREE: { PhysicalBoneSimulator3D *simulator = get_simulator(); if (simulator) { - if (-1 != bone_id) { + if (bone_id != -1) { simulator->unbind_physical_bone_from_bone(bone_id); bone_id = -1; } @@ -816,7 +816,7 @@ void PhysicalBone3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) { PhysicalBoneSimulator3D *simulator = get_simulator(); Skeleton3D *skeleton = get_skeleton(); if (simulator && skeleton) { - if (-1 != bone_id) { + if (bone_id != -1) { simulator->set_bone_global_pose(bone_id, skeleton->get_global_transform().affine_inverse() * (global_transform * body_offset_inverse)); } } @@ -1293,7 +1293,7 @@ void PhysicalBone3D::update_bone_id() { const int new_bone_id = simulator->find_bone(bone_name); if (new_bone_id != bone_id) { - if (-1 != bone_id) { + if (bone_id != -1) { // Assert the unbind from old node simulator->unbind_physical_bone_from_bone(bone_id); } @@ -1313,7 +1313,7 @@ void PhysicalBone3D::update_offset() { Skeleton3D *skeleton = get_skeleton(); if (simulator && skeleton) { Transform3D bone_transform(skeleton->get_global_transform()); - if (-1 != bone_id) { + if (bone_id != -1) { bone_transform *= simulator->get_bone_global_pose(bone_id); } @@ -1328,7 +1328,7 @@ void PhysicalBone3D::update_offset() { } void PhysicalBone3D::_start_physics_simulation() { - if (_internal_simulate_physics || !simulator_id.is_valid()) { + if (_internal_simulate_physics || !simulator_id.is_valid() || bone_id == -1) { return; } reset_to_rest_position(); @@ -1344,7 +1344,7 @@ void PhysicalBone3D::_start_physics_simulation() { void PhysicalBone3D::_stop_physics_simulation() { PhysicalBoneSimulator3D *simulator = get_simulator(); if (simulator) { - if (simulator->is_simulating_physics()) { + if (simulator->is_active() && bone_id != -1) { set_body_mode(PhysicsServer3D::BODY_MODE_KINEMATIC); PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), get_collision_layer()); PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), get_collision_mask()); |