diff options
author | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2020-04-14 19:59:53 +0200 |
---|---|---|
committer | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2021-10-25 18:22:12 -0700 |
commit | daf7dcac7a9e0b4c26ba62ba9a700813d5abec9a (patch) | |
tree | 3ab364852f8804d03e8f6334a792d18f523dfea3 /servers/physics_2d/godot_body_2d.h | |
parent | 24fdedfe948a918b5a67846f7962f83ba0e59258 (diff) | |
download | redot-engine-daf7dcac7a9e0b4c26ba62ba9a700813d5abec9a.tar.gz |
Improved RigidDynamicBody linear/angular damping override
Damping values are now non-negative.
Add new properties linear_damp_mode and angular_damp_mode to set the way
RigidDynamicBody and PhysicalBone (2D & 3D) use damping values.
It can now be Combine (default) to add to the default/areas, or Replace
to override the value completely (current behavior).
Diffstat (limited to 'servers/physics_2d/godot_body_2d.h')
-rw-r--r-- | servers/physics_2d/godot_body_2d.h | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/servers/physics_2d/godot_body_2d.h b/servers/physics_2d/godot_body_2d.h index 5fce362fa7..817d5f1b0d 100644 --- a/servers/physics_2d/godot_body_2d.h +++ b/servers/physics_2d/godot_body_2d.h @@ -53,8 +53,15 @@ class GodotBody2D : public GodotCollisionObject2D { Vector2 constant_linear_velocity; real_t constant_angular_velocity = 0.0; - real_t linear_damp = -1.0; - real_t angular_damp = -1.0; + PhysicsServer2D::BodyDampMode linear_damp_mode = PhysicsServer2D::BODY_DAMP_MODE_COMBINE; + PhysicsServer2D::BodyDampMode angular_damp_mode = PhysicsServer2D::BODY_DAMP_MODE_COMBINE; + + real_t linear_damp = 0.0; + real_t angular_damp = 0.0; + + real_t total_linear_damp = 0.0; + real_t total_angular_damp = 0.0; + real_t gravity_scale = 1.0; real_t bounce = 0.0; @@ -73,8 +80,6 @@ class GodotBody2D : public GodotCollisionObject2D { bool calculate_center_of_mass = true; Vector2 gravity; - real_t area_linear_damp = 0.0; - real_t area_angular_damp = 0.0; real_t still_time = 0.0; @@ -276,14 +281,11 @@ public: void update_mass_properties(); void reset_mass_properties(); - _FORCE_INLINE_ Vector2 get_center_of_mass() const { return center_of_mass; } + _FORCE_INLINE_ const Vector2 &get_center_of_mass() const { return center_of_mass; } _FORCE_INLINE_ real_t get_inv_mass() const { return _inv_mass; } _FORCE_INLINE_ real_t get_inv_inertia() const { return _inv_inertia; } _FORCE_INLINE_ real_t get_friction() const { return friction; } - _FORCE_INLINE_ Vector2 get_gravity() const { return gravity; } _FORCE_INLINE_ real_t get_bounce() const { return bounce; } - _FORCE_INLINE_ real_t get_linear_damp() const { return linear_damp; } - _FORCE_INLINE_ real_t get_angular_damp() const { return angular_damp; } void integrate_forces(real_t p_step); void integrate_velocities(real_t p_step); |