diff options
Diffstat (limited to 'servers/physics/body_sw.cpp')
-rw-r--r-- | servers/physics/body_sw.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp index f8cd6ca858..bba4d7a147 100644 --- a/servers/physics/body_sw.cpp +++ b/servers/physics/body_sw.cpp @@ -559,32 +559,30 @@ void BodySW::integrate_velocities(real_t p_step) { if (fi_callback) get_space()->body_add_to_state_query_list(&direct_state_query_list); - if (mode == PhysicsServer::BODY_MODE_KINEMATIC) { - - _set_transform(new_transform, false); - _set_inv_transform(new_transform.affine_inverse()); - if (contacts.size() == 0 && linear_velocity == Vector3() && angular_velocity == Vector3()) - set_active(false); //stopped moving, deactivate - - return; - } - //apply axis lock - if (axis_lock != PhysicsServer::BODY_AXIS_LOCK_DISABLED) { - - int axis = axis_lock - 1; + if (locked_axis[0] || locked_axis[1] || locked_axis[2]) { for (int i = 0; i < 3; i++) { - if (i == axis) { + if (locked_axis[i]) { linear_velocity[i] = 0; biased_linear_velocity[i] = 0; + new_transform.origin[i] = get_transform().origin[i]; } else { - angular_velocity[i] = 0; biased_angular_velocity[i] = 0; } } } + if (mode == PhysicsServer::BODY_MODE_KINEMATIC) { + + _set_transform(new_transform, false); + _set_inv_transform(new_transform.affine_inverse()); + if (contacts.size() == 0 && linear_velocity == Vector3() && angular_velocity == Vector3()) + set_active(false); //stopped moving, deactivate + + return; + } + Vector3 total_angular_velocity = angular_velocity + biased_angular_velocity; real_t ang_vel = total_angular_velocity.length(); @@ -740,8 +738,11 @@ void BodySW::set_kinematic_margin(real_t p_margin) { kinematic_safe_margin = p_margin; } -BodySW::BodySW() - : CollisionObjectSW(TYPE_BODY), active_list(this), inertia_update_list(this), direct_state_query_list(this) { +BodySW::BodySW() : + CollisionObjectSW(TYPE_BODY), + active_list(this), + inertia_update_list(this), + direct_state_query_list(this) { mode = PhysicsServer::BODY_MODE_RIGID; active = true; @@ -772,7 +773,6 @@ BodySW::BodySW() continuous_cd = false; can_sleep = false; fi_callback = NULL; - axis_lock = PhysicsServer::BODY_AXIS_LOCK_DISABLED; } BodySW::~BodySW() { |