summaryrefslogtreecommitdiff
path: root/servers/physics/body_sw.h
diff options
context:
space:
mode:
Diffstat (limited to 'servers/physics/body_sw.h')
-rw-r--r--servers/physics/body_sw.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/servers/physics/body_sw.h b/servers/physics/body_sw.h
index 782bf14a4b..98095fd3c6 100644
--- a/servers/physics/body_sw.h
+++ b/servers/physics/body_sw.h
@@ -223,10 +223,16 @@ public:
angular_velocity += _inv_inertia_tensor.xform(p_j);
}
- _FORCE_INLINE_ void apply_bias_impulse(const Vector3 &p_pos, const Vector3 &p_j) {
+ _FORCE_INLINE_ void apply_bias_impulse(const Vector3 &p_pos, const Vector3 &p_j, real_t p_max_delta_av = -1.0) {
biased_linear_velocity += p_j * _inv_mass;
- biased_angular_velocity += _inv_inertia_tensor.xform((p_pos - center_of_mass).cross(p_j));
+ if (p_max_delta_av != 0.0) {
+ Vector3 delta_av = _inv_inertia_tensor.xform((p_pos - center_of_mass).cross(p_j));
+ if (p_max_delta_av > 0 && delta_av.length() > p_max_delta_av) {
+ delta_av = delta_av.normalized() * p_max_delta_av;
+ }
+ biased_angular_velocity += delta_av;
+ }
}
_FORCE_INLINE_ void apply_bias_torque_impulse(const Vector3 &p_j) {