### Godot version

4.2.dev f2acfb1ffc94d0e381064070108e7a773d86177d

### System information

Ubuntu 22.04 CI

### Issue description

https://github.com/qarmin/GodotBuilds/actions/runs/5790813978/job/15694543373#step:7:679

Command 
```
scons dev_build=yes CCFLAGS="-fpie" LINKFLAGS="-no-pie" module_basis_universal_enabled=no module_bmp_enabled=no module_camera_enabled=no module_csg_enabled=no module_cvtt_enabled=no module_dds_enabled=no module_denoise_enabled=no module_enet_enabled=no module_etcpak_enabled=no module_glslang_enabled=no module_gltf_enabled=no module_gridmap_enabled=no module_hdr_enabled=no module_jpg_enabled=no module_jsonrpc_enabled=no module_lightmapper_rd_enabled=no module_mbedtls_enabled=no module_meshoptimizer_enabled=no module_minimp3_enabled=no module_mobile_vr_enabled=no module_multiplayer_enabled=no module_noise_enabled=no module_ogg_enabled=no module_openxr_enabled=no module_raycast_enabled=no module_regex_enabled=no module_squish_enabled=no module_tga_enabled=no module_theora_enabled=no module_tinyexr_enabled=no module_upnp_enabled=no module_vhacd_enabled=no module_vorbis_enabled=no module_webp_enabled=no module_webrtc_enabled=no module_websocket_enabled=no module_webxr_enabled=no module_xatlas_unwrap_enabled=no target=editor -j2
```
produce such errors

```
In file included from modules/navigation/nav_mesh_generator_3d.cpp:33:
modules/navigation/nav_mesh_generator_3d.h:40:7: note: forward declaration of 'class NavigationMesh'
   40 | class NavigationMesh;
      |       ^~~~~~~~~~~~~~
modules/navigation/nav_mesh_generator_3d.cpp:704:42: error: invalid use of incomplete type 'class NavigationMesh'
  704 |                         p_navigation_mesh->add_polygon(nav_indices);
      |                                          ^~
In file included from modules/navigation/nav_mesh_generator_3d.cpp:33:
modules/navigation/nav_mesh_generator_3d.h:40:7: note: forward declaration of 'class NavigationMesh'
   40 | class NavigationMesh;
      |       ^~~~~~~~~~~~~~
In file included from ./core/io/resource_uid.h:34,
                 from ./core/io/resource.h:34,
                 from ./core/input/input_event.h:35,
                 from ./core/os/main_loop.h:34,
                 from ./scene/main/scene_tree.h:34,
                 from ./scene/main/node.h:37,
                 from ./scene/3d/node_3d.h:34,
                 from ./scene/3d/visual_instance_3d.h:34,
                 from ./scene/3d/mesh_instance_3d.h:35,
                 from modules/navigation/nav_mesh_generator_3d.cpp:37:
./core/object/ref_counted.h: In instantiation of 'void Ref<T>::ref(const Ref<T>&) [with T = NavigationMesh]':
./core/object/ref_counted.h:166:3:   required from 'Ref<T>::Ref(const Ref<T>&) [with T = NavigationMesh]'
modules/navigation/nav_mesh_generator_3d.cpp:118:42:   required from here
./core/object/ref_counted.h:69:36: error: invalid use of incomplete type 'class NavigationMesh'
   69 |                         reference->reference();
      |                         ~~~~~~~~~~~^~~~~~~~~
In file included from modules/navigation/nav_mesh_generator_3d.cpp:33:
modules/navigation/nav_mesh_generator_3d.h:40:7: note: forward declaration of 'class NavigationMesh'
   40 | class NavigationMesh;
      |       ^~~~~~~~~~~~~~
In file included from ./core/io/resource_uid.h:34,
                 from ./core/io/resource.h:34,
                 from ./core/input/input_event.h:35,
                 from ./core/os/main_loop.h:34,
                 from ./scene/main/scene_tree.h:34,
                 from ./scene/main/node.h:37,
                 from ./scene/3d/node_3d.h:34,
                 from ./scene/3d/visual_instance_3d.h:34,
                 from ./scene/3d/mesh_instance_3d.h:35,
                 from modules/navigation/nav_mesh_generator_3d.cpp:37:
./core/object/ref_counted.h: In instantiation of 'void Ref<T>::unref() [with T = NavigationMesh]':
./core/object/ref_counted.h:222:3:   required from 'Ref<T>::~Ref() [with T = NavigationMesh]'
modules/navigation/nav_mesh_generator_3d.cpp:118:42:   required from here
./core/object/ref_counted.h:209:45: error: invalid use of incomplete type 'class NavigationMesh'
  209 |                 if (reference && reference->unreference()) {
      |                                  ~~~~~~~~~~~^~~~~~~~~~~
In file included from modules/navigation/nav_mesh_generator_3d.cpp:33:
modules/navigation/nav_mesh_generator_3d.h:40:7: note: forward declaration of 'class NavigationMesh'
   40 | class NavigationMesh;
      |       ^~~~~~~~~~~~~~
scons: *** [modules/navigation/nav_mesh_generator_3d.linuxbsd.editor.dev.x86_64.o] Error 1
scons: building terminated because of errors.
```
this is 1 day old regression, probably caused by https://github.com/godotengine/godot/commit/7eb047a5edf5b87e519e149b11e2b00543b62e72

CSGShape3D *csgshape3d = Object::cast_to<CSGShape3D>(p_node);
	if (csgshape3d) {
		NavigationMesh::ParsedGeometryType parsed_geometry_type = p_navigation_mesh->get_parsed_geometry_type();
		uint32_t parsed_collision_mask = p_navigation_mesh->get_collision_mask();
		if (parsed_geometry_type == NavigationMesh::PARSED_GEOMETRY_MESH_INSTANCES || (parsed_geometry_type == NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS && csgshape3d->is_using_collision() && (csgshape3d->get_collision_layer() & parsed_collision_mask)) || parsed_geometry_type == NavigationMesh::PARSED_GEOMETRY_BOTH) {
			CSGShape3D *csg_shape = Object::cast_to<CSGShape3D>(p_node);
			Array meshes = csg_shape->get_meshes();
			if (!meshes.is_empty()) {
				Ref<Mesh> mesh = meshes[1];
				if (mesh.is_valid()) {
					p_source_geometry_data->add_mesh(mesh, csg_shape->get_global_transform());
				}
			}
		}
	}
}
#endif 
#ifdef MODULE_GRIDMAP_ENABLED
void NavMeshGenerator3D::generator_parse_gridmap_node(const Ref<NavigationMesh> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry_data, Node *p_node) {