A* Pathfinding Project  3.6.6
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
GraphNode Class Referenceabstract

Public Member Functions

 GraphNode (AstarPath astar)
 Constructor for a graph node.
 
abstract void AddConnection (GraphNode node, uint cost)
 
abstract void ClearConnections (bool alsoReverse)
 Remove all connections from this node.
 
virtual bool ContainsConnection (GraphNode node)
 Checks if this node has a connection to the specified node.
 
virtual void DeserializeNode (GraphSerializationContext ctx)
 
virtual void DeserializeReferences (GraphSerializationContext ctx)
 Used to deserialize references to other nodes e.g connections.
 
void Destroy ()
 Destroys the node.
 
virtual void FloodFill (Stack< GraphNode > stack, uint region)
 
abstract void GetConnections (GraphNodeDelegate del)
 Calls the delegate with all connections from this node.
 
virtual bool GetPortal (GraphNode other, List< Vector3 > left, List< Vector3 > right, bool backwards)
 Add a portal from this node to the specified node.
 
abstract void Open (Path path, PathNode pathNode, PathHandler handler)
 Open the node.
 
virtual void RecalculateConnectionCosts ()
 Recalculates all connection costs from this node.
 
abstract void RemoveConnection (GraphNode node)
 
virtual void SerializeNode (GraphSerializationContext ctx)
 
virtual void SerializeReferences (GraphSerializationContext ctx)
 Used to serialize references to other nodes e.g connections.
 
void UpdateG (Path path, PathNode pathNode)
 
virtual void UpdateRecursiveG (Path path, PathNode pathNode, PathHandler handler)
 

Public Attributes

const uint MaxAreaIndex = FlagsAreaMask >> FlagsAreaOffset
 
const uint MaxGraphIndex = FlagsGraphMask >> FlagsGraphOffset
 Max number of graphs-1.
 
Int3 position
 

Protected Attributes

uint flags
 

Properties

uint Area [get, set]
 
bool Destroyed [get]
 
uint Flags [get, set]
 Holds various bitpacked variables.
 
uint graphIndex [get, set]
 
uint GraphIndex [get, set]
 
int NodeIndex [get]
 
uint Penalty [get, set]
 Penalty cost for walking on this node.
 
Int3 Position [get]
 
uint Tag [get, set]
 
uint tags [get, set]
 
bool walkable [get, set]
 
bool Walkable [get, set]
 True if the node is traversable.
 

Private Attributes

const uint FlagsAreaMask = (131072-1) << FlagsAreaOffset
 Mask of region bits.
 
const int FlagsAreaOffset = 1
 Start of region bits.
 
const uint FlagsGraphMask = (256u-1) << FlagsGraphOffset
 Mask of graph index bits.
 
const int FlagsGraphOffset = 24
 Start of graph index bits.
 
const uint FlagsTagMask = (32-1) << FlagsTagOffset
 Mask of tag bits.
 
const int FlagsTagOffset = 19
 Start of tag bits.
 
const uint FlagsWalkableMask = 1 << FlagsWalkableOffset
 Mask of the walkable bit.
 
const int FlagsWalkableOffset = 0
 Position of the walkable bit.
 
int nodeIndex
 
uint penalty
 Penlty cost for walking on this node.
 

Constructor & Destructor Documentation

GraphNode ( AstarPath  astar)

Constructor for a graph node.

Member Function Documentation

abstract void AddConnection ( GraphNode  node,
uint  cost 
)
pure virtual
abstract void ClearConnections ( bool  alsoReverse)
pure virtual

Remove all connections from this node.

Parameters
alsoReverseif true, neighbours will be requested to remove connections to this node.

Implemented in LevelGridNode, MeshNode, QuadtreeNode, GridNode, and PointNode.

virtual bool ContainsConnection ( GraphNode  node)
virtual

Checks if this node has a connection to the specified node.

Reimplemented in MeshNode, and PointNode.

