navigation_mesh_instance.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /**************************************************************************/
  2. /* navigation_mesh_instance.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_MESH_INSTANCE_H
  31. #define NAVIGATION_MESH_INSTANCE_H
  32. #include "scene/3d/spatial.h"
  33. #include "scene/resources/mesh.h"
  34. #include "scene/resources/navigation_mesh.h"
  35. class Navigation;
  36. class NavigationMeshInstance : public Spatial {
  37. GDCLASS(NavigationMeshInstance, Spatial);
  38. bool enabled = true;
  39. RID region;
  40. Ref<NavigationMesh> navmesh;
  41. real_t enter_cost = 0.0;
  42. real_t travel_cost = 1.0;
  43. uint32_t navigation_layers = 1;
  44. Navigation *navigation = nullptr;
  45. Node *debug_view = nullptr;
  46. Thread bake_thread;
  47. protected:
  48. void _notification(int p_what);
  49. static void _bind_methods();
  50. void _changed_callback(Object *p_changed, const char *p_prop);
  51. public:
  52. void set_enabled(bool p_enabled);
  53. bool is_enabled() const;
  54. void set_navigation_layers(uint32_t p_navigation_layers);
  55. uint32_t get_navigation_layers() const;
  56. RID get_region_rid() const;
  57. void set_enter_cost(real_t p_enter_cost);
  58. real_t get_enter_cost() const;
  59. void set_travel_cost(real_t p_travel_cost);
  60. real_t get_travel_cost() const;
  61. void set_navigation_mesh(const Ref<NavigationMesh> &p_navmesh);
  62. Ref<NavigationMesh> get_navigation_mesh() const;
  63. /// Bakes the navigation mesh; once done, automatically
  64. /// sets the new navigation mesh and emits a signal
  65. void bake_navigation_mesh(bool p_on_thread);
  66. void _bake_finished(Ref<NavigationMesh> p_nav_mesh);
  67. String get_configuration_warning() const;
  68. NavigationMeshInstance();
  69. ~NavigationMeshInstance();
  70. };
  71. #endif // NAVIGATION_MESH_INSTANCE_H