Contact Class |
Namespace: DigitalRune.Geometry.Collisions
The Contact type exposes the following members.
Name | Description | |
---|---|---|
Create |
Creates an instance of the Contact class. (This method
reuses a previously recycled instance or allocates a new instance if necessary.)
| |
Equals | (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Recycle |
Recycles this instance of the Contact class.
| |
ToString | (Overrides ObjectToString.) |
Name | Description | |
---|---|---|
FeatureA |
Gets or sets the index of the shape feature of object A that was hit.
| |
FeatureB |
Gets or sets the index of the shape feature of object B that was hit.
| |
IsRayHit |
Gets a value indicating whether this contact is a hit by a ray.
| |
Lifetime |
Gets or sets the lifetime of this contact (in seconds).
| |
Normal |
Gets or sets the normalized contact normal (pointing from object A to object B; in world space).
| |
PenetrationDepth |
Gets or sets the penetration depth.
| |
Position |
Gets or sets the contact position (in world space).
| |
PositionALocal |
Gets or sets the contact position on object A in the local space of object A.
| |
PositionAWorld |
Gets the contact position on object A (in world space).
| |
PositionBLocal |
Gets or sets the contact position on object B in the local space of object B.
| |
PositionBWorld |
Gets the contact position on object B (in world space).
| |
Swapped |
Gets a copy of the contact where the collision objects are swapped.
| |
UserData |
Gets or sets the user data.
|
A Contact is the result of a collision query. Contacts are usually stored in a ContactSet. A Contact describes a single contact point (or closest-point pair), whereas a ContactSet contains all contacts between two objects. (The involved objects are called "object A" and "object B".)
A Contact includes 2 points: a point on object A (see PositionALocal or PositionAWorld) and a point on object B (see PositionBLocal or PositionBWorld). The property Position is a point that lies halfway between those two points.
There are 4 types of contacts:
Closest points (separated objects): Object A and object B are separated. They are not in contact. This can be the result of a closest-point query (see GetClosestPoints(CollisionObject, CollisionObject)). Normal contact queries such as GetContacts(CollisionObject, CollisionObject) or the contact queries performed inside a CollisionDomain ignore separated objects!
The PenetrationDepth is negative. The absolute value of PenetrationDepth indicates the distance between the object A and object B. (The "penetration depth" is the inverse of "separation distance".) PositionAWorld and PositionBWorld are the closest points between the two objects. Position lies halfway between the closest points.
Closest-point query is a special type of collision query. At first this might look confusing: Why does a closest-point query return a Contact? The reason that contacts and closest points are represented by the same class is that the collision detection internally treats contacts and closest points the same way.
Ray Hit: Either object A or object B is a ray that hits the other object. The PenetrationDepth stores the distance from the ray origin to the contact position on the second object. The Normal describes the surface normal at the contact position.
(Ray hits can easily be found by checking whether the property IsRayHit is set in a Contact.)