summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2011-02-19 20:04:05 +0000
committerJesse Morgan <jesse@jesterpm.net>2011-02-19 20:04:05 +0000
commit2d6b06a6e4169c301527efe4635f58a390cf79a7 (patch)
treee24aefbcd5b9fb2bbc8333761e7d05fcefbb9b16
parentdba5b22dd4a913b5addff0558e861c6613156783 (diff)
Added dynamic friction.
-rw-r--r--src/alden/CollidableObject.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/alden/CollidableObject.java b/src/alden/CollidableObject.java
index 236b731..a2738fa 100644
--- a/src/alden/CollidableObject.java
+++ b/src/alden/CollidableObject.java
@@ -212,6 +212,26 @@ public abstract class CollidableObject {
if (totalInverseMass == 0)
return;
+ /* Dynamic Friction */
+ if (dynamicFriction > 0) {
+ Vector3f perpVelocity = new Vector3f();
+ perpVelocity.scaleAdd(initialClosingSpeed, ci.contactNormal, previousVelocity);
+ if (perpVelocity.length() > 0) {
+ perpVelocity.normalize();
+ Vector3f acceleration = new Vector3f();
+ acceleration.scaleAdd(-1, previousVelocity, velocity);
+ velocity.scaleAdd(dynamicFriction * acceleration.dot(ci.contactNormal), perpVelocity, velocity);
+ }
+
+ perpVelocity.scaleAdd(initialClosingSpeed, ci.contactNormal, other.previousVelocity);
+ if (perpVelocity.length() > 0) {
+ perpVelocity.normalize();
+ Vector3f acceleration = new Vector3f();
+ acceleration.scaleAdd(-1, other.previousVelocity, other.velocity);
+ other.velocity.scaleAdd(dynamicFriction * acceleration.dot(ci.contactNormal), perpVelocity, other.velocity);
+ }
+ }
+
Vector3f thisMovementUnit = new Vector3f();
thisMovementUnit.cross(thisRelativeContactPosition, ci.contactNormal);
getInverseInertiaTensor().transform(thisMovementUnit);