| 1484 | } |
| 1485 | |
| 1486 | void GridMap::navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry_data, Node *p_node) { |
| 1487 | GridMap *gridmap = Object::cast_to<GridMap>(p_node); |
| 1488 | |
| 1489 | if (gridmap == nullptr) { |
| 1490 | return; |
| 1491 | } |
| 1492 | |
| 1493 | NavigationMesh::ParsedGeometryType parsed_geometry_type = p_navigation_mesh->get_parsed_geometry_type(); |
| 1494 | #ifndef PHYSICS_3D_DISABLED |
| 1495 | uint32_t parsed_collision_mask = p_navigation_mesh->get_collision_mask(); |
| 1496 | #endif // PHYSICS_3D_DISABLED |
| 1497 | |
| 1498 | if (parsed_geometry_type == NavigationMesh::PARSED_GEOMETRY_MESH_INSTANCES || parsed_geometry_type == NavigationMesh::PARSED_GEOMETRY_BOTH) { |
| 1499 | Array meshes = gridmap->get_meshes(); |
| 1500 | Transform3D xform = gridmap->get_global_transform(); |
| 1501 | for (int i = 0; i < meshes.size(); i += 2) { |
| 1502 | Ref<Mesh> mesh = meshes[i + 1]; |
| 1503 | if (mesh.is_valid()) { |
| 1504 | p_source_geometry_data->add_mesh(mesh, xform * (Transform3D)meshes[i]); |
| 1505 | } |
| 1506 | } |
| 1507 | } |
| 1508 | #ifndef PHYSICS_3D_DISABLED |
| 1509 | else if ((parsed_geometry_type == NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS || parsed_geometry_type == NavigationMesh::PARSED_GEOMETRY_BOTH) && (gridmap->get_collision_layer() & parsed_collision_mask)) { |
| 1510 | Array shapes = gridmap->get_collision_shapes(); |
| 1511 | for (int i = 0; i < shapes.size(); i += 2) { |
| 1512 | RID shape = shapes[i + 1]; |
| 1513 | PhysicsServer3D::ShapeType type = PhysicsServer3D::get_singleton()->shape_get_type(shape); |
| 1514 | Variant data = PhysicsServer3D::get_singleton()->shape_get_data(shape); |
| 1515 | |
| 1516 | switch (type) { |
| 1517 | case PhysicsServer3D::SHAPE_SPHERE: { |
| 1518 | real_t radius = data; |
| 1519 | Array arr; |
| 1520 | arr.resize(RS::ARRAY_MAX); |
| 1521 | SphereMesh::create_mesh_array(arr, radius, radius * 2.0); |
| 1522 | p_source_geometry_data->add_mesh_array(arr, shapes[i]); |
| 1523 | } break; |
| 1524 | case PhysicsServer3D::SHAPE_BOX: { |
| 1525 | Vector3 extents = data; |
| 1526 | Array arr; |
| 1527 | arr.resize(RS::ARRAY_MAX); |
| 1528 | BoxMesh::create_mesh_array(arr, extents * 2.0); |
| 1529 | p_source_geometry_data->add_mesh_array(arr, shapes[i]); |
| 1530 | } break; |
| 1531 | case PhysicsServer3D::SHAPE_CAPSULE: { |
| 1532 | Dictionary dict = data; |
| 1533 | real_t radius = dict["radius"]; |
| 1534 | real_t height = dict["height"]; |
| 1535 | Array arr; |
| 1536 | arr.resize(RS::ARRAY_MAX); |
| 1537 | CapsuleMesh::create_mesh_array(arr, radius, height); |
| 1538 | p_source_geometry_data->add_mesh_array(arr, shapes[i]); |
| 1539 | } break; |
| 1540 | case PhysicsServer3D::SHAPE_CYLINDER: { |
| 1541 | Dictionary dict = data; |
| 1542 | real_t radius = dict["radius"]; |
| 1543 | real_t height = dict["height"]; |
nothing calls this directly
no test coverage detected