diff options
author | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2020-03-26 12:32:20 +0100 |
---|---|---|
committer | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2020-04-27 18:24:33 +0200 |
commit | 9353a2bbd161f99de5e6de6365b288bf19f910b6 (patch) | |
tree | 433d26be12c05ecd2e8858bd5caac2f814499d2d /modules/bullet/space_bullet.cpp | |
parent | f61587b158bd0eae6ea5b9d07e90983ff4988772 (diff) | |
download | redot-engine-9353a2bbd161f99de5e6de6365b288bf19f910b6.tar.gz |
Better damping implementation for Bullet rigid bodies
Apply old method for linear & angular damping in Bullet, in order to
make it easier to tweak and consistent with Godot Physics.
Diffstat (limited to 'modules/bullet/space_bullet.cpp')
-rw-r--r-- | modules/bullet/space_bullet.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index 1659664ff9..d49e635fd5 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -342,6 +342,8 @@ SpaceBullet::SpaceBullet() : godotFilterCallback(nullptr), gravityDirection(0, -1, 0), gravityMagnitude(10), + linear_damp(0.0), + angular_damp(0.0), contactDebugCount(0), delta_time(0.) { @@ -379,8 +381,11 @@ void SpaceBullet::set_param(PhysicsServer3D::AreaParameter p_param, const Varian update_gravity(); break; case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP: + linear_damp = p_value; + break; case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP: - break; // No damp + angular_damp = p_value; + break; case PhysicsServer3D::AREA_PARAM_PRIORITY: // Priority is always 0, the lower break; @@ -401,8 +406,9 @@ Variant SpaceBullet::get_param(PhysicsServer3D::AreaParameter p_param) { case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR: return gravityDirection; case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP: + return linear_damp; case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP: - return 0; // No damp + return angular_damp; case PhysicsServer3D::AREA_PARAM_PRIORITY: return 0; // Priority is always 0, the lower case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT: |