This page has been translated automatically.
编程
Fundamentals
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
应用程序接口
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

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: ()