virtual void DeserializeNode ( GraphSerializationContext  ctx)
virtual
virtual void DeserializeReferences ( GraphSerializationContext  ctx)
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, and PointNode.

void Destroy ( )

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.

Note
Assumes the current active AstarPath instance is the same one that created this node.
Warning
Should only be called by graph classes on their own nodes
virtual void FloodFill ( Stack< GraphNode stack,
uint  region 
)
virtual

Reimplemented in LevelGridNode, MeshNode, and GridNode.

abstract void GetConnections ( GraphNodeDelegate  del)
pure virtual

Calls the delegate with all connections from this node.

Implemented in LevelGridNode, ConvexMeshNode, MeshNode, QuadtreeNode, GridNode, and PointNode.

virtual bool GetPortal ( GraphNode  other,
List< Vector3 >  left,
List< Vector3 >  right,
bool  backwards 
)
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).

Parameters
otherThe 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).
leftList of portal points on the left side of the funnel
rightList of portal points on the right side of the funnel
backwardsIf 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.
Returns
True if the call was deemed successful. False if some unknown case was encountered and no portal could be added. If both calls to node1.GetPortal (node2,...) and node2.GetPortal (node1,...) return false, the funnel modifier will fall back to adding to the path the positions of the node.

The default implementation simply returns false.

This function may add more than one portal if necessary.

See Also
http://digestingduck.blogspot.se/2010/03/simple-stupid-funnel-algorithm.html

Reimplemented in LevelGridNode, GridNode, and NodeLink3Node.

abstract void Open ( Path  path,
PathNode  pathNode,
PathHandler  handler 
)
pure virtual
virtual void RecalculateConnectionCosts ( )
virtual

Recalculates all connection costs from this node.

Depending on the node type, this may or may not be supported. Nothing will be done if the operation is not supported

Todo:
Use interface?
abstract void RemoveConnection ( GraphNode  node)
pure virtual
virtual void SerializeNode ( GraphSerializationContext  ctx)
virtual
virtual void SerializeReferences ( GraphSerializationContext  ctx)
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, and PointNode.

void UpdateG ( Path  path,
PathNode  pathNode 
)
virtual void UpdateRecursiveG ( Path  path,
PathNode  pathNode,
PathHandler  handler 
)
virtual

Member Data Documentation

uint flags
protected
const uint FlagsAreaMask = (131072-1) << FlagsAreaOffset
private

Mask of region bits.

See Also
Area
const int FlagsAreaOffset = 1
private

Start of region bits.

See Also
Area
const uint FlagsGraphMask = (256u-1) << FlagsGraphOffset
private

Mask of graph index bits.

See Also
GraphIndex
const int FlagsGraphOffset = 24
private

Start of graph index bits.

See Also
GraphIndex
const uint FlagsTagMask = (32-1) << FlagsTagOffset
private

Mask of tag bits.

See Also
Tag
const int FlagsTagOffset = 19
private

Start of tag bits.

See Also
Tag
const uint FlagsWalkableMask = 1 << FlagsWalkableOffset
private

Mask of the walkable bit.

See Also
Walkable
const int FlagsWalkableOffset = 0
private

Position of the walkable bit.

See Also
Walkable
const uint MaxAreaIndex = FlagsAreaMask >> FlagsAreaOffset
const uint MaxGraphIndex = FlagsGraphMask >> FlagsGraphOffset

Max number of graphs-1.

int nodeIndex
private
uint penalty
private

Penlty cost for walking on this node.

This can be used to make it harder/slower to walk over certain areas.

Int3 position

Property Documentation

uint Area
getset
bool Destroyed
get
uint Flags
getset

Holds various bitpacked variables.

uint graphIndex
getset
uint GraphIndex
getset
int NodeIndex
get
uint Penalty
getset

Penalty cost for walking on this node.

This can be used to make it harder/slower to walk over certain areas.

Int3 Position
get
uint Tag
getset
uint tags
getset
bool walkable
getset
bool Walkable
getset

True if the node is traversable.


The documentation for this class was generated from the following file: