A* Pathfinding Project
4.1.23
The A* Pathfinding Project for Unity 3D
|
Base class for all nodes. More...
Base class for all nodes.
Public Member Functions | |
abstract void | AddConnection (GraphNode node, uint cost) |
abstract void | ClearConnections (bool alsoReverse) |
Remove all connections from this node. More... | |
virtual bool | ContainsConnection (GraphNode node) |
Checks if this node has a connection to the specified node. More... | |
virtual void | DeserializeNode (GraphSerializationContext ctx) |
Deserializes the node data from a byte array. More... | |
virtual void | DeserializeReferences (GraphSerializationContext ctx) |
Used to deserialize references to other nodes e.g connections. More... | |
abstract void | GetConnections (System.Action< GraphNode > action) |
Calls the delegate with all connections from this node. More... | |
virtual int | GetGizmoHashCode () |
Hash code used for checking if the gizmos need to be updated. More... | |
virtual bool | GetPortal (GraphNode other, List< Vector3 > left, List< Vector3 > right, bool backwards) |
Add a portal from this node to the specified node. More... | |
abstract void | Open (Path path, PathNode pathNode, PathHandler handler) |
Open the node. More... | |
virtual Vector3 | RandomPointOnSurface () |
A random point on the surface of the node. More... | |
abstract void | RemoveConnection (GraphNode node) |
virtual void | SerializeNode (GraphSerializationContext ctx) |
Serialized the node data to a byte array. More... | |
virtual void | SerializeReferences (GraphSerializationContext ctx) |
Used to serialize references to other nodes e.g connections. More... | |
void | SetConnectivityDirty () |
Inform the system that the node's connectivity has changed. More... | |
virtual float | SurfaceArea () |
The surface area of the node in square world units. More... | |
virtual void | UpdateRecursiveG (Path path, PathNode pathNode, PathHandler handler) |
Public Attributes | |
const uint | MaxGraphIndex = FlagsGraphMask >> FlagsGraphOffset |
Max number of graphs-1. More... | |
const uint | MaxHierarchicalNodeIndex = HierarchicalIndexMask >> FlagsHierarchicalIndexOffset |
Int3 | position |
Position of the node in world space. More... | |
Protected Member Functions | |
GraphNode (AstarPath astar) | |
Constructor for a graph node. More... | |
Protected Attributes | |
uint | flags |
Bitpacked field holding several pieces of data. More... | |
Package Functions | |
void | Destroy () |
Destroys the node. More... | |
Properties | |
uint | Area [get] |
Connected component that contains the node. More... | |
bool | Destroyed [get] |
uint | Flags [get, set] |
Holds various bitpacked variables. More... | |
NavGraph | Graph [get] |
Graph which this node belongs to. More... | |
uint | GraphIndex [get, set] |
Graph which contains this node. More... | |
int | HierarchicalNodeIndex [get, set] |
Hierarchical Node that contains this node. More... | |
bool | IsHierarchicalNodeDirty [get, set] |
Some internal bookkeeping. More... | |
int | NodeIndex [get, private set] |
Internal unique index. More... | |
uint | Penalty [get, set] |
Penalty cost for walking on this node. More... | |
uint | Tag [get, set] |
Node tag. More... | |
bool | TemporaryFlag1 [get, set] |
Temporary flag for internal purposes. More... | |
bool | TemporaryFlag2 [get, set] |
Temporary flag for internal purposes. More... | |
bool | Walkable [get, set] |
True if the node is traversable. More... | |
Private Attributes | |
const int | DestroyedNodeIndex = NodeIndexMask - 1 |
const uint | FlagsGraphMask = (256u-1) << FlagsGraphOffset |
Mask of graph index bits. More... | |
const int | FlagsGraphOffset = 24 |
Start of graph index bits. More... | |
const int | FlagsHierarchicalIndexOffset = 1 |
Start of hierarchical node index bits. More... | |
const uint | FlagsTagMask = (32-1) << FlagsTagOffset |
Mask of tag bits. More... | |
const int | FlagsTagOffset = 19 |
Start of tag bits. More... | |
const uint | FlagsWalkableMask = 1 << FlagsWalkableOffset |
Mask of the walkable bit. More... | |
const int | FlagsWalkableOffset = 0 |
Position of the walkable bit. More... | |
const uint | HierarchicalDirtyMask = 1 << HierarchicalDirtyOffset |
Mask of the IsHierarchicalNodeDirty bit. More... | |
const int | HierarchicalDirtyOffset = 18 |
Start of IsHierarchicalNodeDirty bits. More... | |
const uint | HierarchicalIndexMask = (131072-1) << FlagsHierarchicalIndexOffset |
Mask of hierarchical node index bits. More... | |
int | nodeIndex |
Internal unique index. More... | |
const int | NodeIndexMask = 0xFFFFFFF |
uint | penalty |
Penalty cost for walking on this node. More... | |
const int | TemporaryFlag1Mask = 0x10000000 |
const int | TemporaryFlag2Mask = 0x20000000 |
|
pure virtual |
Implemented in MeshNode, GridNodeBase, and PointNode.
|
pure virtual |
Remove all connections from this node.
alsoReverse | if true, neighbours will be requested to remove connections to this node. |
Implemented in LevelGridNode, MeshNode, GridNodeBase, GridNode, and PointNode.
|
virtual |
Checks if this node has a connection to the specified node.
Reimplemented in MeshNode, GridNodeBase, and PointNode.
|
virtual |
Deserializes the node data from a byte array.
Reimplemented in LevelGridNode, GridNode, TriangleMeshNode, and PointNode.
|
virtual |
Used to deserialize references to other nodes e.g connections.
Use the GraphSerializationContext.GetNodeIdentifier and GraphSerializationContext.GetNodeFromIdentifier methods for serialization and deserialization respectively.
Nodes must override this method and serialize their connections. Graph generators do not need to call this method, it will be called automatically on all nodes at the correct time by the serializer.
Reimplemented in MeshNode, GridNodeBase, and PointNode.
|
package |
Destroys the node.
Cleans up any temporary pathfinding data used for this node. The graph is responsible for calling this method on nodes when they are destroyed, including when the whole graph is destoyed. Otherwise memory leaks might present themselves.
Once called the Destroyed property will return true and subsequent calls to this method will not do anything.
|
pure virtual |
Calls the delegate with all connections from this node.
You can add all connected nodes to a list like this
Implemented in LevelGridNode, MeshNode, GridNodeBase, GridNode, and PointNode.
|
virtual |
Hash code used for checking if the gizmos need to be updated.
Will change when the gizmos for the node might change.
Reimplemented in LevelGridNode, MeshNode, PointNode, and GridNodeBase.
|
virtual |
Add a portal from this node to the specified node.
This function should add a portal to the left and right lists which is connecting the two nodes (this and other).
other | The node which is on the other side of the portal (strictly speaking it does not actually have to be on the other side of the portal though). |
left | List of portal points on the left side of the funnel |
right | List of portal points on the right side of the funnel |
backwards | If this is true, the call was made on a node with the other node as the node before this one in the path. In this case you may choose to do nothing since a similar call will be made to the other node with this node referenced as other (but then with backwards = true). You do not have to care about switching the left and right lists, that is done for you already. |
The default implementation simply returns false.
This function may add more than one portal if necessary.
Reimplemented in LevelGridNode, GridNode, and NodeLink3Node.
|
pure virtual |
Open the node.
Used internally for the A* algorithm.
Implemented in LevelGridNode, GridNode, TriangleMeshNode, GridNodeBase, and PointNode.
|
virtual |
A random point on the surface of the node.
For point nodes and other nodes which do not have a surface, this will always return the position of the node.
Reimplemented in TriangleMeshNode, and GridNodeBase.
|
pure virtual |
Implemented in MeshNode, GridNodeBase, and PointNode.
|
virtual |
Serialized the node data to a byte array.
Reimplemented in LevelGridNode, GridNode, TriangleMeshNode, and PointNode.
|
virtual |
Used to serialize references to other nodes e.g connections.
Use the GraphSerializationContext.GetNodeIdentifier and GraphSerializationContext.GetNodeFromIdentifier methods for serialization and deserialization respectively.
Nodes must override this method and serialize their connections. Graph generators do not need to call this method, it will be called automatically on all nodes at the correct time by the serializer.
Reimplemented in MeshNode, GridNodeBase, and PointNode.
void SetConnectivityDirty | ( | ) |
Inform the system that the node's connectivity has changed.
This is used for recalculating the connected components of the graph.
You must call this method if you change the connectivity or walkability of the node without going through the high level methods such as the Walkable property or the AddConnection method. For example if your manually change the Pathfinding.MeshNode.connections array you need to call this method.
|
virtual |
The surface area of the node in square world units.
Reimplemented in TriangleMeshNode, and GridNodeBase.
|
virtual |
Reimplemented in LevelGridNode, MeshNode, GridNode, TriangleMeshNode, GridNodeBase, and PointNode.
|
private |
|
protected |
Bitpacked field holding several pieces of data.
|
private |
Mask of graph index bits.
|
private |
Start of graph index bits.
|
private |
Start of hierarchical node index bits.
|
private |
Mask of tag bits.
|
private |
Start of tag bits.
|
private |
Mask of the walkable bit.
|
private |
Position of the walkable bit.
|
private |
Mask of the IsHierarchicalNodeDirty bit.
|
private |
Start of IsHierarchicalNodeDirty bits.
|
private |
Mask of hierarchical node index bits.
const uint MaxGraphIndex = FlagsGraphMask >> FlagsGraphOffset |
Max number of graphs-1.
const uint MaxHierarchicalNodeIndex = HierarchicalIndexMask >> FlagsHierarchicalIndexOffset |
|
private |
Internal unique index.
Also stores some bitpacked values such as TemporaryFlag1 and TemporaryFlag2.
|
private |
|
private |
Penalty cost for walking on this node.
This can be used to make it harder/slower to walk over certain nodes.
A penalty of 1000 (Int3.Precision) corresponds to the cost of walking one world unit.
Int3 position |
|
private |
|
private |
|
get |
Connected component that contains the node.
This is visualized in the scene view as differently colored nodes (if the graph coloring mode is set to 'Areas'). Each area represents a set of nodes such that there is no valid path between nodes of different colors.
|
get |
|
getset |
Holds various bitpacked variables.
Bit 0: Walkable Bits 1 through 17: HierarchicalNodeIndex Bit 18: IsHierarchicalNodeDirty Bits 19 through 23: Tag Bits 24 through 31: GraphIndex
|
get |
Graph which this node belongs to.
If you know the node belongs to a particular graph type, you can cast it to that type:
Will return null if the node has been destroyed.
|
getset |
Graph which contains this node.
|
getsetpackage |
Hierarchical Node that contains this node.
The graph is divided into clusters of small hierarchical nodes in which there is a path from every node to every other node. This structure is used to speed up connected component calculations which is used to quickly determine if a node is reachable from another node.
|
getsetpackage |
Some internal bookkeeping.
|
getprivate set |
Internal unique index.
Every node will get a unique index. This index is not necessarily correlated with e.g the position of the node in the graph.
|
getset |
Penalty cost for walking on this node.
This can be used to make it harder/slower to walk over certain nodes. A cost of 1000 (Int3.Precision) corresponds to the cost of moving 1 world unit.
|
getset |
Node tag.
|
getsetpackage |
Temporary flag for internal purposes.
May only be used in the Unity thread. Must be reset to false after every use.
|
getsetpackage |
Temporary flag for internal purposes.
May only be used in the Unity thread. Must be reset to false after every use.
|
getset |
True if the node is traversable.