diff options
author | Kester Maddock <Christopher.Maddock.1@uni.massey.ac.nz> | 2004-04-16 10:26:33 +0400 |
---|---|---|
committer | Kester Maddock <Christopher.Maddock.1@uni.massey.ac.nz> | 2004-04-16 10:26:33 +0400 |
commit | 4e2f7baff2ef86a6104f9cb17ea09088875454c5 (patch) | |
tree | 85706bc5b96d47d25945702cc328a713fab39b88 /source/gameengine/Physics/Sumo | |
parent | 98b8c5102d50d1141061ea3cb276fac6786ae7e7 (diff) |
Improved rigid body handling for non spherical bounds type.
Polyheder dynamic objects are now converted properly.
Diffstat (limited to 'source/gameengine/Physics/Sumo')
-rw-r--r-- | source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h | 10 | ||||
-rw-r--r-- | source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp | 34 |
2 files changed, 16 insertions, 28 deletions
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h index 92cecbdebaa..e7fbf3cdacc 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h +++ b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h @@ -14,14 +14,14 @@ public: void setPosition(const MT_Point3& pos) { m_pos = pos; } void setOrientation(const MT_Quaternion& orn) { m_orn = orn; } - void setLinearVelocity(const MT_Vector3& lin_vel) { m_lin_vel = lin_vel; } + void setLinearVelocity(const MT_Vector3& lin_vel) { m_lin_vel = lin_vel; } void setAngularVelocity(const MT_Vector3& ang_vel) { m_ang_vel = ang_vel; } - + const MT_Point3& getPosition() const { return m_pos; } const MT_Quaternion& getOrientation() const { return m_orn; } - const MT_Vector3& getLinearVelocity() const { return m_lin_vel; } - const MT_Vector3& getAngularVelocity() const { return m_ang_vel; } - + const MT_Vector3& getLinearVelocity() const { return m_lin_vel; } + const MT_Vector3& getAngularVelocity() const { return m_ang_vel; } + virtual MT_Transform getTransform() const { return MT_Transform(m_pos, m_orn); } diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp index d0d52934768..f6b0f50219e 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp +++ b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp @@ -51,7 +51,7 @@ // Tweak parameters -static const MT_Scalar ImpulseThreshold = 0.5; +static const MT_Scalar ImpulseThreshold = -10.; static const MT_Scalar FixThreshold = 0.01; static const MT_Scalar FixVelocity = 0.01; SM_Object::SM_Object( @@ -177,27 +177,22 @@ void SM_Object::dynamicCollision(const MT_Point3 &local2, MT_Scalar invMass ) { - // Same again but now obj1 is non-dynamic - // Compute the point on obj1 closest to obj2 (= sphere with radius = 0) - // local1 is th point closest to obj2 - // local2 is the local origin of obj2 - // This should look familiar.... MT_Scalar rel_vel_normal = normal.dot(rel_vel); - if (rel_vel_normal <= 0.0) { - if (-rel_vel_normal < ImpulseThreshold) { - restitution = 0.0; - } + if (rel_vel_normal < -MT_EPSILON) { + restitution *= MT_min(MT_Scalar(1.0), rel_vel_normal/ImpulseThreshold); MT_Scalar impulse = -(1.0 + restitution) * rel_vel_normal; if (isRigidBody()) { - MT_Vector3 temp = getInvInertiaTensor() * local2.cross(normal); - applyImpulse(local2 + m_pos, (impulse / (invMass + normal.dot(temp.cross(local2)))) * normal); + MT_Vector3 temp = getInvInertiaTensor() * local2.cross(normal); + impulse /= invMass + normal.dot(temp.cross(local2)); + applyImpulse(local2 + m_pos, impulse * normal); } else { - applyCenterImpulse( ( impulse / invMass ) * normal ); + impulse /= invMass; + applyCenterImpulse( impulse * normal ); } // The friction part starts here!!!!!!!! @@ -361,15 +356,8 @@ DT_Bool SM_Object::boing( local1 -= obj1->m_pos, local2 -= obj2->m_pos; // Calculate collision parameters - MT_Vector3 rel_vel = obj1->getVelocity(local1) + obj1->m_combined_lin_vel - - obj2->getVelocity(local2) - obj2->m_combined_lin_vel; + MT_Vector3 rel_vel = obj1->getVelocity(local1) - obj2->getVelocity(local2); - if (obj1->isRigidBody()) - rel_vel += obj1->actualAngVelocity().cross(local1); - - if (obj2->isRigidBody()) - rel_vel -= obj2->actualAngVelocity().cross(local2); - MT_Scalar restitution = MT_min(obj1->getMaterialProps()->m_restitution, obj2->getMaterialProps()->m_restitution); @@ -1013,9 +1001,9 @@ getVelocity( */ return m_prev_kinematic && !isDynamic() ? (m_xform(local) - m_prev_xform(local)) / m_timeStep : - m_lin_vel + m_ang_vel.cross(local); + actualLinVelocity() + actualAngVelocity().cross(local); - // m_lin_vel + m_ang_vel.cross(m_xform.getBasis() * local); + //m_lin_vel + m_ang_vel.cross(m_xform.getBasis() * local); // NB: m_xform.getBasis() * local == m_xform(local) - m_xform.getOrigin() } |