Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. for (int i = 0; i < nContacts; i++) {
  2. // access data from collision detector
  3. point = mCollisionDetector->getContact(i).point; // contact point
  4. normal = mCollisionDetector->getContact(i).normal; // normal vector of contact point
  5. RigidBody *A = mCollisionDetector->getContact(i).rb1;
  6. RigidBody *B = mCollisionDetector->getContact(i).rb2;
  7. pVelocity = mCollisionDetector->getContact(i).pinataVelocity;
  8.  
  9. // pre-impulse normal velocity
  10. double vN = normal.dot(deriveContactPoint(A) - deriveContactPoint(B));
  11. // compute j
  12. j = -(1 + epsilon) * vN / (denominator(A) + denominator(B));
  13.  
  14. // update linear and angular momentum
  15. updateMomentum(A);
  16. normal = -normal;
  17. updateMomentum(B);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement