Class LineGraphDrawer
Makes it extremely easy to 'draw' a road graph. Just add lines/edges and close enough vertices will automatically be joined together.
Namespace: AnyPath.Graphs.Line
Assembly: AnyPath.dll
Syntax
public class LineGraphDrawer
Examples
void Example()
{
// create a drawer which merges vertices that are closer than .1f
var drawer = new LineGraphDrawer(.1f);
// draw a square
drawer.AddUndirected(new float3(0, 0, 0), new float3(1, 0, 0));
drawer.AddUndirected(new float3(1, 0, 0), new float3(1, 1, 0));
drawer.AddUndirected(new float3(1, 1, 0), new float3(0, 1, 0));
drawer.AddUndirected(new float3(0, 1, 0), new float3(0, 0, 0));
// create our graph
var graph = new LineGraph(Allocator.Persistent);
// populate it with our square
graph.Populate(drawer.Vertices, drawer.UndirectedEdges);
}
Constructors
LineGraphDrawer(float)
Construct a LineGraphDrawer
Declaration
public LineGraphDrawer(float weldThreshold)
Parameters
| Type | Name | Description |
|---|---|---|
| float | weldThreshold | Approx maximum distance vertices can have in order to be joined/welded together |
Properties
DirectedEdges
All edges that have been added as directed edges, use to populate the graph
Declaration
public IReadOnlyList<LineGraph.Edge> DirectedEdges { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<LineGraph.Edge> |
UndirectedEdges
All edges that have been added as undirected, use to populate the graph
Declaration
public IReadOnlyList<LineGraph.Edge> UndirectedEdges { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<LineGraph.Edge> |
Vertices
The welded vertices, use to populate the graph
Declaration
public IReadOnlyList<float3> Vertices { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<float3> |
Methods
AddDirected(float3, float3)
Draw a directed edge
Declaration
public void AddDirected(float3 from, float3 to)
Parameters
| Type | Name | Description |
|---|---|---|
| float3 | from | |
| float3 | to |
AddDirected(float3, float3, float, int, int)
Draw a directed edge with some additional traversal cost and flags associated with it
Declaration
public void AddDirected(float3 from, float3 to, float enterCost, int flags = 0, int id = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| float3 | from | |
| float3 | to | |
| float | enterCost | |
| int | flags | |
| int | id |
AddUndirected(float3, float3)
Draw an undirected edge
Declaration
public void AddUndirected(float3 from, float3 to)
Parameters
| Type | Name | Description |
|---|---|---|
| float3 | from | |
| float3 | to |
AddUndirected(float3, float3, float, int, int)
Draw an undirected edge with some additional traversal cost and flags associated with it
Declaration
public void AddUndirected(float3 from, float3 to, float enterCost, int flags = 0, int id = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| float3 | from | |
| float3 | to | |
| float | enterCost | |
| int | flags | |
| int | id |