17-OVERVIEW OF THE ENGINE

OVERVIEW OF THE ENGINE

The physics engine we have built has four distinct parts:

  • The force generators (and torque generators) examine the current state of the game and calculate what forces need to be applied to which objects.
  • The rigid-body simulator processes the movement of rigid bodies in response to those forces.
  • The collision detector rapidly identifies collisions and other contacts both between objects and between an object and the immovable parts of the level. The collision detector creates a set of contacts to be used by the collision resolver.
  • The collision resolver processes a set of contacts and adjusts the motion of rigid bodies to accurately depict their effects

Notice that there are two kinds of internal data used in the preceding components:

  • The forces and torques generated are never represented in an explicit data structure. They are applied directly to the appropriate rigid body as soon as they are calculated.
  • Contacts are generated by the collision detector and stored together, before being sent as a group to the collision resolver.

To represent objects in the game we need three kinds of data:

  • Rendering geometry
  • Collision geometry
  • Rigid-body data contains information about the physical characteristics of the object. It includes things like mass and inertia tensor, as well as position and velocity.

SIMULTANEOUS CONTACT RESOLUTION

Most physics engines that perform this simultaneous calculation are based on force calculations rather than impulses.The most common approach to doing this is called the “linear-complementary problem.” It involves building a mathematical structure called a Jacobian, which encodes the interactions between different contacts.

Jacobian

The Jacobian is a mathematical construct that says how one contact affects another. It is used to determine the right balance of adjustments to make with the full knowledge of the side effects of any tweak. The Jacobian is a matrix and may be of any size.
All the forces and torques for all objects are combined into one very long vector. There will be three force entries and three torque entries for each rigid body, so the vector will have 6n entries, where n is the number of rigid bodies. In the same way all the accelerations (linear and angular) for all objects are treated as one long vector (again having 6n entries).

posted on 2024-03-22 14:41  Ultraman_X  阅读(2)  评论(0编辑  收藏  举报

导航