nav_obstacle.h 3.9 KB

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