Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/tests/scene/test_navigation_obstacle_3d.cpp
45993 views
1
/**************************************************************************/
2
/* test_navigation_obstacle_3d.cpp */
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
#include "tests/test_macros.h"
32
33
TEST_FORCE_LINK(test_navigation_obstacle_3d)
34
35
#include "modules/modules_enabled.gen.h" // For navigation 3D.
36
37
#ifdef MODULE_NAVIGATION_3D_ENABLED
38
39
#include "scene/3d/navigation/navigation_obstacle_3d.h"
40
#include "scene/main/scene_tree.h"
41
#include "scene/main/window.h"
42
43
namespace TestNavigationObstacle3D {
44
45
TEST_SUITE("[Navigation3D]") {
46
TEST_CASE("[SceneTree][NavigationObstacle3D] New obstacle should have valid RID") {
47
NavigationObstacle3D *obstacle_node = memnew(NavigationObstacle3D);
48
CHECK(obstacle_node->get_rid().is_valid());
49
memdelete(obstacle_node);
50
}
51
52
TEST_CASE("[SceneTree][NavigationObstacle3D] New obstacle should attach to default map") {
53
Node3D *node_3d = memnew(Node3D);
54
SceneTree::get_singleton()->get_root()->add_child(node_3d);
55
56
NavigationObstacle3D *obstacle_node = memnew(NavigationObstacle3D);
57
// obstacle should not be attached to any map when outside of tree
58
CHECK_FALSE(obstacle_node->get_navigation_map().is_valid());
59
60
SUBCASE("Obstacle should attach to default map when it enters the tree") {
61
node_3d->add_child(obstacle_node);
62
CHECK(obstacle_node->get_navigation_map().is_valid());
63
CHECK(obstacle_node->get_navigation_map() == node_3d->get_world_3d()->get_navigation_map());
64
}
65
66
memdelete(obstacle_node);
67
memdelete(node_3d);
68
}
69
}
70
71
} // namespace TestNavigationObstacle3D
72
73
#endif // MODULE_NAVIGATION_3D_ENABLED
74
75