| |
|
|
||||
![]() |
||||||
| |
|
|||||
|
GDC 2002: Polygon Soup for the Programmer's Soul: 3D Pathfinding Vehicles A complete vehicle pathfinding solution is outside the scope of this paper, however we will present a brief overview that may work for some games. Firstly,
modify the flood fill algorithm to use the bounding volume of the largest
vehicle regardless of its orientation. During the run-time path solve,
take the turn radius of the vehicle into consideration when evaluating
portals. In other words, we know which portal the vehicle is coming from,
so discard any destination portals that would cause the vehicle to turn
sharper then it is able.
Once the path is generated, it may be problematic for a vehicle to follow. This is because orientation is important when dealing with vehicles; however our sector/portal system doesn't implicitly handle this very well. Consider the following diagram.
In the sector/portal system, the vehicle will beeline from the Sector A's entrance to Sector B. This orients the vehicle in such a way that it will be impossible for the vehicle to make the following turn into the portal for Sector C. However, if the vehicle would "arc" out into Sector A, it would be possible to make both Sector B and Sector C. Unfortunately there is no way of knowing this is required unless we search ahead on the path. A simple solution to this problem, which works well with the system we've described so far, is to spline the path. However, none of the classical "true" splines will work for this situation; which is fine -- we'll create our own custom curve. Our goal: create a continuous curved line that will cause the vehicle to arc around corners while still obeying the vehicle's turn radius restrictions. Such a path can be created using only a straight line and the vehicle's turning circle. Unlike "true" splines, this path is not continuous in the mathematical sense, but composed of three distinct continuous parts, which, when placed end-to-end, form a continuous path. The three parts are: the exit curve from the previous point, a straight line from the exit curve to the enter curve of the next point, and the enter curve of the next point. Note: The starting and ending points only contain two parts (there is no previous part for the starting point, nor is there a next point for the ending point). Consider the following diagram:
To build this curve, overlay the vehicle's turning circle onto each node of the path. We will assume the optimal center of this turn arc will lie at the point halfway between the angles formed by the (prev_node - curr_node) and (next_node - curr_node) vectors. This causes the actual node point to lie on the perimeter of the turning arc. For each turning circle on the path, find the "in" and "out" tangent points. The "in" tangent point is the closest point of tangency from the previous point to the turn arc. The "out" tangent point is the closet point of tangency from the next point to the turn arc. Now, simply connect the dots. The path is as follows: straight-line from starting point to the "in" tangent point on the turn arc of the next path node; follow the turn arc to "out" tangent point; straight line from this point to the "in" tangent point of the turn arc of the next path node, etc, etc. Once finished, this algorithm yields a continuous curve that follows the turning restrictions of the vehicle following the path.
Keep in mind that this curve may cause the vehicle to drive outside the "safe" areas of the path, thus potentially colliding with objects along the way. Conclusion Special
thanks to Eric Cosky for the original concept of the flood fill algorithm,
a brilliant idea that proves the worth of brainstorming with a friend
before jumping into a complex problem. Also, thanks to Colin Mclaughlan
for suggesting the concept of dynamic temporary "jump" portals.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|