Browse Source

Merge pull request #3748 from akien-mga/pr-navpoly

Fix NavigationPolygon doc + drop polygon path finder demo
Rémi Verschelde 9 years ago
parent
commit
c94669f5b5

+ 0 - 5
demos/3d/polygon_path_finder/engine.cfg

@@ -1,5 +0,0 @@
-[application]
-
-name="Polygon Pathfinder"
-main_scene="res://poly_with_holes.scn"
-icon="res://icon.png"

BIN
demos/3d/polygon_path_finder/icon.png


BIN
demos/3d/polygon_path_finder/poly_with_holes.scn


+ 0 - 77
demos/3d/polygon_path_finder/polygonpathfinder.gd

@@ -1,77 +0,0 @@
-
-extends Spatial
-
-
-func _ready():
-	var pf = PolygonPathFinder.new()
-	
-	var points = Vector2Array()
-	var connections = IntArray()
-	
-	# Poly 1
-	points.push_back(Vector2(0, 0))		# 0
-	points.push_back(Vector2(10, 0))	# 1
-	points.push_back(Vector2(10, 10))	# 2
-	points.push_back(Vector2(0, 10))	# 3
-	
-	connections.push_back(0) # Connect vertex 0...
-	connections.push_back(1) # ... to 1
-	drawLine(points[0], points[1], get_node("/root/Spatial/Polys"))
-	connections.push_back(1) # Connect vertex 1...
-	connections.push_back(2) # ... to 2
-	drawLine(points[1], points[2], get_node("/root/Spatial/Polys"))
-	connections.push_back(2) # Etc.
-	connections.push_back(3)
-	drawLine(points[2], points[3], get_node("/root/Spatial/Polys"))
-	connections.push_back(3) # Connect vertex 3...
-	connections.push_back(0) # ... back to vertex 0, to close the polygon
-	drawLine(points[3], points[0], get_node("/root/Spatial/Polys"))
-	
-	# Poly 2, as obstacle inside poly 1
-	points.push_back(Vector2(2, 0.5))	# 4
-	points.push_back(Vector2(4, 0.5))	# 5
-	points.push_back(Vector2(4, 9.5))	# 6
-	points.push_back(Vector2(2, 9.5))	# 7
-	
-	connections.push_back(4)
-	connections.push_back(5)
-	drawLine(points[4], points[5], get_node("/root/Spatial/Polys"))
-	connections.push_back(5)
-	connections.push_back(6)
-	drawLine(points[5], points[6], get_node("/root/Spatial/Polys"))
-	connections.push_back(6)
-	connections.push_back(7)
-	drawLine(points[6], points[7], get_node("/root/Spatial/Polys"))
-	connections.push_back(7)
-	connections.push_back(4)
-	drawLine(points[7], points[4], get_node("/root/Spatial/Polys"))
-	
-	print("points: ", points)
-	print("connections: ", connections)
-	
-	pf.setup(points, connections)
-	
-	var path = pf.find_path(Vector2(1, 5), Vector2(8, 5))
-	
-	var lastStep = null
-	print("path: ", path)
-	for step in path:
-		print("step: ", step)
-		if (lastStep != null):
-			var currPathSegment = Vector2Array()
-			drawLine(lastStep, step, get_node("/root/Spatial/Path"))
-		lastStep = step
-
-
-func drawLine(pointA, pointB, immediateGeo):
-	var drawPosY = 0.1
-	var im = immediateGeo
-	
-	im.begin(Mesh.PRIMITIVE_POINTS, null)
-	im.add_vertex(Vector3(pointA.x, drawPosY, pointA.y))
-	im.add_vertex(Vector3(pointB.x, drawPosY, pointB.y))
-	im.end()
-	im.begin(Mesh.PRIMITIVE_LINE_STRIP, null)
-	im.add_vertex(Vector3(pointA.x, drawPosY, pointA.y))
-	im.add_vertex(Vector3(pointB.x, drawPosY, pointB.y))
-	im.end()

+ 13 - 12
doc/base/classes.xml

@@ -9608,7 +9608,8 @@ This approximation makes straight segments between each point, then subdivides t
 	<brief_description>
 	Directory type.
 	</brief_description>
-	<description>Directory type. Is used to manage directories and their content (not restricted to the project folder).
+	<description>
+	Directory type. Is used to manage directories and their content (not restricted to the project folder).
 
 How to iterate through the files of a directory example:
 
@@ -9633,21 +9634,21 @@ func dir(path):
 			<argument index="0" name="path" type="String">
 			</argument>
 			<description>
