godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.99k stars 21.16k forks source link

NavMesh source geometry parsing ignores CSGShape3D set to `use_collision` #79843

Closed smix8 closed 1 year ago

smix8 commented 1 year ago

Godot version

Godot 4.1

System information

Windows 10

Issue description

The source geometry parsing for the navigation mesh baking only adds mesh geometry from CSGShape3D when set to NavigationMesh::PARSED_GEOMETRY_MESH_INSTANCES or PARSED_GEOMETRY_BOTH.

The parsing ignores CSG shapes with use_collision enabled when set to PARSED_GEOMETRY_STATIC_COLLIDERS. The parsing also ignores the collision_layers bitmask in all cases.

Steps to reproduce

Add CSGShape3D with use_collision enabled and set the NavigationMesh to PARSED_GEOMETRY_STATIC_COLLIDERS.

Minimal reproduction project

N/A

venilark commented 1 year ago

When doing NavigationServer3D.bake_from_source_geometry_data() I always get "NavigationMeshSourceGeometryData3D is empty. Parse source geometry first." I used the callable from parse_source_geometry_data() and tried with both Static Colliders and Mesh Instances

Tried with the CSGCombiner, same as you. If I add a StaticBody the error disappears because it finally finds some geometry but if there are only CSGs in neither mode I get anything.

smix8 commented 1 year ago

As mentioned in the other open issue the problem in venilark's project was that the parsing was done in a _ready() function.

The SceneTree is not done with all the nodes setups when a _ready() function in a node gets called, use call_deferred(). Some node types like TileMap or GridMap do their setups deferred themself so you need to wait a frame for them to be truly ready.