diff options
author | Kester Maddock <Christopher.Maddock.1@uni.massey.ac.nz> | 2004-12-06 14:10:41 +0300 |
---|---|---|
committer | Kester Maddock <Christopher.Maddock.1@uni.massey.ac.nz> | 2004-12-06 14:10:41 +0300 |
commit | e54f51c462592eb297dfa38314f4a9802d57bf95 (patch) | |
tree | 4f82fb8b378c49ffedbe8d31dbdf3fcc0b306b13 /source/gameengine | |
parent | 85a8203cbce1fda35694c82dfad8a1349f3dc288 (diff) |
Fix numerical precision issue in physics. Dividing by a number too close to zero would make the impulse response normal large hence the jittering.
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp index cab191707be..26687663006 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp +++ b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp @@ -49,7 +49,7 @@ #include "MT_MinMax.h" -MT_Scalar SM_Object::ImpulseThreshold = -0.01; +MT_Scalar SM_Object::ImpulseThreshold = -1.0; struct Contact { @@ -278,12 +278,12 @@ void SM_Object::dynamicCollision(const MT_Point3 &local2, /** * if rel_vel_normal > 0, the objects are moving apart! */ - if (rel_vel_normal < 0.) { + if (rel_vel_normal < -MT_EPSILON) { /** * if rel_vel_normal < ImpulseThreshold, scale the restitution down. * This should improve the simulation where the object is stacked. - */ - restitution *= MT_min(MT_Scalar(1.0), m_shapeProps->m_mass*rel_vel_normal/ImpulseThreshold); + */ + restitution *= MT_min(MT_Scalar(1.0), rel_vel_normal/ImpulseThreshold); MT_Scalar impulse = -(1.0 + restitution) * rel_vel_normal; @@ -607,9 +607,6 @@ SM_Object::SM_Object() : m_scaling(1.0, 1.0, 1.0), m_reaction_impulse(0.0, 0.0, 0.0), m_reaction_force(0.0, 0.0, 0.0), - m_kinematic(false), - m_prev_kinematic(false), - m_is_rigid_body(false), m_lin_mom(0.0, 0.0, 0.0), m_ang_mom(0.0, 0.0, 0.0), m_force(0.0, 0.0, 0.0), @@ -617,7 +614,10 @@ SM_Object::SM_Object() : m_error(0.0, 0.0, 0.0), m_combined_lin_vel (0.0, 0.0, 0.0), m_combined_ang_vel (0.0, 0.0, 0.0), - m_fh_object(0) + m_fh_object(0), + m_kinematic(false), + m_prev_kinematic(false), + m_is_rigid_body(false) { // warning no initialization of variables done by moto. } |