void UpdateBroadPhaseOverlap(int i)
{
BroadPhaseOverlap overlap = broadPhaseOverlaps.Elements[i];
if (overlap.collisionRule < CollisionRule.NoNarrowPhasePair)
{
NarrowPhasePair pair;
//see if the overlap is already present in the narrow phase.
if (!overlapMapping.TryGetValue(overlap, out pair))
{
//Create/enqueue based on collision table
pair = NarrowPhaseHelper.GetPairHandler(ref overlap);
if (pair != null)
{
pair.NarrowPhase = this;
//Add the new object to the 'todo' list.
//Technically, this doesn't need to be thread-safe when this is called from the sequential context.
//It's just bunched together for maintainability despite the slight performance hit.
newNarrowPhasePairs.Enqueue(pair);
}
}
if (pair != null)
{
//Update the collision rule.
pair.CollisionRule = overlap.collisionRule;
if (pair.BroadPhaseOverlap.collisionRule < CollisionRule.NoNarrowPhaseUpdate)
{
pair.UpdateCollision(TimeStepSettings.TimeStepDuration);
}
pair.NeedsUpdate = false;
}
}
}