More consistency and pass velocity and position iterations to cloth constraint solver
This commit is contained in:
@ -29,8 +29,7 @@ class b3Shape;
|
||||
|
||||
class b3Particle;
|
||||
class b3Force;
|
||||
class b3BodyContact;
|
||||
class b3ParticleContact;
|
||||
struct b3ParticleBodyContact;
|
||||
|
||||
struct b3ParticleDef;
|
||||
struct b3ForceDef;
|
||||
@ -134,7 +133,7 @@ public:
|
||||
float32 GetEnergy() const;
|
||||
|
||||
// Perform a time step.
|
||||
void Step(float32 dt);
|
||||
void Step(float32 dt, u32 velocityIterations, u32 positionIterations);
|
||||
|
||||
// Debug draw the cloth using the associated cloth mesh.
|
||||
void Draw() const;
|
||||
@ -149,7 +148,7 @@ private:
|
||||
void UpdateContacts();
|
||||
|
||||
// Solve
|
||||
void Solve(float32 dt, const b3Vec3& gravity);
|
||||
void Solve(float32 dt, const b3Vec3& gravity, u32 velocityIterations, u32 positionIterations);
|
||||
|
||||
// Stack allocator
|
||||
b3StackAllocator m_stackAllocator;
|
||||
|
@ -27,7 +27,7 @@ class b3StackAllocator;
|
||||
class b3Particle;
|
||||
class b3Body;
|
||||
|
||||
class b3BodyContact;
|
||||
struct b3ParticleBodyContact;
|
||||
|
||||
struct b3DenseVec3;
|
||||
|
||||
@ -88,7 +88,7 @@ struct b3ClothContactSolverDef
|
||||
b3DenseVec3* velocities;
|
||||
|
||||
u32 bodyContactCount;
|
||||
b3BodyContact** bodyContacts;
|
||||
b3ParticleBodyContact** bodyContacts;
|
||||
};
|
||||
|
||||
inline float32 b3MixFriction(float32 u1, float32 u2)
|
||||
@ -118,7 +118,7 @@ protected:
|
||||
b3DenseVec3* m_velocities;
|
||||
|
||||
u32 m_bodyContactCount;
|
||||
b3BodyContact** m_bodyContacts;
|
||||
b3ParticleBodyContact** m_bodyContacts;
|
||||
b3ClothSolverBodyContactVelocityConstraint* m_bodyVelocityConstraints;
|
||||
b3ClothSolverBodyContactPositionConstraint* m_bodyPositionConstraints;
|
||||
};
|
||||
|
@ -33,8 +33,7 @@ struct b3DiagMat33;
|
||||
struct b3SparseSymMat33;
|
||||
struct b3SparseSymMat33View;
|
||||
|
||||
class b3BodyContact;
|
||||
class b3ParticleContact;
|
||||
struct b3ParticleBodyContact;
|
||||
|
||||
struct b3ClothSolverDef
|
||||
{
|
||||
@ -75,10 +74,9 @@ public:
|
||||
|
||||
void Add(b3Particle* p);
|
||||
void Add(b3Force* f);
|
||||
void Add(b3BodyContact* c);
|
||||
void Add(b3ParticleContact* c);
|
||||
void Add(b3ParticleBodyContact* c);
|
||||
|
||||
void Solve(float32 dt, const b3Vec3& gravity);
|
||||
void Solve(float32 dt, const b3Vec3& gravity, u32 velocityIterations, u32 positionIterations);
|
||||
private:
|
||||
// Apply forces.
|
||||
void ApplyForces();
|
||||
@ -107,11 +105,7 @@ private:
|
||||
|
||||
u32 m_bodyContactCapacity;
|
||||
u32 m_bodyContactCount;
|
||||
b3BodyContact** m_bodyContacts;
|
||||
|
||||
u32 m_particleContactCapacity;
|
||||
u32 m_particleContactCount;
|
||||
b3ParticleContact** m_particleContacts;
|
||||
b3ParticleBodyContact** m_bodyContacts;
|
||||
|
||||
b3ClothSolverData m_solverData;
|
||||
};
|
||||
|
@ -62,27 +62,13 @@ struct b3ParticleDef
|
||||
};
|
||||
|
||||
// A contact between a particle and a solid
|
||||
class b3BodyContact
|
||||
struct b3ParticleBodyContact
|
||||
{
|
||||
public:
|
||||
b3BodyContact() { }
|
||||
~b3BodyContact() { }
|
||||
|
||||
b3Particle* p1;
|
||||
b3Shape* s2;
|
||||
|
||||
// Contact constraint
|
||||
float32 s;
|
||||
b3Vec3 p;
|
||||
b3Vec3 n;
|
||||
float32 fn0;
|
||||
float32 fn;
|
||||
float32 ft1, ft2;
|
||||
bool nActive;
|
||||
bool t1Active;
|
||||
bool t2Active;
|
||||
|
||||
// Contact constraint
|
||||
b3Vec3 normal1;
|
||||
b3Vec3 localPoint1;
|
||||
b3Vec3 localPoint2;
|
||||
float32 normalImpulse;
|
||||
@ -94,9 +80,9 @@ public:
|
||||
bool active;
|
||||
};
|
||||
|
||||
struct b3BodyContactWorldPoint
|
||||
struct b3ParticleBodyContactWorldPoint
|
||||
{
|
||||
void Initialize(const b3BodyContact* c, float32 rA, const b3Transform& xfA, float32 rB, const b3Transform& xfB);
|
||||
void Initialize(const b3ParticleBodyContact* c, float32 rA, const b3Transform& xfA, float32 rB, const b3Transform& xfB);
|
||||
|
||||
b3Vec3 point;
|
||||
b3Vec3 normal;
|
||||
@ -210,8 +196,8 @@ private:
|
||||
//
|
||||
b3Cloth* m_cloth;
|
||||
|
||||
//
|
||||
b3BodyContact m_bodyContact;
|
||||
// Contact
|
||||
b3ParticleBodyContact m_bodyContact;
|
||||
|
||||
//
|
||||
b3Particle* m_prev;
|
||||
|
Reference in New Issue
Block a user