This commit is contained in:
Irlan 2018-07-24 16:46:28 -03:00
parent bea108510f
commit 927b35a45d
2 changed files with 29 additions and 19 deletions

View File

@ -152,6 +152,9 @@ public:
// Get the local position of the center of mass.
b3Vec3 GetLocalCenter() const;
// Get the velocity at a given point.
b3Vec3 GetPointVelocity(const b3Vec3& point) const;
// Get the linear velocity of the center of mass.
b3Vec3 GetLinearVelocity() const;
@ -556,6 +559,11 @@ inline void b3Body::SetGravityScale(float32 scale)
}
}
inline b3Vec3 b3Body::GetPointVelocity(const b3Vec3& point) const
{
return m_linearVelocity + b3Cross(m_angularVelocity, point - m_sweep.worldCenter);
}
inline b3Vec3 b3Body::GetLinearVelocity() const
{
return m_linearVelocity;

View File

@ -594,18 +594,6 @@ void b3Cloth::UpdateContacts()
}
}
#if 0
// Notify the new contact state
if (c0.n_active == false && c->n_active == true)
{
// The contact has begun
}
if (c0.n_active == true && c->active_n == false)
{
// The contact has ended
}
#endif
if (c->n_active == false)
{
continue;
@ -618,13 +606,16 @@ void b3Cloth::UpdateContacts()
}
b3Shape* s = c->s2;
b3Body* b = s->GetBody();
b3Vec3 n = c->n;
float32 u = s->GetFriction();
float32 normalForce = c0.Fn;
float32 maxFrictionForce = u * normalForce;
// Relative velocity
b3Vec3 dv = p->m_velocity;
// Relative velocity at contact point
b3Vec3 v1 = b->GetPointVelocity(c->p);
b3Vec3 v2 = p->m_velocity;
b3Vec3 dv = v2 - v1;
b3Vec3 t1 = dv - b3Dot(dv, n) * n;
if (b3Dot(t1, t1) > B3_EPSILON * B3_EPSILON)
@ -637,11 +628,6 @@ void b3Cloth::UpdateContacts()
c->t1 = t1;
c->t2 = t2;
//c->f_active = true;
//c->f.m_type = e_frictionForce;
//c->f.m_p = p;
//c->f.m_kd = 10.0f;
}
b3Vec3 ts[2];
@ -676,6 +662,22 @@ void b3Cloth::UpdateContacts()
c->t1_active = t_active[0];
c->t2_active = t_active[1];
if (c0.t1_active == true)
{
if (c0.Ft1 > maxFrictionForce)
{
c->t1_active = false;
}
}
if (c0.t2_active == true)
{
if (c0.Ft2 > maxFrictionForce)
{
c->t2_active = false;
}
}
}
}