PathEngine home previous: Converting to and from PathEngine's Position Representationnext: Collision Queries
Contents, Programmers Guide, Applying the SDK, Obstacle Management

Obstacle Management

PathEngine's dynamic obstacle mechanisms provide a powerful tool for managing the state of collision in a world, or for representing agent knowledge or beliefs about this state of collision.

See this page for an introduction to PathEngine obstacles.
See this page for information about placing obstacles through the API.

Applying dynamic obstacles to queries

Obstacles that haven't been burnt into a mesh (see Obstacle Placement) need to be either added to a 'collision context' or 'obstacle set' in order to affect pathfinding or collision queries.

Collision contexts

Each collision or pathfinding query in the API takes a collision context argument specifying the state of collision to be applied for that query.
For convenience, a null pointer may be passed into this argument to specify that only static collision should be applied.

A state of collision essentially means a set of dynamic obstacles, so collision contexts started out essentially as a way of representing the set of obstacles to be included for a query.
Obstacles can be included in a collision context directly, or indirectly by being included in an obstacle set that is then included in the collision context.
(In situations where obstacles are naturally organised into groups that need to be added or removed from contexts obstacle sets can greatly simplify obstacle management. In simpler situations adding obstacles directly to collision contexts avoids the need to work with an additional interface object.)

In addition to representing simply a 'state of collision', collision contexts have evolved to also manage information about movement costs for certain types of regions with cost to traverse (see Representing Regions with Cost to Traverse), as well as enabling bounds to be applied to pathfinding queries (see Limiting the Scope for Pathfinding).

Refer to Interface iCollisionContext for detailed API reference for the iCollisionContext interface class.

Free standing obstacle sets

Release 5 of the SDK adds the possibility to organise obstacles into sets which can then be compounded together differently in different collision contexts.

In addition to enabling groups of obstacles to be represented more naturally, collision preprocess is cached with each obstacle set, which can be an important optimisation for certain situations where collision is being performed against large number of dynamic obstacles.

Refer to Interface iObstacleSet for detailed API reference for the iObstacleSet interface class.

Working with multiple or changing sets of static obstacles

Obstacle sets now enable you to effectively work with multiple sets of 'burnt-in' obstacles, and to modify these sets of obstacles semi-dynamically.
This is implemented in terms of special obstacle sets that are marked for extended preprocessing.

To mark an obstacle set for extended preprocessing the obstacle set should be created with iMesh::newObstacleSet_WithAttributes() (instead of iMesh::newObstacleSet()), with 'markForPreprocessing' supplied, and set to 'true'.

The following code snippet shows how this can be done:

char* attributes[3];
attributes[0] = "markForPreprocessing";
attributes[1] = "true";
attributes[2] = 0;
obstacleSet = mesh->newObstacleSet_WithAttributes(attributes);

The attributes supplied on the creation of a preprocessed obstacle set are also cached and passed in to the actual preprocess generation.
(So if you want to apply the small convex optimisation to this preprocess then the relevant attribute should be supplied on obstacle set creation.)

Only one such obstacle set may be added to any one collision context.
Internally, PathEngine will generate the same kind of preprocess for the obstacle set as is normally generated for the set of obstacles burnt in to a mesh.
When queries are made against a collision context that includes an obstacle set marked in this way, preprocess from the obstacle set is used instead of mesh preprocess.

This feature is very useful in the case where different sets of static obstacles should be applied to different types of agents.
It is also possible to modify the set of obstacles in 'preprocessed obstacle sets' but note that this can incur a (potentially very big) delay when the obstacle preprocess is subsequently updated.
iObstacleSet::updatePathfindingPreprocessFor() can be used to force the update of this preprocess after changes.

Double buffered obstacle sets

The semi dynamic obstacles example project demonstrates a technique for double buffering a pair of preprocessed obstacle sets for fast pathfinding and collision around large numbers of run-time determined obstacles.


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