This page has been translated automatically.
Programming
Fundamentials
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Bounds-Related Classes
Containers
Controls-Related Classes
Core Library
Engine-Related Classes
GUI-Related Classes
Node-Related Classes
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Utility Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Collision Detection

Collision Detection

What we've described earlier refers to the body movement without constraints and obstacles, but this rarely happens in real life, and therefore, in virtual life, too. To correctly describe the situation when the body meets an obstacle, collision detection is used.

All collision detection algorithms, regardless of their implementation, usually start with creating simple shapes that approximate the colliding objects. Such approximations are called colliders, their vertices are used during collision detection calculation, not the vertices of the original objects. There are many types of colliders, which can be combined, for example, boxes, spheres, cylinders, capped cylinders, convex hulls, and meshes (often simplified).

Collider vertices are tested, if they are in contact with some plane or even behind it. There are two types of contact: static, when the body rests on another body, and dynamic, when two bodies collide. In the first case, one calculates force that prevents the upper body from moving downwards. In the second case, one needs to calculate instantaneous change in velocity for both colliding objects.

Collision detection for static objects

There are two main approaches to collision detection calculation, which, in essence, do the same work, and both are iterative in their nature:

  1. Iterative LCP constraint solving (all contact points are solved simultaneously).
    Notice
    Though often this problem is solved iteratively, it is not always so. Non-iterative methods also exist, and they are frequently more accurate, but slower.
  2. Sequential impulse-based calculations (one contact point is solved after another, updating the current velocity of the bodies).
As both methods are iterative, the accuracy is highly dependent on the number of iterations.

Another, completely different, approach is continuous collision detection, when the body that is moving is extruded along its way (between two frames), and if something gets into this volume, a collision is detected, and the body is taken back in time to correctly react to the collision.

No matter what approach is used to detect collisions, factors like friction and restitution, etc. are taken into account. Also, physics engines often "freeze" the body, if it does not move or move a little during some period of time. In this case all physics calculations are disabled for the body, except collision detection. The body remains "frozen" until a collision occurs.

Last update: 2017-07-03
Build: ()