2 . 1. Collision Detection. Overview. Note: The material in this section is based on the course text. Introduction to Collision Detection. Collision detection is used within many types of application, e.g. from robotics, through engineering simulations, to computer games.
Introduction to Collision Detection
Collision detection is used within many types of application, e.g. from robotics, through engineering simulations, to computer games.
In computer games, collision detection provides:
the illusion of a solid world (e.g. preventing the player from falling through the floor, rag-dolls from visually intersecting their surroundings)
line-of-sight queries (e.g. for driving AI opponent visibility/aiming tests, etc.).
The following considers a number of key design issues to consider when building a collision detection system.
Core issues for consideration when building a collision detection system
Game object representations include:
e.g. polygon (triangle) mesh consisting of a number of defined vertices, connected by edges and forming faces.
Most game objects are represented (and rendered) using a triangle mesh.
e.g. Spheres, ellipsoids, cylinders, whose surface is defined mathematically .
Aside:Some objects can be precisely defined both explicitly and implicitly, e.g. cuboids.
Typically an explicit mesh used for rendering will be too complex (hence computationally expensive) to be used for collision detection. An implicit object description or simple explicit representation can be employed as an object approximation.
This is effective as 1) we are very tolerant of minor inaccuracies between collision detection (particularly if the objects are moving quickly or there are many on-screen collisions) , 2) in games there is rarely a need for very high precision.
The downside of using separate collision geometry is data duplication (more information needs to be stored) and the extra work required to build and maintain the collision geometry.
Common types of collision query include (in all cases assumed between two objects based on their current positions/orientations)
Determining (i.e. true/false response) if two objects are intersecting (broadly easy/fast to accomplish)
Determining the point(s) of contact between two objects. The point(s) of contact might be expressed in terms of a penetration depth, surface normal, etc.
Aside: Often a rigid-body physics simulation will need to consider the set of all contacting points between two bodies (i.e. the contact manifold). Computing the contact manifold is typically a complex problem.
The number of potentially intersecting objects and their spatial organisation will likely have a bearing upon how a collision detection system is introduced.
For large numbers of items an exhaustive set of pairwise tests becomes impractical (n(n-1)/2 individual tests). The number of tested pairs needs to be reduced.
This is typically done by separating collision detection into two phases:
Broad phase – identifying (small) subgroups of objects that may be colliding
Narrow phase – Pairwise collision tests between objects contained within subgroups
All objects are stepped (i.e. position/rotation updated) by a small time step (e.g. 1/50s).
A set of all intersecting objects is determined and processed (e.g. the set of intersecting objects can respond in a physically plausible manner)
Each object is moved and immediately tested for collision (alongside collision resolution). Then the next object is given an opportunity to move.
Sequential movement is the more physically inaccurate approach (e.g. resulting in collisions that should not have occurred).
This involves checking for intersection between objects at discrete time instances. At each point, the objects are considered to be stationary.
This involves considering the continuous motion of the object over the specified period of time (i.e. its swept volume).
Continuous motion intersection is often a lot more expensive than discrete motion, but can determine the exact point of initial contact and is not subject to tunnelling.
Aside: Tunnelling can be a problem with discrete motion if, within the time step between intersections, an object moves more than its spatial extent (i.e. it may simply through another object without detection).
Intersection detection is typically an expensive test. Means of improving performance include:
Selecting a board-phase approach that exploits object spatial distribution.
Performing simple bounding volume tests first, before considering more complex/accurate geometric intersection tests.
Exploiting temporal coherency, i.e. in general the position/orientation of objects change slowly from one frame to the next (often permitting results to be cached and reused).
Of course there are a range of lower-level, implementation and platform specific optimisations that can be considered if needed.
Read Chapter 2 (pp7-21) of Real Time Collision Detection
Today we explored: