lod_manager.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**************************************************************************/
  2. /* lod_manager.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 LOD_MANAGER_H
  31. #define LOD_MANAGER_H
  32. #include "core/local_vector.h"
  33. #include "core/os/mutex.h"
  34. class Camera;
  35. class LOD;
  36. struct Vector3;
  37. class LODManager {
  38. public:
  39. enum { NUM_LOD_QUEUES = 5 };
  40. void register_camera(Camera *p_camera);
  41. void remove_camera(Camera *p_camera);
  42. void register_lod(LOD *p_lod, uint32_t p_queue_id);
  43. void unregister_lod(LOD *p_lod, uint32_t p_queue_id);
  44. void update();
  45. void notify_saving(bool p_active);
  46. static void set_enabled(bool p_enabled) { _enabled = p_enabled; }
  47. static bool is_enabled() { return _enabled; }
  48. private:
  49. void _update_queue(uint32_t p_queue_id, const Vector3 *p_camera_positions, uint32_t p_num_cameras);
  50. struct Queue {
  51. LocalVector<LOD *> lods;
  52. uint32_t lod_iterator = 0;
  53. };
  54. struct Data {
  55. LocalVector<Camera *> cameras;
  56. Queue queues[NUM_LOD_QUEUES];
  57. BinaryMutex mutex;
  58. bool saving = false;
  59. } data;
  60. static bool _enabled;
  61. };
  62. #endif // LOD_MANAGER_H