Debian Codegraph @

tests/scene/test_navigation_region_3d.h

raw symbols SCIP
1 /**************************************************************************/
2 /* test_navigation_region_3d.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "scene/3d/mesh_instance_3d.h"
34 #include "scene/3d/navigation/navigation_region_3d.h"
35 #include "scene/main/window.h"
36 #include "scene/resources/3d/primitive_meshes.h"
37
38 #include "tests/test_macros.h"
39
40 namespace TestNavigationRegion3D {
41
42 TEST_SUITE("[Navigation3D]") {
43 TEST_CASE("[SceneTree][NavigationRegion3D] New region should have valid RID") {
44 NavigationRegion3D *region_node = memnew(NavigationRegion3D);
45 CHECK(region_node->get_rid().is_valid());
46 memdelete(region_node);
47 }
48
49 TEST_CASE("[SceneTree][NavigationRegion3D] Region should bake successfully from valid geometry") {
50 Node3D *node_3d = memnew(Node3D);
51 SceneTree::get_singleton()->get_root()->add_child(node_3d);
52 Ref<NavigationMesh> navigation_mesh = memnew(NavigationMesh);
53 NavigationRegion3D *navigation_region = memnew(NavigationRegion3D);
54 navigation_region->set_navigation_mesh(navigation_mesh);
55 node_3d->add_child(navigation_region);
56 Ref<PlaneMesh> plane_mesh = memnew(PlaneMesh);
57 plane_mesh->set_size(Size2(10.0, 10.0));
58 MeshInstance3D *mesh_instance = memnew(MeshInstance3D);
59 mesh_instance->set_mesh(plane_mesh);
60 navigation_region->add_child(mesh_instance);
61
62 CHECK_FALSE(navigation_region->is_baking());
63 CHECK_EQ(navigation_mesh->get_polygon_count(), 0);
64 CHECK_EQ(navigation_mesh->get_vertices().size(), 0);
65
66 SUBCASE("Synchronous bake should have immediate effects") {
67 ERR_PRINT_OFF; // Suppress warning about baking from visual meshes as source geometry.
68 navigation_region->bake_navigation_mesh(false);
69 ERR_PRINT_ON;
70 CHECK_FALSE(navigation_region->is_baking());
71 CHECK_NE(navigation_mesh->get_polygon_count(), 0);
72 CHECK_NE(navigation_mesh->get_vertices().size(), 0);
73 }
74
75 memdelete(mesh_instance);
76 memdelete(navigation_region);
77 memdelete(node_3d);
78 }
79 }
80
81 } //namespace TestNavigationRegion3D