Implements the funnel algorithm as well as various related methods.
More...
Implements the funnel algorithm as well as various related methods.
- See also
- http://digestingduck.blogspot.se/2010/03/simple-stupid-funnel-algorithm.html
-
FunnelModifier for the component that you can attach to objects to use the funnel algorithm.
|
static Vector3 | FromXZ (Vector2 p) |
|
static bool | LeftOrColinear (Vector2 a, Vector2 b) |
| True if b is to the left of or on the line from (0,0) to a. More...
|
|
static bool | RightOrColinear (Vector2 a, Vector2 b) |
| True if b is to the right of or on the line from (0,0) to a. More...
|
|
static Vector2 | ToXZ (Vector3 p) |
|
|
static void | Calculate (Vector2[] left, Vector2[] right, int numPortals, int startIndex, List< int > funnelPath, int maxCorners, out bool lastCorner) |
| Funnel algorithm. More...
|
|
static int | FixFunnel (Vector2[] left, Vector2[] right, int numPortals) |
| Try to fix degenerate or invalid funnels. More...
|
|
static bool | UnwrapHelper (Vector3 portalStart, Vector3 portalEnd, Vector3 prevPoint, Vector3 nextPoint, ref Quaternion mRot, ref Vector3 mOffset) |
|
◆ Calculate() [1/2]
static List<Vector3> Calculate |
( |
FunnelPortals |
funnel, |
|
|
bool |
unwrap, |
|
|
bool |
splitAtEveryPortal |
|
) |
| |
|
static |
Calculate the shortest path through the funnel.
- Parameters
-
funnel | The portals of the funnel. The first and last vertices portals must be single points (so for example left[0] == right[0]). |
unwrap | Determines if twists and bends should be straightened out before running the funnel algorithm. |
splitAtEveryPortal | If true, then a vertex will be inserted every time the path crosses a portal instead of only at the corners of the path. The result will have exactly one vertex per portal if this is enabled. This may introduce vertices with the same position in the output (esp. in corners where many portals meet). |
If the unwrap option is disabled the funnel will simply be projected onto the XZ plane. If the unwrap option is enabled then the funnel may be oriented arbitrarily and may have twists and bends. This makes it possible to support the funnel algorithm in XY space as well as in more complicated cases, such as on curved worlds.
- See also
- Unwrap
◆ Calculate() [2/2]
static void Calculate |
( |
Vector2 [] |
left, |
|
|
Vector2 [] |
right, |
|
|
int |
numPortals, |
|
|
int |
startIndex, |
|
|
List< int > |
funnelPath, |
|
|
int |
maxCorners, |
|
|
out bool |
lastCorner |
|
) |
| |
|
staticprivate |
Funnel algorithm.
funnelPath will be filled with the result. The result is the indices of the vertices that were picked, a non-negative value refers to the corresponding index in the left array, a negative value refers to the corresponding index in the right array. So e.g 5 corresponds to left[5] and -2 corresponds to right[2]
- See also
- http://digestingduck.blogspot.se/2010/03/simple-stupid-funnel-algorithm.html
◆ ConstructFunnelPortals()
◆ FixFunnel()
static int FixFunnel |
( |
Vector2 [] |
left, |
|
|
Vector2 [] |
right, |
|
|
int |
numPortals |
|
) |
| |
|
staticprivate |
Try to fix degenerate or invalid funnels.
- Returns
- The number of vertices at the start of both arrays that should be ignored or -1 if the algorithm failed.
◆ FromXZ()
static Vector3 FromXZ |
( |
Vector2 |
p | ) |
|
|
staticprotected |
◆ LeftOrColinear()
static bool LeftOrColinear |
( |
Vector2 |
a, |
|
|
Vector2 |
b |
|
) |
| |
|
staticprotected |
True if b is to the left of or on the line from (0,0) to a.
◆ RightOrColinear()
static bool RightOrColinear |
( |
Vector2 |
a, |
|
|
Vector2 |
b |
|
) |
| |
|
staticprotected |
True if b is to the right of or on the line from (0,0) to a.
◆ ShrinkPortals()
static void ShrinkPortals |
( |
FunnelPortals |
portals, |
|
|
float |
shrink |
|
) |
| |
|
static |
◆ SplitIntoParts()
◆ ToXZ()
static Vector2 ToXZ |
( |
Vector3 |
p | ) |
|
|
staticprotected |
◆ Unwrap()
static void Unwrap |
( |
FunnelPortals |
funnel, |
|
|
Vector2 [] |
left, |
|
|
Vector2 [] |
right |
|
) |
| |
|
static |
Unwraps the funnel portals from 3D space to 2D space.
The result is stored in the left and right arrays which must be at least as large as the funnel.left and funnel.right lists.
The input is a funnel like in the image below. It may be rotated and twisted.
The output will be a funnel in 2D space like in the image below. All twists and bends will have been straightened out.
- See also
- Calculate(FunnelPortals,bool,bool)
◆ UnwrapHelper()
static bool UnwrapHelper |
( |
Vector3 |
portalStart, |
|
|
Vector3 |
portalEnd, |
|
|
Vector3 |
prevPoint, |
|
|
Vector3 |
nextPoint, |
|
|
ref Quaternion |
mRot, |
|
|
ref Vector3 |
mOffset |
|
) |
| |
|
staticprivate |
The documentation for this class was generated from the following file:
- /Users/arong/Unity/a-pathfinding-project/Assets/AstarPathfindingProject/Utilities/Funnel.cs