diff options
Diffstat (limited to 'servers/physics_2d/body_pair_2d_sw.cpp')
-rw-r--r-- | servers/physics_2d/body_pair_2d_sw.cpp | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp index be8dcf6fa8..2633edf7bb 100644 --- a/servers/physics_2d/body_pair_2d_sw.cpp +++ b/servers/physics_2d/body_pair_2d_sw.cpp @@ -220,41 +220,11 @@ bool BodyPair2DSW::_test_ccd(real_t p_step, Body2DSW *p_A, int p_shape_A, const } real_t combine_bounce(Body2DSW *A, Body2DSW *B) { - const Physics2DServer::CombineMode cm = A->get_bounce_combine_mode(); - - switch (cm) { - case Physics2DServer::COMBINE_MODE_INHERIT: - if (B->get_bounce_combine_mode() != Physics2DServer::COMBINE_MODE_INHERIT) - return combine_bounce(B, A); - // else use MAX [This is used when the two bodies doesn't use physical material] - case Physics2DServer::COMBINE_MODE_MAX: - return MAX(A->get_bounce(), B->get_bounce()); - case Physics2DServer::COMBINE_MODE_MIN: - return MIN(A->get_bounce(), B->get_bounce()); - case Physics2DServer::COMBINE_MODE_MULTIPLY: - return A->get_bounce() * B->get_bounce(); - default: // Is always Physics2DServer::COMBINE_MODE_AVERAGE: - return (A->get_bounce() + B->get_bounce()) / 2; - } + return CLAMP(A->get_bounce() + B->get_bounce(), 0, 1); } real_t combine_friction(Body2DSW *A, Body2DSW *B) { - const Physics2DServer::CombineMode cm = A->get_friction_combine_mode(); - - switch (cm) { - case Physics2DServer::COMBINE_MODE_INHERIT: - if (B->get_friction_combine_mode() != Physics2DServer::COMBINE_MODE_INHERIT) - return combine_friction(B, A); - // else use Multiply [This is used when the two bodies doesn't use physical material] - case Physics2DServer::COMBINE_MODE_MULTIPLY: - return A->get_friction() * B->get_friction(); - case Physics2DServer::COMBINE_MODE_MAX: - return MAX(A->get_friction(), B->get_friction()); - case Physics2DServer::COMBINE_MODE_MIN: - return MIN(A->get_friction(), B->get_friction()); - default: // Is always Physics2DServer::COMBINE_MODE_AVERAGE: - return (A->get_friction() + B->get_friction()) / 2; - } + return ABS(MIN(A->get_friction(), B->get_friction())); } bool BodyPair2DSW::setup(real_t p_step) { |