Guest User

Untitled

a guest
Oct 22nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. Particle *np = particle->nbs[j].neighbour;
  2.  
  3. vec3 r = particle->x - np->x;
  4. float r_length = glm::length(r);
  5.  
  6. float distDiff = r_length - restDistance;
  7.  
  8. if(distDiff >= 0 ) continue;
  9.  
  10. //Frictional Constraint
  11. vec3 n = r/r_length;
  12. vec3 xxi = particle->x - xi[particle->getIndex()];
  13. vec3 xxj = np->x - xi[np->getIndex()];
  14.  
  15. vec3 tangentialDisplacement = (xxi - xxj) - glm::dot(xxi - xxj, n) * n;
  16.  
  17. float td_length = glm::length(tangentialDisplacement);
  18.  
  19. float genMass = ( imass / (imass + imass) );
  20.  
  21.  
  22. if(td_length < (staticFriciton * distDiff)){
  23. particle->x += genMass * tangentialDisplacement;
  24.  
  25. np->x += -genMass * tangentialDisplacement;
  26. }else{
  27. float upper = kineticFriction * distDiff;
  28. particle->x += genMass * tangentialDisplacement * std::min(upper/td_length, 1.f);
  29.  
  30. np->x += -genMass * tangentialDisplacement * std::min(upper/td_length, 1.f);
  31. }
Add Comment
Please, Sign In to add comment