CollisionDomainGetContacts Method (CollisionObject) |
Namespace: DigitalRune.Geometry.Collisions
Exception | Condition |
---|---|
ArgumentNullException | collisionObject is . |
Each returned ContactSet contains a pair of collision objects ( collisionObject and another object) that describes the contact between the objects. The collision objects in the returned ContactSet can be swapped! See ContactSet for more information on swapped contact sets.
If collisionObject is part of this CollisionDomain, then this method returns the currently cached contacts sets (which are stored in ContactSets). The contact sets are only updated, when Update(TimeSpan) is called. If the collision object has moved since the collision domain was updated last, the contact information will not be up-to-date. In this case you need to call Update(TimeSpan) again before calling GetContacts(CollisionObject) to get up-to-date results.
If collisionObject is not part of this CollisionDomain, then this method automatically calculates the new contact information.
If collisionObject is part of this CollisionDomain, then the returned contact sets are managed by the domain. You must not modify or recycle the contact sets! However, if collisionObject is not part of this CollisionDomain, the returned contact sets are not managed by the domain. The contact sets can be modified. When they are no longer needed, they should be recycled to avoid unnecessary memory allocations. For example:
foreach (ContactSet contactSet in myCollisionDomain.GetContacts(myCollisionObject)) { // Check contact set. ... Debug.Assert(myCollisionObject.Domain != myCollisionDomain); foreach(var contact in contactSet) contact.Recycle(); contactSet.Recycle(); }