diff options
Diffstat (limited to 'servers/physics/body_pair_sw.cpp')
-rw-r--r-- | servers/physics/body_pair_sw.cpp | 36 |
1 files changed, 3 insertions, 33 deletions
diff --git a/servers/physics/body_pair_sw.cpp b/servers/physics/body_pair_sw.cpp index 5a41b621eb..357fc05355 100644 --- a/servers/physics/body_pair_sw.cpp +++ b/servers/physics/body_pair_sw.cpp @@ -31,7 +31,7 @@ #include "body_pair_sw.h" #include "collision_solver_sw.h" -#include "os/os.h" +#include "core/os/os.h" #include "space_sw.h" /* @@ -212,41 +212,11 @@ bool BodyPairSW::_test_ccd(real_t p_step, BodySW *p_A, int p_shape_A, const Tran } real_t combine_bounce(BodySW *A, BodySW *B) { - const PhysicsServer::CombineMode cm = A->get_bounce_combine_mode(); - - switch (cm) { - case PhysicsServer::COMBINE_MODE_INHERIT: - if (B->get_bounce_combine_mode() != PhysicsServer::COMBINE_MODE_INHERIT) - return combine_bounce(B, A); - // else use MAX [This is used when the two bodies doesn't use physical material] - case PhysicsServer::COMBINE_MODE_MAX: - return MAX(A->get_bounce(), B->get_bounce()); - case PhysicsServer::COMBINE_MODE_MIN: - return MIN(A->get_bounce(), B->get_bounce()); - case PhysicsServer::COMBINE_MODE_MULTIPLY: - return A->get_bounce() * B->get_bounce(); - default: // Is always PhysicsServer::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(BodySW *A, BodySW *B) { - const PhysicsServer::CombineMode cm = A->get_friction_combine_mode(); - - switch (cm) { - case PhysicsServer::COMBINE_MODE_INHERIT: - if (B->get_friction_combine_mode() != PhysicsServer::COMBINE_MODE_INHERIT) - return combine_friction(B, A); - // else use Multiply [This is used when the two bodies doesn't use physical material] - case PhysicsServer::COMBINE_MODE_MULTIPLY: - return A->get_friction() * B->get_friction(); - case PhysicsServer::COMBINE_MODE_MAX: - return MAX(A->get_friction(), B->get_friction()); - case PhysicsServer::COMBINE_MODE_MIN: - return MIN(A->get_friction(), B->get_friction()); - default: // Is always PhysicsServer::COMBINE_MODE_AVERAGE: - return (A->get_friction() + B->get_friction()) / 2; - } + return ABS(MIN(A->get_friction(), B->get_friction())); } bool BodyPairSW::setup(real_t p_step) { |