From 61ddf05eefb698fabdf3ad92253df2ae9e1d5914 Mon Sep 17 00:00:00 2001 From: andrei-g99 Date: Mon, 19 Aug 2024 02:56:47 +0300 Subject: [PATCH] Add descriptions to `PolygonPathFinder` `setup` and `is_point_inside` methods --- doc/classes/PolygonPathFinder.xml | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/doc/classes/PolygonPathFinder.xml b/doc/classes/PolygonPathFinder.xml index f37a8a05e4f0..b70633883c8c 100644 --- a/doc/classes/PolygonPathFinder.xml +++ b/doc/classes/PolygonPathFinder.xml @@ -42,6 +42,30 @@ + 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] @@ -56,6 +80,27 @@ + 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]