NavigationMeshGenerator
Helper class for creating and clearing navigation meshes.
NavigationMeshGenerator.swift:20class NavigationMeshGenerator
This class is responsible for creating and clearing 3D navigation meshes used as NavigationMesh
resources inside NavigationRegion3D
. 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 MeshInstance3D
s to CSGShape3D
s or various CollisionObject3D
s, some operations to collect geometry data can trigger RenderingServer
and PhysicsServer3D
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 number 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 NavigationRegion3D
nodes.
Superclasses
class Object
Base class for all other classes in the engine.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.