13-Generating_ Contacts

Many collision detection systems perform this check for each pair and return a single point of maximum interpenetration if the objects are in contact. That is not what we need. We need contact generation.
The bulk of this chapter looks at generating the contacts between geometric primitives that are useful as stand-in collision geometry.

COLLISION GEOMETRY

In many games, it is simplified into a chunky geometry created just for the physics.This chunky geometry consists of certain geometric primitives namely, spheres, boxes, planes, and capsules.It is important to remember that the primitives your game needs will depend to
some extent on the game.

PRIMITIVE ASSEMBLIES


The vast majority of objects can't easily be approximated by a single primitive shape. Some developers don't even try: they use convex meshes to approximate all objects. Another approach is to use assemblies of primitive objects as collision geometry.

Generating Collision Geometry

  • The easiest method is to ask designers to create the collision geometry manually.
  • created tools for generating simplified convex meshes to act as collision geometry.

Contact Generation

It is important to make a distinction between collision detection and contact generation.Collision detection determines whether two objects are touching or interpenetrated, and normally provides data on the largest interpenetration point.Contact generation produces the set of points on each object that are in contact(or penetrating).

The difference is crucial. In figure, one box is lying across another: in the left part of the figure the result of a typical collision detection system is shown: the box is slightly(microscopically) twisted, so one edge generates the contact. In the right part of the figure the correct contact patch is generated. To make things easier we would like to deal only with point contacts.

we will be looking for point–face contacts and edge–edge contacts first.

Contact Data

  • The collision point This is the point of contact between the objects. In practice objects will be interpenetrating somewhat, and there may be any number of possible points.
  • The collision normal. This is the direction in which an impact impulse will be felt between the two objects.
  • The penetration depth This is the amount that the two objects are interpenetrating.
class Contact
{
    /**
    * Holds the position of the contact in world coordinates.
    */
    Vector3 contactPoint;
    /**
    * Holds the direction of the contact in world coordinates.
    */
    Vector3 contactNormal;
    /**
    * Holds the depth of penetration at the contact point. If both
    * bodies are specified then the contact point should be midway
    * between the inter-penetrating points.
    */
    real penetration;
};

Primitive Collision Algorithms

Each of the collision algorithms in this chapter checks for contact and generates contact data structures for different combinations of primitives.

    /**
    * A helper structure that contains information for the detector to use
    * in building its contact data.
    */
    struct CollisionData
    {
        /** Holds the contact array to write into. */
        Contact *contacts;
        /** Holds the maximum number of contacts the array can take. */
        unsigned contactsLeft;
    };
  • COLLIDING TWO SPHERE

  • COLLIDING A SPHERE AND A BOX

  • COLLIDING TWO BOXES

There are six possible types of contact between two boxes, as shown in figure. We're trying to avoid face–face and edge–face contacts because they are not stable.A single contact point between two planes allows the planes to rotate; it is unlikely that the contact normal will be generated so that it passes through both centers of gravity.

We can always replace a face–face contact with up to four point–face or edge–edge contacts. Similarly we can replace face–edge contacts with up to two point–face or edge–edge contacts.

posted on 2024-03-13 14:59  Ultraman_X  阅读(5)  评论(0编辑  收藏  举报

导航