Skip to content

Commit 293c0cb

Browse files
committed
Merge pull request godotengine#95782 from andrei-g99/master
Add descriptions to `PolygonPathFinder` `setup` and `is_point_inside` methods
2 parents 13a90e9 + 61ddf05 commit 293c0cb

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

doc/classes/PolygonPathFinder.xml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,30 @@
4242
<return type="bool" />
4343
<param index="0" name="point" type="Vector2" />
4444
<description>
45+
Returns [code]true[/code] if [param point] falls inside the polygon area.
46+
[codeblocks]
47+
[gdscript]
48+
var polygon_path_finder = PolygonPathFinder.new()
49+
var points = [Vector2(0.0, 0.0), Vector2(1.0, 0.0), Vector2(0.0, 1.0)]
50+
var connections = [0, 1, 1, 2, 2, 0]
51+
polygon_path_finder.setup(points, connections)
52+
print(polygon_path_finder.is_point_inside(Vector2(0.2, 0.2))) # Prints true
53+
print(polygon_path_finder.is_point_inside(Vector2(1.0, 1.0))) # Prints false
54+
[/gdscript]
55+
[csharp]
56+
var polygonPathFinder = new PolygonPathFinder();
57+
var points = new Vector2[]
58+
{
59+
new Vector2(0.0f, 0.0f),
60+
new Vector2(1.0f, 0.0f),
61+
new Vector2(0.0f, 1.0f)
62+
};
63+
var connections = new int[] { 0, 1, 1, 2, 2, 0 };
64+
polygonPathFinder.Setup(points, connections);
65+
GD.Print(polygonPathFinder.IsPointInside(new Vector2(0.2f, 0.2f))); // Prints true
66+
GD.Print(polygonPathFinder.IsPointInside(new Vector2(1.0f, 1.0f))); // Prints false
67+
[/csharp]
68+
[/codeblocks]
4569
</description>
4670
</method>
4771
<method name="set_point_penalty">
@@ -56,6 +80,27 @@
5680
<param index="0" name="points" type="PackedVector2Array" />
5781
<param index="1" name="connections" type="PackedInt32Array" />
5882
<description>
83+
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.
84+
The length of [param connections] must be even, returns an error if odd.
85+
[codeblocks]
86+
[gdscript]
87+
var polygon_path_finder = PolygonPathFinder.new()
88+
var points = [Vector2(0.0, 0.0), Vector2(1.0, 0.0), Vector2(0.0, 1.0)]
89+
var connections = [0, 1, 1, 2, 2, 0]
90+
polygon_path_finder.setup(points, connections)
91+
[/gdscript]
92+
[csharp]
93+
var polygonPathFinder = new PolygonPathFinder();
94+
var points = new Vector2[]
95+
{
96+
new Vector2(0.0f, 0.0f),
97+
new Vector2(1.0f, 0.0f),
98+
new Vector2(0.0f, 1.0f)
99+
};
100+
var connections = new int[] { 0, 1, 1, 2, 2, 0 };
101+
polygonPathFinder.Setup(points, connections);
102+
[/csharp]
103+
[/codeblocks]
59104
</description>
60105
</method>
61106
</methods>

0 commit comments

Comments
 (0)