protected void OnCreatePair(NarrowPhasePair pair) { overlapMapping.Add(pair.BroadPhaseOverlap, pair); pair.OnAddedToNarrowPhase(); if (CreatingPair != null) { CreatingPair(pair); } }
void RemoveFriction(EntityCollidable sender, BroadPhaseEntry other, NarrowPhasePair pair) { var collidablePair = pair as CollidablePairHandler; if (collidablePair != null) { //The default values for InteractionProperties is all zeroes- zero friction, zero bounciness. //That's exactly how we want the character to behave when hitting objects. collidablePair.UpdateMaterialProperties(new InteractionProperties()); } }
public void OnPairUpdated(BroadPhaseEntry other, NarrowPhasePair collisionPair) { if (InternalPairUpdated != null) { eventStoragePairUpdated.Enqueue(new EventStoragePairUpdated(other, collisionPair)); } if (PairUpdating != null) { PairUpdating(owner, other, collisionPair); } }
///<summary> /// Gets a narrow phase pair for a given broad phase overlap. ///</summary> ///<param name="pair">Overlap to use to create the pair.</param> ///<returns>A INarrowPhasePair for the overlap.</returns> public static NarrowPhasePair GetPairHandler(ref BroadPhaseOverlap pair) { NarrowPhasePairFactory factory; if (collisionManagers.TryGetValue(new TypePair(pair.entryA.GetType(), pair.entryB.GetType()), out factory)) { var toReturn = factory.GetNarrowPhasePair(); toReturn.BroadPhaseOverlap = pair; toReturn.Factory = factory; return(toReturn); } //Convex-convex collisions are a pretty significant chunk of all tests, so rather than defining them all, just have a fallback. var a = pair.entryA as ConvexCollidable; var b = pair.entryB as ConvexCollidable; if (a != null && b != null) { NarrowPhasePair toReturn = Factories.ConvexConvex.GetNarrowPhasePair(); toReturn.BroadPhaseOverlap = pair; toReturn.Factory = Factories.ConvexConvex; return(toReturn); } return(null); }
/// <summary> /// Returns a pair to the factory for re-use. /// </summary> /// <param name="pair">Pair to return.</param> public abstract void GiveBack(NarrowPhasePair pair);