through an acceleration constraint, the solver can remove acceleration from kinematic particles; consistency; in effect test update

This commit is contained in:
Irlan
2018-05-27 02:50:40 -03:00
parent 8abb45fd21
commit dba5ffbe06
8 changed files with 146 additions and 145 deletions

View File

@ -145,14 +145,14 @@ struct b3Spring
// Solver temp
// Action tensile force (f_i entry)
b3Vec3 tension;
// Force (f_i entry)
b3Vec3 f;
// Jacobian (J_ii entry)
b3Mat33 Jx, Jv;
// Apply spring forces.
void ApplyForces(const b3ClothSolverData* data);
// Initialize forces and its derivatives.
void InitializeForces(const b3ClothSolverData* data);
};
// Read-only body contact between a particle and a solid
@ -191,15 +191,15 @@ public:
// Set the type of a given particle.
void SetType(b3Particle* p, b3ParticleType type);
// Translate a given particle in the next time step.
void Translate(b3Particle* p, const b3Vec3& translation);
// Set the velocity of a given particle.
void SetVelocity(b3Particle* p, const b3Vec3& velocity);
// Apply a force to a given particle.
void ApplyForce(b3Particle* p, const b3Vec3& force);
// Apply a translation to a given particle.
void ApplyTranslation(b3Particle* p, const b3Vec3& translation);
// Return the number of springs in this cloth.
u32 GetSpringCount() const;
@ -317,11 +317,6 @@ inline void b3Cloth::SetType(b3Particle* p, b3ParticleType type)
}
}
inline void b3Cloth::Translate(b3Particle* p, const b3Vec3& translation)
{
p->translation += translation;
}
inline void b3Cloth::SetVelocity(b3Particle* p, const b3Vec3& velocity)
{
if (p->type == e_staticParticle)
@ -340,6 +335,11 @@ inline void b3Cloth::ApplyForce(b3Particle* p, const b3Vec3& force)
p->force += force;
}
inline void b3Cloth::ApplyTranslation(b3Particle* p, const b3Vec3& translation)
{
p->translation += translation;
}
inline u32 b3Cloth::GetSpringCount() const
{
return m_springCount;

View File

@ -25,6 +25,7 @@
struct b3DenseVec3;
struct b3DiagMat33;
struct b3SparseMat33;
struct b3SolverSparseMat33;
struct b3Particle;
struct b3Spring;
@ -50,6 +51,13 @@ struct b3ClothSolverData
float32 invdt;
};
struct b3SpringForce
{
u32 i1, i2;
b3Vec3 f;
b3Mat33 Jx, Jv;
};
struct b3AccelerationConstraint
{
u32 i1;
@ -69,11 +77,14 @@ public:
void Solve(float32 dt, const b3Vec3& gravity);
private:
// Initialize forces.
void InitializeForces();
// Initialize constraints.
void InitializeConstraints();
// Compute A and b in Ax = b
void Compute_A_b(b3SparseMat33& A, b3DenseVec3& b, const b3DenseVec3& f, const b3DenseVec3& x, const b3DenseVec3& v, const b3DenseVec3& y) const;
void Compute_A_b(b3SolverSparseMat33& A, b3DenseVec3& b, const b3DenseVec3& f, const b3DenseVec3& x, const b3DenseVec3& v, const b3DenseVec3& y) const;
// Compute S and z.
void Compute_S_z(b3DiagMat33& S, b3DenseVec3& z);