This commit is contained in:
Irlan
2018-06-27 11:31:42 -03:00
parent 73777b9f1a
commit 2485f92ba4
5 changed files with 79 additions and 101 deletions

View File

@ -48,6 +48,8 @@ struct b3ClothSolverData
b3DenseVec3* y;
b3SparseSymMat33* dfdx;
b3SparseSymMat33* dfdv;
b3DiagMat33* S;
b3DenseVec3* z;
float32 dt;
float32 invdt;
};
@ -57,6 +59,8 @@ struct b3AccelerationConstraint
u32 i1;
u32 ndof;
b3Vec3 p, q, z;
void Apply(const b3ClothSolverData* data);
};
class b3ClothSolver
@ -71,21 +75,15 @@ public:
void Solve(float32 dt, const b3Vec3& gravity);
private:
// Initialize forces.
void InitializeForces();
// Apply forces.
void ApplyForces();
// Initialize constraints.
void InitializeConstraints();
// Apply constraints.
void ApplyConstraints();
// Compute A and b in Ax = b
// Compute A and b in Ax = b.
void Compute_A_b(b3SparseSymMat33& A, b3DenseVec3& b) const;
// Compute S and z.
void Compute_S_z(b3DiagMat33& S, b3DenseVec3& z);
// Solve Ax = b.
void Solve(b3DenseVec3& x, u32& iterations, const b3SparseSymMat33& A, const b3DenseVec3& b, const b3DiagMat33& S, const b3DenseVec3& z, const b3DenseVec3& y) const;

View File

@ -58,11 +58,8 @@ protected:
b3Force() { }
virtual ~b3Force() { }
virtual void Initialize(const b3ClothSolverData* data) = 0;
virtual void Apply(const b3ClothSolverData* data) = 0;
// Solver shared
// Force type
b3ForceType m_type;

View File

@ -73,9 +73,7 @@ private:
b3SpringForce(const b3SpringForceDef* def);
~b3SpringForce();
void Initialize(const b3ClothSolverData* data);
void Apply(const b3ClothSolverData* data);
// Solver shared
@ -95,16 +93,8 @@ private:
// Damping stiffness
float32 m_kd;
// Solver temp
// Force (f_1 entry)
// Applied internal force (on particle 1)
b3Vec3 m_f;
// Jacobian (J_11 entry)
b3Mat33 m_Jx;
// Jacobian (J_11 entry)
b3Mat33 m_Jv;
};
inline b3Particle * b3SpringForce::GetParticle1()