A* Pathfinding Project
3.7.3
The A* Pathfinding Project for Unity 3D
|
Represents a collection of settings used to update nodes in a specific region of a graph. More...
Represents a collection of settings used to update nodes in a specific region of a graph.
Public Member Functions | |
GraphUpdateObject () | |
GraphUpdateObject (Bounds b) | |
Creates a new GUO with the specified bounds. | |
virtual void | Apply (GraphNode node) |
Updates the specified node using this GUO's settings. | |
virtual void | RevertFromBackup () |
Reverts penalties and flags (which includes walkability) on every node which was updated using this GUO. | |
virtual void | WillUpdateNode (GraphNode node) |
Should be called on every node which is updated with this GUO before it is updated. | |
Public Attributes | |
int | addPenalty |
Penalty to add to the nodes. | |
Bounds | bounds |
The bounds to update nodes within. | |
List< GraphNode > | changedNodes |
Nodes which were updated by this GraphUpdateObject. | |
bool | modifyTag |
If true, all nodes' tag will be set to setTag. | |
bool | modifyWalkability |
If true, all nodes' walkable variable will be set to setWalkability. | |
NNConstraint | nnConstraint = NNConstraint.None |
NNConstraint to use. | |
bool | requiresFloodFill = true |
Controlls if a flood fill will be carried out after this GUO has been applied. | |
bool | resetPenaltyOnPhysics = true |
When updatePhysics is true, GridGraphs will normally reset penalties, with this option you can override it. | |
int | setTag |
If modifyTag is true, all nodes' tag will be set to this value. | |
bool | setWalkability |
If modifyWalkability is true, the nodes' walkable variable will be set to this value. | |
GraphUpdateShape | shape |
A shape can be specified if a bounds object does not give enough precision. | |
bool | trackChangedNodes |
Track which nodes are changed and save backup data. | |
bool | updateErosion = true |
Update Erosion for GridGraphs. | |
bool | updatePhysics = true |
Use physics checks to update nodes. | |
Private Attributes | |
List< uint > | backupData |
List< Int3 > | backupPositionData |
GraphUpdateObject | ( | Bounds | b | ) |
Creates a new GUO with the specified bounds.
|
virtual |
Updates the specified node using this GUO's settings.
|
virtual |
Reverts penalties and flags (which includes walkability) on every node which was updated using this GUO.
Data for reversion is only saved if trackChangedNodes is true
|
virtual |
Should be called on every node which is updated with this GUO before it is updated.
node | The node to save fields for. If null, nothing will be done |
int addPenalty |
Penalty to add to the nodes.
A penalty of 1000 is equivalent to the cost of moving 1 world unit.
|
private |
|
private |
Bounds bounds |
The bounds to update nodes within.
Defined in world space.
List<GraphNode> changedNodes |
Nodes which were updated by this GraphUpdateObject.
Will only be filled if trackChangedNodes is true.
bool modifyTag |
If true, all nodes' tag will be set to setTag.
bool modifyWalkability |
If true, all nodes' walkable variable will be set to setWalkability.
NNConstraint nnConstraint = NNConstraint.None |
NNConstraint to use.
The Pathfinding.NNConstraint.SuitableGraph function will be called on the NNConstraint to enable filtering of which graphs to update.
bool requiresFloodFill = true |
Controlls if a flood fill will be carried out after this GUO has been applied.
Disabling this can be used to gain a performance boost, but use with care. If you are sure that a GUO will not modify walkability or connections. You can set this to false. For example when only updating penalty values it can save processing power when setting this to false. Especially on large graphs.
If using the basic GraphUpdateObject (not a derived class), a quick way to check if it is going to need a flood fill is to check if modifyWalkability is true or updatePhysics is true.
bool resetPenaltyOnPhysics = true |
When updatePhysics is true, GridGraphs will normally reset penalties, with this option you can override it.
Good to use when you want to keep old penalties even when you update the graph.
The images below shows two overlapping graph update objects, the right one happened to be applied before the left one. They both have updatePhysics = true and are set to increase the penalty of the nodes by some amount.
The first image shows the result when resetPenaltyOnPhysics is false. Both penalties are added correctly.
This second image shows when resetPenaltyOnPhysics is set to true. The first GUO is applied correctly, but then the second one (the left one) is applied and during its updating, it resets the penalties first and then adds penalty to the nodes. The result is that the penalties from both GUOs are not added together. The green patch in at the border is there because physics recalculation (recalculation of the position of the node, checking for obstacles etc.) affects a slightly larger area than the original GUO bounds because of the Grid Graph -> Collision Testing -> Diameter setting (it is enlarged by that value). So some extra nodes have their penalties reset.
int setTag |
If modifyTag is true, all nodes' tag will be set to this value.
bool setWalkability |
If modifyWalkability is true, the nodes' walkable variable will be set to this value.
GraphUpdateShape shape |
A shape can be specified if a bounds object does not give enough precision.
bool trackChangedNodes |
Track which nodes are changed and save backup data.
Used internally to revert changes if needed.
bool updateErosion = true |
Update Erosion for GridGraphs.
When enabled, erosion will be recalculated for grid graphs after the GUO has been applied.
In the below image you can see the different effects you can get with the different values.
The first image shows the graph when no GUO has been applied. The blue box is not identified as an obstacle by the graph, the reason there are unwalkable nodes around it is because there is a height difference (nodes are placed on top of the box) so erosion will be applied (an erosion value of 2 is used in this graph). The orange box is identified as an obstacle, so the area of unwalkable nodes around it is a bit larger since both erosion and collision has made nodes unwalkable.
The GUO used simply sets walkability to true, i.e making all nodes walkable.
When updateErosion=True, the reason the blue box still has unwalkable nodes around it is because there is still a height difference so erosion will still be applied. The orange box on the other hand has no height difference and all nodes are set to walkable.
When updateErosion=False, all nodes walkability are simply set to be walkable in this example.
bool updatePhysics = true |
Use physics checks to update nodes.
When updating a grid graph and this is true, the nodes' position and walkability will be updated using physics checks with settings from "Collision Testing" and "Height Testing".
When updating a PointGraph, setting this to true will make it re-evaluate all connections in the graph which passes through the bounds. This has no effect when updating GridGraphs if modifyWalkability is turned on.
On RecastGraphs, having this enabled will trigger a complete recalculation of all tiles intersecting the bounds. This is quite slow (but powerful). If you only want to update e.g penalty on existing nodes, leave it disabled.