PathEngine home previous: Working with Terrainnext: Mesh Federations
Contents, Programmers Guide, World Representation, Pathfinding Through Forests

Pathfinding Through Forests

Forests can cause problems for a straightforward points-of-visibility pathfinding system. The problem is that forests generally have a very large number of points of visibility, with relatively open visibility between those points. It can become costly to represent the visibility graph for connections between these points.
This applies to any 'forest-like' environments, where a large number of small obstructions are scattered around in an external space.

To a human, the problem of finding a shortest path through a forest is a straightforward one. (Assuming that there is no dense undergrowth!)
The point is that obstacles like trees are not relevant over large distances.
If a tree blocks the path to a target then you just walk around it.

PathEngine provides a similar solution to this problem. Small convex obstacles can be automatically identified and split off from the rest of the geometry.
Pathfinding is first performed against the base geometry. The resulting path is then modified to go around any small convex obstacles that are crossed

Small convex obstacles are detected after obstacles are expanded and combined. This way, groups of trees that clump together into larger obstructions are correctly included with the base geometry.
The small convex boundaries are stored in a separate partitioning of the ground mesh.


A ground mesh with lots of trees and rocks. Yellow lines show obstruction boundaries that got split off with the small convex optimisation.

To enable this optimisation you need to pass an attribute into iMesh::generatePathfindPreprocessFor().
The attribute both enables the optimisation and specifies a maximum circumference for the small convex obstacles.
The following code snippet shows how this could be done:

const char* attributes[3];
attributes[0] = "splitWithCircumferenceBelow";
attributes[1] = "2000";
attributes[2] = 0;
mesh->generatePathfindPreprocessFor(shape, attributes); 

When using this optimisation you should be aware that the resulting paths are not guaranteed to be geometrically shortest paths.
(But in practice this is generally not an issue.)


Documentation for PathEngine release 5.23 - Copyright © 2002-2010 PathEnginenext: Mesh Federations