2
0

face_position_cache.h 612 B

1234567891011121314151617181920212223242526
  1. // Luanti
  2. // SPDX-License-Identifier: LGPL-2.1-or-later
  3. // Copyright (C) 2015 Nerzhul, Loic Blot <loic.blot@unix-experience.fr>
  4. #pragma once
  5. #include "irr_v3d.h"
  6. #include <map>
  7. #include <vector>
  8. #include <unordered_map>
  9. #include <mutex>
  10. /*
  11. * This class permits caching getFacePosition call results.
  12. * This reduces CPU usage and vector calls.
  13. */
  14. class FacePositionCache {
  15. public:
  16. static const std::vector<v3s16> &getFacePositions(u16 d);
  17. private:
  18. static const std::vector<v3s16> &generateFacePosition(u16 d);
  19. static std::unordered_map<u16, std::vector<v3s16>> cache;
  20. static std::mutex cache_mutex;
  21. };