Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Particle *np = particle->nbs[j].neighbour;
- vec3 r = particle->x - np->x;
- float r_length = glm::length(r);
- float distDiff = r_length - restDistance;
- if(distDiff >= 0 ) continue;
- //Frictional Constraint
- vec3 n = r/r_length;
- vec3 xxi = particle->x - xi[particle->getIndex()];
- vec3 xxj = np->x - xi[np->getIndex()];
- vec3 tangentialDisplacement = (xxi - xxj) - glm::dot(xxi - xxj, n) * n;
- float td_length = glm::length(tangentialDisplacement);
- float genMass = ( imass / (imass + imass) );
- if(td_length < (staticFriciton * distDiff)){
- particle->x += genMass * tangentialDisplacement;
- np->x += -genMass * tangentialDisplacement;
- }else{
- float upper = kineticFriction * distDiff;
- particle->x += genMass * tangentialDisplacement * std::min(upper/td_length, 1.f);
- np->x += -genMass * tangentialDisplacement * std::min(upper/td_length, 1.f);
- }
Add Comment
Please, Sign In to add comment