navigation.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**************************************************************************/
  2. /* navigation.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 NAVIGATION_H
  31. #define NAVIGATION_H
  32. #include "scene/3d/navigation_mesh_instance.h"
  33. #include "scene/3d/spatial.h"
  34. class Navigation : public Spatial {
  35. GDCLASS(Navigation, Spatial);
  36. RID map;
  37. Vector3 up = Vector3(0, 1, 0);
  38. real_t cell_size = 0.25;
  39. real_t cell_height = 0.25;
  40. real_t edge_connection_margin = 0.25;
  41. uint32_t navigation_layers = 1;
  42. protected:
  43. static void _bind_methods();
  44. void _notification(int p_what);
  45. public:
  46. RID get_rid() const {
  47. return map;
  48. }
  49. void set_up_vector(const Vector3 &p_up);
  50. Vector3 get_up_vector() const;
  51. void set_cell_size(float p_cell_size);
  52. float get_cell_size() const {
  53. return cell_size;
  54. }
  55. void set_cell_height(float p_cell_height);
  56. float get_cell_height() const {
  57. return cell_height;
  58. }
  59. void set_navigation_layers(uint32_t p_navigation_layers);
  60. uint32_t get_navigation_layers() const;
  61. void set_edge_connection_margin(float p_edge_connection_margin);
  62. float get_edge_connection_margin() const {
  63. return edge_connection_margin;
  64. }
  65. Vector<Vector3> get_simple_path(const Vector3 &p_start, const Vector3 &p_end, bool p_optimize = true) const;
  66. Vector3 get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, bool p_use_collision = false) const;
  67. Vector3 get_closest_point(const Vector3 &p_point) const;
  68. Vector3 get_closest_point_normal(const Vector3 &p_point) const;
  69. RID get_closest_point_owner(const Vector3 &p_point) const;
  70. virtual String get_configuration_warning() const;
  71. Navigation();
  72. ~Navigation();
  73. };
  74. #endif // NAVIGATION_H