Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
face_position_cache.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2015 Nerzhul, Loic Blot <loic.blot@unix-experience.fr>
4
5#pragma once
6
7#include "irr_v3d.h"
8
9#include <map>
10#include <vector>
11#include <unordered_map>
12#include <mutex>
13
14/*
15 * This class permits caching getFacePosition call results.
16 * This reduces CPU usage and vector calls.
17 */
19public:
20 static const std::vector<v3s16> &getFacePositions(u16 d);
21
22private:
23 static const std::vector<v3s16> &generateFacePosition(u16 d);
24 static std::unordered_map<u16, std::vector<v3s16>> cache;
25 static std::mutex cache_mutex;
26};
Definition face_position_cache.h:18
static const std::vector< v3s16 > & getFacePositions(u16 d)
Definition face_position_cache.cpp:13
static const std::vector< v3s16 > & generateFacePosition(u16 d)
Definition face_position_cache.cpp:23
static std::unordered_map< u16, std::vector< v3s16 > > cache
Definition face_position_cache.h:24
static std::mutex cache_mutex
Definition face_position_cache.h:25