PathEngine home previous: Obstacle Managementnext: Performing Collision Queries without Preprocess
Contents, Programmers Guide, Applying the SDK, Collision Queries

Collision Queries

Point and line collision

The collision queries break down into two categories, 'point' collision queries and 'line' collision queries.
As explained in The PathEngine Movement Model, point queries test whether an agent is obstructed at a given position, whereas line queries relate to movement along a line.
A number of line collision queries are provided with different functionality.

Supplying a context

Each query accepts a collision context argument.
This controls the set of obstacles to be 'included' for the query.

Calling against the mesh or agent interfaces

In general, each query can be invoked on either the Interface iMesh or the Interface iAgent interface.
The iAgent methods supply arguments corresponding to the position and shape of the agent on which the method is called, and ensure that the agent itself is excluded from collision.

The queries

Basic point collision

iMesh::testPointCollision() and iAgent::testCollisionAt() provide basic point collision functionality.
This can be used to test whether an agent can be placed at a given position.

Obtaining a set of agents overlapped

iMesh::getAllAgentsOverlapped() and iAgent::getAllAgentsOverlapped() obtain a set of agents overlapped by the query agent.
This can be useful, for example, when using dynamic obstacles to implement switches or trigger systems.

Straightforward line collision

iMesh::testLineCollision() and iAgent::testCollisionTo() both provide a straightforward line collision test, with start and end positions both specified as positions on the surface of the ground mesh.
This version of the line collision can be used, for example, to see if movement is unobstructed from one agent to another, or to a known end position.

Movement in a direction

iMesh::testLineCollision_XY() and iAgent::testCollisionTo_XY() takes a start position on the surface of the ground mesh and x and y coordinates for the line end.
This is essentially a test for collision when moving in a direction from a known start position.
The query performs a traversal over the surface of the mesh to determine the actual end position with respect to overlapping geometry.

First collision

iMesh::firstCollision() and iAgent::firstCollisionTo() also take a start position on the surface of the ground mesh and x and y coordinates for the line end.
This is also essentially a movement in direction query.
This version does some extra work where necessary in order to obtain information about the point of collision.
This can be used then, to implement basic contact physics such as sliding against walls, or pushing obstacles.

Application

The collision queries are very fast, so these can be used (in addition to managing agent movement) for generate and test style algorithms.
The path post processing is an example of this. In this case, curved paths are generated from a base path, and then tested for collision.
Speculative generate and test approaches can also be applied very effectively for highly interactive behaviours, such as dodging bullets and so on.


Documentation for PathEngine release 5.16 - Copyright © 2002-2008 PathEnginenext: Performing Collision Queries without Preprocess