typo, optimization, consistency
This commit is contained in:
@ -64,9 +64,9 @@ struct b3ClothDef
|
||||
float32 kd;
|
||||
};
|
||||
|
||||
// Static particles have zero mass and velocity, and therefore they can't move.
|
||||
// Kinematic particles are't moved by external and internal forces but can be moved by contact forces.
|
||||
// Dynamic particles have non-zero mass and can move due to internal and external forces.
|
||||
// Static particle: Has zero mass, can be moved manually.
|
||||
// Kinematic particle: Has zero mass, non-zero velocity, can be moved by the solver.
|
||||
// Dynamic particle: Has non-zero mass, non-zero velocity determined by force, can be moved by the solver.
|
||||
enum b3ParticleType
|
||||
{
|
||||
e_staticParticle,
|
||||
@ -98,10 +98,10 @@ struct b3Particle
|
||||
// Radius
|
||||
float32 radius;
|
||||
|
||||
// User data
|
||||
// User data.
|
||||
void* userData;
|
||||
|
||||
// Translation used for direct position manipulation
|
||||
// Applied external translation
|
||||
b3Vec3 translation;
|
||||
|
||||
// Solver temp
|
||||
@ -125,6 +125,8 @@ struct b3ClothSolverData;
|
||||
// Read-only spring
|
||||
struct b3Spring
|
||||
{
|
||||
// Solver shared
|
||||
|
||||
// Spring type
|
||||
b3SpringType type;
|
||||
|
||||
@ -151,8 +153,8 @@ struct b3Spring
|
||||
// Jacobian (J_ii entry)
|
||||
b3Mat33 Jx, Jv;
|
||||
|
||||
// Initialize solver data.
|
||||
void Initialize(const b3ClothSolverData* data);
|
||||
// Apply spring forces.
|
||||
void ApplyForces(const b3ClothSolverData* data);
|
||||
};
|
||||
|
||||
// Read-only contact
|
||||
@ -160,6 +162,7 @@ struct b3ParticleContact
|
||||
{
|
||||
b3Particle* p1;
|
||||
b3Shape* s2;
|
||||
float32 s;
|
||||
b3Vec3 n, t1, t2;
|
||||
float32 Fn, Ft1, Ft2;
|
||||
bool n_active, t1_active, t2_active;
|
||||
@ -254,8 +257,8 @@ protected:
|
||||
u32 m_particleCount;
|
||||
b3Particle* m_particles;
|
||||
|
||||
b3Spring* m_springs;
|
||||
u32 m_springCount;
|
||||
b3Spring* m_springs;
|
||||
|
||||
b3ParticleContact* m_contacts;
|
||||
//u32 m_contactCount;
|
||||
|
@ -50,6 +50,13 @@ struct b3ClothSolverData
|
||||
float32 invdt;
|
||||
};
|
||||
|
||||
struct b3AccelerationConstraint
|
||||
{
|
||||
u32 i1;
|
||||
u32 ndof;
|
||||
b3Vec3 p, q, z;
|
||||
};
|
||||
|
||||
class b3ClothSolver
|
||||
{
|
||||
public:
|
||||
@ -62,17 +69,16 @@ public:
|
||||
|
||||
void Solve(float32 dt, const b3Vec3& gravity);
|
||||
private:
|
||||
// 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;
|
||||
|
||||
// Compute S.
|
||||
void Compute_S(b3DiagMat33& S);
|
||||
|
||||
// Compute z.
|
||||
void Compute_z(b3DenseVec3& z);
|
||||
// Compute S and z.
|
||||
void Compute_S_z(b3DiagMat33& S, b3DenseVec3& z);
|
||||
|
||||
// Solve Ax = b.
|
||||
// Output x and the residual error f = Ax - b ~ 0.
|
||||
void Solve(b3DenseVec3& x, u32& iterations, const b3SparseMat33& A, const b3DenseVec3& b, const b3DiagMat33& S, const b3DenseVec3& z, const b3DenseVec3& y) const;
|
||||
|
||||
b3StackAllocator* m_allocator;
|
||||
@ -89,6 +95,10 @@ private:
|
||||
u32 m_contactCount;
|
||||
b3ParticleContact** m_contacts;
|
||||
|
||||
u32 m_constraintCapacity;
|
||||
u32 m_constraintCount;
|
||||
b3AccelerationConstraint* m_constraints;
|
||||
|
||||
b3ClothSolverData m_solverData;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user