public override void Update(float dt)
{
//First, refresh all existing contacts. This is an incremental manifold.
ContactRefresher.ContactRefresh(contacts, supplementData, ref collidableA.worldTransform, ref collidableB.worldTransform, contactIndicesToRemove);
RemoveQueuedContacts();
//Now, generate a contact between the two shapes.
ContactData contact;
if (pairTester.GenerateContactCandidate(out contact))
{
if (IsContactUnique(ref contact))
{
//Check if adding the new contact would overflow the manifold.
if (contacts.Count == 4)
{
//Adding that contact would overflow the manifold. Reduce to the best subset.
bool addCandidate;
ContactReducer.ReduceContacts(contacts, ref contact, contactIndicesToRemove, out addCandidate);
RemoveQueuedContacts();
if (addCandidate)
Add(ref contact);
}
else
{
//Won't overflow the manifold, so just toss it in.
Add(ref contact);
}
}
}
else
{
//No collision, clean out the manifold.
for (int i = contacts.Count - 1; i >= 0; i--)
{
Remove(i);
}
}
}