Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (int i = 0; i < nContacts; i++) {
- // access data from collision detector
- point = mCollisionDetector->getContact(i).point; // contact point
- normal = mCollisionDetector->getContact(i).normal; // normal vector of contact point
- RigidBody *A = mCollisionDetector->getContact(i).rb1;
- RigidBody *B = mCollisionDetector->getContact(i).rb2;
- pVelocity = mCollisionDetector->getContact(i).pinataVelocity;
- // pre-impulse normal velocity
- double vN = normal.dot(deriveContactPoint(A) - deriveContactPoint(B));
- // compute j
- j = -(1 + epsilon) * vN / (denominator(A) + denominator(B));
- // update linear and angular momentum
- updateMomentum(A);
- normal = -normal;
- updateMomentum(B);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement