summaryrefslogtreecommitdiff
path: root/servers/physics_2d/godot_body_2d.h
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-12-06 16:49:42 +0100
committerGitHub <noreply@github.com>2021-12-06 16:49:42 +0100
commit4bce5e302ef8cc6fcd0caf5137f0c1d3abdb88c2 (patch)
treed09ba42181856f0fea07228b450dcb9ffc9fff39 /servers/physics_2d/godot_body_2d.h
parent3ae8eda1ed30b6c32f6fc1141118c5a062161a96 (diff)
parent2273a78af1034b23b6bdefd993c41a27b4847d4b (diff)
Merge pull request #55602 from nekomatata/improve-rigidbody-contacts
Diffstat (limited to 'servers/physics_2d/godot_body_2d.h')
-rw-r--r--servers/physics_2d/godot_body_2d.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/servers/physics_2d/godot_body_2d.h b/servers/physics_2d/godot_body_2d.h
index ba4c39737a..f00512fe92 100644
--- a/servers/physics_2d/godot_body_2d.h
+++ b/servers/physics_2d/godot_body_2d.h
@@ -234,9 +234,15 @@ public:
angular_velocity += _inv_inertia * p_torque;
}
- _FORCE_INLINE_ void apply_bias_impulse(const Vector2 &p_impulse, const Vector2 &p_position = Vector2()) {
+ _FORCE_INLINE_ void apply_bias_impulse(const Vector2 &p_impulse, const Vector2 &p_position = Vector2(), real_t p_max_delta_av = -1.0) {
biased_linear_velocity += p_impulse * _inv_mass;
- biased_angular_velocity += _inv_inertia * (p_position - center_of_mass).cross(p_impulse);
+ if (p_max_delta_av != 0.0) {
+ real_t delta_av = _inv_inertia * (p_position - center_of_mass).cross(p_impulse);
+ if (p_max_delta_av > 0 && delta_av > p_max_delta_av) {
+ delta_av = p_max_delta_av;
+ }
+ biased_angular_velocity += delta_av;
+ }
}
void set_active(bool p_active);