1/**************************************************************************/
2/* nav_obstacle.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#ifndef NAV_OBSTACLE_H
32#define NAV_OBSTACLE_H
33
34#include "nav_rid.h"
35
36#include "core/object/class_db.h"
37#include "core/templates/local_vector.h"
38
39class NavAgent;
40class NavMap;
41
42class NavObstacle : public NavRid {
43 NavAgent *agent = nullptr;
44 NavMap *map = nullptr;
45 Vector3 velocity;
46 Vector3 position;
47 Vector<Vector3> vertices;
48
49 real_t radius = 0.0;
50 real_t height = 0.0;
51
52 bool avoidance_enabled = false;
53 bool use_3d_avoidance = false;
54 uint32_t avoidance_layers = 1;
55
56 bool obstacle_dirty = true;
57
58 uint32_t map_update_id = 0;
59 bool paused = false;
60
61public:
62 NavObstacle();
63 ~NavObstacle();
64
65 void set_avoidance_enabled(bool p_enabled);
66 bool is_avoidance_enabled() { return avoidance_enabled; }
67
68 void set_use_3d_avoidance(bool p_enabled);
69 bool get_use_3d_avoidance() { return use_3d_avoidance; }
70
71 void set_map(NavMap *p_map);
72 NavMap *get_map() { return map; }
73
74 void set_agent(NavAgent *p_agent);
75 NavAgent *get_agent() { return agent; }
76
77 void set_position(const Vector3 p_position);
78 const Vector3 &get_position() const { return position; }
79
80 void set_radius(real_t p_radius);
81 real_t get_radius() const { return radius; }
82
83 void set_height(const real_t p_height);
84 real_t get_height() const { return height; }
85
86 void set_velocity(const Vector3 p_velocity);
87 const Vector3 &get_velocity() const { return velocity; }
88
89 void set_vertices(const Vector<Vector3> &p_vertices);
90 const Vector<Vector3> &get_vertices() const { return vertices; }
91
92 bool is_map_changed();
93
94 void set_avoidance_layers(uint32_t p_layers);
95 uint32_t get_avoidance_layers() const { return avoidance_layers; };
96
97 void set_paused(bool p_paused);
98 bool get_paused() const;
99
100 bool check_dirty();
101
102private:
103 void internal_update_agent();
104};
105
106#endif // NAV_OBSTACLE_H
107