-Opens a directory to work with. Needs a path, example "res://folder"
+			Opens a directory to work with. Needs a path, example "res://folder"
 			</description>
 		</method>
 		<method name="list_dir_begin">
 			<return type="bool">
 			</return>
 			<description>
-Loads all file names of the current directory (prepares the get_next() function).
+			Loads all file names of the current directory (prepares the get_next() function).
 			</description>
 		</method>
 		<method name="get_next">
 			<return type="String">
 			</return>
 			<description>
-Is used to iterate through the files of the current directory. Returns the name(no path) of the current file/directory, it also contains "." and ".." .
+			Is used to iterate through the files of the current directory. Returns the name(no path) of the current file/directory, it also contains "." and ".." .
 Returns an empty String "" at the end of the list.
 			</description>
 		</method>
@@ -9655,12 +9656,12 @@ Returns an empty String "" at the end of the list.
 			<return type="bool">
 			</return>
 			<description>
-Returns true if the current file you are looking at with get_next() is a directory or "." or ".." otherwise false.
+			Returns true if the current file you are looking at with get_next() is a directory or "." or ".." otherwise false.
 			</description>
 		</method>
 		<method name="list_dir_end">
 			<description>
-Run this to empty the list of remaining files in get_next(). You can use it to end the iteration, as soon as your goal is reached.
+			Run this to empty the list of remaining files in get_next(). You can use it to end the iteration, as soon as your goal is reached.
 			</description>
 		</method>
 		<method name="get_drive_count">
@@ -9683,14 +9684,14 @@ Run this to empty the list of remaining files in get_next(). You can use it to e
 			<argument index="0" name="todir" type="String">
 			</argument>
 			<description>
-Needs a path or name to the next directory. When the target directory is in the current directory you can use "newfolder" otherwise you need the full path "res://currentfolder/newfolder"
+			Needs a path or name to the next directory. When the target directory is in the current directory you can use "newfolder" otherwise you need the full path "res://currentfolder/newfolder"
 			</description>
 		</method>
 		<method name="get_current_dir">
 			<return type="String">
 			</return>
 			<description>
-Returns a path to the current directory, example: "res://folder"
+			Returns a path to the current directory, example: "res://folder"
 			</description>
 		</method>
 		<method name="make_dir">
@@ -9723,7 +9724,7 @@ Returns a path to the current directory, example: "res://folder"
 			<argument index="0" name="name" type="String">
 			</argument>
 			<description>
-Returns true if directory exists otherwise false. Needs a path, example: "res://folder"
+			Returns true if directory exists otherwise false. Needs a path, example: "res://folder"
 			</description>
 		</method>
 		<method name="get_space_left">
@@ -18475,13 +18476,13 @@ verify_host will check the SSL identity of the host if set to true.
 	</description>
 	<methods>
 		<method name="set_navigation_polygon">
-			<argument index="0" name="navpoly" type="Object">
+			<argument index="0" name="navpoly" type="NavigationPolygon">
 			</argument>
 			<description>
 			</description>
 		</method>
 		<method name="get_navigation_polygon" qualifiers="const">
-			<return type="Object">
+			<return type="NavigationPolygon">
 			</return>
 			<description>
 			</description>
@@ -36428,7 +36429,7 @@ This method controls whether the position between two cached points is interpola
 			<argument index="1" name="y" type="int">
 			</argument>
 			<description>
-                        Return whether the referenced cell is transposed, i.e. the X and Y axes are swapped (mirroring with regard to the (1,1) vector).
+			Return whether the referenced cell is transposed, i.e. the X and Y axes are swapped (mirroring with regard to the (1,1) vector).
 			</description>
 		</method>
 		<method name="clear">

+ 2 - 2
scene/2d/navigation_polygon.cpp

@@ -429,8 +429,8 @@ void NavigationPolygonInstance::_navpoly_changed() {
 
 void NavigationPolygonInstance::_bind_methods() {
 
-	ObjectTypeDB::bind_method(_MD("set_navigation_polygon","navpoly"),&NavigationPolygonInstance::set_navigation_polygon);
-	ObjectTypeDB::bind_method(_MD("get_navigation_polygon"),&NavigationPolygonInstance::get_navigation_polygon);
+	ObjectTypeDB::bind_method(_MD("set_navigation_polygon","navpoly:NavigationPolygon"),&NavigationPolygonInstance::set_navigation_polygon);
+	ObjectTypeDB::bind_method(_MD("get_navigation_polygon:NavigationPolygon"),&NavigationPolygonInstance::get_navigation_polygon);
 
 	ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&NavigationPolygonInstance::set_enabled);
 	ObjectTypeDB::bind_method(_MD("is_enabled"),&NavigationPolygonInstance::is_enabled);