2017-09-12 20:42:36 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2023-07-06 08:08:05 +00:00
<class name= "PolygonPathFinder" inherits= "Resource" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2017-09-12 20:42:36 +00:00
<brief_description >
</brief_description>
<description >
</description>
<tutorials >
</tutorials>
<methods >
<method name= "find_path" >
2021-07-30 13:28:05 +00:00
<return type= "PackedVector2Array" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "from" type= "Vector2" />
<param index= "1" name= "to" type= "Vector2" />
2017-09-12 20:42:36 +00:00
<description >
</description>
</method>
<method name= "get_bounds" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Rect2" />
2017-09-12 20:42:36 +00:00
<description >
</description>
</method>
<method name= "get_closest_point" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Vector2" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "point" type= "Vector2" />
2017-09-12 20:42:36 +00:00
<description >
</description>
</method>
<method name= "get_intersections" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "PackedVector2Array" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "from" type= "Vector2" />
<param index= "1" name= "to" type= "Vector2" />
2017-09-12 20:42:36 +00:00
<description >
</description>
</method>
<method name= "get_point_penalty" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "float" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "idx" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
</description>
</method>
<method name= "is_point_inside" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "point" type= "Vector2" />
2017-09-12 20:42:36 +00:00
<description >
2024-08-18 23:56:47 +00:00
Returns [code]true[/code] if [param point] falls inside the polygon area.
[codeblocks]
[gdscript]
var polygon_path_finder = PolygonPathFinder.new()
var points = [Vector2(0.0, 0.0), Vector2(1.0, 0.0), Vector2(0.0, 1.0)]
var connections = [0, 1, 1, 2, 2, 0]
polygon_path_finder.setup(points, connections)
print(polygon_path_finder.is_point_inside(Vector2(0.2, 0.2))) # Prints true
print(polygon_path_finder.is_point_inside(Vector2(1.0, 1.0))) # Prints false
[/gdscript]
[csharp]
var polygonPathFinder = new PolygonPathFinder();
var points = new Vector2[]
{
new Vector2(0.0f, 0.0f),
new Vector2(1.0f, 0.0f),
new Vector2(0.0f, 1.0f)
};
var connections = new int[] { 0, 1, 1, 2, 2, 0 };
polygonPathFinder.Setup(points, connections);
GD.Print(polygonPathFinder.IsPointInside(new Vector2(0.2f, 0.2f))); // Prints true
GD.Print(polygonPathFinder.IsPointInside(new Vector2(1.0f, 1.0f))); // Prints false
[/csharp]
[/codeblocks]
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "set_point_penalty" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "idx" type= "int" />
<param index= "1" name= "penalty" type= "float" />
2017-09-12 20:42:36 +00:00
<description >
</description>
</method>
<method name= "setup" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "points" type= "PackedVector2Array" />
<param index= "1" name= "connections" type= "PackedInt32Array" />
2017-09-12 20:42:36 +00:00
<description >
2024-08-18 23:56:47 +00:00
Sets up [PolygonPathFinder] with an array of points that define the vertices of the polygon, and an array of indices that determine the edges of the polygon.
The length of [param connections] must be even, returns an error if odd.
[codeblocks]
[gdscript]
var polygon_path_finder = PolygonPathFinder.new()
var points = [Vector2(0.0, 0.0), Vector2(1.0, 0.0), Vector2(0.0, 1.0)]
var connections = [0, 1, 1, 2, 2, 0]
polygon_path_finder.setup(points, connections)
[/gdscript]
[csharp]
var polygonPathFinder = new PolygonPathFinder();
var points = new Vector2[]
{
new Vector2(0.0f, 0.0f),
new Vector2(1.0f, 0.0f),
new Vector2(0.0f, 1.0f)
};
var connections = new int[] { 0, 1, 1, 2, 2, 0 };
polygonPathFinder.Setup(points, connections);
[/csharp]
[/codeblocks]
2017-09-12 20:42:36 +00:00
</description>
</method>
</methods>
</class>