7 #include "imstkPbdConstraint.h" 48 case (SolverType::PBD):
51 case (SolverType::xPBD):
54 dlambda = -(c + alpha *
m_lambda) / (w + alpha);
61 const double invMass = bodies.getInvMass(
m_particles[i]);
72 if (!m_correctVelocity)
77 const double fricFrac = 1.0 - m_friction;
80 const double invMass = bodies.getInvMass(
m_particles[i]);
85 const Vec3d n =
m_dcdx[i].normalized();
89 const Vec3d vN = n.dot(v) * n;
90 const Vec3d vT = v - vN;
93 v = vN * m_restitution + vT * fricFrac;
std::vector< Vec3d > m_dcdx
Normalized constraint gradients (per particle)
double m_lambda
Lagrange multiplier.
std::vector< PbdParticleId > m_particles
body, particle index
double computeGeneralizedInvMass(const PbdState &bodies, const size_t particleIndex) const
Compute generalized inverse mass of the particle. Note perf sensitive function. It has been intention...
double m_compliance
used in xPBD, inverse of Stiffness
virtual bool computeValueAndGradient(PbdState &bodies, double &c, std::vector< Vec3d > &dcdx)=0
Compute value and gradient of the constraint.
double m_stiffness
used in PBD, [0, 1]
SolverType
Type of solvers.
double m_C
Constraint Value.
virtual void projectConstraint(PbdState &bodies, const double dt, const SolverType &type)
Update positions by projecting constraints.
virtual void correctVelocity(PbdState &bodies, const double dt)
Correct velocities according to friction and restitution Corrects according to the gradient direction...
Provides interface for accessing particles from a 2d array of PbdBody,Particles.