mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-24 04:46:48 +01:00
Ported the docs from the navigation mesh generator rework pr.
This commit is contained in:
parent
32e0e80ac8
commit
7ce5f939a9
@ -63,6 +63,9 @@
|
||||
<member name="NavigationMeshGenerator" type="NavigationMeshGenerator" setter="" getter="">
|
||||
The [NavigationMeshGenerator] singleton.
|
||||
</member>
|
||||
<member name="NavigationMeshGeneratorManager" type="NavigationMeshGeneratorManager" setter="" getter="">
|
||||
The [NavigationMeshGeneratorManager] singleton.
|
||||
</member>
|
||||
<member name="NavigationServer" type="NavigationServer" setter="" getter="">
|
||||
The [NavigationServer] singleton.
|
||||
</member>
|
||||
|
@ -1,10 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="NavigationMesh" inherits="Resource" version="3.11">
|
||||
<brief_description>
|
||||
A mesh to approximate the walkable areas and obstacles.
|
||||
A mesh that defines the areas traversable by navigation agents that are safe from obstructions.
|
||||
</brief_description>
|
||||
<description>
|
||||
A navigation mesh is a collection of polygons that define which areas of an environment are traversable to aid agents in pathfinding through complicated spaces.
|
||||
A NavigationMesh is used in pathfinding to describe the traversable area that is safe from collision and other obstructions, assuming an agent's center position at zero radius. The mesh data can be created and baked to polygons with the [NavigationMeshGenerator] by parsing source geometry from the [SceneTree]. The mesh data can also be created without baking by adding the required arrays of vertices and polygon indices with a script.
|
||||
When making procedual changes, a call to [method commit_changes] is required to apply these changes and to synchronize them with the [NavigationServer].
|
||||
</description>
|
||||
<tutorials>
|
||||
<link title="3D Navmesh Demo">https://godotengine.org/asset-library/asset/124</link>
|
||||
@ -17,6 +18,31 @@
|
||||
Adds a polygon using the indices of the vertices you get when calling [method get_vertices].
|
||||
</description>
|
||||
</method>
|
||||
<method name="clear">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Clears both the internal polygons and vertices arrays.
|
||||
</description>
|
||||
</method>
|
||||
<method name="commit_changes">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Applies all changes to vertices and polygons and synchronizes with the NavigationServer.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_polygons" qualifiers="const">
|
||||
<return type="Array" />
|
||||
<description>
|
||||
Returns the array of polygons used by the internal navigation mesh. Each polygon array consists of the indices for the vertices that make the polygon.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_polygons">
|
||||
<return type="void" />
|
||||
<param index="0" name="polygons" type="Array" />
|
||||
<description>
|
||||
Sets the navigation mesh polygons. Each polygon array needs to consist of the indices for the vertices that make the polygon.
|
||||
</description>
|
||||
</method>
|
||||
<method name="clear_polygons">
|
||||
<return type="void" />
|
||||
<description>
|
||||
@ -69,7 +95,7 @@
|
||||
<return type="void" />
|
||||
<argument index="0" name="vertices" type="PoolVector3Array" />
|
||||
<description>
|
||||
Sets the vertices that can be then indexed to create polygons with the [method add_polygon] method.
|
||||
Sets the vertices that need to be indexed with the [method add_polygon] or [method set_polygons] methods. When finished changing the navigation mesh call [method commit_changes] in order to synchronize the changes with the [NavigationServer].
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
|
@ -20,6 +20,13 @@
|
||||
<argument index="0" name="on_thread" type="bool" default="true" />
|
||||
<description>
|
||||
Bakes the [NavigationMesh]. If [code]on_thread[/code] is set to [code]true[/code] (default), the baking is done on a separate thread. Baking on separate thread is useful because navigation baking is not a cheap operation. When it is completed, it automatically sets the new [NavigationMesh]. Please note that baking on separate thread may be very slow if geometry is parsed from meshes as async access to each mesh involves heavy synchronization.
|
||||
[b]Note:[/b] Only functional in Pandemonium builds with a [NavigationMeshGenerator] implementation available.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_navigation_map" qualifiers="const">
|
||||
<return type="RID" />
|
||||
<description>
|
||||
Returns the current navigation map [RID] use by this region.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_region_rid" qualifiers="const">
|
||||
@ -28,6 +35,13 @@
|
||||
Returns the [RID] of this region on the [NavigationServer]. Combined with [method NavigationServer.map_get_closest_point_owner] can be used to identify the [NavigationMeshInstance] closest to a point on the merged navigation map.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_navigation_map">
|
||||
<return type="void" />
|
||||
<param index="0" name="navigation_map" type="RID" />
|
||||
<description>
|
||||
Sets the [RID] of the navigation map this region should use. By default the region will automatically join the [World3D] default navigation map so this function is only required to override the default map.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true">
|
||||
@ -49,12 +63,12 @@
|
||||
<signals>
|
||||
<signal name="bake_finished">
|
||||
<description>
|
||||
Notifies when the navigation mesh bake operation is completed.
|
||||
Emitted when a navigation mesh bake operation is completed.
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="navigation_mesh_changed">
|
||||
<description>
|
||||
Notifies when the [NavigationMesh] has changed.
|
||||
Emitted when the used navigation mesh is replaced or changes to the internals of the current navigation mesh are committed.
|
||||
</description>
|
||||
</signal>
|
||||
</signals>
|
||||
|
256
doc/classes/NavigationPolygon.xml
Normal file
256
doc/classes/NavigationPolygon.xml
Normal file
@ -0,0 +1,256 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="NavigationPolygon" inherits="Resource" version="3.11">
|
||||
<brief_description>
|
||||
A NavigationPolygon is used in pathfinding to describe the traversable area that is safe from collision and other obstructions, assuming an agent's center position at zero radius.
|
||||
</brief_description>
|
||||
<description>
|
||||
A NavigationPolygon is used in pathfinding to describe the traversable area that is safe from collision and other obstructions, assuming an agent's center position at zero radius. The mesh data can be created and baked to polygons with the [NavigationMeshGenerator] by drawing outlines in the Editor, or defining outlines by script, or by parsing source geometry from the [SceneTree]. The mesh data can also be created without outlines and baking by adding the required arrays of vertices and polygon indices more manually and calling [method commit_changes] afterwards.
|
||||
When doing procedual changes a call to [method commit_changes] is required to apply all the made changes and to synchronize the changes with the [NavigationServer2D].
|
||||
In scripts there are two more manual ways to create navigation polygons. Either by using the [method add_outline] method and baking with the [NavigationMeshGenerator], or using the methods [method set_vertices] and [method set_polygons] directly.
|
||||
Using [method add_outline]:
|
||||
[codeblock]
|
||||
var new_navigation_polygon = NavigationPolygon.new()
|
||||
var new_navigation_polygon_outline = PackedVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
|
||||
new_navigation_polygon.add_outline(new_navigation_polygon_outline)
|
||||
NavigationMeshGenerator.bake_2d_from_source_geometry_data(new_navigation_polygon, NavigationMeshSourceGeometryData2D.new());
|
||||
$NavigationRegion2D.navigation_polygon = new_navigation_polygon
|
||||
[/codeblock]
|
||||
Using [method add_polygon] and indices of the vertices array.
|
||||
[codeblock]
|
||||
var new_navigation_polygon = NavigationPolygon.new()
|
||||
var new_navigation_polygon_vertices = PackedVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
|
||||
new_navigation_polygon.vertices = new_navigation_polygon_vertices
|
||||
var new_navigation_polygon_polygon_indices = PackedInt32Array([0, 1, 2, 3])
|
||||
new_navigation_polygon.add_polygon(new_navigation_polygon_polygon_indices)
|
||||
new_navigation_polygon.commit_changes()
|
||||
$NavigationRegion2D.navigation_polygon = new_navigation_polygon
|
||||
[/codeblock]
|
||||
</description>
|
||||
<tutorials>
|
||||
<link title="2D Navigation Demo">https://godotengine.org/asset-library/asset/117</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="add_outline">
|
||||
<return type="void" />
|
||||
<argument index="0" name="outline" type="PoolVector2Array" />
|
||||
<description>
|
||||
Appends a [PoolVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use.
|
||||
</description>
|
||||
</method>
|
||||
<method name="add_outline_at_index">
|
||||
<return type="void" />
|
||||
<argument index="0" name="outline" type="PoolVector2Array" />
|
||||
<argument index="1" name="index" type="int" />
|
||||
<description>
|
||||
Adds a [PoolVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use.
|
||||
</description>
|
||||
</method>
|
||||
<method name="add_polygon">
|
||||
<return type="void" />
|
||||
<argument index="0" name="polygon" type="PoolIntArray" />
|
||||
<description>
|
||||
Adds a polygon using the indices of the vertices you get when calling [method get_vertices].
|
||||
</description>
|
||||
</method>
|
||||
<method name="clear_outlines">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them.
|
||||
</description>
|
||||
</method>
|
||||
<method name="clear_polygons">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Clears the array of polygons, but it doesn't clear the array of outlines and vertices.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_mesh">
|
||||
<return type="NavigationMesh" />
|
||||
<description>
|
||||
Returns the [NavigationMesh] resulting from this navigation polygon. This navmesh can be used to update the navmesh of a region with the [method NavigationServer.region_set_navmesh] API directly (as 2D uses the 3D server behind the scene).
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_outline" qualifiers="const">
|
||||
<return type="PoolVector2Array" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<description>
|
||||
Returns a [PoolVector2Array] containing the vertices of an outline that was created in the editor or by script.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_outline_count" qualifiers="const">
|
||||
<return type="int" />
|
||||
<description>
|
||||
Returns the number of outlines that were created in the editor or by script.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_polygon">
|
||||
<return type="PoolIntArray" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<description>
|
||||
Returns a [PoolIntArray] containing the indices of the vertices of a created polygon.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_polygon_count" qualifiers="const">
|
||||
<return type="int" />
|
||||
<description>
|
||||
Returns the number of polygons.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_polygons" qualifiers="const">
|
||||
<return type="Array" />
|
||||
<description>
|
||||
Returns the array of polygons used by the internal navigation mesh. Each polygon array consists of the indices for the vertices that make the polygon.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_baked_outlines">
|
||||
<return type="void" />
|
||||
<param index="0" name="baked_outlines" type="Array" />
|
||||
<description>
|
||||
Sets the array of baked outlines. The baked outlines are the result of a finished [NavigationMeshGenerator] baking process and primarily used for debugging purposes.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_outlines">
|
||||
<return type="void" />
|
||||
<param index="0" name="outlines" type="Array" />
|
||||
<description>
|
||||
Sets the outline arrays. The outlines need to be baked to actual navigation mesh polygons by using the [NavigationMeshGenerator].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_polygons">
|
||||
<return type="void" />
|
||||
<param index="0" name="polygons" type="Array" />
|
||||
<description>
|
||||
Sets the navigation mesh polygons. Each polygon array needs to consist of the indices for the vertices that make the polygon.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_vertices" qualifiers="const">
|
||||
<return type="PoolVector2Array" />
|
||||
<description>
|
||||
Returns a [PoolVector2Array] containing all the vertices being used to create the polygons.
|
||||
</description>
|
||||
</method>
|
||||
<method name="make_polygons_from_outlines">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Creates polygons from the outlines added in the editor or by script.
|
||||
</description>
|
||||
</method>
|
||||
<method name="remove_outline">
|
||||
<return type="void" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<description>
|
||||
Removes an outline created in the editor or by script.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_outline">
|
||||
<return type="void" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<argument index="1" name="outline" type="PoolVector2Array" />
|
||||
<description>
|
||||
Changes an outline created in the editor or by script.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_vertices">
|
||||
<return type="void" />
|
||||
<argument index="0" name="vertices" type="PoolVector2Array" />
|
||||
<description>
|
||||
Sets the vertices that need to be indexed with the [method add_polygon] or [method set_polygons] methods. When finished changing the navigation polygon call [method commit_changes] in order to synchronize the changes with the [Navigation2DServer].
|
||||
</description>
|
||||
</method>
|
||||
<method name="commit_changes">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Applies all changes to vertices and polygons and synchronizes with the [NavigationServer2D].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_baked_outlines" qualifiers="const">
|
||||
<return type="PackedVector2Array[]" />
|
||||
<description>
|
||||
Returns the array of baked outlines. The baked outlines are the result of a finished [NavigationMeshGenerator] baking process and primarily used for debugging purposes.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_collision_mask_value" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="layer_number" type="int" />
|
||||
<description>
|
||||
Returns whether or not the specified layer of the [member geometry_collision_mask] is enabled, given a [param layer_number] between 1 and 32.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="agent_radius" type="float" setter="set_agent_radius" getter="get_agent_radius" default="10.0">
|
||||
The distance to erode/shrink the traversable area from obstructions when baking polygons.
|
||||
</member>
|
||||
<member name="geometry_collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="4294967295">
|
||||
The physics layers to scan for static colliders. Only used when [member geometry_parsed_geometry_type] is [constant PARSED_GEOMETRY_STATIC_COLLIDERS] or [constant PARSED_GEOMETRY_BOTH].
|
||||
</member>
|
||||
<member name="geometry_parsed_geometry_type" type="int" setter="set_parsed_geometry_type" getter="get_parsed_geometry_type" enum="NavigationPolygon.ParsedGeometryType" default="0">
|
||||
Determines which type of nodes will be parsed as geometry. See [enum ParsedGeometryType] for possible values.
|
||||
</member>
|
||||
<member name="geometry_source_geometry_mode" type="int" setter="set_source_geometry_mode" getter="get_source_geometry_mode" enum="NavigationPolygon.SourceGeometryMode" default="0">
|
||||
The source of the geometry used when baking. See [enum SourceGeometryMode] for possible values.
|
||||
</member>
|
||||
<member name="geometry_source_group_name" type="StringName" setter="set_source_group_name" getter="get_source_group_name" default="&"navigation_polygon_source_group"">
|
||||
The name of the group to scan for geometry. Only used when [member geometry_source_geometry_mode] is [constant SOURCE_GEOMETRY_GROUPS_WITH_CHILDREN] or [constant SOURCE_GEOMETRY_GROUPS_EXPLICIT].
|
||||
</member>
|
||||
<member name="offsetting_jointype" type="int" setter="set_offsetting_jointype" getter="get_offsetting_jointype" enum="NavigationPolygon.OffsettingJoinType" default="2">
|
||||
The [enum OffsettingJoinType] used for joins when offsetting the bake polygons by [member agent_radius].
|
||||
</member>
|
||||
<member name="polygon_bake_fillrule" type="int" setter="set_polygon_bake_fillrule" getter="get_polygon_bake_fillrule" enum="NavigationPolygon.PolygonFillRule" default="0">
|
||||
Filling rule for baking polygons that defines in complex polygons which polygon sub-regions will be considered inside a given polygon, and which sub-regions will not, aka what is a hole.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="PARSED_GEOMETRY_MESH_INSTANCES" value="0" enum="ParsedGeometryType">
|
||||
Parses mesh instances and other visual shapes as geometry. This includes [MeshInstance2D], [MultiMeshInstance2D], [Polygon2D], and [TileMap] (first TileMapLayer only) nodes.
|
||||
</constant>
|
||||
<constant name="PARSED_GEOMETRY_STATIC_COLLIDERS" value="1" enum="ParsedGeometryType">
|
||||
Parses [StaticBody2D], and [TileMap] (first TileMapLayer only) colliders as geometry. The collider should be in any of the layers specified by [member geometry_collision_mask].
|
||||
</constant>
|
||||
<constant name="PARSED_GEOMETRY_BOTH" value="2" enum="ParsedGeometryType">
|
||||
Both [constant PARSED_GEOMETRY_MESH_INSTANCES] and [constant PARSED_GEOMETRY_STATIC_COLLIDERS].
|
||||
</constant>
|
||||
<constant name="PARSED_GEOMETRY_MAX" value="3" enum="ParsedGeometryType">
|
||||
Represents the size of the [enum ParsedGeometryType] enum.
|
||||
</constant>
|
||||
<constant name="SOURCE_GEOMETRY_ROOT_NODE_CHILDREN" value="0" enum="SourceGeometryMode">
|
||||
Scans the child nodes of the root node recursively for geometry.
|
||||
</constant>
|
||||
<constant name="SOURCE_GEOMETRY_GROUPS_WITH_CHILDREN" value="1" enum="SourceGeometryMode">
|
||||
Scans nodes in a group and their child nodes recursively for geometry. The group is specified by [member geometry_source_group_name].
|
||||
</constant>
|
||||
<constant name="SOURCE_GEOMETRY_GROUPS_EXPLICIT" value="2" enum="SourceGeometryMode">
|
||||
Uses nodes in a group for geometry. The group is specified by [member geometry_source_group_name].
|
||||
</constant>
|
||||
<constant name="SOURCE_GEOMETRY_MAX" value="3" enum="SourceGeometryMode">
|
||||
Represents the size of the [enum SourceGeometryMode] enum.
|
||||
</constant>
|
||||
<constant name="POLYGON_FILLRULE_EVENODD" value="0" enum="PolygonFillRule">
|
||||
Only odd numbered sub-regions are filled
|
||||
</constant>
|
||||
<constant name="POLYGON_FILLRULE_NONZERO" value="1" enum="PolygonFillRule">
|
||||
Only non-zero sub-regions are filled
|
||||
</constant>
|
||||
<constant name="POLYGON_FILLRULE_POSITIVE" value="2" enum="PolygonFillRule">
|
||||
Only sub-regions with winding counts greater zero are filled.
|
||||
</constant>
|
||||
<constant name="POLYGON_FILLRULE_NEGATIVE" value="3" enum="PolygonFillRule">
|
||||
Only sub-regions with winding counts smaller zero are filled.
|
||||
</constant>
|
||||
<constant name="POLYGON_FILLRULE_MAX" value="4" enum="PolygonFillRule">
|
||||
Represents the size of the [enum PolygonFillRule] enum.
|
||||
</constant>
|
||||
<constant name="OFFSETTING_JOINTYPE_SQUARE" value="0" enum="OffsettingJoinType">
|
||||
Squaring is applied uniformally at all joins where the internal join angle is less that 90 degrees. The squared edge will be at exactly the offset distance from the join vertex.
|
||||
</constant>
|
||||
<constant name="OFFSETTING_JOINTYPE_ROUND" value="1" enum="OffsettingJoinType">
|
||||
Rounding is applied to all joins that have convex external angles and the exact offset distance from the join vertex is maintained.
|
||||
</constant>
|
||||
<constant name="OFFSETTING_JOINTYPE_MITER" value="2" enum="OffsettingJoinType">
|
||||
Creates mitered joins such that the line of junction bisects the angle. To avoid narrow angled joins producing excessively long and narrow spikes mitered joins are automatically squared when they exceed a given maximum miter distance relative to the offset distance.
|
||||
</constant>
|
||||
<constant name="OFFSETTING_JOINTYPE_MAX" value="3" enum="OffsettingJoinType">
|
||||
Represents the size of the [enum OffsettingJoinType] enum.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
@ -21,6 +21,26 @@
|
||||
Returns the [RID] of this region on the [Navigation2DServer]. Combined with [method Navigation2DServer.map_get_closest_point_owner] can be used to identify the [NavigationPolygonInstance] closest to a point on the merged navigation map.
|
||||
</description>
|
||||
</method>
|
||||
<method name="bake_navigation_polygon">
|
||||
<return type="void" />
|
||||
<param index="0" name="on_thread" type="bool" default="true" />
|
||||
<description>
|
||||
Bakes the [NavigationPolygon]. If [param on_thread] is set to [code]true[/code] (default), the baking is done on a separate thread.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_navigation_map" qualifiers="const">
|
||||
<return type="RID" />
|
||||
<description>
|
||||
Returns the current navigation map [RID] use by this region.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_navigation_map">
|
||||
<return type="void" />
|
||||
<param index="0" name="navigation_map" type="RID" />
|
||||
<description>
|
||||
Sets the [RID] of the navigation map this region should use. By default the region will automatically join the [World2D] default navigation map so this function is only required to override the default map.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true">
|
||||
@ -41,4 +61,16 @@
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
<signals>
|
||||
<signal name="bake_finished">
|
||||
<description>
|
||||
Emitted when a navigation polygon bake operation is completed.
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="navigation_polygon_changed">
|
||||
<description>
|
||||
Emitted when the used navigation polygon is replaced or changes to the internals of the current navigation polygon are committed.
|
||||
</description>
|
||||
</signal>
|
||||
</signals>
|
||||
</class>
|
||||
|
@ -1,133 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="NavigationPolygon" inherits="Resource" version="3.11">
|
||||
<brief_description>
|
||||
A node that has methods to draw outlines or use indices of vertices to create navigation polygons.
|
||||
</brief_description>
|
||||
<description>
|
||||
There are two ways to create polygons. Either by using the [method add_outline] method, or using the [method add_polygon] method.
|
||||
Using [method add_outline]:
|
||||
[codeblock]
|
||||
var polygon = NavigationPolygon.new()
|
||||
var outline = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
|
||||
polygon.add_outline(outline)
|
||||
polygon.make_polygons_from_outlines()
|
||||
$NavigationPolygonInstance.navpoly = polygon
|
||||
[/codeblock]
|
||||
Using [method add_polygon] and indices of the vertices array.
|
||||
[codeblock]
|
||||
var polygon = NavigationPolygon.new()
|
||||
var vertices = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
|
||||
polygon.set_vertices(vertices)
|
||||
var indices = PoolIntArray([0, 1, 2, 3])
|
||||
polygon.add_polygon(indices)
|
||||
$NavigationPolygonInstance.navpoly = polygon
|
||||
[/codeblock]
|
||||
</description>
|
||||
<tutorials>
|
||||
<link title="2D Navigation Demo">https://godotengine.org/asset-library/asset/117</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="add_outline">
|
||||
<return type="void" />
|
||||
<argument index="0" name="outline" type="PoolVector2Array" />
|
||||
<description>
|
||||
Appends a [PoolVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use.
|
||||
</description>
|
||||
</method>
|
||||
<method name="add_outline_at_index">
|
||||
<return type="void" />
|
||||
<argument index="0" name="outline" type="PoolVector2Array" />
|
||||
<argument index="1" name="index" type="int" />
|
||||
<description>
|
||||
Adds a [PoolVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use.
|
||||
</description>
|
||||
</method>
|
||||
<method name="add_polygon">
|
||||
<return type="void" />
|
||||
<argument index="0" name="polygon" type="PoolIntArray" />
|
||||
<description>
|
||||
Adds a polygon using the indices of the vertices you get when calling [method get_vertices].
|
||||
</description>
|
||||
</method>
|
||||
<method name="clear_outlines">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them.
|
||||
</description>
|
||||
</method>
|
||||
<method name="clear_polygons">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Clears the array of polygons, but it doesn't clear the array of outlines and vertices.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_mesh">
|
||||
<return type="NavigationMesh" />
|
||||
<description>
|
||||
Returns the [NavigationMesh] resulting from this navigation polygon. This navmesh can be used to update the navmesh of a region with the [method NavigationServer.region_set_navmesh] API directly (as 2D uses the 3D server behind the scene).
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_outline" qualifiers="const">
|
||||
<return type="PoolVector2Array" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<description>
|
||||
Returns a [PoolVector2Array] containing the vertices of an outline that was created in the editor or by script.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_outline_count" qualifiers="const">
|
||||
<return type="int" />
|
||||
<description>
|
||||
Returns the number of outlines that were created in the editor or by script.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_polygon">
|
||||
<return type="PoolIntArray" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<description>
|
||||
Returns a [PoolIntArray] containing the indices of the vertices of a created polygon.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_polygon_count" qualifiers="const">
|
||||
<return type="int" />
|
||||
<description>
|
||||
Returns the count of all polygons.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_vertices" qualifiers="const">
|
||||
<return type="PoolVector2Array" />
|
||||
<description>
|
||||
Returns a [PoolVector2Array] containing all the vertices being used to create the polygons.
|
||||
</description>
|
||||
</method>
|
||||
<method name="make_polygons_from_outlines">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Creates polygons from the outlines added in the editor or by script.
|
||||
</description>
|
||||
</method>
|
||||
<method name="remove_outline">
|
||||
<return type="void" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<description>
|
||||
Removes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_outline">
|
||||
<return type="void" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<argument index="1" name="outline" type="PoolVector2Array" />
|
||||
<description>
|
||||
Changes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_vertices">
|
||||
<return type="void" />
|
||||
<argument index="0" name="vertices" type="PoolVector2Array" />
|
||||
<description>
|
||||
Sets the vertices that can be then indexed to create polygons with the [method add_polygon] method.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -559,6 +559,13 @@
|
||||
<member name="debug/shapes/navigation/geometry_face_disabled_color" type="Color" setter="" getter="" default="Color(0.5, 0.5, 0.5, 0.4)">
|
||||
Color to display disabled navigation mesh polygon faces, visible when "Visible Navigation" is enabled in the Debug menu.
|
||||
</member>
|
||||
<member name="navigation/baking/generator/navigation_mesh_generator" type="String" setter="" getter="" default=""DEFAULT"">
|
||||
Sets which navigation mesh generator to use to bake navigation meshes and parse source geometry from the scene.
|
||||
"DEFAULT" and "GodotNavigationMeshGenerator" are the same, as there is currently no alternative navigation mesh generator implemented.
|
||||
</member>
|
||||
<member name="navigation/baking/thread_model/use_thread_pool" type="bool" setter="" getter="" default="true">
|
||||
If [code]true[/code] the navigation mesh generator uses ThreadPool for baking navigation meshes.
|
||||
</member>
|
||||
<member name="display/mouse_cursor/custom_image" type="String" setter="" getter="" default="""">
|
||||
Custom image for the mouse cursor (limited to 256×256).
|
||||
</member>
|
||||
|
@ -937,7 +937,7 @@ void PandemoniumNavigationMeshGenerator::_static_parse_3d_source_geometry_data(R
|
||||
#endif // _3D_DISABLED
|
||||
|
||||
PandemoniumNavigationMeshGenerator::PandemoniumNavigationMeshGenerator() {
|
||||
_use_thread_pool = GLOBAL_DEF("navigation/baking/thread_model/use_thread_pool", true);
|
||||
_use_thread_pool = GLOBAL_GET("navigation/baking/thread_model/use_thread_pool");
|
||||
// Can't use threads in Editor as parsing gets stuck on RenderingServer / PhysicsServer locks.
|
||||
// (TODO needs to be tested) The way I have it now, it should work.
|
||||
//_use_thread_pool = !Engine::get_singleton()->is_editor_hint();
|
||||
|
@ -155,7 +155,8 @@
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="bake_navigation" type="bool" setter="set_bake_navigation" getter="is_baking_navigation" default="false">
|
||||
<member name="bake_navigation" type="bool" setter="set_bake_navigation" getter="is_baking_navigation" default="true">
|
||||
If [code]true[/code], this TileMap creates a navigation region for each cell that uses a layer with a navigation polygon.
|
||||
</member>
|
||||
<member name="cell_clip_uv" type="bool" setter="set_clip_uv" getter="get_clip_uv" default="false">
|
||||
</member>
|
||||
|
@ -161,10 +161,7 @@ NavigationMeshGenerator *NavigationMeshGeneratorManager::new_server(const String
|
||||
NavigationMeshGeneratorManager::NavigationMeshGeneratorManager() {
|
||||
singleton = this;
|
||||
|
||||
GLOBAL_DEF("navigation/baking/thread_model/parsing_use_multiple_threads", true);
|
||||
GLOBAL_DEF("navigation/baking/thread_model/parsing_use_high_priority_threads", true);
|
||||
GLOBAL_DEF("navigation/baking/thread_model/baking_use_multiple_threads", true);
|
||||
GLOBAL_DEF("navigation/baking/thread_model/baking_use_high_priority_threads", true);
|
||||
GLOBAL_DEF("navigation/baking/thread_model/use_thread_pool", true);
|
||||
}
|
||||
|
||||
NavigationMeshGeneratorManager::~NavigationMeshGeneratorManager() {
|
||||
|
Loading…
Reference in New Issue
Block a user