mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-22 17:17:17 +01:00
Make sure that the new classes are registered to the ClassDB. Also added in the docs for them.
This commit is contained in:
parent
0a3d1d6cf5
commit
54ae614941
29
doc/classes/NavigationGeometryParser2D.xml
Normal file
29
doc/classes/NavigationGeometryParser2D.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="NavigationGeometryParser2D" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
Parser to contribute a node's geometry data for [NavigationPolygon] baking.
|
||||
</brief_description>
|
||||
<description>
|
||||
Parser to contribute a node's geometry data for [NavigationPolygon] baking. If a script extends this class and the function [method _parses_node] is overridden and returns [code]true[/code], the overridden function [method _parse_geometry] gets called and can be used to add custom geometry data for the [NavigationPolygon] baking process.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="_parse_geometry" qualifiers="virtual const">
|
||||
<return type="void" />
|
||||
<param index="0" name="node" type="Node" />
|
||||
<param index="1" name="navigation_polygon" type="NavigationPolygon" />
|
||||
<param index="2" name="source_geometry" type="NavigationMeshSourceGeometryData2D" />
|
||||
<description>
|
||||
Called when overridden and the [NavigationMeshGenerator] is parsing geometry for [NavigationPolygon] baking. Custom 2D geometry can be added to the [param source_geometry].
|
||||
</description>
|
||||
</method>
|
||||
<method name="_parses_node" qualifiers="virtual const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="node" type="Node" />
|
||||
<description>
|
||||
Called when parsing geometry nodes for [NavigationPolygon] baking. If [code]true[/code] will call [method _parse_geometry] with this node.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
</class>
|
29
doc/classes/NavigationGeometryParser3D.xml
Normal file
29
doc/classes/NavigationGeometryParser3D.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="NavigationGeometryParser3D" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
Parser to contribute a node's geometry data for [NavigationMesh] baking.
|
||||
</brief_description>
|
||||
<description>
|
||||
Parser to contribute a node's geometry data for [NavigationMesh] baking. If a script extends this class and the function [method _parses_node] is overridden and returns [code]true[/code], the overridden function [method _parse_geometry] gets called and can be used to add custom geometry data for the [NavigationMesh] baking process.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="_parse_geometry" qualifiers="virtual const">
|
||||
<return type="void" />
|
||||
<param index="0" name="node" type="Node" />
|
||||
<param index="1" name="navigation_mesh" type="NavigationMesh" />
|
||||
<param index="2" name="source_geometry" type="NavigationMeshSourceGeometryData3D" />
|
||||
<description>
|
||||
Called when overridden and the [NavigationMeshGenerator] is parsing geometry for [NavigationMesh] baking. Custom 3D geometry can be added to the [param source_geometry].
|
||||
</description>
|
||||
</method>
|
||||
<method name="_parses_node" qualifiers="virtual const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="node" type="Node" />
|
||||
<description>
|
||||
Called when parsing geometry nodes for [NavigationMesh] baking. If [code]true[/code] will call [method _parse_geometry] with this node.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
</class>
|
@ -1,34 +1,112 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="NavigationMeshGenerator" inherits="Object" version="3.11">
|
||||
<class name="NavigationMeshGenerator" inherits="Object" is_experimental="true" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
Helper class for creating and clearing navigation meshes.
|
||||
Server for navigation mesh baking and source geometry parsing.
|
||||
</brief_description>
|
||||
<description>
|
||||
This class is responsible for creating and clearing 3D navigation meshes used as [NavigationMesh] resources inside [NavigationMeshInstance]. The [NavigationMeshGenerator] has very limited to no use for 2D as the navigation mesh baking process expects 3D node types and 3D source geometry to parse.
|
||||
The entire navigation mesh baking is best done in a separate thread as the voxelization, collision tests and mesh optimization steps involved are very performance and time hungry operations.
|
||||
Navigation mesh baking happens in multiple steps and the result depends on 3D source geometry and properties of the [NavigationMesh] resource. In the first step, starting from a root node and depending on [NavigationMesh] properties all valid 3D source geometry nodes are collected from the [SceneTree]. Second, all collected nodes are parsed for their relevant 3D geometry data and a combined 3D mesh is build. Due to the many different types of parsable objects, from normal [MeshInstance]s to [CSGShape]s or various [CollisionObject]s, some operations to collect geometry data can trigger [RenderingServer] and [PhysicsServer] synchronizations. Server synchronization can have a negative effect on baking time or framerate as it often involves [Mutex] locking for thread security. Many parsable objects and the continuous synchronization with other threaded Servers can increase the baking time significantly. On the other hand only a few but very large and complex objects will take some time to prepare for the Servers which can noticeably stall the next frame render. As a general rule the total amount of parsable objects and their individual size and complexity should be balanced to avoid framerate issues or very long baking times. The combined mesh is then passed to the Recast Navigation Object to test the source geometry for walkable terrain suitable to [NavigationMesh] agent properties by creating a voxel world around the meshes bounding area.
|
||||
The finalized navigation mesh is then returned and stored inside the [NavigationMesh] for use as a resource inside [NavigationMeshInstance] nodes.
|
||||
[b]Note:[/b] Using meshes to not only define walkable surfaces but also obstruct navigation baking does not always work. The navigation baking has no concept of what is a geometry "inside" when dealing with mesh source geometry and this is intentional. Depending on current baking parameters, as soon as the obstructing mesh is large enough to fit a navigation mesh area inside, the baking will generate navigation mesh areas that are inside the obstructing source geometry mesh.
|
||||
Server for navigation mesh baking and source geometry parsing. [NavigationMesh] baking is the process of creating a simplified mesh used for pathfinding out of (complex) level geometry. For this process, the [NavigationMeshGenerator] parses scene geometry from nodes and uses this information for the creation of the final navigation mesh according to bake parameters.
|
||||
Source geometry parsing and navigation mesh baking are costly operations. It is best to do them infrequently and with the help of background threads at runtime. Source geometry parsing has to finish on the exact frame it was started even when using threads, as the scene tree is not safe to parse when doing updates, and also, by nature, the scene tree itself is not thread-safe. If the amount of geometry that must be parsed is too big, framerate issues may occur.
|
||||
To work around the runtime framerate issues, the source geometry can be parsed to a [NavigationMeshSourceGeometryData2D] or a [NavigationMeshSourceGeometryData3D] resource. This resource can later be (re)used at runtime to bake multiple navigation meshes with different parameters in background threads without touching the scene tree again (assuming the nodes that contribute source geometry have not changed).
|
||||
</description>
|
||||
<tutorials>
|
||||
<link title="Using NavigationMeshes">$DOCS_URL/tutorials/navigation/navigation_using_navigationmeshes.html</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="bake">
|
||||
<method name="bake_2d_from_source_geometry_data">
|
||||
<return type="void" />
|
||||
<argument index="0" name="nav_mesh" type="NavigationMesh" />
|
||||
<argument index="1" name="root_node" type="Node" />
|
||||
<param index="0" name="navigation_polygon" type="NavigationPolygon" />
|
||||
<param index="1" name="source_geometry_data" type="NavigationMeshSourceGeometryData2D" />
|
||||
<param index="2" name="callback" type="Callable" />
|
||||
<description>
|
||||
Bakes navigation data to the provided [code]nav_mesh[/code] by parsing child nodes under the provided [code]root_node[/code] or a specific group of nodes for potential source geometry. The parse behavior can be controlled with the [member NavigationMesh.geometry_parsed_geometry_type] and [member NavigationMesh.geometry_source_geometry_mode] properties on the [NavigationMesh] resource.
|
||||
Bakes the provided [param navigation_polygon] with the data from the provided [param source_geometry_data]. After the process is finished the optional [param callback] will be called.
|
||||
</description>
|
||||
</method>
|
||||
<method name="clear">
|
||||
<method name="bake_3d_from_source_geometry_data">
|
||||
<return type="void" />
|
||||
<argument index="0" name="nav_mesh" type="NavigationMesh" />
|
||||
<param index="0" name="navigation_mesh" type="NavigationMesh" />
|
||||
<param index="1" name="source_geometry_data" type="NavigationMeshSourceGeometryData3D" />
|
||||
<param index="2" name="callback" type="Callable" />
|
||||
<description>
|
||||
Removes all polygons and vertices from the provided [code]nav_mesh[/code] resource.
|
||||
Bakes the provided [param navigation_mesh] with the data from the provided [param source_geometry_data]. After the process is finished the optional [param callback] will be called.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_navigation_mesh_baking" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="navigation_mesh" type="NavigationMesh" />
|
||||
<description>
|
||||
Returns [code]true[/code] if [param navigation_mesh] is currently baking or geometry parsing.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_navigation_polygon_baking" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="navigation_polygon" type="NavigationPolygon" />
|
||||
<description>
|
||||
Returns [code]true[/code] if [param navigation_polygon] is currently baking or geometry parsing.
|
||||
</description>
|
||||
</method>
|
||||
<method name="parse_2d_source_geometry_data">
|
||||
<return type="NavigationMeshSourceGeometryData2D" />
|
||||
<param index="0" name="navigation_polygon" type="NavigationPolygon" />
|
||||
<param index="1" name="root_node" type="Node" />
|
||||
<param index="2" name="callback" type="Callable" />
|
||||
<description>
|
||||
Parses the [SceneTree] (not thread-safe) for source geometry according to the properties of [param navigation_polygon] and returns a [NavigationMeshSourceGeometryData2D] that can be used to bake a navigation mesh. After the process is finished the optional [param callback] will be called.
|
||||
</description>
|
||||
</method>
|
||||
<method name="parse_3d_source_geometry_data">
|
||||
<return type="NavigationMeshSourceGeometryData3D" />
|
||||
<param index="0" name="navigation_mesh" type="NavigationMesh" />
|
||||
<param index="1" name="root_node" type="Node" />
|
||||
<param index="2" name="callback" type="Callable" />
|
||||
<description>
|
||||
Parses the [SceneTree] (not thread-safe) for source geometry according to the properties of [param navigation_mesh] and returns a [NavigationMeshSourceGeometryData2D] that can be used to bake a navigation mesh. After the process is finished the optional [param callback] will be called.
|
||||
</description>
|
||||
</method>
|
||||
<method name="parse_and_bake_2d">
|
||||
<return type="void" />
|
||||
<param index="0" name="navigation_polygon" type="NavigationPolygon" />
|
||||
<param index="1" name="root_node" type="Node" />
|
||||
<param index="2" name="callback" type="Callable" />
|
||||
<description>
|
||||
Uses both [method parse_2d_source_geometry_data] and [method bake_2d_from_source_geometry_data] in sequence. After the process is finished the optional [param callback] will be called.
|
||||
</description>
|
||||
</method>
|
||||
<method name="parse_and_bake_3d">
|
||||
<return type="void" />
|
||||
<param index="0" name="navigation_mesh" type="NavigationMesh" />
|
||||
<param index="1" name="root_node" type="Node" />
|
||||
<param index="2" name="callback" type="Callable" />
|
||||
<description>
|
||||
Uses both [method parse_3d_source_geometry_data] and [method bake_3d_from_source_geometry_data] in sequence. After the process is finished the optional [param callback] will be called.
|
||||
</description>
|
||||
</method>
|
||||
<method name="register_geometry_parser_2d">
|
||||
<return type="void" />
|
||||
<param index="0" name="geometry_parser" type="NavigationGeometryParser2D" />
|
||||
<description>
|
||||
Registers a 2d navigation geometry parser to contribute geometry data from parser specified node class(es) for navigation mesh baking.
|
||||
</description>
|
||||
</method>
|
||||
<method name="register_geometry_parser_3d">
|
||||
<return type="void" />
|
||||
<param index="0" name="geometry_parser" type="NavigationGeometryParser3D" />
|
||||
<description>
|
||||
Registers a 3d navigation geometry parser to contribute geometry data from parser specified node class(es) for navigation mesh baking.
|
||||
</description>
|
||||
</method>
|
||||
<method name="unregister_geometry_parser_2d">
|
||||
<return type="void" />
|
||||
<param index="0" name="geometry_parser" type="NavigationGeometryParser2D" />
|
||||
<description>
|
||||
Unregisters the specific 2d navigation geometry parser.
|
||||
</description>
|
||||
</method>
|
||||
<method name="unregister_geometry_parser_3d">
|
||||
<return type="void" />
|
||||
<param index="0" name="geometry_parser" type="NavigationGeometryParser3D" />
|
||||
<description>
|
||||
Unregisters the specific 3d navigation geometry parser.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
||||
|
65
doc/classes/NavigationMeshSourceGeometryData2D.xml
Normal file
65
doc/classes/NavigationMeshSourceGeometryData2D.xml
Normal file
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="NavigationMeshSourceGeometryData2D" inherits="Resource" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
Contains parsed source geometry data for use in [NavigationPolygon] baking with the [NavigationMeshGenerator].
|
||||
</brief_description>
|
||||
<description>
|
||||
Contains parsed source geometry data for use in [NavigationPolygon] baking with the [NavigationMeshGenerator].
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="add_obstruction_outline">
|
||||
<return type="void" />
|
||||
<param index="0" name="shape_outline" type="PackedVector2Array" />
|
||||
<description>
|
||||
Adds the outline points of a shape as obstructed area.
|
||||
</description>
|
||||
</method>
|
||||
<method name="add_traversable_outline">
|
||||
<return type="void" />
|
||||
<param index="0" name="shape_outline" type="PackedVector2Array" />
|
||||
<description>
|
||||
Adds the outline points of a shape as traversable area.
|
||||
</description>
|
||||
</method>
|
||||
<method name="clear">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Clears the internal data.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_obstruction_outlines" qualifiers="const">
|
||||
<return type="PackedVector2Array[]" />
|
||||
<description>
|
||||
Returns all the obstructed area outlines arrays.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_traversable_outlines" qualifiers="const">
|
||||
<return type="PackedVector2Array[]" />
|
||||
<description>
|
||||
Returns all the traversable area outlines arrays.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_data">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [b]true[/b] when parsed source geometry data exists.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_obstruction_outlines">
|
||||
<return type="void" />
|
||||
<param index="0" name="obstruction_outlines" type="PackedVector2Array[]" />
|
||||
<description>
|
||||
Sets all the obstructed area outlines arrays.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_traversable_outlines">
|
||||
<return type="void" />
|
||||
<param index="0" name="traversable_outlines" type="PackedVector2Array[]" />
|
||||
<description>
|
||||
Sets all the traversable area outlines arrays.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
</class>
|
77
doc/classes/NavigationMeshSourceGeometryData3D.xml
Normal file
77
doc/classes/NavigationMeshSourceGeometryData3D.xml
Normal file
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="NavigationMeshSourceGeometryData3D" inherits="Resource" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
Contains parsed source geometry data for use in [NavigationMesh] baking with the [NavigationMeshGenerator].
|
||||
</brief_description>
|
||||
<description>
|
||||
Contains parsed source geometry data for use in [NavigationMesh] baking with the [NavigationMeshGenerator].
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="add_faces">
|
||||
<return type="void" />
|
||||
<param index="0" name="faces" type="PackedVector3Array" />
|
||||
<param index="1" name="xform" type="Transform3D" />
|
||||
<description>
|
||||
Adds an array of vertex positions to the geometry data for navigation mesh baking to form triangulated faces. For each face the array must have three vertex positions in clockwise winding order. Since [NavigationMesh] resource have no transform all vertex positions need to be offset by the node's transform using the [code]xform[/code] parameter.
|
||||
</description>
|
||||
</method>
|
||||
<method name="add_mesh">
|
||||
<return type="void" />
|
||||
<param index="0" name="mesh" type="Mesh" />
|
||||
<param index="1" name="xform" type="Transform3D" />
|
||||
<description>
|
||||
Adds the geometry data of a [Mesh] resource to the navigation mesh baking data. The mesh must have valid triangulated mesh data to be considered. Since [NavigationMesh] resource have no transform all vertex positions need to be offset by the node's transform using the [code]xform[/code] parameter.
|
||||
</description>
|
||||
</method>
|
||||
<method name="add_mesh_array">
|
||||
<return type="void" />
|
||||
<param index="0" name="mesh_array" type="Array" />
|
||||
<param index="1" name="xform" type="Transform3D" />
|
||||
<description>
|
||||
Adds an [Array] the size of [constant Mesh.ARRAY_MAX] and with vertices at index [constant Mesh.ARRAY_VERTEX] and indices at index [constant Mesh.ARRAY_INDEX] to the navigation mesh baking data. The array must have valid triangulated mesh data to be considered. Since [NavigationMesh] resource have no transform all vertex positions need to be offset by the node's transform using the [code]xform[/code] parameter.
|
||||
</description>
|
||||
</method>
|
||||
<method name="clear">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Clears the internal data.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_indices" qualifiers="const">
|
||||
<return type="PackedInt32Array" />
|
||||
<description>
|
||||
Returns the parsed source geometry data indices array.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_vertices" qualifiers="const">
|
||||
<return type="PackedFloat32Array" />
|
||||
<description>
|
||||
Returns the parsed source geometry data vertices array.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_data">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [b]true[/b] when parsed source geometry data exists.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_indices">
|
||||
<return type="void" />
|
||||
<param index="0" name="indices" type="PackedInt32Array" />
|
||||
<description>
|
||||
Sets the parsed source geometry data indices. The indices need to be matched with appropriated vertices.
|
||||
[b]Warning:[/b] Inappropriate data can crash the baking process of the involved third-party libraries.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_vertices">
|
||||
<return type="void" />
|
||||
<param index="0" name="vertices" type="PackedFloat32Array" />
|
||||
<description>
|
||||
Sets the parsed source geometry data vertices. The vertices need to be matched with appropriated indices.
|
||||
[b]Warning:[/b] Inappropriate data can crash the baking process of the involved third-party libraries.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
</class>
|
@ -53,9 +53,9 @@
|
||||
#include "scene/2d/multimesh_instance_2d.h"
|
||||
#include "scene/2d/navigation_2d.h"
|
||||
#include "scene/2d/navigation_agent_2d.h"
|
||||
#include "scene/2d/navigation_geometry_parser_2d.h"
|
||||
#include "scene/2d/navigation_obstacle_2d.h"
|
||||
#include "scene/2d/navigation_region_2d.h"
|
||||
#include "scene/resources/navigation_polygon.h"
|
||||
#include "scene/2d/parallax_background.h"
|
||||
#include "scene/2d/parallax_layer.h"
|
||||
#include "scene/2d/path_2d.h"
|
||||
@ -158,6 +158,9 @@
|
||||
#include "scene/resources/mesh_data_tool.h"
|
||||
#include "scene/resources/multimesh.h"
|
||||
#include "scene/resources/navigation_mesh.h"
|
||||
#include "scene/resources/navigation_mesh_source_geometry_data_2d.h"
|
||||
#include "scene/resources/navigation_mesh_source_geometry_data_3d.h"
|
||||
#include "scene/resources/navigation_polygon.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "scene/resources/particles_material.h"
|
||||
#include "scene/resources/physics_material.h"
|
||||
@ -195,6 +198,7 @@
|
||||
#include "scene/3d/multimesh_instance.h"
|
||||
#include "scene/3d/navigation.h"
|
||||
#include "scene/3d/navigation_agent.h"
|
||||
#include "scene/3d/navigation_geometry_parser_3d.h"
|
||||
#include "scene/3d/navigation_mesh_instance.h"
|
||||
#include "scene/3d/navigation_obstacle.h"
|
||||
#include "scene/3d/occluder.h"
|
||||
@ -686,6 +690,14 @@ void register_scene_types() {
|
||||
ClassDB::register_class<NavigationAgent2D>();
|
||||
ClassDB::register_class<NavigationObstacle2D>();
|
||||
|
||||
ClassDB::register_class<NavigationMeshSourceGeometryData2D>();
|
||||
ClassDB::register_class<NavigationMeshSourceGeometryData3D>();
|
||||
ClassDB::register_class<NavigationGeometryParser2D>();
|
||||
|
||||
#ifndef _3D_DISABLED
|
||||
ClassDB::register_class<NavigationGeometryParser3D>();
|
||||
#endif
|
||||
|
||||
OS::get_singleton()->yield(); //may take time to init
|
||||
|
||||
ClassDB::register_virtual_class<SceneState>();
|
||||
|
Loading…
Reference in New Issue
Block a user