Skip to content

Commit

Permalink
Guard against overflowing the contact manifold
Browse files Browse the repository at this point in the history
  • Loading branch information
notgiven688 committed Nov 8, 2024
1 parent 541f6b0 commit 1ad1a02
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Jitter2/World.Detect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ static void Support(RigidBodyShape shape, in JVector direction, out JVector v)
float diff = JVector.Dot(p - pB, normal);
mB[manifoldCount] = p;
mA[manifoldCount++] = p - (diff - penetration) * normal;

if (manifoldCount == 6) return;
}
}
}
Expand Down Expand Up @@ -193,6 +195,8 @@ static void Support(RigidBodyShape shape, in JVector direction, out JVector v)
float diff = -JVector.Dot(p - pA, normal);
mA[manifoldCount] = p;
mB[manifoldCount++] = p - (diff - penetration) * normal;

if (manifoldCount == 6) return;
}
}
}
Expand Down Expand Up @@ -401,7 +405,7 @@ private void Detect(IDynamicTreeProxy proxyA, IDynamicTreeProxy proxyB)
arbiter.Handle.Data.AddContact(mfA, mfB, normal, nd);
}

arbiter.Handle.Data.AddContact(pA, pB, normal, penetration);
if(cvh.Count < 4) arbiter.Handle.Data.AddContact(pA, pB, normal, penetration);

memContacts.ResizeLock.ExitReadLock();
}
Expand Down

0 comments on commit 1ad1a02

Please sign in to comment.