|
42 | 42 | <return type="bool" /> |
43 | 43 | <param index="0" name="point" type="Vector2" /> |
44 | 44 | <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] |
45 | 69 | </description> |
46 | 70 | </method> |
47 | 71 | <method name="set_point_penalty"> |
|
56 | 80 | <param index="0" name="points" type="PackedVector2Array" /> |
57 | 81 | <param index="1" name="connections" type="PackedInt32Array" /> |
58 | 82 | <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] |
59 | 104 | </description> |
60 | 105 | </method> |
61 | 106 | </methods> |
|
0 commit comments