summaryrefslogtreecommitdiff
path: root/scene/2d/physical_bone_2d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d/physical_bone_2d.cpp')
-rw-r--r--scene/2d/physical_bone_2d.cpp26
1 files changed, 8 insertions, 18 deletions
diff --git a/scene/2d/physical_bone_2d.cpp b/scene/2d/physical_bone_2d.cpp
index d547914e16..c1b0bc35dd 100644
--- a/scene/2d/physical_bone_2d.cpp
+++ b/scene/2d/physical_bone_2d.cpp
@@ -30,10 +30,12 @@
#include "physical_bone_2d.h"
+#include "scene/2d/joint_2d.h"
+
void PhysicalBone2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
- // Position the RigidBody in the correct position.
+ // Position the RigidDynamicBody in the correct position.
if (follow_bone_when_simulating) {
_position_at_bone2d();
}
@@ -150,27 +152,15 @@ void PhysicalBone2D::_start_physics_simulation() {
return;
}
- // Reset to Bone2D position
+ // Reset to Bone2D position.
_position_at_bone2d();
- // Apply the layers and masks
+ // Apply the layers and masks.
PhysicsServer2D::get_singleton()->body_set_collision_layer(get_rid(), get_collision_layer());
PhysicsServer2D::get_singleton()->body_set_collision_mask(get_rid(), get_collision_mask());
- // Apply the correct mode
- RigidBody2D::Mode rigid_mode = get_mode();
- if (rigid_mode == RigidBody2D::MODE_STATIC) {
- set_body_mode(PhysicsServer2D::BODY_MODE_STATIC);
- } else if (rigid_mode == RigidBody2D::MODE_DYNAMIC) {
- set_body_mode(PhysicsServer2D::BODY_MODE_DYNAMIC);
- } else if (rigid_mode == RigidBody2D::MODE_KINEMATIC) {
- set_body_mode(PhysicsServer2D::BODY_MODE_KINEMATIC);
- } else if (rigid_mode == RigidBody2D::MODE_DYNAMIC_LOCKED) {
- set_body_mode(PhysicsServer2D::BODY_MODE_DYNAMIC_LOCKED);
- } else {
- // Default to Dynamic.
- set_body_mode(PhysicsServer2D::BODY_MODE_DYNAMIC);
- }
+ // Apply the correct mode.
+ _apply_body_mode();
_internal_simulate_physics = true;
set_physics_process_internal(true);
@@ -295,7 +285,7 @@ void PhysicalBone2D::_bind_methods() {
}
PhysicalBone2D::PhysicalBone2D() {
- // Stop the RigidBody from executing its force integration.
+ // Stop the RigidDynamicBody from executing its force integration.
PhysicsServer2D::get_singleton()->body_set_collision_layer(get_rid(), 0);
PhysicsServer2D::get_singleton()->body_set_collision_mask(get_rid(), 0);
PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BodyMode::BODY_MODE_STATIC);