Documentation/Articles/Overview of Physics System

From NeoAxis Engine Wiki

Jump to: navigation, search
Go to higher level
Physics08.jpg

Contents

Overview

Physics system is a module that enables working with collisions and simulating rigid body dynamics.

The module represents a universal abstract wrapper for implementation of third-party physics engines. Currently, two physics engines are implemented:

See detailed comparison below.

Features

  • Abstract wrapper for physics. Makes it easy to implement other third-party physics libraries.
  • File format for storing physical models (.physics files)
  • Primitives: boxes, spheres, capsules, user-defined triangular mesh collision detection
  • Joints: hinge, universal, ball, hinge2, slider, fixed
  • Motors: attractor, geared, servo
  • Linear and angular motion damping
  • Breakable joints
  • Per-shape collision events
  • Per-shape ray casts
  • Volume casts
  • Events: Collision event handler, Joint break event handler
  • Contact groups (define which objects can interact physically)
  • Opportunity to save customized physics material
  • Per-shape material settings

Collision detection methods

Discrete Collision Detection (overlap test) is faster and simpler to implement but may suffer from tunneling effect - collision may not be detected for thin, small and fast objects, because their shape is not overlapped in each consecutive frame. This problem is even greater in low framerates as objects displace a lot more between frames.

Discrete Collision Detection

CCD (Continuous Collision Detection) is a method of calculating collision especially useful for small, fast moving objects. It is more expensive to calculate, but collision detection is not affected by framerate, object size or speed, and also can provide data such as point of contact, time of contact and normal of contact.

Continuous Collision Detection

NVIDIA PhysX

Free physics engine.

Official website: http://developer.nvidia.com/object/physx.html

This physics engine supports continuous collision detection. Following points are to be noted:

  • Dynamic vs. static does not work when the static shape is a Sphere, Capsule and Box Shape. These shapes are not used for static geometry in games and it would require significant work to support them since they are not polygon based shapes (the CCD algorithm works with meshes).
  • In NeoAxis Engine, dynamic vs. dynamic bodies checks is switched off, because it works very slowly.
  • The CCD code assumes shapes will not rotate by more than 180 degrees in a time step.

Open Dynamics Engine (ODE)

Free and open-source physics engine.

Official website: http://www.ode.org

The orginal code of ODE has no support for continuous collision detection (CCD). However it is implemented in NeoAxis Engine by a simpler method that is not as precise but is less CPU-expensive.

The method consists of a check that is carried out by sending out a ray from the previous position of a body to the current position. If the ray intersect an obstacle then the body is moved to the obstacle.

For this method to work correctly, it is necessary to observe the following rules:

  • Shapes of a body should be in the center of this body i.e. they should have Position = 0,0,0
  • The method will work better if bodies have proportional sizes i.e. dimensions of a body (x, y, z) are approximately identical.
  • The method works best with Box shapes. The method is not so effective with Capsule and Sphere shapes.
  • The method does not work if both objects are dynamic.

The method does not give 100% accurate results. It is necessary to carefully test physics models with CCD.

Switching between physics engines

You can switch between physics engines by opening NeoAxis Configurator (Configurator.exe) (by default in your Start Menu -> Programs -> NeoAxis Engine SDK -> Configurator). Open the Physics tab and select the Physics system from the listbox. Press OK to save changes. You will have to restart the Resource Editor for changes to take effect.

Selecting the physics engine.